avr: improved module SK6812 and app MA_LIGHT.
- RGBW values are now only set by SK6812 - MA_LIGHT can now also take into account a brightness value reported by any node to switch on light only after dawn
This commit is contained in:
@@ -33,6 +33,8 @@ AppMotionLight_OnPacketReceived:
|
||||
; "report value" message
|
||||
AppMotionLight_OnPacketReceived_report:
|
||||
rcall NETMSG_ValueRead ; (none)
|
||||
rcall appMotionLightIsBrightnessSource ; (R16)
|
||||
brcs AppMotionLight_OnPacketReceived_isBrightness
|
||||
mov r16, r18
|
||||
or r16, r19
|
||||
breq AppMotionLight_OnPacketReceived_clcRet ; zero value, ignore
|
||||
@@ -40,41 +42,62 @@ AppMotionLight_OnPacketReceived_report:
|
||||
brcs AppMotionLight_OnPacketReceived_turnOn
|
||||
ret
|
||||
AppMotionLight_OnPacketReceived_turnOn:
|
||||
lds r16, appMotionLightTimer
|
||||
lds r16, appMotionLightLSourceAddr ; do we have a source for brightness value?
|
||||
tst r16
|
||||
breq AppMotionLight_OnPacketReceived_checkTimer ; no, jmp and don't check brightness
|
||||
lds r16, appMotionLightLastBrightness
|
||||
lds r17, appMotionLightLastBrightness+1
|
||||
tst r16
|
||||
brne AppMotionLight_OnPacketReceived_checkBrightness
|
||||
tst r17
|
||||
breq AppMotionLight_OnPacketReceived_secRet ; we don't have a brightness value, keep light off
|
||||
AppMotionLight_OnPacketReceived_checkBrightness:
|
||||
lds r16, appMotionLightLSourceValue ; check last brightness reported
|
||||
lds r17, appMotionLightLSourceValue+1
|
||||
lds r24, appMotionLightLastBrightness
|
||||
lds r25, appMotionLightLastBrightness+1
|
||||
sub r16, r24
|
||||
sbc r17, r25
|
||||
brcs AppMotionLight_OnPacketReceived_secRet ; too bright to turn on
|
||||
AppMotionLight_OnPacketReceived_checkTimer:
|
||||
lds r16, appMotionLightTimer ; time up?
|
||||
lds r17, appMotionLightTimer+1
|
||||
or r16, r17
|
||||
brne AppMotionLight_OnPacketReceived_startTimer
|
||||
rcall appMotionLightTurnOn ; (r16, r17, r18, r19, r20, r21, r23)
|
||||
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:
|
||||
rcall appMotionLightStartTimer
|
||||
AppMotionLight_OnPacketReceived_secRet:
|
||||
sec
|
||||
ret
|
||||
AppMotionLight_OnPacketReceived_isBrightness:
|
||||
sts appMotionLightLastBrightness, r18
|
||||
sts appMotionLightLastBrightness+1, r19
|
||||
sec
|
||||
ret
|
||||
|
||||
; "set value" message
|
||||
AppMotionLight_OnPacketReceived_set:
|
||||
rcall NETMSG_ValueRead ; (none)
|
||||
cpi r17, VALUE_ID_MAL_RGBW_VALUE
|
||||
breq AppMotionLight_OnPacketReceived_setRGBW
|
||||
cpi r17, VALUE_ID_MAL_ONTIME
|
||||
breq AppMotionLight_OnPacketReceived_setOnTime
|
||||
cpi r17, VALUE_ID_MAL_SOURCE1
|
||||
breq AppMotionLight_OnPacketReceived_setSource1
|
||||
cpi r17, VALUE_ID_MAL_SOURCE2
|
||||
breq AppMotionLight_OnPacketReceived_setSource2
|
||||
cpi r17, VALUE_ID_MAL_BSOURCE
|
||||
breq AppMotionLight_OnPacketReceived_setBSource
|
||||
cpi r17, VALUE_ID_MAL_BVALUE
|
||||
breq AppMotionLight_OnPacketReceived_setBValue
|
||||
AppMotionLight_OnPacketReceived_clcRet:
|
||||
clc ; unexpected message
|
||||
ret
|
||||
AppMotionLight_OnPacketReceived_setRGBW: ; "setValue nodes/XXXXXXXX/MALRGBWVALUE GRWB"
|
||||
sts appMotionLightColor, r18
|
||||
sts appMotionLightColor+1, r19
|
||||
sts appMotionLightColor+2, r20
|
||||
sts appMotionLightColor+3, r21
|
||||
push r24
|
||||
push r25
|
||||
rcall appMotionLightStartTimer ; immediately ON with new color (r16)
|
||||
rcall appMotionLightTurnOn ; (r16, r17, r18, r19, r20, r21, r23)
|
||||
pop r25
|
||||
pop r24
|
||||
AppMotionLight_OnPacketReceived_setBSource: ; setValue "nodes/XXXXXXXX/MALSOURCEB 0xVVNN" (VV=value id, NN=node addr)
|
||||
sts appMotionLightLSourceAddr, r18
|
||||
sts appMotionLightLSourceValueId, r19
|
||||
rjmp AppMotionLight_OnPacketReceived_sendAck
|
||||
AppMotionLight_OnPacketReceived_setBValue: ; "setValue nodes/XXXXXXXX/MALVALUEB n" (n brightness value)
|
||||
sts appMotionLightLSourceValue, r18
|
||||
sts appMotionLightLSourceValue+1, r19
|
||||
rjmp AppMotionLight_OnPacketReceived_sendAck
|
||||
AppMotionLight_OnPacketReceived_setOnTime: ; "setValue nodes/XXXXXXXX/MALONTIME n" (n in 1/10 secs)
|
||||
sts appMotionLightOnTime, r18
|
||||
|
||||
Reference in New Issue
Block a user