diff --git a/avr/apps/ma_light/data.asm b/avr/apps/ma_light/data.asm index 2ff11ed..8b0d62b 100644 --- a/avr/apps/ma_light/data.asm +++ b/avr/apps/ma_light/data.asm @@ -23,6 +23,7 @@ appMotionLightDataBegin: appMotionLightLSourceValueId: .byte 1 appMotionLightLSourceValue: .byte 2 appMotionLightLastBrightness: .byte 2 + appMotionLightFlags: .byte 1 appMotionLightDataEnd: diff --git a/avr/apps/ma_light/defs.asm b/avr/apps/ma_light/defs.asm index 993efa2..b4c6efa 100644 --- a/avr/apps/ma_light/defs.asm +++ b/avr/apps/ma_light/defs.asm @@ -20,6 +20,6 @@ .equ APP_MOTIONLIGHT_SOURCE_SIZE = 2 - +.equ APP_MOTIONLIGHT_FLAGS_HAVELIGHT = 0x01 diff --git a/avr/apps/ma_light/recv.asm b/avr/apps/ma_light/recv.asm index f6f8dbc..d28ae8f 100644 --- a/avr/apps/ma_light/recv.asm +++ b/avr/apps/ma_light/recv.asm @@ -45,12 +45,9 @@ AppMotionLight_OnPacketReceived_turnOn: 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 + lds r16, appMotionLightFlags ; check last brightness reported + andi r16, APP_MOTIONLIGHT_FLAGS_HAVELIGHT + breq AppMotionLight_OnPacketReceived_secRet ; no brightness, yet AppMotionLight_OnPacketReceived_checkBrightness: lds r16, appMotionLightLSourceValue ; check last brightness reported lds r17, appMotionLightLSourceValue+1 @@ -77,6 +74,9 @@ AppMotionLight_OnPacketReceived_secRet: AppMotionLight_OnPacketReceived_isBrightness: sts appMotionLightLastBrightness, r18 sts appMotionLightLastBrightness+1, r19 + lds r16, appMotionLightFlags + ori r16, APP_MOTIONLIGHT_FLAGS_HAVELIGHT + sts appMotionLightFlags, r16 sec ret ; "set value" message