From 6920117ba14a32bf6994ff94939ea0fe127220c2 Mon Sep 17 00:00:00 2001 From: Martin Preuss Date: Mon, 22 Sep 2025 20:27:44 +0200 Subject: [PATCH] immediately apply ontime setting. --- avr/apps/ma_light/recv.asm | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/avr/apps/ma_light/recv.asm b/avr/apps/ma_light/recv.asm index a4f860a..ddfedfb 100644 --- a/avr/apps/ma_light/recv.asm +++ b/avr/apps/ma_light/recv.asm @@ -54,11 +54,11 @@ AppMotionLight_OnPacketReceived_turnOn: AppMotionLight_OnPacketReceived_checkBrightness: lds r16, appMotionLightLSourceValue ; check last brightness reported lds r17, appMotionLightLSourceValue+1 - lds r24, appMotionLightLastBrightness - lds r25, appMotionLightLastBrightness+1 + lds r24, appMotionLightLastBrightness ; r25:r24>r17:r16? + lds r25, appMotionLightLastBrightness+1 ; appMotionLightLastBrightness>appMotionLightLSourceValue? sub r16, r24 sbc r17, r25 - brcs AppMotionLight_OnPacketReceived_secRet ; too bright to turn on + brcs AppMotionLight_OnPacketReceived_secRet ; yes, too bright to turn on AppMotionLight_OnPacketReceived_checkTimer: lds r16, appMotionLightTimer ; time up? lds r17, appMotionLightTimer+1 @@ -102,6 +102,12 @@ AppMotionLight_OnPacketReceived_setBValue: ; "setValue nodes AppMotionLight_OnPacketReceived_setOnTime: ; "setValue nodes/XXXXXXXX/MALONTIME n" (n in 1/10 secs) sts appMotionLightOnTime, r18 sts appMotionLightOnTime+1, r19 + lds r16, appMotionLightTimer ; timer active? + lds r17, appMotionLightTimer+1 + or r16, r17 + breq AppMotionLight_OnPacketReceived_sendAck ; nope, just set it and leave + sts appMotionLightTimer, r18 ; restart timer with new value + sts appMotionLightTimer+1, r19 rjmp AppMotionLight_OnPacketReceived_sendAck AppMotionLight_OnPacketReceived_setSource1: ; setValue "nodes/XXXXXXXX/MALSOURCE1 0xVVNN" (VV=value id, NN=node addr) sts appMotionLightSources, r18 ; peerAddr