Timers with Littlefoot



I’m an absolute beginner with Blicks dev and Littlefoot. I’m very excited with the possibilities of Littlefoot but I am missing the key feature of setting a timer, for instance after a touch event.

I see that the repaint() function is called each 40ms, so it could be used to trigger time-related tasks. However, if I need more precise control, I can think of a couple of alternatives:

  • Custom programmable timers
  • Or otherwise, a more frequently called function (like each 10ms).

Is there any hack that can get me any of features?




For creating custom timers, you can use getMillisecondCounter() and getTimeInCurrentFunctionCall() functions, see Littlefoot Docs.

As for more frequently called functions, I don’t think it is possible in Littlefoot.



Thanks @AnthonyAlfimov. Can you provide an example. I’ve googled and found nothing. What comes to mind is using them in a loop. But that wouldn’t be very elegant. Can they be used to invoke a callback at a given count?



I might be missing something, but I don’t think there are more elegant solutions to this.

Anything time-related hinges on repaint() and has to be called from it. Unfortunately, if you want a callback at a specific timer count, the only way is to check getMillisecondCounter() inside repaint(). If you want finer time resolution than 25Hz at which repaint() is called, all I can think of is using a loop inside repaint(), like you suggested.

As for time-related examples, check out the little stopwatch script that I made and the step sequencer script with internal clock from this article.



Thanks @AnthonyAlfimov. DO you know if there is any possibility of calling c++ o JUCE libraries from Littlefoot?



If you are writing a self-contained Littlefoot script that runs entirely on a Block, then no.

However, you can create a JUCE application which will run on a desktop/mobile device and communicate with the Block. Check out examples in DemoRunner under the “BLOCKS” category and the docs.