Files
aqhomecontrol/avr/devices/c03/main/w_climate.asm
2026-04-20 23:57:41 +02:00

189 lines
5.7 KiB
NASM

; ***************************************************************************
; 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_W_CLIMATE_ASM
#define AQH_AVR_W_CLIMATE_ASM
; ***************************************************************************
; defines
.equ CLIMATEWIN_OFFS_BEGIN = MAINWINDOW_SIZE
.equ CLIMATEWIN_SIZE = CLIMATEWIN_OFFS_BEGIN+0
; ***************************************************************************
; code
.cseg
; ---------------------------------------------------------------------------
; @routine ClimateWin_new @global
;
; @param Y pointer to GUIAPP
; @return CFLAG set of okay, cleared otherwise
; @return Y address of newly created object
ClimateWin_new:
bigcall GuiApp_GetRootWindow
brcc ClimateWin_new_ret
mov xl, r18 ; use root window as parent for main window
mov xh, r19
ldi r24, LOW(CLIMATEWIN_SIZE)
ldi r25, HIGH(CLIMATEWIN_SIZE)
bigcall Object_Alloc ; Y=space (!r16, !r17, !X)
brcc ClimateWin_new_ret
rcall ClimateWin_Init
ClimateWin_new_ret:
ret
; @end
; ---------------------------------------------------------------------------
; @routine ClimateWin_new @global
;
; @param Y pointer to newly allocated widget data
; @param X pointer to root window
; @return CFLAG set of okay, cleared otherwise
; @clobbers any, !Y
ClimateWin_Init:
ldi r16, 0 ; OPTS
ldi r17, (WIDGET_PACK_FILLED<<WIDGET_PACK_HSELF0_BIT) | (WIDGET_PACK_FILLED<<WIDGET_PACK_VSELF0_BIT) ; PACK
ldi r20, LOW(RESSOURCE_TXT_ROOMCLIMATE)
ldi r21, HIGH(RESSOURCE_TXT_ROOMCLIMATE)
bigcall MainWindow_new ; Y=main window
brcc ClimateWin_Init_ret
bigcall MainWindow_GetContentWidget ; r19:r18=content window
brcc ClimateWin_Init_ret
mov xl, r18 ; use content window as parent
mov xh, r19
; Y=MainWindow
push yl ; main window
push yh
push xl ; content window
push xh
rcall climateWinCreateSensorWatches
pop xh ; content window
pop xl
bigcall C03App_CreateBackButton
pop yh ; main window
pop yl
ClimateWin_Init_ret:
ret
; @end
; ---------------------------------------------------------------------------
; @routine climateWinCreateSensorWatches
;
; @param X pointer to MainWindow content window (becomes parent)
; @return CFLAG set of okay, cleared otherwise
climateWinCreateSensorWatches:
ldi r16, 0 ; OPTS
ldi r17, (WIDGET_PACK_FILLED<<WIDGET_PACK_HSELF0_BIT) | (WIDGET_PACK_FILLED<<WIDGET_PACK_VSELF0_BIT) ; PACK
ldi r20, HLAYOUT_MODE_SPREAD
bigcall HLayout_new
brcc climateWinCreateSensorWatches_ret
ldi r16, LOW(ClimateWindow_HLayoutStyle*2)
std Y+WIDGET_OFFS_STYLE_LO, r16
ldi r16, HIGH(ClimateWindow_HLayoutStyle*2)
std Y+WIDGET_OFFS_STYLE_HI, r16
mov xl, yl ; use HLayout as parent
mov xh, yh
; CO2 sensor watch
push xl ; HLayout
push xh
ldi r16, (1<<OBJECT_OPTS_TIMER_BIT) | \
(1<<WIDGET_OPTS_INPUT_BIT) | \
(1<<OBJECT_OPTS_MSGRECV_BIT) ; OPTS
ldi r17, (WIDGET_PACK_BEGIN<<WIDGET_PACK_HSELF0_BIT) | \
(WIDGET_PACK_BEGIN<<WIDGET_PACK_VSELF0_BIT) ; PACK
ldi r20, VALUE_ID_SENSOR_CO2_BASE
ldi r21, C03_EEID_SENSOR_CO2
ldi r22, SENSORWATCH_TYPE_CO2
bigcall SensorWatch_new
pop xh
pop xl
brcc climateWinCreateSensorWatches_ret
; temp sensor watch
push xl ; HLayout
push xh
ldi r16, (1<<OBJECT_OPTS_TIMER_BIT) | \
(1<<WIDGET_OPTS_INPUT_BIT) | \
(1<<OBJECT_OPTS_MSGRECV_BIT); OPTS
ldi r17, (WIDGET_PACK_BEGIN<<WIDGET_PACK_HSELF0_BIT) | \
(WIDGET_PACK_BEGIN<<WIDGET_PACK_VSELF0_BIT) ; PACK
ldi r20, VALUE_ID_SENSOR_TEMP_BASE
ldi r21, C03_EEID_SENSOR_TEMP
ldi r22, SENSORWATCH_TYPE_TEMP
bigcall SensorWatch_new
pop xh
pop xl
brcc climateWinCreateSensorWatches_ret
; humidity sensor watch
push xl ; HLayout
push xh
ldi r16, (1<<OBJECT_OPTS_TIMER_BIT) | \
(1<<WIDGET_OPTS_INPUT_BIT) | \
(1<<OBJECT_OPTS_MSGRECV_BIT); OPTS
ldi r17, (WIDGET_PACK_BEGIN<<WIDGET_PACK_HSELF0_BIT) | \
(WIDGET_PACK_BEGIN<<WIDGET_PACK_VSELF0_BIT) ; PACK
ldi r20, VALUE_ID_SENSOR_HUM_BASE
ldi r21, C03_EEID_SENSOR_HUM
ldi r22, SENSORWATCH_TYPE_HUM
bigcall SensorWatch_new
pop xh
pop xl
climateWinCreateSensorWatches_ret:
ret
; @end
; ***************************************************************************
; data in FLASH
ClimateWindow_HLayoutStyle:
.dw DISPLAY_COLOR_BLACK ; frontCol_norm
.dw DISPLAY_COLOR_LIGHTGREY ; backCol_norm
.dw DISPLAY_COLOR_BLACK ; borderCol_norm
.dw DISPLAY_COLOR_WHITE ; shadowCol_norm
.dw DISPLAY_COLOR_WHITE ; frontCol_activated
.dw DISPLAY_COLOR_NAVY ; backCol_activated
.dw DISPLAY_COLOR_BLACK ; borderCol_activated
.dw DISPLAY_COLOR_WHITE ; shadowCol_activated
.db 0, 1 ; outerBorderSize, innerBorderSize
.dw ili9341Font12x16_1*2 ; font
.db 12, 16 ; charWidth, charHeight
#endif