What's the "latch" operation in rockpool?


#1

I’ve had a play with it merging a slider and a clock input, but couldn’t see rhyme or reason in the output. Any ideas?


#2

“Latch” in Rockpool is effectively one “bit” of memory. It has two inputs:

  • The top input is the value being input, and which you want to store
  • The bottom input is the latch signal, which locks the value into the latch

The exact logic of latch is as follows, where latch_value is the latch signal, and input_value is the data signal:

if( latch_value > 0.5 && this.last_value <= 0.5 ){
    this.latched_value = this.input_value
}
this.last_value = latch_value 

What it’s effectively saying is:

If the latch signal crosses half way from bottom to top (known as a “rising edge” in electronics lingo) then save the current input value.

Latch will always return the last value which was latched into it, so you can use it to dial in and save a brightness value for example.

If you have the Noisemaker kit, or a Touch, Rainbow and Dial then the following Rockpool save will show you how to use the dial to control Red, Green and Blue by latching each colour value into the Rainbow using Touch 1, 2 and 3:

Save the following as: latch-example.rpl and drag ‘n’ drop it into the file drop zone of the Rockpool load dialog.

_rockpool_save([{"enabled":true,"input":{"key":"0_2_dial_position","option":-1,"value":-1},"output":{"key":"0_0_rainbow_LED","option":0},"converters":[{"key":"latch","child":{"enabled":true,"input":{"key":"0_4_touch_button","option":0,"value":-1},"output":{"key":"latch","option":-1},"converters":[]}},{"key":"noop"},{"key":"noop"}]},{"enabled":true,"input":{"key":"0_2_dial_position","option":-1,"value":-1},"output":{"key":"0_0_rainbow_LED","option":1},"converters":[{"key":"latch","child":{"enabled":true,"input":{"key":"0_4_touch_button","option":1,"value":-1},"output":{"key":"latch","option":-1},"converters":[]}},{"key":"noop"},{"key":"noop"}]},{"enabled":true,"input":{"key":"0_2_dial_position","option":-1,"value":-1},"output":{"key":"0_0_rainbow_LED","option":2},"converters":[{"key":"latch","child":{"enabled":true,"input":{"key":"0_4_touch_button","option":2,"value":-1},"output":{"key":"latch","option":-1},"converters":[]}},{"key":"noop"},{"key":"noop"}]}]);

#3

Nice! Thanks for the info.


#4

You’re welcome! It’s by far one of the most opaque widgets in Rockpool, but it’s too useful to leave out! There were others that didn’t quite make the cut.


#5

Sorry, short followup. What’s the rockpool “load dialog”? I’m using the OSX prerelease software, and my rockpool has an anchor at the bottom that opens a drawer with a load circle. If I tap that, nothing happens. If I drag an rpl file on to it, the browser (chrome) interprets that as wanting the file to be opened in the browser, which obviously doesn’t work.


#6

That will now be somewhat old code, you should use the Rockpool version at Flotil.la here: http://flotil.la/rockpool/

Hopefully it’ll work with your Dock/Daemon versions.


#7

Yes, that’s working! Thanks.