I'd keep a table of profiles of all sensors. A profile includes all the sensor specifics, including what the callback(s)/callback chain is(are) for processing of the read data. At the end of the processing of an individual event, I would calculate next setTimeout() based on the running time and the reading schedule. With calculated timeout time closing in on 0 - and setBusyIndicator(LED#) #=1..3 in the code - you can figure out how busy you can define your schedule and whether your system 'is getting late' or you have still cycles in reserve.
© Espruino, powered by microcosm.
Report a problem