From ae137efb269403cf791c3e33e89d177d0d7c28e2 Mon Sep 17 00:00:00 2001 From: Martin Preuss Date: Wed, 4 Mar 2026 23:26:37 +0100 Subject: [PATCH] gui2: started working on GuiApp, MainWindow, RootWindow --- avr/modules/lcd2/gui2/base/guiapp.asm | 42 +++++++ avr/modules/lcd2/gui2/base/mainwindow.asm | 88 ++++++++++++++ avr/modules/lcd2/gui2/base/rootwindow.asm | 139 ++++++++++++++++++++++ 3 files changed, 269 insertions(+) create mode 100644 avr/modules/lcd2/gui2/base/guiapp.asm create mode 100644 avr/modules/lcd2/gui2/base/mainwindow.asm create mode 100644 avr/modules/lcd2/gui2/base/rootwindow.asm diff --git a/avr/modules/lcd2/gui2/base/guiapp.asm b/avr/modules/lcd2/gui2/base/guiapp.asm new file mode 100644 index 0000000..5034125 --- /dev/null +++ b/avr/modules/lcd2/gui2/base/guiapp.asm @@ -0,0 +1,42 @@ +; *************************************************************************** +; 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_GUI2_GUIAPP_ASM +#define AQH_AVR_GUI2_GUIAPP_ASM + + +; *************************************************************************** +; defines + +; Widget in flash + +.equ GUIAPP_OFFS_BEGIN = OBJECT_SIZE +.equ GUIAPP_OFFS_ROOTWINDOW_LO = GUIAPP_OFFS_BEGIN+0 +.equ GUIAPP_OFFS_ROOTWINDOW_HI = GUIAPP_OFFS_BEGIN+1 +.equ GUIAPP_OFFS_SCREENSAVER_LO = GUIAPP_OFFS_BEGIN+2 +.equ GUIAPP_OFFS_SCREENSAVER_HI = GUIAPP_OFFS_BEGIN+3 +.equ GUIAPP_OFFS_CURRENTWIDGET_LO = GUIAPP_OFFS_BEGIN+4 +.equ GUIAPP_OFFS_CURRENTWIDGET_HI = GUIAPP_OFFS_BEGIN+5 +.equ GUIAPP_OFFS_ROOTWINDOW_HI = GUIAPP_OFFS_BEGIN+6 +.equ GUIAPP_OFFS_TOUCHWIDGET_LO = GUIAPP_OFFS_BEGIN+7 +.equ GUIAPP_OFFS_TOUCHWIDGET_HI = GUIAPP_OFFS_BEGIN+8 +.equ GUIAPP_OFFS_DRAWTIMER = GUIAPP_OFFS_BEGIN+9 +.equ GUIAPP_SIZE = WIDGET_OFFS_BEGIN+10 + + + + +; *************************************************************************** +; code + +.cseg + + + +#endif diff --git a/avr/modules/lcd2/gui2/base/mainwindow.asm b/avr/modules/lcd2/gui2/base/mainwindow.asm new file mode 100644 index 0000000..ca78191 --- /dev/null +++ b/avr/modules/lcd2/gui2/base/mainwindow.asm @@ -0,0 +1,88 @@ +; *************************************************************************** +; 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_GUI2_MAINWINDOW_ASM +#define AQH_AVR_GUI2_MAINWINDOW_ASM + + +; *************************************************************************** +; defines + +.equ MAINWINDOW_OFFS_BEGIN = WIDGET_SIZE +; no data for now +.equ MAINWINDOW_SIZE = MAINWINDOW_OFFS_BEGIN+0 + + + +; *************************************************************************** +; code + +.cseg + + + +; --------------------------------------------------------------------------- +; @routine MainWindow_new @global +; +; @return CFLAG set of okay, cleared otherwise +; @return Y address of newly created object +; @param r16 value for OBJECT_OFFS_OPTS_LO +; @param r17 value for OBJECT_OFFS_OPTS_HI +; @clobbers any + +MainWindow_new: + ldi r24, LOW(MAINWINDOW_SIZE) + ldi r25, HIGH(MAINWINDOW_SIZE) + bigcall Object_Alloc ; (!r16, !r17) + brcc MainWindow_new_ret + rcall MainWindow_Init ; (r16, r17, X) + sec +MainWindow_new_ret: + ret +; @end + + + +; --------------------------------------------------------------------------- +; @routine MainWindow_Init @global +; +; @param Y address of widget +; @clobbers r16, r17, X + +MainWindow_Init: + ; call base class + bigcall Widget_Init ; (r16, r17, X) + + ; move widget + clr r4 + clr r5 + clr r6 + clr r7 + bigcall Widget_Move ; (R16) + ldi r16, LOW(DISPLAY_WIDTH) + mov r8, r16 + ldi r16, HIGH(DISPLAY_WIDTH) + mov r9, r16 + + ; resize widget + ldi r16, LOW(DISPLAY_HEIGHT) + mov r10, r16 + ldi r16, HIGH(DISPLAY_HEIGHT) + mov r11, r16 + bigcall Widget_Resize ; (R16) + + ret +; @end + + + + + +#endif + diff --git a/avr/modules/lcd2/gui2/base/rootwindow.asm b/avr/modules/lcd2/gui2/base/rootwindow.asm new file mode 100644 index 0000000..976b137 --- /dev/null +++ b/avr/modules/lcd2/gui2/base/rootwindow.asm @@ -0,0 +1,139 @@ +; *************************************************************************** +; 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_GUI2_ROOTWINDOW_ASM +#define AQH_AVR_GUI2_ROOTWINDOW_ASM + + +; *************************************************************************** +; defines + +.equ ROOTWINDOW_OFFS_BEGIN = WIDGET_SIZE +.equ ROOTWINDOW_OFFS_GUIAPP_LO = ROOTWINDOW_OFFS_BEGIN+0 +.equ ROOTWINDOW_OFFS_GUIAPP_HI = ROOTWINDOW_OFFS_BEGIN+1 +.equ ROOTWINDOW_SIZE = ROOTWINDOW_OFFS_BEGIN+2 + + + +; *************************************************************************** +; code + +.cseg + + + +; --------------------------------------------------------------------------- +; @routine RootWindow_new @global +; +; @return CFLAG set of okay, cleared otherwise +; @return Y address of newly created object +; @param r16 value for OBJECT_OFFS_OPTS_LO +; @param r17 value for OBJECT_OFFS_OPTS_HI +; @clobbers any + +RootWindow_new: + ldi r24, LOW(ROOTWINDOW_SIZE) + ldi r25, HIGH(ROOTWINDOW_SIZE) + bigcall Object_Alloc ; (!r16, !r17) + brcc RootWindow_new_ret + rcall RootWindow_Init ; (r16, r17, X) + sec +RootWindow_new_ret: + ret +; @end + + + +; --------------------------------------------------------------------------- +; @routine RootWindow_Init @global +; +; @return CFLAG set if okay, cleared otherwise +; @param Y address of widget +; @param r16 value for OBJECT_OFFS_OPTS_LO +; @param r17 value for OBJECT_OFFS_OPTS_HI +; @clobbers r16, r17, X + +RootWindow_Init: + ; call base class + bigcall MainWindow_Init ; (r16, r17, X) + + ; clear widget-specific data + mov xl, yl + mov xh, yh + adiw xh:xl, ROOTWINDOW_OFFS_BEGIN + clr r16 + ldi r17, (ROOTWINDOW_SIZE-ROOTWINDOW_OFFS_BEGIN) + bigcall Utils_FillSram ; (r17, X) + + ; set default signal map + ldi r16, LOW(RootWindow_DefaultSignalmap*2) + std Y+OBJECT_OFFS_SIGNALMAP_LO, r16 + ldi r16, HIGH(RootWindow_DefaultSignalmap*2) + std Y+OBJECT_OFFS_SIGNALMAP_HI, r16 + + ; set default style + ldi r16, LOW(RootWindow_DefaultStyle*2) + std Y+WIDGET_OFFS_STYLE_LO, r16 + ldi r16, HIGH(RootWindow_DefaultStyle*2) + std Y+WIDGET_OFFS_STYLE_HI, r16 + + ret +; @end + + + +; --------------------------------------------------------------------------- +; @routine RootWindow_GetApp @global +; +; @param Y address of widget +; @return R19:R18 address pointer to GuiApp +; @clobbers none + +RootWindow_GetApp: + ldd r18, Y+ROOTWINDOW_OFFS_GUIAPP_LO + ldd r19, Y+ROOTWINDOW_OFFS_GUIAPP_HI + ret +; @end + + + + + + + + + +; *************************************************************************** +; data in FLASH + +RootWindow_DefaultSignalmap: + .db 0, WIDGET_SIGNAL_DRAW, LOW(Widget_OnDrawNop), HIGH(Widget_OnDrawNop) + .db 0, OBJECT_SIGNAL_DESTROY, LOW(OBJ_OnDestroy), HIGH(OBJ_OnDestroy) + .db 0, 0, 0, 0 ; end of table + + +RootWindow_DefaultStyle: + .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 +