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: AppMotionLight_Every100ms_ret:
ret ret
AppMotionLight_Every100ms_off: 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 ; @end
@@ -147,11 +147,13 @@ appMotionLightStartTimer:
; --------------------------------------------------------------------------- ; ---------------------------------------------------------------------------
; @routine appMotionLightTurnOn ; @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: appMotionLightTurnOn:
ldi r18, 1 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 ; @end
@@ -159,11 +161,35 @@ appMotionLightTurnOn:
; --------------------------------------------------------------------------- ; ---------------------------------------------------------------------------
; @routine appMotionLightTurnOff ; @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: appMotionLightTurnOff:
clr r18 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 ; @end

View File

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

View File

@@ -21,6 +21,7 @@
.equ AQHOME_VALUETYPE_TVOC = 8 .equ AQHOME_VALUETYPE_TVOC = 8
.equ AQHOME_VALUETYPE_STATS = 9 .equ AQHOME_VALUETYPE_STATS = 9
.equ AQHOME_VALUETYPE_LIGHT = 10 .equ AQHOME_VALUETYPE_LIGHT = 10
.equ AQHOME_VALUETYPE_ONOFF = 11
; Value Ids ; Value Ids

View File

@@ -16,6 +16,7 @@
<value name="MALSOURCE2" id="0x87" type="actor" dataType="uint16" /> <value name="MALSOURCE2" id="0x87" type="actor" dataType="uint16" />
<value name="MALSOURCEB" id="0x89" type="actor" dataType="uint16" /> <value name="MALSOURCEB" id="0x89" type="actor" dataType="uint16" />
<value name="MALVALUEB" id="0x8a" type="actor" dataType="uint16" /> <value name="MALVALUEB" id="0x8a" type="actor" dataType="uint16" />
<value name="MALSTATE" id="0x07" type="sensor" dataType="uint16" modality="onOff" />
<value name="LEDTIMING" id="0x88" type="actor" dataType="uint16" /> <value name="LEDTIMING" id="0x88" type="actor" dataType="uint16" />
</values> </values>

View File

@@ -76,6 +76,7 @@
;.equ VALUE_ID_REED1 = 0x04 ;.equ VALUE_ID_REED1 = 0x04
;.equ VALUE_ID_REED2 = 0x05 ;.equ VALUE_ID_REED2 = 0x05
.equ VALUE_ID_DS18B20_TEMP = 0x06 .equ VALUE_ID_DS18B20_TEMP = 0x06
.equ VALUE_ID_MAL_STATE = 0x07
;.equ VALUE_ID_REED_CONF = 0x81 ;.equ VALUE_ID_REED_CONF = 0x81
.equ VALUE_ID_LED_STATE = 0x81 .equ VALUE_ID_LED_STATE = 0x81

View File

@@ -16,6 +16,7 @@
<value name="MALSOURCE2" id="0x87" type="actor" dataType="uint16" /> <value name="MALSOURCE2" id="0x87" type="actor" dataType="uint16" />
<value name="MALSOURCEB" id="0x89" type="actor" dataType="uint16" /> <value name="MALSOURCEB" id="0x89" type="actor" dataType="uint16" />
<value name="MALVALUEB" id="0x8a" type="actor" dataType="uint16" /> <value name="MALVALUEB" id="0x8a" type="actor" dataType="uint16" />
<value name="MALSTATE" id="0x07" type="sensor" dataType="uint16" modality="onOff" />
<value name="LEDTIMING" id="0x88" type="actor" dataType="uint16" /> <value name="LEDTIMING" id="0x88" type="actor" dataType="uint16" />
</values> </values>

View File

@@ -77,6 +77,8 @@
;.equ VALUE_ID_REED1 = 0x04 ;.equ VALUE_ID_REED1 = 0x04
;.equ VALUE_ID_REED2 = 0x05 ;.equ VALUE_ID_REED2 = 0x05
.equ VALUE_ID_DS18B20_TEMP = 0x06 .equ VALUE_ID_DS18B20_TEMP = 0x06
.equ VALUE_ID_MAL_STATE = 0x07
;.equ VALUE_ID_REED_CONF = 0x81 ;.equ VALUE_ID_REED_CONF = 0x81
.equ VALUE_ID_LED_STATE = 0x81 .equ VALUE_ID_LED_STATE = 0x81