ma_light: add "malstate".

report state change (i.e. when switching LED on/off).
This commit is contained in:
Martin Preuss
2025-09-22 22:44:39 +02:00
parent 12a64b8c91
commit 408b173ae1
7 changed files with 43 additions and 7 deletions

View File

@@ -68,7 +68,7 @@ AppMotionLight_Every100ms:
AppMotionLight_Every100ms_ret:
ret
AppMotionLight_Every100ms_off:
rjmp appMotionLightTurnOff ; (r16, r17, r18, r19, r20, r21, r23, r24, r25)
rjmp appMotionLightTurnOff ; (r16, r17, r18, r19, r20, r21, r22, r23, r24, r25, X)
; @end
@@ -147,11 +147,13 @@ appMotionLightStartTimer:
; ---------------------------------------------------------------------------
; @routine appMotionLightTurnOn
;
; @clobbers r18 (r16, r17, r19, r20, r21, r23, r24, r25)
; @clobbers r18 (r16, r17, r19, r20, r21, r22, r23, r24, r25, X)
appMotionLightTurnOn:
ldi r18, 1
rjmp SK6812_SetState ; (r16, r17, r18, r19, r20, r21, r23, r24, r25)
rcall SK6812_SetState ; (R16, R17, R18, R19, R20, R21, R23, R24, R25)
ldi r18, 1
rjmp appMotionLightReportState ; (R16, R17, R18, R19, R20, R21, R22, R23, R24, R25, X)
; @end
@@ -159,11 +161,35 @@ appMotionLightTurnOn:
; ---------------------------------------------------------------------------
; @routine appMotionLightTurnOff
;
; @clobbers r18 (r16, r17, r19, r20, r21, r23, r24, r25)
; @clobbers r18 (r16, r17, r19, r20, r21, r22, r23, r24, r25, X)
appMotionLightTurnOff:
clr r18
rjmp SK6812_SetState ; (r16, r17, r18, r19, r20, r21, r23, r24, r25)
rcall SK6812_SetState ; (R16, R17, R18, R19, R20, R21, R23, R24, R25)
clr r18
rjmp appMotionLightReportState ; (R16, R17, R18, R19, R20, R21, R22, R23, R24, R25, X)
; @end
; ---------------------------------------------------------------------------
; @routine appMotionLightReportState
;
; @param R18 state (0=off, 1=on)
; @clobbers (R16, R17, R18, R19, R20, R21, R22, R23, R24, R25, X)
appMotionLightReportState:
ldi r17, VALUE_ID_MAL_STATE
clr r19
ldi r20, 1
clr r21
ldi r22, AQHOME_VALUETYPE_ONOFF
push yl
push yh
rcall Main_SendValueReport ; (R16, R17, R18, R19, R20, R21, R23, R24, R25, X)
pop yh
pop yl
ret
; @end

View File

@@ -64,8 +64,12 @@ AppMotionLight_OnPacketReceived_checkTimer:
lds r17, appMotionLightTimer+1
or r16, r17
brne AppMotionLight_OnPacketReceived_startTimer ; no, just restart timer (light already on)
rcall appMotionLightTurnOn ; (r16, r17, r18, r19, r20, r21, r23, r24, r25)
AppMotionLight_OnPacketReceived_startTimer:
push xl
push xh
rcall appMotionLightTurnOn ; (r16, r17, r18, r19, r20, r21, r22, r23, r24, r25, X)
pop xh
pop xl
AppMotionLight_OnPacketReceived_startTimer:
rcall appMotionLightStartTimer
AppMotionLight_OnPacketReceived_secRet:
sec