Split sensor types into files

This commit is contained in:
2026-07-06 17:31:02 -06:00
parent e6cb6a32b9
commit 9e03767e1b
25 changed files with 918 additions and 0 deletions
+27
View File
@@ -0,0 +1,27 @@
class Timer:
def __init__(self, interval_s):
self._interval_s = interval_s
self._last_time = 0
self._last_utc = (0,0,0)
def set_interval(self, new_interval_s):
self._interval_s = new_interval_s
def check_timer(self, utc):
ns = utc[3] * 0.000000001
timestamp = utc[0] * 3600 + utc[1] * 60 + utc[2] + ns
shifted_timestamp = timestamp
if self._last_utc[0] == 23 and utc[0] == 0:
shifted_timestamp += 24*3600
if (shifted_timestamp - self._last_time) >= self._interval_s:
self._last_time = timestamp
self._last_utc = (utc[0], utc[1], utc[2])
return True
return False
def reset(self, utc):
ns = utc[3] * 0.000000001
self._last_time = utc[0] * 3600 + utc[1] * 60 + utc[2] + ns
self._last_utc = (utc[0], utc[1], utc[2])