Add delay before publishing brightness change
This commit is contained in:
parent
84dfa554b0
commit
343722086b
11
code/main.py
11
code/main.py
@ -209,6 +209,7 @@ MqttMultiPublish(data)
|
|||||||
|
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
|
|
||||||
|
BRIGHTN_DATA = None
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
|
|
||||||
@ -217,8 +218,9 @@ while True:
|
|||||||
if BRIGHTN != ENCODER.value:
|
if BRIGHTN != ENCODER.value:
|
||||||
print(ENCODER.value)
|
print(ENCODER.value)
|
||||||
BRIGHTN = ENCODER.value
|
BRIGHTN = ENCODER.value
|
||||||
MqttMultiPublish([['brightness/date', now(rtc), True, 1],
|
MQTT_TIMER = time.ticks_add(time.ticks_ms(), MQTT_DELAY * 1000)
|
||||||
['brightness/value', "{}".format(BRIGHTN), True, 0]])
|
BRIGHTN_DATA = [['brightness/date', now(rtc), True, 1],
|
||||||
|
['brightness/value', "{}".format(BRIGHTN), True, 0]]
|
||||||
|
|
||||||
# Mise à jour des LED
|
# Mise à jour des LED
|
||||||
light_modes.update_neopixel(CURRENT_MODE,
|
light_modes.update_neopixel(CURRENT_MODE,
|
||||||
@ -232,3 +234,8 @@ while True:
|
|||||||
PWR, CURRENT_MODE)
|
PWR, CURRENT_MODE)
|
||||||
|
|
||||||
BUTTN_STATE = ENC_BUT.value()
|
BUTTN_STATE = ENC_BUT.value()
|
||||||
|
|
||||||
|
# On n'envoie les données de luminosité qu'une fois stabilisée (MQTT_DELAY)
|
||||||
|
if BRIGHTN_DATA is not None and time.ticks_diff(time.ticks_ms(), MQTT_TIMER) >= 0:
|
||||||
|
MqttMultiPublish(BRIGHTN_DATA)
|
||||||
|
BRIGHTN_DATA = None
|
||||||
|
Loading…
Reference in New Issue
Block a user