From caa2a927220996cc8b052bc962520d5f21e0372b Mon Sep 17 00:00:00 2001 From: Martin Preuss Date: Mon, 12 Jan 2026 22:47:08 +0100 Subject: [PATCH] another GUI approach, this time more generic. --- avr/devices/c03/main/main.asm | 38 +- avr/devices/c03/main/testwin.asm | 101 +++++ avr/modules/lcd2/gui2/0BUILD | 10 + avr/modules/lcd2/gui2/TODO | 46 ++ avr/modules/lcd2/gui2/guiapp.asm | 310 +++++++++++++ avr/modules/lcd2/gui2/guicntrl.asm | 260 +++++++++++ avr/modules/lcd2/gui2/label.asm | 109 +++++ avr/modules/lcd2/gui2/object.asm | 366 +++++++++++++++ avr/modules/lcd2/gui2/style.asm | 32 ++ avr/modules/lcd2/gui2/widget.asm | 706 +++++++++++++++++++++++++++++ 10 files changed, 1967 insertions(+), 11 deletions(-) create mode 100644 avr/devices/c03/main/testwin.asm create mode 100644 avr/modules/lcd2/gui2/0BUILD create mode 100644 avr/modules/lcd2/gui2/TODO create mode 100644 avr/modules/lcd2/gui2/guiapp.asm create mode 100644 avr/modules/lcd2/gui2/guicntrl.asm create mode 100644 avr/modules/lcd2/gui2/label.asm create mode 100644 avr/modules/lcd2/gui2/object.asm create mode 100644 avr/modules/lcd2/gui2/style.asm create mode 100644 avr/modules/lcd2/gui2/widget.asm diff --git a/avr/devices/c03/main/main.asm b/avr/devices/c03/main/main.asm index 26ecd02..f8d6fd8 100644 --- a/avr/devices/c03/main/main.asm +++ b/avr/devices/c03/main/main.asm @@ -194,7 +194,9 @@ onMessageReceived: ; Called every 100ms. Add your routine calls here. No arguments, no results. onEvery100ms: - bigcall DialogMgr_Every100ms + ldi zl, LOW(testCntrl*2) + ldi zh, HIGH(testCntrl*2) + bigcall GuiCntrl_Every100ms ret onEveryMinute: @@ -221,9 +223,17 @@ onEveryLoop: test: - bigcall DialogMgr_Init - bigcall DlgNetStats_Init - bigcall DialogMgr_PushDialog + ldi zl, LOW(testCntrl*2) + ldi zh, HIGH(testCntrl*2) + + ; init GuiAppCntrl + ldi r16, OBJECT_SIGNAL_CREATE + clr r17 + bigcall OBJ_TreeAllHandleSignal + + ; show first app + bigcall GuiCntrl_ShowFirstApp + ret @@ -238,16 +248,16 @@ test: .include "common/debug.asm" - .include "modules/lcd2/gui/titlewindow2.asm" - .include "modules/lcd2/gui/dialog.asm" - .include "modules/lcd2/gui/button.asm" ;.include "modules/lcd2/font/font2.asm" ;.include "modules/lcd2/font/font3.asm" ;.include "modules/lcd2/font/font16x26.asm" ;.include "modules/lcd2/font/font4.asm" ;.include "modules/lcd2/font/font12x16.asm" -.include "modules/lcd2/ili9341/font12x16.asm" -.include "modules/lcd2/ili9341/font12x16_1.asm" + +;.include "modules/lcd2/ili9341/font12x16.asm" +;.include "modules/lcd2/ili9341/font12x16_1.asm" +.equ ili9341Font12x16_1 = 0 + ;.include "modules/lcd2/ili9341/font12x20.asm" ;.include "modules/lcd2/ili9341/font12x20_1.asm" ;.include "common/list_t.asm" @@ -255,8 +265,14 @@ test: .include "common/divide.asm" .include "common/ressource.asm" - .include "modules/lcd2/gui/style.asm" - .include "dlg_netstats.asm" +.include "modules/lcd2/gui2/style.asm" +.include "modules/lcd2/gui2/object.asm" +.include "modules/lcd2/gui2/widget.asm" +.include "modules/lcd2/gui2/guiapp.asm" +.include "modules/lcd2/gui2/guicntrl.asm" + +.include "testwin.asm" + .include "ressources.inc" diff --git a/avr/devices/c03/main/testwin.asm b/avr/devices/c03/main/testwin.asm new file mode 100644 index 0000000..37a82e7 --- /dev/null +++ b/avr/devices/c03/main/testwin.asm @@ -0,0 +1,101 @@ +; *************************************************************************** +; copyright : (C) 2025 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_DEVICE_C03_TESTWIN_ASM +#define AQH_AVR_DEVICE_C03_TESTWIN_ASM + + +; *************************************************************************** +; defines + + + +; *************************************************************************** +; data + +.dseg + +testApp_ramdata: + .byte GUIAPP_SD_SIZE + + +testWin_ramdata: + .byte WIDGET_SD_SIZE + + + +; *************************************************************************** +; code + +.cseg + +testCntrl: + ; OBJECT + .dw 0 ; next + .dw 0 ; parent + .dw testApp_flashdata*2 ; first child + .dw 0 ; target + .dw 0 ; selector (ony lower 8 bits used) + .dw testCntrl_signalmap*2 ; signal map + +testCntrl_signalmap: + .db 0, OBJECT_SIGNAL_CREATE, LOW(GuiCntlr_OnCreate), HIGH(GuiCntlr_OnCreate) + .db 0, GUIAPP_SIGNAL_RAISE, LOW(GuiCntlr_OnRaise), HIGH(GuiCntlr_OnRaise) + .db 0, 0, 0, 0 ; end of table + + +testApp_flashdata: + ; OBJECT + .dw 0 ; next + .dw testCntrl*2 ; parent + .dw 0 ; first child + .dw testCntrl*2 ; target + .dw 0 ; selector (ony lower 8 bits used) + .dw testApp_signalmap*2 ; signal map + ; GUIAPP + .dw testApp_ramdata ; SDRAM data + .dw testWin_flashdata*2 ; root widget + .dw 0 ; root timer + +testApp_signalmap: + .db 0, OBJECT_SIGNAL_CREATE, LOW(GuiApp_OnCreate), HIGH(GuiApp_OnCreate) + .db 0, 0, 0, 0 ; end of table + + +testWin_flashdata: + ; OBJECT + .dw 0 ; next + .dw 0 ; parent + .dw 0 ; first child + .dw 0 ; target + .dw 0 ; selector (ony lower 8 bits used) + .dw testWin_signalmap*2 ; signal map + ; WIDGET + .db 0, 0 ; opts lo, hi + .dw 0 ; X + .dw 0 ; Y + .dw DISPLAY_WIDTH ; W + .dw DISPLAY_HEIGHT ; H + .dw 0 ; front color + .dw DISPLAY_COLOR_PURPLE ; back color +; .dw STYLE_WIN_FONT*2 ; font + .dw 0 ; font + .dw testWin_ramdata ; ptr to SDRAM +testWin_signalmap: + .db 0, OBJECT_SIGNAL_CREATE, LOW(Widget_OnCreate), HIGH(Widget_OnCreate) + .db 0, WIDGET_SIGNAL_DRAW, LOW(Widget_OnDraw), HIGH(Widget_OnDraw) + .db 0, 0, 0, 0 ; end of table + + + + + + +#endif + diff --git a/avr/modules/lcd2/gui2/0BUILD b/avr/modules/lcd2/gui2/0BUILD new file mode 100644 index 0000000..9135924 --- /dev/null +++ b/avr/modules/lcd2/gui2/0BUILD @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/avr/modules/lcd2/gui2/TODO b/avr/modules/lcd2/gui2/TODO new file mode 100644 index 0000000..d5c4987 --- /dev/null +++ b/avr/modules/lcd2/gui2/TODO @@ -0,0 +1,46 @@ + +Object: +- next +- parent +- firstChild +- options (2 bytes) +- signal handling + - targetAddr (like in FOX) + - selector + - handlerMap: + - selector/signal (00: end), handlerAddr +Widgets: +- x (2 bytes) +- y (2 bytes) +- width (2 bytes) +- height (2 bytes) +- font (2 bytes) +- frontColor (2 bytes) +- backColor (2 bytes) + +Labels: +- text + + +Signals: +- CREATE +- DESTROY +- SHOW +- HIDE +- DRAW +- TIMER +- TOUCH +[- KEY] +- USER = 16 + + + +OBJ: +- SDRAM pointer hierher verschieben +- speichere dort: + - FLAGS_LO, FLAGS_HI (2 bytes) + - NEXT, PARENT, CHILD (6 bytes) + +- OBJ_AddNeighbour() +- OBJ_AddChild() +- OBJ_Unlink() diff --git a/avr/modules/lcd2/gui2/guiapp.asm b/avr/modules/lcd2/gui2/guiapp.asm new file mode 100644 index 0000000..54f429f --- /dev/null +++ b/avr/modules/lcd2/gui2/guiapp.asm @@ -0,0 +1,310 @@ +; *************************************************************************** +; 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 + +; GuiApp in flash +.equ GUIAPP_OFFS_GUIAPP = OBJECT_SIZE +.equ GUIAPP_OFFS_SDRAM_LO = GUIAPP_OFFS_GUIAPP+0 +.equ GUIAPP_OFFS_SDRAM_HI = GUIAPP_OFFS_GUIAPP+1 +.equ GUIAPP_OFFS_ROOTWIDGET_LO = GUIAPP_OFFS_GUIAPP+2 +.equ GUIAPP_OFFS_ROOTWIDGET_HI = GUIAPP_OFFS_GUIAPP+3 +.equ GUIAPP_OFFS_ROOTTIMER_LO = GUIAPP_OFFS_GUIAPP+4 +.equ GUIAPP_OFFS_ROOTTIMER_HI = GUIAPP_OFFS_GUIAPP+5 +.equ GUIAPP_SIZE = GUIAPP_OFFS_GUIAPP+6 + +; signals +.equ GUIAPP_SIGNAL_RAISE = OBJECT_SIGNAL_NEXTFREE+0 ; X=GUIAPP to raise + +; SDRAM data for guiapp +.equ GUIAPP_SD_OFFS_FLAGS = 0 +.equ GUIAPP_SD_OFFS_DRAWTIMER = 1 +.equ GUIAPP_SD_SIZE = 2 + + +; guiapp flags +.equ GUIAPP_FLAGS_ACTIVE_BIT = 7 + + +.equ GUIAPP_DRAWTIMER = 3 + + + +; *************************************************************************** +; code + +.cseg + + + +; --------------------------------------------------------------------------- +; @routine GuiApp_Init +; +; @param Z byte address of guiapp object (for LPM!) + +GuiApp_Init: + ; init sdram data + rcall GuiApp_GetSdramPtr + clr r16 + std Y+GUIAPP_SD_OFFS_FLAGS, r16 + ldi r16, GUIAPP_DRAWTIMER + std Y+GUIAPP_SD_OFFS_DRAWTIMER, r16 + + rcall guiAppInitWidgets + rcall guiAppInitTimers + + ret +; @end + + + +; --------------------------------------------------------------------------- +; @routine guiAppInitWidgets +; +; @param Z byte address of guiapp object (for LPM!) + +guiAppInitWidgets: + ; init widgets + push zl + push zh + adiw zh:zl, GUIAPP_OFFS_ROOTWIDGET_LO + lpm r16, Z+ + lpm zh, Z + mov zl, r16 + or r16, zh + breq guiAppInitWidgets_done + ldi r16, OBJECT_SIGNAL_CREATE + clr r17 + bigcall OBJ_TreeAllHandleSignal +guiAppInitWidgets_done: + pop zh + pop zl + ret +; @end + + + +; --------------------------------------------------------------------------- +; @routine guiAppInitTimers +; +; @param Z byte address of guiapp object (for LPM!) + +guiAppInitTimers: + ; init timers + push zl + push zh + adiw zh:zl, GUIAPP_OFFS_ROOTTIMER_LO + lpm r16, Z+ + lpm zh, Z + mov zl, r16 + or r17, zh + breq guiAppInitTimers_done + ldi r16, OBJECT_SIGNAL_CREATE + clr r17 + bigcall OBJ_TreeAllHandleSignal +guiAppInitTimers_done: + pop zh + pop zl + ret +; @end + + + +; --------------------------------------------------------------------------- +; @routine GuiApp_Show +; +; @param Z byte address of guiapp object (for LPM!) + +GuiApp_Show: + push zl + push zh + adiw zh:zl, GUIAPP_OFFS_ROOTWIDGET_LO + lpm r16, Z+ + lpm zh, Z + mov zl, r16 + or r17, zh + breq GuiApp_Show_done + ldi r16, (1<