nonblocking_timer¶
- class BlinkDemo(nonblocking_timer):
- def __init__(self):
- super(BlinkDemo, self).__init__(0.1) self.led = digitalio.DigitalInOut(board.D13) self.led.direction = digitalio.Direction.OUTPUT self.value = True
- def stop(self):
- self.led.value = False
- def next(self):
- if (super(BlinkDemo, self).next()):
- self.led.value = not (self.led.value)
blinkdemo.BlinkDemo()
- while True:
- blinkDemo.next() # This is the only place you should use time.sleep: to set the overall # “sampling rate” of your program. time.sleep(0.001)
- Author(s): Michael Schneider
-
class
nonblocking_timer.NonBlockingTimer(interval=-1)¶ Non blocking timer class for use with CircuitPython
-
get_interval()¶ Get interval
-
next()¶ Returns true or false according to the following algorithm: if interval <= 0 raise RuntimeError if status != RUNNING raise RuntimeError if time.monotonic() - start_time > interval return True and set start_time = time.monotonic() else return False
-
set_interval(seconds)¶ Set the trigger interval time in seconds (float). If interval <= 0 raise a RuntimeError
-
start()¶ Sets status to RUNNING. Sets start_time to time.monotonic(). Call next() repeatedly to determine if the timer has been triggered. If interval <= 0 raise a RuntimeError
-
status¶ Get Status
-
stop()¶ Sets status to STOPPED. Do any cleanup here such as releasing pins, etc. Call start() to restart. Does not reset start_time.
-