avr: more work on fan- and light controller app and modules.

This commit is contained in:
Martin Preuss
2026-08-07 23:45:21 +02:00
parent 296ead3241
commit f973ce1b14
9 changed files with 132 additions and 39 deletions

View File

@@ -201,6 +201,7 @@ appFanControlWriteEeprom_ret:
appFanControlActorOn:
ldd r16, Y+APP_FANCONTROL_RAM_OFFS_VALUE_LO
rcall appFanControlSetFanDutyFromTable
bigcall AppFanControl_ReportState
ret
; @end
@@ -214,7 +215,9 @@ appFanControlActorOn:
appFanControlActorOff:
clr r16
rjmp appFanControlSetFanDutyFromTable
rcall appFanControlSetFanDutyFromTable
bigcall AppFanControl_ReportState
ret
; @end

View File

@@ -0,0 +1,53 @@
; ***************************************************************************
; copyright : (C) 2026 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. *
; ***************************************************************************
#ifndef AQH_AVR_APPS_FAN_CONTROL_SEND_ASM
#define AQH_AVR_APPS_FAN_CONTROL_SEND_ASM
.cseg
; ---------------------------------------------------------------------------
; @routine AppFanControl_ReportState
;
; @clobbers R16, R17, R18, R19, R20, R21, R22, R23, R24, R25, X
AppFanControl_ReportState:
push yl
push yh
push zl
push zh
ldi zl, LOW(appFanControlObjectFlash*2)
ldi zh, HIGH(appFanControlObjectFlash*2)
lpm yl, Z+
lpm yh, Z
sbiw zh:zl, 1
ldd r16, Y+HTIM_RAM_OFFS_FLAGS
clr r18
sbrc r16, HTIM_FLAGBIT_STATE
inc r18
ldi r17, VALUE_ID_FANCTRL_STATE
clr r19
ldi r20, 1
clr r21
ldi r22, AQHOME_VALUETYPE_ONOFF
rcall Main_SendValueReport ; (R16, R17, R18, R19, R20, R21, R23, R24, R25, X)
pop zh
pop zl
pop yh
pop yl
ret
; @end
#endif

View File

@@ -11,7 +11,7 @@
#define AQH_AVR_APPS_LIGHT_CONTROL_MAIN_ASM
.equ APP_LIGHTCONTROL_LIGHT_LIMIT = 15
.equ APP_LIGHTCONTROL_LIGHT_LIMIT = 20
@@ -139,9 +139,10 @@ appLightControlUpdate:
appLightControlUpdate_auto:
sbr r16, (1<<HTIM_FLAGBIT_ACTIVE) | (1<<HTIM_FLAGBIT_ACTORENABLED) ; enable timer
std Y+HTIM_RAM_OFFS_FLAGS, r16
sbrs r16, HTIM_FLAGBIT_STATE
rjmp appLightControlUpdate_ret ; jump if clear (actor is off)
rcall appLightControlActorOn
bigcall HTIM_Trigger
; sbrs r16, HTIM_FLAGBIT_STATE
; rjmp appLightControlUpdate_ret ; jump if clear (actor is off)
; rcall appLightControlActorOn
rjmp appLightControlUpdate_ret
appLightControlUpdate_on:
rcall appLightControlActorOn
@@ -185,16 +186,16 @@ appLightControlReadEeprom_ret:
appLightControlWriteEeprom:
ldi r16, APP_LIGHTCONTROL_EEID
bigcall EepromTlv_FindFirst
bigcall EepromTlv_FindFirst ; X=ptr, r17=length (r16, r18)
brcs appLightControlWriteEeprom_write
; create eeprom TLV
ldi r16, APP_LIGHTCONTROL_EEID
ldi r17, APP_LIGHTCONTROL_EE_SIZE
bigcall EepromTlv_AddTlv
bigcall EepromTlv_AddTlv ; X=ptr (r16, r20, r21, r18)
brcc appLightControlWriteEeprom_ret
appLightControlWriteEeprom_write:
; let base class write
bigcall TCA_WriteEepromAt
bigcall TCA_WriteEepromAt ;
brcc appLightControlWriteEeprom_ret
push yl
push yh
@@ -220,12 +221,8 @@ appLightControlActorOn:
ldd r20, Y+APP_LIGHTCONTROL_RAM_OFFS_VALUE_BLUE
ldd r21, Y+APP_LIGHTCONTROL_RAM_OFFS_VALUE_WHITE
bigcall SK6812_SetRGBW ; (r16, r24, r25)
ldi r18, 1
push yl
push yh
bigcall AppLightControl_ReportState
pop yh
pop yl
bigcall AppLightControl_ReportState
ret
; @end
@@ -243,14 +240,32 @@ appLightControlActorOff:
clr r20
clr r21
bigcall SK6812_SetRGBW ; (r16, r24, r25)
ldi r18, 0
bigcall AppLightControl_ReportState
ret
; @end
#if 0
appLightControlDebug:
; debug
ldi r17, 0xf0
ldd r18, Y+HTIM_RAM_OFFS_FLAGS
ldd r19, Y+HTIM_RAM_OFFS_MODE
ldd r20, Y+HTIM_RAM_OFFS_CURRVAL_LO
ldd r21, Y+HTIM_RAM_OFFS_CURRVAL_HI
ldi r22, AQHOME_VALUETYPE_ONOFF
push yl
push yh
bigcall AppLightControl_ReportState
rcall Main_SendValueReport ; (R16, R17, R18, R19, R20, R21, R23, R24, R25, X)
pop yh
pop yl
ret
; @end
#endif

View File

@@ -1,5 +1,5 @@
; ***************************************************************************
; copyright : (C) 2024 by Martin Preuss
; copyright : (C) 2026 by Martin Preuss
; email : martin@libchipcard.de
;
; ***************************************************************************
@@ -14,20 +14,33 @@
; ---------------------------------------------------------------------------
; @routine sk6812ReportState
; @routine AppLightControl_ReportState
;
; @param R18 state (0=off, 1=on)
; @clobbers R16, R17, R18, R19, R20, R21, R22, R23, R24, R25, X
AppLightControl_ReportState:
ldi r17, VALUE_ID_LIGHTCONTROL_STATE
clr r19
ldi r20, 1
clr r21
ldi r22, AQHOME_VALUETYPE_ONOFF
push yl
push yh
rcall Main_SendValueReport ; (R16, R17, R18, R19, R20, R21, R23, R24, R25, X)
push zl
push zh
ldi zl, LOW(appLightControlObjectFlash*2)
ldi zh, HIGH(appLightControlObjectFlash*2)
lpm yl, Z+
lpm yh, Z
sbiw zh:zl, 1
ldd r16, Y+HTIM_RAM_OFFS_FLAGS
clr r18
sbrc r16, HTIM_FLAGBIT_STATE
inc r18
ldi r17, VALUE_ID_LIGHTCONTROL_STATE
clr r19
ldi r20, 1
clr r21
ldi r22, AQHOME_VALUETYPE_ONOFF
rcall Main_SendValueReport ; (R16, R17, R18, R19, R20, R21, R23, R24, R25, X)
pop zh
pop zl
pop yh
pop yl
ret