avr/apps: added ma_light (was previously a module).
This commit is contained in:
101
avr/apps/ma_light/recv.asm
Normal file
101
avr/apps/ma_light/recv.asm
Normal file
@@ -0,0 +1,101 @@
|
||||
; ***************************************************************************
|
||||
; copyright : (C) 2025 by Martin Preuss
|
||||
; email : martin@libchipcard.de
|
||||
;
|
||||
; ***************************************************************************
|
||||
; * This file is part of the project "AqHome". *
|
||||
; * Please see toplevel file COPYING of that project for license details. *
|
||||
; ***************************************************************************
|
||||
|
||||
|
||||
; ***************************************************************************
|
||||
; code
|
||||
|
||||
.cseg
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine AppMotionLight_OnPacketReceived @global
|
||||
;
|
||||
; @clobbers any, -X
|
||||
|
||||
AppMotionLight_OnPacketReceived:
|
||||
adiw xh:xl, 2 ; command
|
||||
ld r16, X
|
||||
sbiw xh:xl, 2
|
||||
cpi r16, NETMSG_CMD_VALUE_SET
|
||||
breq AppMotionLight_OnPacketReceived_set
|
||||
cpi r16, NETMSG_CMD_VALUE_REPORT
|
||||
breq AppMotionLight_OnPacketReceived_report
|
||||
clc ; unexpected msg
|
||||
ret
|
||||
; "report value" message
|
||||
AppMotionLight_OnPacketReceived_report:
|
||||
rcall NETMSG_ValueRead ; (none)
|
||||
mov r16, r18
|
||||
or r16, r19
|
||||
breq AppMotionLight_OnPacketReceived_clcRet ; zero value, ignore
|
||||
rcall appMotionLightHasSource ; (r16, r24, Y)
|
||||
brcs AppMotionLight_OnPacketReceived_turnOn
|
||||
ret
|
||||
AppMotionLight_OnPacketReceived_turnOn:
|
||||
lds r16, appMotionLightTimer
|
||||
lds r17, appMotionLightTimer+1
|
||||
or r16, r17
|
||||
brne AppMotionLight_OnPacketReceived_startTimer
|
||||
rcall appMotionLightTurnOn ; (r16, r17, r18, r19, r20, r21, r23)
|
||||
AppMotionLight_OnPacketReceived_startTimer:
|
||||
rcall appMotionLightStartTimer
|
||||
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
|
||||
AppMotionLight_OnPacketReceived_clcRet:
|
||||
clc ; unexpected message
|
||||
ret
|
||||
AppMotionLight_OnPacketReceived_setRGBW:
|
||||
sts appMotionLightColor, r18
|
||||
sts appMotionLightColor+1, r19
|
||||
sts appMotionLightColor+2, r20
|
||||
sts appMotionLightColor+3, r21
|
||||
rcall appMotionLightStartTimer ; immediately ON with new color (r16)
|
||||
rcall appMotionLightTurnOn ; (r16, r17, r18, r19, r20, r21, r23)
|
||||
rjmp AppMotionLight_OnPacketReceived_sendAck
|
||||
AppMotionLight_OnPacketReceived_setOnTime:
|
||||
sts appMotionLightOnTime, r18
|
||||
sts appMotionLightOnTime+1, r19
|
||||
rjmp AppMotionLight_OnPacketReceived_sendAck
|
||||
AppMotionLight_OnPacketReceived_setSource1:
|
||||
sts appMotionLightSources, r18 ; peerAddr
|
||||
sts appMotionLightSources+1, r19 ; valueId
|
||||
rjmp AppMotionLight_OnPacketReceived_sendAck
|
||||
AppMotionLight_OnPacketReceived_setSource2:
|
||||
sts appMotionLightSources+APP_MOTIONLIGHT_SOURCE_SIZE, r18 ; peerAddr
|
||||
sts appMotionLightSources+APP_MOTIONLIGHT_SOURCE_SIZE+1, r19 ; valueId
|
||||
AppMotionLight_OnPacketReceived_sendAck:
|
||||
push xl
|
||||
push xh
|
||||
mov r16, r22 ; src address
|
||||
ldi r23, NETMSG_CMD_VALUE_SET_ACK
|
||||
clr r17
|
||||
rcall Main_SendValueResponse ; (clobbers all, including Y)
|
||||
rcall appMotionLightWriteConfToEeprom
|
||||
pop xh
|
||||
pop xl
|
||||
sec
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user