Crontask feature ! #6586
Replies: 1 comment
-
Posted at 2021-10-28 by @gfwilliams There is actually a module for this already in https://www.espruino.com/Cron So for normal Espruino you could use that - but yes, it'd be nice if something was built in to Bangle.js - it's been asked before - it's just hard thinking of a 'nice' way to do it. Posted at 2021-10-28 by VSerain For bangle, Create method have two parameters, first is a time string ("* * ...") and second is name of file ("myapp.[CRON_NAME].cron.js"). Remove method have same parameters, and we remove data in file/config. And regularly (e.g. at all minutes) the cron engine, read cron file (or config file). And check if this now match with time string. The cron engine can be writing in C or in JS. We need to define what we want to allow as a time value? If cron engine is good, we can use engine for alarm and calendar event. Posted at 2021-11-02 by @gfwilliams Yes, I think that makes a lot of sense. It does need a little thought though - RAM on Bangle.js 1 is quite scarce, so do we store the whole cron table in RAM, or keep it in flash and load it every minute? But once I've figured those things out I think it would make a good addition. Posted at 2021-11-02 by VSerain Hello, Good day, Posted at 2021-11-02 by rigrig As it is a watch, how about having
At least for buzzing every hour or redrawing clocks this should be sufficient to get rid of manually setting timeouts/intervals. No idea if this would have a serious impact on performance/battery life though (especially for the V1, where clocks tend to clear their timeouts when the LCD is off) Posted at 2021-11-02 by @gfwilliams I was wondering about that. I think the second handler could actually end up using some power, but minute/hour would effectively be free, and for the new 'health' event we're already doing something similar (just every 10 minutes) |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Posted at 2021-10-28 by VSerain
Hello,
I wonder if adding a "cron" feature in Espruino or just in Bangle would be a good idea ?
For my case, i want start a buzz at every hour. I can use setTimeout or setInterval.
But if many app use setTimeout/Intervale, in internal we check at all loop turn if this timeout is done and if is true, we start the callback.
It can be memory and cpu intensive.
If we add a simply cron (just hours and minutes) we have one interval (one minutes) and at all minutes check if many tasks match with this time.
In memory it would be enough to store the pointer of callback and one string (e.g.: "* 0" all hours at zero minutes).
What's do you think ?
Good day,
Victor
Beta Was this translation helpful? Give feedback.
All reactions