FEAT : ex. gestion des HC
This commit is contained in:
parent
b07a2e3669
commit
30509b7f2c
15
main.py
15
main.py
@ -50,16 +50,25 @@ def set_relays(mask):
|
||||
"""mask = bits 0..3 (1=ON, 0=OFF)"""
|
||||
i2c.writeto_mem(I2C_ADDR, 0x10, bytes([mask]))
|
||||
|
||||
def HC() -> bool:
|
||||
heure, minute = rtc.datetime()[4], rtc.datetime()[5]
|
||||
nb_minutes = heure * 60 + minute
|
||||
_21h30 = 21 * 60 + 30 # TODO : Ne pas faire le calcul à chaque appel
|
||||
_23h30 = 23 * 60 + 30
|
||||
if (nb_minutes > _21h30 and nb_minutes < _23h30):
|
||||
return True
|
||||
return False
|
||||
|
||||
def ntp():
|
||||
global ntp_ok, ntp_ttl, ntp_attente
|
||||
if (wifi.isconnected() and (not ntp_ok or ntp_attente < 0)):
|
||||
print("WIFI OK, call NTP")
|
||||
ntptime.settime()
|
||||
ntptime.settime() # TODO : gérer TZ et h été/hivers
|
||||
ntp_ok = True
|
||||
ntp_attente = ntp_ttl
|
||||
if (ntp_ok):
|
||||
date_heure = rtc.datetime()
|
||||
print(f"Date et heure : {date_heure} ({ntp_attente})")
|
||||
date_heure = time.localtime()
|
||||
print(f"Date et heure : {date_heure[3]}:{date_heure[4]}:{date_heure[5]} ({ntp_attente}, {HC()})")
|
||||
ntp_attente = ntp_attente - 1
|
||||
|
||||
# Init
|
||||
|
||||
Loading…
Reference in New Issue
Block a user