Files
aqhomecontrol/avr/devices/c03/test/w_climate.asm
Martin Preuss 51cedae0cb gui2: fixed problems with layouts
need to look into spread mode, too.
2026-03-11 00:32:08 +01:00

168 lines
5.1 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 r16, 0 ; OPTS
ldi r17, (WIDGET_PACK_FILLED<<WIDGET_PACK_HSELF0_BIT) | (WIDGET_PACK_FILLED<<WIDGET_PACK_VSELF0_BIT) ; PACK
ldi r20, LOW(RESSSOURCE_TXT_LIVINGROOM) ; TODO: use "Room Climate"
ldi r21, HIGH(RESSSOURCE_TXT_LIVINGROOM)
bigcall MainWindow_new
brcc ClimateWin_new_ret
; Y=MainWindow
push yl
push yh
bigcall MainWindow_GetContentWidget ; r19:r18=content window
brcc ClimateWin_new_popRet
mov xl, r18 ; use content window as parent
mov xh, r19
push xl ; content window
push xh
rcall climateWinCreateSensorWatches
pop xh
pop xl
; brcc ClimateWin_new_popRet
; TODO: create menu bar below
ClimateWin_new_popRet:
pop yh
pop yl
ClimateWin_new_ret:
ret
; @end
; ---------------------------------------------------------------------------
; @routine climateWinCreateSensorWatches
;
; @param X pointer to MainWindow content window (becomes parent)
; @return CFLAG set of okay, cleared otherwise
; @return Y address of newly created object
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
ldi r20, HLAYOUT_MODE_EXPAND
bigcall HLayout_new
brcc climateWinCreateSensorWatches_ret
mov xl, yl ; use HLayout as parent
mov xh, yh
push xl ; HLayout
push xh
ldi r16, 0
ldi r17, (WIDGET_PACK_BEGIN<<WIDGET_PACK_HSELF0_BIT) | (WIDGET_PACK_BEGIN<<WIDGET_PACK_VSELF0_BIT) ; PACK
ldi r20, LOW(RESSSOURCE_IMG_HUMIDITY96)
ldi r21, HIGH(RESSSOURCE_IMG_HUMIDITY96)
bigcall ImageView_new
pop xh
pop xl
; CO2 sensor watch
push xl ; HLayout
push xh
ldi r16, (1<<OBJECT_OPTS_TIMER_BIT) | (1<<WIDGET_OPTS_INPUT_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) ; 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
#if 0
; humidity sensor watch
push xl ; HLayout
push xh
ldi r16, (1<<OBJECT_OPTS_TIMER_BIT) | (1<<WIDGET_OPTS_INPUT_BIT) | (1<<WIDGET_OPTS_BORDER_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
#endif
climateWinCreateSensorWatches_ret:
ret
; @end
#if 0
Debug_Style:
.dw DISPLAY_COLOR_BLACK ; frontCol_norm
; .dw DISPLAY_COLOR_LIGHTGREY ; backCol_norm
.dw DISPLAY_COLOR_GREEN ; 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 1, 1 ; outerBorderSize, innerBorderSize
.dw ili9341Font12x16_1*2 ; font
.db 12, 16 ; charWidth, charHeight
# endif
#endif