• 0 Votes
    3 Posts
    1k Views
    N
    @robert-hh Thanks for that insight. My issue was that (unlike my example) the callback would trigger a separate function that included an additional but non-related alarm call back that would get 'stalled' from the original callback. Having worked out that as long as an alarm is created from the 'main' thread it will not be blocked by work from the caller I have adjusted my program to use a mix of sensor alarms and secondary "worker" threads which are triggered by not run from the alarm callback. Not sure if it is the best way but seems to allow things to run smoothly without blocking.
  • 0 Votes
    4 Posts
    1k Views
    robert-hhR
    No, the callback handler can be inside a class. But then the handler must have self as first additional argument. Example (ESP8266 one, but principle should work) with ISR fucntion sample. class acquire: def __init__(self): self.adc_read = machine.ADC(0).read self.data = array.array("L", [0] * _BUFFERSIZE) self.index_put = 0 def sample(self, x): self.data[self.index_put] = self.adc_read() self.index_put = (self.index_put + 1) % _BUFFERSIZE self.irq_busy = False