split code up into modules and add pubsub and timers
This commit is contained in:
parent
05c470197f
commit
001f99db7c
7 changed files with 228 additions and 137 deletions
10
CIRCUITPY/weather_station/timer.py
Executable file
10
CIRCUITPY/weather_station/timer.py
Executable file
|
|
@ -0,0 +1,10 @@
|
|||
class Timer:
|
||||
def __init__(self, pubsub, timer_length):
|
||||
self.timer_length = timer_length
|
||||
self.last_tick = 0
|
||||
self.pubsub = pubsub
|
||||
self.topic = f"tick {self.timer_length}"
|
||||
def tick(self, now):
|
||||
if (now - self.last_tick) > self.timer_length:
|
||||
self.last_tick = now
|
||||
self.pubsub.publish(self.topic, {})
|
||||
Loading…
Add table
Add a link
Reference in a new issue