gui2: fixed problems with layouts

need to look into spread mode, too.
This commit is contained in:
Martin Preuss
2026-03-11 00:32:08 +01:00
parent 282cd738b4
commit 51cedae0cb
10 changed files with 493 additions and 84 deletions

View File

@@ -253,49 +253,41 @@ test:
sts guiApp, yl
sts guiApp+1, yh
bigcall GuiApp_GetRootWindow
brcc DEBUG_STOP
push yl
push yh
mov xl, r18
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)
ldi r21, HIGH(RESSSOURCE_TXT_LIVINGROOM)
bigcall MainWindow_new
bigcall MainWindow_GetContentWidget
brcc DEBUG_STOP
mov xl, yl ; X=MainWindow
bigcall ClimateWin_new
; rcall mkTestWindow
mov xl, yl
mov xh, yh
push xl ; mainWindow
push xh
mov xl, r18 ; contentWindow
mov xh, r19
push xl
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_CO2_BASE
ldi r21, C03_EEID_SENSOR_CO2
ldi r22, SENSORWATCH_TYPE_CO2
bigcall SensorWatch_new
pop xh
pop xl
pop xh
pop xl
pop yh
pop yl
brcc DEBUG_STOP
brcc DEBUG_STOP2
bigcall GuiApp_EnterWindow
push xl
push xh
bigcall GuiApp_EnterWindow
pop xh
pop xl
brcc DEBUG_STOP3
push yl
push yh
mov yl, xl
mov yh, xh
ldi r16, (1<<WIDGET_FLAGS_VISIBLE_BIT) | (1<<WIDGET_FLAGS_DIRTY_BIT) | (1<<WIDGET_FLAGS_LAYOUT_BIT)
bigcall OBJ_AddFlagsUp
pop yh
pop yl
ret
; ; debug
; ldi r16, LOW(Debug_Style*2)
; std Y+WIDGET_OFFS_STYLE_LO, r16
; ldi r16, HIGH(Debug_Style*2)
; std Y+WIDGET_OFFS_STYLE_HI, r16
DEBUG_STOP:
bigjmp DEBUG1
@@ -309,6 +301,122 @@ DEBUG_STOP3:
mkTestWindow:
bigcall GuiApp_GetRootWindow
brcc mkTestWindow_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 mkTestWindow_ret
; Y=MainWindow
push yl
push yh
bigcall MainWindow_GetContentWidget ; r19:r18=content window
brcc mkTestWindow_popRet
mov xl, r18 ; use content window as parent
mov xh, r19
push xl ; content window
push xh
rcall mkTestWidgets
; rcall mkSimpleTestWidgets
pop xh
pop xl
mkTestWindow_popRet:
pop yh
pop yl
mkTestWindow_ret:
ret
; @end
; ---------------------------------------------------------------------------
; @routine mkTestWidgets
;
; @param X pointer to MainWindow content window (becomes parent)
; @return CFLAG set of okay, cleared otherwise
; @return Y address of newly created object
mkTestWidgets:
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, VLAYOUT_MODE_EXPAND
bigcall VLayout_new
brcc mkTestWidgets_ret
push yl
push yh
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
brcc mkTestWidgets_popRet
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_CLOUD96)
ldi r21, HIGH(RESSSOURCE_IMG_CLOUD96)
bigcall ImageView_new
pop xh
pop xl
brcc mkTestWidgets_popRet
mkTestWidgets_popRet:
pop yh
pop yl
mkTestWidgets_ret:
ret
; @end
mkSimpleTestWidgets:
push xl ; Contentwindow
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
brcc mkSimpleTestWidgets_ret
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_CLOUD96)
ldi r21, HIGH(RESSSOURCE_IMG_CLOUD96)
bigcall ImageView_new
pop xh
pop xl
brcc mkSimpleTestWidgets_ret
mkSimpleTestWidgets_ret:
ret
; @end
; ***************************************************************************
; includes
@@ -355,9 +463,9 @@ GUI2_MODULE_BEGIN:
.include "modules/lcd2/gui2/base/valuelabel.asm"
.include "modules/lcd2/gui2/aqhome/sensorwatch.asm"
GUI2_MODULE_END:
.equ MODULE_SIZE_GUI2 = GUI2_MODULE_END-GUI2_MODULE_BEGIN
.include "w_climate.asm"
.include "ressources.inc"

View File

@@ -0,0 +1,167 @@
; ***************************************************************************
; 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