diff --git a/avr/modules/sk6812/main.asm b/avr/modules/sk6812/main.asm index ac0d3ea..250cfbc 100644 --- a/avr/modules/sk6812/main.asm +++ b/avr/modules/sk6812/main.asm @@ -71,17 +71,50 @@ SK6812_Init_error: ; --------------------------------------------------------------------------- -; SK6812_Fini +; @routine SK6812_Fini ; -; IN: -; - nothing -; OUT: -; - CFLAG: set if okay, clear on error +; @return CFLAG set if okay, clear on error ; USED: SK6812_Fini: sec ret +; @end + + + +; --------------------------------------------------------------------------- +; @routine SK6812_OnPacketReceived @global +; +; @clobbers any, -X + +SK6812_OnPacketReceived: + adiw xh:xl, 2 ; command + ld r16, X + sbiw xh:xl, 2 + cpi r16, CPRO_CMD_VALUE_SET + breq SK6812_OnPacketReceived_set + clc ; unexpected msg + ret +SK6812_OnPacketReceived_set: + rcall CPRO_ReadValue ; (none) + cpi r17, VALUE_ID_LED_RGBW_VALUE + breq SK6812_OnPacketReceived_setRGBW + cpi r17, VALUE_ID_LED_NUMLEDS + breq SK6812_OnPacketReceived_setNumLeds + clc + ret +SK6812_OnPacketReceived_setRGBW: + rcall SK6812_SetAllColor ; value is in R18-R21 + rjmp SK6812_OnPacketReceived_sendAck +SK6812_OnPacketReceived_setNumLeds: + sts sk6812NumLeds, r18 +SK6812_OnPacketReceived_sendAck: + ldi r16, CPRO_CMD_VALUE_SET_ACK + rcall CPRO_SendSetValueResponse + sec + ret +; @end