another GUI approach, this time more generic.
This commit is contained in:
@@ -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"
|
||||
|
||||
|
||||
|
||||
101
avr/devices/c03/main/testwin.asm
Normal file
101
avr/devices/c03/main/testwin.asm
Normal file
@@ -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
|
||||
|
||||
10
avr/modules/lcd2/gui2/0BUILD
Normal file
10
avr/modules/lcd2/gui2/0BUILD
Normal file
@@ -0,0 +1,10 @@
|
||||
<?xml?>
|
||||
|
||||
<gwbuild>
|
||||
|
||||
<extradist>
|
||||
</extradist>
|
||||
|
||||
</gwbuild>
|
||||
|
||||
|
||||
46
avr/modules/lcd2/gui2/TODO
Normal file
46
avr/modules/lcd2/gui2/TODO
Normal file
@@ -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()
|
||||
310
avr/modules/lcd2/gui2/guiapp.asm
Normal file
310
avr/modules/lcd2/gui2/guiapp.asm
Normal file
@@ -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<<WIDGET_FLAGS_ACTIVE_BIT) | (1<<WIDGET_FLAGS_DIRTY_BIT)
|
||||
rcall Widget_AddFlagsDown
|
||||
GuiApp_Show_done:
|
||||
pop zh
|
||||
pop zl
|
||||
|
||||
rcall GuiApp_GetSdramPtr
|
||||
ldd r16, Y+GUIAPP_SD_OFFS_FLAGS
|
||||
sbr r16, (1<<GUIAPP_FLAGS_ACTIVE_BIT)
|
||||
std Y+GUIAPP_SD_OFFS_FLAGS, r16
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine GuiApp_Hide
|
||||
;
|
||||
; @param Z byte address of guiapp object (for LPM!)
|
||||
|
||||
GuiApp_Hide:
|
||||
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_Hide_done
|
||||
ldi r16, (1<<WIDGET_FLAGS_ACTIVE_BIT) | (1<<WIDGET_FLAGS_DIRTY_BIT)
|
||||
rcall Widget_SubFlagsDown
|
||||
GuiApp_Hide_done:
|
||||
pop zh
|
||||
pop zl
|
||||
|
||||
rcall GuiApp_GetSdramPtr
|
||||
ldd r16, Y+GUIAPP_SD_OFFS_FLAGS
|
||||
cbr r16, (1<<GUIAPP_FLAGS_ACTIVE_BIT)
|
||||
std Y+GUIAPP_SD_OFFS_FLAGS, r16
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine GuiApp_Every100ms
|
||||
;
|
||||
; @param Z byte address of guiapp object (for LPM!)
|
||||
|
||||
GuiApp_Every100ms:
|
||||
; generate timer event for all app 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 GuiApp_Every100ms_done
|
||||
ldi r16, OBJECT_SIGNAL_TIMER
|
||||
clr r17
|
||||
bigcall OBJ_TreeAllHandleSignal
|
||||
GuiApp_Every100ms_done:
|
||||
pop zh
|
||||
pop zl
|
||||
|
||||
; draw widgets
|
||||
rcall GuiApp_GetSdramPtr
|
||||
ldd r16, Y+GUIAPP_SD_OFFS_FLAGS
|
||||
sbrs r16, GUIAPP_FLAGS_ACTIVE_BIT
|
||||
rjmp GuiApp_Every100ms_ret
|
||||
ldd r16, Y+GUIAPP_SD_OFFS_DRAWTIMER
|
||||
tst r16
|
||||
breq GuiApp_Every100ms_ret
|
||||
dec r16
|
||||
brne GuiApp_Every100ms_writeDrawTimer
|
||||
rcall guiAppDrawWidgets
|
||||
ldi r16, GUIAPP_DRAWTIMER
|
||||
GuiApp_Every100ms_writeDrawTimer:
|
||||
std Y+GUIAPP_SD_OFFS_DRAWTIMER, r16
|
||||
GuiApp_Every100ms_ret:
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine GuiApp_Touch
|
||||
;
|
||||
; @param Z byte address of guiapp object (for LPM!)
|
||||
; @param X pointer to touch event in SDRAM
|
||||
|
||||
GuiApp_Touch:
|
||||
push zl
|
||||
push zh
|
||||
adiw zh:zl, GUIAPP_OFFS_ROOTWIDGET_LO
|
||||
lpm r18, Z+
|
||||
lpm zh, Z
|
||||
mov zl, r18
|
||||
or r18, zh
|
||||
breq GuiApp_Touch_done
|
||||
ldi r16, WIDGET_SIGNAL_TOUCH
|
||||
clr r17
|
||||
rcall OBJ_TreeHandleSignal
|
||||
GuiApp_Touch_done:
|
||||
pop zh
|
||||
pop zl
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine GuiApp_OnCreate @global
|
||||
;
|
||||
; @param Z byte address of object (for LPM!)
|
||||
; @return CFLAG set if signal handled
|
||||
; @clobbers any, !Z
|
||||
|
||||
GuiApp_OnCreate:
|
||||
rcall GuiApp_Init
|
||||
sec
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine guiAppDrawWidgets
|
||||
;
|
||||
; @param Z byte address of guiapp object (for LPM!)
|
||||
|
||||
guiAppDrawWidgets:
|
||||
rcall GuiApp_GetSdramPtr
|
||||
ldd r16, Y+GUIAPP_SD_OFFS_FLAGS
|
||||
sbrs r16, GUIAPP_FLAGS_ACTIVE_BIT
|
||||
rjmp guiAppDrawWidgets_ret
|
||||
|
||||
push zl
|
||||
push zh
|
||||
adiw zh:zl, GUIAPP_OFFS_ROOTWIDGET_LO
|
||||
lpm r16, Z+
|
||||
lpm zh, Z
|
||||
mov zl, r16
|
||||
or r17, zh
|
||||
breq guiAppDrawWidgets_done
|
||||
bigcall Widget_Tree_Draw
|
||||
guiAppDrawWidgets_done:
|
||||
pop zh
|
||||
pop zl
|
||||
guiAppDrawWidgets_ret:
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine GuiApp_GetSdramPtr @global
|
||||
;
|
||||
; @param Z byte address of object (for LPM!)
|
||||
; @return Y pointer to SDRAM data for widget
|
||||
; @clobbers none
|
||||
|
||||
GuiApp_GetSdramPtr:
|
||||
adiw zh:zl, GUIAPP_OFFS_SDRAM_LO
|
||||
lpm yl, Z+
|
||||
lpm yh, Z
|
||||
sbiw zh:zl, GUIAPP_OFFS_SDRAM_LO+1
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
#endif
|
||||
260
avr/modules/lcd2/gui2/guicntrl.asm
Normal file
260
avr/modules/lcd2/gui2/guicntrl.asm
Normal file
@@ -0,0 +1,260 @@
|
||||
; ***************************************************************************
|
||||
; 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_GUICNTRL_ASM
|
||||
#define AQH_AVR_GUI2_GUICNTRL_ASM
|
||||
|
||||
|
||||
; ***************************************************************************
|
||||
; defines
|
||||
|
||||
|
||||
|
||||
; ***************************************************************************
|
||||
; data
|
||||
|
||||
.dseg
|
||||
|
||||
guicntl_touch_event:
|
||||
.byte WIDGET_DATA_TOUCH_SIZE
|
||||
|
||||
guicntl_current_app:
|
||||
.byte 2
|
||||
|
||||
|
||||
|
||||
; ***************************************************************************
|
||||
; code
|
||||
|
||||
.cseg
|
||||
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine GuiApp_ShowFirstChild @global
|
||||
;
|
||||
; @param Z byte address of guiapp object (for LPM!)
|
||||
|
||||
GuiCntrl_ShowFirstApp:
|
||||
; select first child (GuiApp) as current app
|
||||
bigcall OBJ_GetFirstChild
|
||||
mov xl, r18
|
||||
mov xh, r19
|
||||
or r18, r19
|
||||
breq GuiCntrl_ShowFirstApp_ret
|
||||
rcall GuiCntlr_ShowApp
|
||||
GuiCntrl_ShowFirstApp_ret:
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine GuiCntrl_ShowApp @global
|
||||
;
|
||||
; @param Z byte address of object (for LPM!)
|
||||
; @param X byte address of object to raise (for LPM!)
|
||||
; @return CFLAG set if signal handled
|
||||
; @clobbers any, !Z
|
||||
|
||||
GuiCntlr_ShowApp:
|
||||
lds r18, guicntl_current_app
|
||||
lds r19, guicntl_current_app+1
|
||||
|
||||
cp r18, xl
|
||||
brne GuiCntlr_ShowApp_changed
|
||||
cp r19, xh
|
||||
breq GuiCntlr_ShowApp_secRet ; already current app
|
||||
GuiCntlr_ShowApp_changed:
|
||||
push zl
|
||||
push zh
|
||||
push xl
|
||||
push xh
|
||||
; hide previous app
|
||||
mov zl, r18
|
||||
mov zh, r19
|
||||
or r18, r19
|
||||
breq GuiCntlr_ShowApp_l1
|
||||
bigcall GuiApp_Hide
|
||||
GuiCntlr_ShowApp_l1:
|
||||
pop zh
|
||||
pop zl
|
||||
; show new app
|
||||
mov r16, zl
|
||||
or r16, zh
|
||||
breq GuiCntlr_ShowApp_l2
|
||||
bigcall GuiApp_Show
|
||||
GuiCntlr_ShowApp_l2:
|
||||
pop zh
|
||||
pop zl
|
||||
GuiCntlr_ShowApp_secRet:
|
||||
sec
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine GuiCntrl_Every100ms @global
|
||||
;
|
||||
; @param Z byte address of guiapp object (for LPM!)
|
||||
|
||||
GuiCntrl_Every100ms:
|
||||
rcall guiCntrlCheckTouch
|
||||
rcall guiCntrlSendTimer
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine guiCntrlCheckTouch
|
||||
;
|
||||
; @param Z byte address of guiapp object (for LPM!)
|
||||
|
||||
guiCntrlCheckTouch:
|
||||
bigcall Display_InputGetState ; r16=flags, r5:r4=x, r7:r6=y
|
||||
mov r17, r16
|
||||
andi r17, (1<<DISPLAY_IFLAGS_CHGCOORD_BIT) | (1<<DISPLAY_IFLAGS_CHGPRESS_BIT)
|
||||
breq guiCntrlCheckTouch_ret
|
||||
ldi xl, LOW(guicntl_touch_event)
|
||||
ldi xh, HIGH(guicntl_touch_event)
|
||||
st X+, r4 ; X
|
||||
st X+, r5
|
||||
st X+, r6 ; Y
|
||||
st X+, r7
|
||||
st X, r16 ; flags
|
||||
sbiw xh:xl, 4 ; (4 times incremented)
|
||||
push zl
|
||||
push zh
|
||||
lds zl, guicntl_current_app
|
||||
lds zh, guicntl_current_app+1
|
||||
mov r16, zl
|
||||
or r16, zh
|
||||
breq guiCntrlCheckTouch_l1
|
||||
bigcall GuiApp_Touch
|
||||
guiCntrlCheckTouch_l1:
|
||||
pop zh
|
||||
pop zl
|
||||
guiCntrlCheckTouch_ret:
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine guiCntrlSendTimer
|
||||
;
|
||||
; @param Z byte address of guiapp object (for LPM!)
|
||||
|
||||
guiCntrlSendTimer:
|
||||
push zl
|
||||
push zh
|
||||
bigcall OBJ_GetFirstChild
|
||||
guiCntrlSendTimer_loop:
|
||||
mov zl, r18
|
||||
mov zh, r19
|
||||
or r18, r19
|
||||
breq guiCntrlSendTimer_loopEnd
|
||||
bigcall GuiApp_Every100ms
|
||||
bigcall OBJ_GetNext
|
||||
rjmp guiCntrlSendTimer_loop
|
||||
guiCntrlSendTimer_loopEnd:
|
||||
pop zh
|
||||
pop zl
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine GuiApp_Init @global
|
||||
;
|
||||
; @param Z byte address of guiapp object (for LPM!)
|
||||
|
||||
GuiCntrl_Init:
|
||||
clr r16
|
||||
sts guicntl_current_app, r16
|
||||
sts guicntl_current_app+1, r16
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
; +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
; signal handlers (to directly be used in signal maps)
|
||||
; +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine GuiCntrl_OnCreate @global
|
||||
;
|
||||
; @param Z byte address of object (for LPM!)
|
||||
; @return CFLAG set if signal handled
|
||||
; @clobbers any, !Z
|
||||
|
||||
GuiCntlr_OnCreate:
|
||||
rcall GuiCntrl_Init
|
||||
sec
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine GuiCntrl_OnRaise @global
|
||||
;
|
||||
; @param Z byte address of object (for LPM!)
|
||||
; @param X byte address of object to raise (for LPM!)
|
||||
; @return CFLAG set if signal handled
|
||||
; @clobbers any, !Z
|
||||
|
||||
GuiCntlr_OnRaise:
|
||||
lds r18, guicntl_current_app
|
||||
lds r19, guicntl_current_app+1
|
||||
|
||||
cp r18, xl
|
||||
brne GuiCntlr_OnRaise_changed
|
||||
cp r19, xh
|
||||
breq GuiCntlr_OnRaise_secRet ; already current app
|
||||
GuiCntlr_OnRaise_changed:
|
||||
push zl
|
||||
push zh
|
||||
push xl
|
||||
push xh
|
||||
mov zl, r18
|
||||
mov zh, r19
|
||||
or r18, r19
|
||||
breq GuiCntlr_OnRaise_l1
|
||||
bigcall GuiApp_Hide
|
||||
GuiCntlr_OnRaise_l1:
|
||||
pop zh
|
||||
pop zl
|
||||
mov r16, zl
|
||||
or r16, zh
|
||||
breq GuiCntlr_OnRaise_l2
|
||||
bigcall GuiApp_Show
|
||||
GuiCntlr_OnRaise_l2:
|
||||
pop zh
|
||||
pop zl
|
||||
GuiCntlr_OnRaise_secRet:
|
||||
sec
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
109
avr/modules/lcd2/gui2/label.asm
Normal file
109
avr/modules/lcd2/gui2/label.asm
Normal file
@@ -0,0 +1,109 @@
|
||||
; ***************************************************************************
|
||||
; 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_LABEL_ASM
|
||||
#define AQH_AVR_GUI2_LABEL_ASM
|
||||
|
||||
|
||||
; ***************************************************************************
|
||||
; defines
|
||||
|
||||
; Label in flash
|
||||
.equ LABEL_OFFS_LABEL = WIDGET_SIZE
|
||||
.equ LABEL_OFFS_TEXT_LO = LABEL_OFFS_LABEL+0
|
||||
.equ LABEL_OFFS_TEXT_HI = LABEL_OFFS_LABEL+1
|
||||
.equ LABEL_SIZE = LABEL_OFFS_LABEL+2
|
||||
|
||||
|
||||
|
||||
; ***************************************************************************
|
||||
; code
|
||||
|
||||
.cseg
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine Label_OnDraw @global
|
||||
;
|
||||
; @param Z byte address of object (for LPM!)
|
||||
; @param xl param1
|
||||
; @param xh param2
|
||||
; @clobbers any, !Z
|
||||
|
||||
Label_OnDraw:
|
||||
bigcall Widget_GetSdramPtr ; (none)
|
||||
ldd r16, Y+WIDGET_SD_OFFS_FLAGS
|
||||
andi r16, (1<<WIDGET_FLAGS_DIRTY_BIT)
|
||||
breq Label_OnDraw_ret
|
||||
|
||||
bigcall Widget_LoadDisplayRegs
|
||||
adiw zh:zl, WIDGET_OFFS_OPTS_LO ; get OPTS low
|
||||
lpm r14, Z
|
||||
sbiw zh:zl, WIDGET_OFFS_OPTS_LO
|
||||
|
||||
rcall Widget_Clear
|
||||
rcall labelWriteText
|
||||
mov r16, r14
|
||||
andi r16, (1<<WIDGETS_OPTSLO_BORDER_BIT)
|
||||
breq Label_OnDraw_done
|
||||
|
||||
ldi r16, LOW(STYLE_BUTTON_COL_BORDER)
|
||||
mov r2, r16
|
||||
ldi r16, HIGH(STYLE_BUTTON_COL_BORDER)
|
||||
mov r3, r16
|
||||
bigcall Widget_DrawBorder
|
||||
|
||||
Label_OnDraw_done:
|
||||
ldd r16, Y+WIDGET_SD_OFFS_FLAGS
|
||||
cbr r16, (1<<WIDGET_FLAGS_DIRTY_BIT)
|
||||
std Y+WIDGET_SD_OFFS_FLAGS, r16
|
||||
|
||||
Label_OnDraw_ret:
|
||||
sec
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine labelWriteText
|
||||
;
|
||||
; @param Z byte address of object (for LPM!)
|
||||
; @param R1:R0 background color
|
||||
; @param R3:R2 foreground color
|
||||
; @param R5:R4 X
|
||||
; @param R7:R6 Y
|
||||
; @param R9:R8 widget width
|
||||
; @param R11:R10 widget height
|
||||
; @param R14 opts low
|
||||
; @clobbers any, !Z
|
||||
|
||||
labelWriteText:
|
||||
mov r16, r14
|
||||
andi r16, (1<<WIDGETS_OPTSLO_BORDER_BIT)
|
||||
breq labelWriteText_draw
|
||||
ldi r16, 2
|
||||
clr r17
|
||||
add r4, r16 ; x+=2
|
||||
adc r5, r17
|
||||
add r6, r16 ; y+=2
|
||||
adc r7, r17
|
||||
labelWriteText_draw:
|
||||
adiw zh:zl, LABEL_OFFS_TEXT_LO
|
||||
lpm r12, Z+
|
||||
lpm r13, Z
|
||||
sbiw zh:zl, LABEL_OFFS_TEXT_LO+1
|
||||
bigcall Widget_DrawTextFlash
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
366
avr/modules/lcd2/gui2/object.asm
Normal file
366
avr/modules/lcd2/gui2/object.asm
Normal file
@@ -0,0 +1,366 @@
|
||||
; ***************************************************************************
|
||||
; 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_OBJECT_ASM
|
||||
#define AQH_AVR_GUI2_OBJECT_ASM
|
||||
|
||||
|
||||
; ***************************************************************************
|
||||
; defines
|
||||
|
||||
; Object in flash
|
||||
.equ OBJECT_OFFS_NEXT_LO = 0 ; byte address (for LPM!)
|
||||
.equ OBJECT_OFFS_NEXT_HI = 1
|
||||
.equ OBJECT_OFFS_PARENT_LO = 2 ; byte address (for LPM!)
|
||||
.equ OBJECT_OFFS_PARENT_HI = 3
|
||||
.equ OBJECT_OFFS_CHILD_LO = 4 ; byte address (for LPM!)
|
||||
.equ OBJECT_OFFS_CHILD_HI = 5
|
||||
.equ OBJECT_OFFS_TARGET_LO = 6 ; byte address (for LPM!)
|
||||
.equ OBJECT_OFFS_TARGET_HI = 7
|
||||
.equ OBJECT_OFFS_SELECTOR = 8
|
||||
.equ OBJECT_OFFS_UNUSED = 9
|
||||
.equ OBJECT_OFFS_SIGNALMAP_LO = 10 ; byte address (for LPM!)
|
||||
.equ OBJECT_OFFS_SIGNALMAP_HI = 11
|
||||
.equ OBJECT_SIZE = 12
|
||||
|
||||
; SignalMap entries
|
||||
.equ OBJECT_SIGNALMAP_OFFS_SELECTOR = 0
|
||||
.equ OBJECT_SIGNALMAP_OFFS_SIGNAL = 1 ; end if 0
|
||||
.equ OBJECT_SIGNALMAP_OFFS_HANDLER_LO = 2
|
||||
.equ OBJECT_SIGNALMAP_OFFS_HANDLER_HI = 3
|
||||
|
||||
; signals
|
||||
.equ OBJECT_SIGNAL_NONE = 0
|
||||
.equ OBJECT_SIGNAL_CREATE = 1
|
||||
.equ OBJECT_SIGNAL_DESTROY = 2
|
||||
.equ OBJECT_SIGNAL_TIMER = 3
|
||||
.equ OBJECT_SIGNAL_NEXTFREE = 4
|
||||
|
||||
|
||||
|
||||
|
||||
; ***************************************************************************
|
||||
; code
|
||||
|
||||
.cseg
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine OBJ_GetParent @global
|
||||
;
|
||||
; @param Z byte address of object (for LPM!)
|
||||
; @return r19:r18 resulting object (byte address for LPM!), NULL otherwise
|
||||
; @clobbers none
|
||||
|
||||
OBJ_GetParent:
|
||||
adiw zh:zl, OBJECT_OFFS_PARENT_LO
|
||||
lpm r18, Z+
|
||||
lpm r19, Z
|
||||
sbiw zh:zl, (OBJECT_OFFS_PARENT_LO+1)
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine OBJ_GetFirstChild @global
|
||||
;
|
||||
; @param Z byte address of object (for LPM!)
|
||||
; @return r19:r18 resulting object (byte address for LPM!), NULL otherwise
|
||||
; @clobbers none
|
||||
|
||||
OBJ_GetFirstChild:
|
||||
adiw zh:zl, OBJECT_OFFS_CHILD_LO
|
||||
lpm r18, Z+
|
||||
lpm r19, Z
|
||||
sbiw zh:zl, OBJECT_OFFS_CHILD_LO+1
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine OBJ_GetNext @global
|
||||
;
|
||||
; @param Z byte address of object (for LPM!)
|
||||
; @return r19:r18 resulting object (byte address for LPM!), NULL otherwise
|
||||
; @clobbers none
|
||||
|
||||
OBJ_GetNext:
|
||||
adiw zh:zl, OBJECT_OFFS_NEXT_LO
|
||||
lpm r18, Z+
|
||||
lpm r19, Z
|
||||
sbiw zh:zl, OBJECT_OFFS_NEXT_LO+1
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine OBJ_GetBelow @global
|
||||
;
|
||||
; @param Z byte address of object (for LPM!)
|
||||
; @return r19:r18 resulting object (byte address for LPM!), NULL otherwise
|
||||
; @clobbers r16
|
||||
|
||||
OBJ_GetBelow:
|
||||
; check first child
|
||||
rcall OBJ_GetFirstChild
|
||||
mov r16, r18
|
||||
or r16, r19
|
||||
sec
|
||||
brne OBJ_GetBelow_ret
|
||||
; check neighbour
|
||||
rcall OBJ_GetNext
|
||||
mov r16, r18
|
||||
or r16, r19
|
||||
sec
|
||||
brne OBJ_GetBelow_ret
|
||||
|
||||
OBJ_GetBelow_loop:
|
||||
rcall OBJ_GetParent
|
||||
mov r16, r18
|
||||
or r16, r19
|
||||
clc
|
||||
breq OBJ_GetBelow_ret
|
||||
; use parent
|
||||
mov zl, r18
|
||||
mov zh, r19
|
||||
; don't check for first child here, we came from there!
|
||||
rcall OBJ_GetNext
|
||||
mov r16, r18
|
||||
or r16, r19
|
||||
sec
|
||||
brne OBJ_GetBelow_ret
|
||||
rjmp OBJ_GetBelow_loop
|
||||
OBJ_GetBelow_ret:
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine OBJ_EmitSignal @global
|
||||
;
|
||||
; @param Z byte address of object (for LPM!)
|
||||
; @param R16 signal number
|
||||
; @param xl param1
|
||||
; @param xh param2
|
||||
; @clobbers any, !Z
|
||||
|
||||
OBJ_EmitSignal:
|
||||
push zl
|
||||
push zh
|
||||
rcall OBJ_EmitSignal_savedZ
|
||||
pop zh
|
||||
pop zl
|
||||
rjmp OBJ_EmitSignal_ret
|
||||
|
||||
OBJ_EmitSignal_savedZ:
|
||||
adiw zh:zl, OBJECT_OFFS_SELECTOR
|
||||
lpm r17, Z
|
||||
sbiw zh:zl, OBJECT_OFFS_SELECTOR
|
||||
adiw zh:zl, OBJECT_OFFS_TARGET_LO
|
||||
lpm r23, Z+
|
||||
lpm zh, Z
|
||||
mov zl, r23
|
||||
rjmp objHandleSignal ; (any, !Z)
|
||||
|
||||
OBJ_EmitSignal_ret:
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine OBJ_TreeHandleSignal @global
|
||||
;
|
||||
; @param Z byte address of object (for LPM!)
|
||||
; @param R16 signal number
|
||||
; @param R17 selector
|
||||
; @param xl param1
|
||||
; @param xh param2
|
||||
; @return CFLAG set if handled, cleared otherwise
|
||||
; @clobbers any, !R16, !R17, !X, !Z
|
||||
|
||||
OBJ_TreeHandleSignal:
|
||||
push zl
|
||||
push zh
|
||||
mov r18, zl
|
||||
or r18, zh
|
||||
clc
|
||||
breq OBJ_TreeHandleSignal_done
|
||||
rcall objectHandleSignalSaveInRegs
|
||||
brcs OBJ_TreeHandleSignal_done
|
||||
|
||||
rcall OBJ_GetFirstChild
|
||||
OBJ_TreeHandleSignal_loop:
|
||||
mov zl, r18
|
||||
mov zh, r19
|
||||
or r18, r19
|
||||
clc
|
||||
breq OBJ_TreeHandleSignal_done
|
||||
rcall OBJ_TreeHandleSignal ; recursion
|
||||
;rcall objectHandleSignalSaveInRegs
|
||||
brcs OBJ_TreeHandleSignal_done
|
||||
rcall OBJ_GetNext
|
||||
rjmp OBJ_TreeHandleSignal_loop
|
||||
|
||||
OBJ_TreeHandleSignal_done:
|
||||
pop zh
|
||||
pop zl
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine OBJ_TreeAllHandleSignal @global
|
||||
;
|
||||
; @param Z byte address of object (for LPM!)
|
||||
; @param R16 signal number
|
||||
; @param R17 selector
|
||||
; @param xl param1
|
||||
; @param xh param2
|
||||
; @clobbers any, !R16, !R17, !X, !Z
|
||||
|
||||
OBJ_TreeAllHandleSignal:
|
||||
push zl
|
||||
push zh
|
||||
|
||||
OBJ_TreeAllHandleSignal_loop:
|
||||
mov r18, zl
|
||||
or r18, zh
|
||||
breq OBJ_TreeAllHandleSignal_done
|
||||
rcall objectHandleSignalSaveInRegs
|
||||
push r16
|
||||
rcall OBJ_GetBelow ; (R16)
|
||||
pop r16
|
||||
brcc OBJ_TreeAllHandleSignal_done
|
||||
mov zl, r18
|
||||
mov zh, r19
|
||||
rjmp OBJ_TreeAllHandleSignal_loop
|
||||
OBJ_TreeAllHandleSignal_done:
|
||||
pop zh
|
||||
pop zl
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine objectHandleSignalSaveInRegs
|
||||
;
|
||||
; @param Z byte address of object (for LPM!)
|
||||
; @param R16 signal number
|
||||
; @param R17 selector
|
||||
; @param xl param1
|
||||
; @param xh param2
|
||||
; @return CFLAG set if handled, cleared otherwise
|
||||
; @clobbers any, !R16, !R17, !X, !Z
|
||||
|
||||
objectHandleSignalSaveInRegs:
|
||||
push r16
|
||||
push r17
|
||||
push xl
|
||||
push xh
|
||||
rcall objHandleSignal
|
||||
pop xh
|
||||
pop xl
|
||||
pop r17
|
||||
pop r16
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine objHandleSignal
|
||||
;
|
||||
; @param Z byte address of object (for LPM!)
|
||||
; @param R16 signal number
|
||||
; @param R17 selector
|
||||
; @param xl param1
|
||||
; @param xh param2
|
||||
; @return CFLAG set if handled, cleared otherwise
|
||||
; @clobbers any, !Z
|
||||
|
||||
objHandleSignal:
|
||||
push zl
|
||||
push zh
|
||||
rcall objGetHandlerFromSignalMap
|
||||
brcc objHandleSignal_done
|
||||
rcall objHandleSignal_jmpR19R18
|
||||
objHandleSignal_done:
|
||||
pop zh
|
||||
pop zl
|
||||
ret
|
||||
objHandleSignal_jmpR19R18:
|
||||
; jmp to r19:r18 via stack
|
||||
push r18
|
||||
push r19
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine objGetHandlerFromSignalMap
|
||||
;
|
||||
; @param Z byte address of object (for LPM!)
|
||||
; @param R16 signal number
|
||||
; @param R17 selector
|
||||
; @param xl param1
|
||||
; @param xh param2
|
||||
; @return CFLAG set if found, cleared otherwise
|
||||
; @return R19:R18 handler found
|
||||
; @clobbers any, !Z
|
||||
|
||||
objGetHandlerFromSignalMap:
|
||||
push zl
|
||||
push zh
|
||||
adiw zh:zl, OBJECT_OFFS_SIGNALMAP_LO
|
||||
lpm r23, Z+
|
||||
lpm zh, Z
|
||||
mov zl, r23
|
||||
or r23, zh
|
||||
clc
|
||||
breq objGetHandlerFromSignalMap_done ; no signal map
|
||||
objGetHandlerFromSignalMap_loop:
|
||||
lpm r22, Z+ ; selector
|
||||
lpm r23, Z+ ; signal (0=end of table)
|
||||
lpm r18, Z+ ; handler LOW
|
||||
lpm r19, Z+ ; handler HIGH
|
||||
tst r23
|
||||
clc
|
||||
breq objGetHandlerFromSignalMap_done
|
||||
cp r16, r23
|
||||
brne objGetHandlerFromSignalMap_next
|
||||
cp r17, r22
|
||||
brne objGetHandlerFromSignalMap_next
|
||||
mov r23, r18
|
||||
or r23, r19
|
||||
clc
|
||||
breq objGetHandlerFromSignalMap_done
|
||||
sec ; found handler
|
||||
rjmp objGetHandlerFromSignalMap_done
|
||||
objGetHandlerFromSignalMap_next:
|
||||
rjmp objGetHandlerFromSignalMap_loop
|
||||
|
||||
objGetHandlerFromSignalMap_done:
|
||||
pop zh
|
||||
pop zl
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
32
avr/modules/lcd2/gui2/style.asm
Normal file
32
avr/modules/lcd2/gui2/style.asm
Normal file
@@ -0,0 +1,32 @@
|
||||
; ***************************************************************************
|
||||
; 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_STYLE_ASM
|
||||
#define AQH_AVR_GUI2_STYLE_ASM
|
||||
|
||||
|
||||
.equ STYLE_WIN_TITLE_BACKGROUND = DISPLAY_COLOR_NAVY
|
||||
.equ STYLE_WIN_TITLE_FOREGROUND = DISPLAY_COLOR_WHITE
|
||||
.equ STYLE_BUTTON_COL_BORDER = DISPLAY_COLOR_BLACK
|
||||
.equ STYLE_BUTTON_COL_BG_NORM = DISPLAY_COLOR_WHITE
|
||||
.equ STYLE_BUTTON_COL_BG_PRESSED = DISPLAY_COLOR_NAVY
|
||||
.equ STYLE_BUTTON_COL_FG_NORM = DISPLAY_COLOR_BLACK
|
||||
.equ STYLE_BUTTON_COL_FG_PRESSED = DISPLAY_COLOR_WHITE
|
||||
|
||||
.equ STYLE_WIN_BACKGROUND = DISPLAY_COLOR_LIGHTGREY
|
||||
.equ STYLE_WIN_FOREGROUND = DISPLAY_COLOR_BLACK
|
||||
.equ STYLE_WIN_FONT = ili9341Font12x16_1
|
||||
.equ STYLE_WIN_FONT_WIDTH = 12
|
||||
.equ STYLE_WIN_FONT_HEIGHT = 16
|
||||
|
||||
.equ STYLE_WIN_TITLE_HEIGHT = (STYLE_WIN_FONT_HEIGHT+4)
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
706
avr/modules/lcd2/gui2/widget.asm
Normal file
706
avr/modules/lcd2/gui2/widget.asm
Normal file
@@ -0,0 +1,706 @@
|
||||
; ***************************************************************************
|
||||
; 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_WIDGET_ASM
|
||||
#define AQH_AVR_GUI2_WIDGET_ASM
|
||||
|
||||
|
||||
; ***************************************************************************
|
||||
; defines
|
||||
|
||||
; Widget in flash
|
||||
.equ WIDGET_OFFS_WIDGET = OBJECT_SIZE
|
||||
.equ WIDGET_OFFS_OPTS_LO = WIDGET_OFFS_WIDGET+0
|
||||
.equ WIDGET_OFFS_OPTS_HI = WIDGET_OFFS_WIDGET+1
|
||||
.equ WIDGET_OFFS_X_LO = WIDGET_OFFS_WIDGET+2
|
||||
.equ WIDGET_OFFS_X_HI = WIDGET_OFFS_WIDGET+3
|
||||
.equ WIDGET_OFFS_Y_LO = WIDGET_OFFS_WIDGET+4
|
||||
.equ WIDGET_OFFS_Y_HI = WIDGET_OFFS_WIDGET+5
|
||||
.equ WIDGET_OFFS_WIDTH_LO = WIDGET_OFFS_WIDGET+6
|
||||
.equ WIDGET_OFFS_WIDTH_HI = WIDGET_OFFS_WIDGET+7
|
||||
.equ WIDGET_OFFS_HEIGHT_LO = WIDGET_OFFS_WIDGET+8
|
||||
.equ WIDGET_OFFS_HEIGHT_HI = WIDGET_OFFS_WIDGET+9
|
||||
.equ WIDGET_OFFS_FRONTCOL_LO = WIDGET_OFFS_WIDGET+10
|
||||
.equ WIDGET_OFFS_FRONTCOL_HI = WIDGET_OFFS_WIDGET+11
|
||||
.equ WIDGET_OFFS_BACKCOL_LO = WIDGET_OFFS_WIDGET+12
|
||||
.equ WIDGET_OFFS_BACKCOL_HI = WIDGET_OFFS_WIDGET+13
|
||||
.equ WIDGET_OFFS_FONT_LO = WIDGET_OFFS_WIDGET+14
|
||||
.equ WIDGET_OFFS_FONT_HI = WIDGET_OFFS_WIDGET+15
|
||||
.equ WIDGET_OFFS_SDRAM_LO = WIDGET_OFFS_WIDGET+16
|
||||
.equ WIDGET_OFFS_SDRAM_HI = WIDGET_OFFS_WIDGET+17
|
||||
.equ WIDGET_SIZE = WIDGET_OFFS_WIDGET+18
|
||||
|
||||
; SDRAM data for widget
|
||||
.equ WIDGET_SD_OFFS_FLAGS = 0
|
||||
.equ WIDGET_SD_SIZE = 1
|
||||
|
||||
; widget opts_lo
|
||||
.equ WIDGETS_OPTSLO_BORDER_BIT = 7
|
||||
.equ WIDGETS_OPTSLO_INPUT_BIT = 6 ; TOUCH, KEY
|
||||
|
||||
; widget flags
|
||||
.equ WIDGET_FLAGS_ACTIVE_BIT = 7
|
||||
.equ WIDGET_FLAGS_TOUCH_BIT = 6
|
||||
.equ WIDGET_FLAGS_DIRTY_BIT = 5
|
||||
.equ WIDGET_FLAGS_PRESSED_BIT = 4
|
||||
|
||||
; SDRAM data for signal WIDGET_SIGNAL_TOUCH
|
||||
.equ WIDGET_DATA_TOUCH_OFFS_X_LO = 0
|
||||
.equ WIDGET_DATA_TOUCH_OFFS_X_HI = 1
|
||||
.equ WIDGET_DATA_TOUCH_OFFS_Y_LO = 2
|
||||
.equ WIDGET_DATA_TOUCH_OFFS_Y_HI = 3
|
||||
.equ WIDGET_DATA_TOUCH_OFFS_STATE = 4
|
||||
.equ WIDGET_DATA_TOUCH_SIZE = 5
|
||||
|
||||
; signals
|
||||
.equ WIDGET_SIGNAL_SHOW = OBJECT_SIGNAL_NEXTFREE+0
|
||||
.equ WIDGET_SIGNAL_HIDE = OBJECT_SIGNAL_NEXTFREE+1
|
||||
.equ WIDGET_SIGNAL_DRAW = OBJECT_SIGNAL_NEXTFREE+2
|
||||
.equ WIDGET_SIGNAL_TOUCH = OBJECT_SIGNAL_NEXTFREE+3
|
||||
.equ WIDGET_SIGNAL_CLICKED = OBJECT_SIGNAL_NEXTFREE+4
|
||||
.equ WIDGET_SIGNAL_NEXTFREE = OBJECT_SIGNAL_NEXTFREE+5
|
||||
|
||||
|
||||
|
||||
; ***************************************************************************
|
||||
; code
|
||||
|
||||
.cseg
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine Widget_Init @global
|
||||
;
|
||||
; @param Z byte address of object (for LPM!)
|
||||
|
||||
Widget_Init:
|
||||
rcall Widget_GetSdramPtr ; (none)
|
||||
clr r16
|
||||
ori r16, (1<<WIDGET_FLAGS_DIRTY_BIT)
|
||||
std Y+WIDGET_SD_OFFS_FLAGS, r16
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine Widget_OnCreate @global
|
||||
;
|
||||
; @param Z byte address of object (for LPM!)
|
||||
; @return CFLAG set if signal handled
|
||||
; @clobbers any, !Z
|
||||
|
||||
Widget_OnCreate:
|
||||
rcall Widget_Init
|
||||
sec
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine Widget_OnTouch @global
|
||||
;
|
||||
; @param Z byte address of object (for LPM!)
|
||||
; @param xl param1
|
||||
; @param xh param2
|
||||
; @return CFLAG set if signal handled
|
||||
; @clobbers any, !Z
|
||||
|
||||
Widget_OnTouch:
|
||||
; check whether inputs are handled by this widget
|
||||
adiw zh:zl, WIDGET_OFFS_OPTS_LO
|
||||
lpm r16, Z
|
||||
sbiw zh:zl, WIDGET_OFFS_OPTS_LO
|
||||
andi r16, (1<<WIDGETS_OPTSLO_INPUT_BIT)
|
||||
clc
|
||||
breq Widget_OnTouch_ret
|
||||
|
||||
rcall Widget_GetSdramPtr
|
||||
; check whether widget is active
|
||||
ldd r17, Y+WIDGET_SD_OFFS_FLAGS
|
||||
andi r17, (1<<WIDGET_FLAGS_ACTIVE_BIT)
|
||||
breq Widget_OnTouch_secRet ; nope, jmp
|
||||
|
||||
; read touch signal data from X
|
||||
ld r18, X+ ; WIDGET_DATA_TOUCH_OFFS_X_LO
|
||||
ld r19, X+ ; WIDGET_DATA_TOUCH_OFFS_X_HI
|
||||
ld r20, X+ ; WIDGET_DATA_TOUCH_OFFS_Y_LO
|
||||
ld r21, X+ ; WIDGET_DATA_TOUCH_OFFS_Z_HI
|
||||
ld r22, X+ ; WIDGET_DATA_TOUCH_OFFS_STATE
|
||||
|
||||
; check for change of touch press
|
||||
mov r16, r22
|
||||
andi r16, (1<<DISPLAY_IFLAGS_CHGPRESS_BIT)
|
||||
breq Widget_OnTouch_secRet ; no press change, jmp
|
||||
|
||||
; check for position inside this widget
|
||||
rcall Widget_LoadDisplayRegs ; (R0-R11)
|
||||
rcall Widget_IsPointInRect ; (R16, R17)
|
||||
sbci r16, 0 ; r16=ff if touched inside, 0 otherwise
|
||||
|
||||
; touch changed, check whether touch came down or up
|
||||
mov r18, r22
|
||||
andi r18, (1<<DISPLAY_IFLAGS_PRESSED_BIT)
|
||||
breq Widget_OnTouch_up
|
||||
|
||||
; touch came down
|
||||
ldd r17, Y+WIDGET_SD_OFFS_FLAGS
|
||||
andi r17, (1<<WIDGET_FLAGS_PRESSED_BIT)
|
||||
brne Widget_OnTouch_secRet ; already down
|
||||
tst r16 ; down inside this widget?
|
||||
brne Widget_OnTouch_secRet ; nope, jmp
|
||||
ldd r17, Y+WIDGET_SD_OFFS_FLAGS
|
||||
ori r17, (1<<WIDGET_FLAGS_PRESSED_BIT) | (1<<WIDGET_FLAGS_DIRTY_BIT) ; up, dirty
|
||||
std Y+WIDGET_SD_OFFS_FLAGS, r17
|
||||
rjmp Widget_OnTouch_secRet
|
||||
|
||||
Widget_OnTouch_up:
|
||||
ldd r17, Y+WIDGET_SD_OFFS_FLAGS
|
||||
andi r17, (1<<WIDGET_FLAGS_PRESSED_BIT)
|
||||
breq Widget_OnTouch_secRet ; already up
|
||||
ldd r17, Y+WIDGET_SD_OFFS_FLAGS
|
||||
cbr r17, (1<<WIDGET_FLAGS_PRESSED_BIT) ; up
|
||||
ori r17, (1<<WIDGET_FLAGS_DIRTY_BIT)
|
||||
std Y+WIDGET_SD_OFFS_FLAGS, r17
|
||||
tst r16 ; was touch lost inside this widget?
|
||||
brne Widget_OnTouch_secRet ; nope, jmp
|
||||
; emit "CLICKED" signal
|
||||
ldi r16, WIDGET_SIGNAL_CLICKED
|
||||
rcall OBJ_EmitSignal
|
||||
Widget_OnTouch_secRet:
|
||||
sec
|
||||
Widget_OnTouch_ret:
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine Widget_OnDraw @global
|
||||
;
|
||||
; @param Z byte address of object (for LPM!)
|
||||
; @param xl param1
|
||||
; @param xh param2
|
||||
; @return CFLAG set if signal handled
|
||||
; @clobbers any, !Z
|
||||
|
||||
Widget_OnDraw:
|
||||
rcall Widget_GetSdramPtr
|
||||
ldd r17, Y+WIDGET_SD_OFFS_FLAGS
|
||||
|
||||
; check whether widget is active
|
||||
clc
|
||||
sbrs r17, WIDGET_FLAGS_ACTIVE_BIT
|
||||
rjmp Widget_OnDraw_ret
|
||||
|
||||
; check whether widget is dirty
|
||||
sec
|
||||
sbrs r17, WIDGET_FLAGS_DIRTY_BIT
|
||||
rjmp Widget_OnDraw_ret
|
||||
|
||||
; clear dirty bit
|
||||
cbr r17, (1<<WIDGET_FLAGS_DIRTY_BIT)
|
||||
std Y+WIDGET_SD_OFFS_FLAGS, r17
|
||||
; clear widget background
|
||||
rcall Widget_Clear
|
||||
|
||||
Widget_OnDraw_ret:
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine Widget_IsPointInRect @global
|
||||
;
|
||||
; @param R19:R18 check X
|
||||
; @param R21:R20 check Y
|
||||
; @param R5:R4 widget X
|
||||
; @param R7:R6 widget Y
|
||||
; @param R9:R8 widget width
|
||||
; @param R11:R10 widget height
|
||||
; @return CFLAG set if inside rect, cleared otherwise
|
||||
; @clobbers R16, R17
|
||||
|
||||
Widget_IsPointInRect:
|
||||
; check X
|
||||
mov r16, r18 ; checkX-widgetX
|
||||
mov r17, r19
|
||||
sub r16, r4
|
||||
sbc r17, r5
|
||||
brcs Widget_IsPointInRect_no
|
||||
sub r16, r8 ; sub width
|
||||
sbc r17, r9
|
||||
brcc Widget_IsPointInRect_no
|
||||
|
||||
mov r16, r20 ; checkY-widgetY
|
||||
mov r17, r21
|
||||
sub r16, r8
|
||||
sbc r17, r9
|
||||
brcs Widget_IsPointInRect_no
|
||||
sub r16, r10 ; sub height
|
||||
sbc r17, r11
|
||||
brcc Widget_IsPointInRect_no
|
||||
|
||||
sec ; is inside rect
|
||||
rjmp Widget_IsPointInRect_ret
|
||||
|
||||
Widget_IsPointInRect_no:
|
||||
clc
|
||||
Widget_IsPointInRect_ret:
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine Widget_LoadDisplayRegs @global
|
||||
;
|
||||
; @param Z byte address of object (for LPM!)
|
||||
; @return R1:R0 background color
|
||||
; @return R3:R2 foreground color
|
||||
; @return R5:R4 X
|
||||
; @return R7:R6 Y
|
||||
; @return R9:R8 widget width
|
||||
; @return R11:R10 widget height
|
||||
; @clobbers none
|
||||
|
||||
Widget_LoadDisplayRegs:
|
||||
push zl
|
||||
push zh
|
||||
adiw zh:zl, WIDGET_OFFS_X_LO
|
||||
lpm r4, Z+ ; X_LO
|
||||
lpm r5, Z+
|
||||
lpm r6, Z+ ; Y_LO
|
||||
lpm r7, Z+
|
||||
lpm r8, Z+ ; WIDTH_LO
|
||||
lpm r9, Z+
|
||||
lpm r10, Z+ ; HEIGHT_LO
|
||||
lpm r11, Z+
|
||||
lpm r2, Z+ ; FRONTCOL_LO
|
||||
lpm r3, Z+
|
||||
lpm r0, Z+ ; BACKCOL_LO
|
||||
lpm r1, Z+
|
||||
pop zh
|
||||
pop zl
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine Widget_GetSdramPtr @global
|
||||
;
|
||||
; @param Z byte address of object (for LPM!)
|
||||
; @return Y pointer to SDRAM data for widget
|
||||
; @clobbers none
|
||||
|
||||
Widget_GetSdramPtr:
|
||||
adiw zh:zl, WIDGET_OFFS_SDRAM_LO
|
||||
lpm yl, Z+
|
||||
lpm yh, Z
|
||||
sbiw zh:zl, WIDGET_OFFS_SDRAM_LO+1
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine Widget_AddFlagsDown @global
|
||||
;
|
||||
; @param Z byte address of object (for LPM!)
|
||||
; @param R16 flags to add
|
||||
; @clobbers R17, R18, R19, Y
|
||||
|
||||
Widget_AddFlagsDown:
|
||||
mov r17, zl
|
||||
or r17, zh
|
||||
breq Widget_AddFlagsDown_ret
|
||||
|
||||
rcall Widget_GetSdramPtr
|
||||
ldd r17, Y+WIDGET_SD_OFFS_FLAGS
|
||||
or r17, r16
|
||||
std Y+WIDGET_SD_OFFS_FLAGS, r17
|
||||
push zl
|
||||
push zh
|
||||
bigcall OBJ_GetFirstChild ; R19:R18=next object
|
||||
Widget_AddFlagsDown_loop:
|
||||
mov r17, r18
|
||||
or r17, r19
|
||||
breq Widget_AddFlagsDown_loopEnd
|
||||
mov zl, r18
|
||||
mov zh, r19
|
||||
rcall Widget_AddFlagsDown
|
||||
rcall OBJ_GetNext
|
||||
rjmp Widget_AddFlagsDown_loop
|
||||
|
||||
Widget_AddFlagsDown_loopEnd:
|
||||
pop zh
|
||||
pop zl
|
||||
Widget_AddFlagsDown_ret:
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine Widget_SubFlagsDown @global
|
||||
;
|
||||
; @param Z byte address of object (for LPM!)
|
||||
; @param R16 flags to add
|
||||
; @clobbers R17, R18, R19, Y
|
||||
|
||||
Widget_SubFlagsDown:
|
||||
mov r17, zl
|
||||
or r17, zh
|
||||
breq Widget_SubFlagsDown_ret
|
||||
|
||||
rcall Widget_GetSdramPtr
|
||||
ldd r17, Y+WIDGET_SD_OFFS_FLAGS
|
||||
com r16 ; one's-complement
|
||||
and r17, r16
|
||||
com r16
|
||||
std Y+WIDGET_SD_OFFS_FLAGS, r17
|
||||
push zl
|
||||
push zh
|
||||
bigcall OBJ_GetFirstChild ; R19:R18=next object
|
||||
Widget_SubFlagsDown_loop:
|
||||
mov r17, r18
|
||||
or r17, r19
|
||||
breq Widget_SubFlagsDown_loopEnd
|
||||
mov zl, r18
|
||||
mov zh, r19
|
||||
rcall Widget_SubFlagsDown
|
||||
bigcall OBJ_GetNext
|
||||
rjmp Widget_SubFlagsDown_loop
|
||||
|
||||
Widget_SubFlagsDown_loopEnd:
|
||||
pop zh
|
||||
pop zl
|
||||
Widget_SubFlagsDown_ret:
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine Widget_Clear @global
|
||||
;
|
||||
; @param Z byte address of object (for LPM!)
|
||||
|
||||
Widget_Clear:
|
||||
rcall Widget_LoadDisplayRegs
|
||||
rcall Widget_GetSdramPtr ; (none)
|
||||
adiw zh:zl, WIDGET_OFFS_OPTS_LO ; get OPTS low
|
||||
lpm r14, Z
|
||||
sbiw zh:zl, WIDGET_OFFS_OPTS_LO
|
||||
rcall Widget_SelectColors ; (R16)
|
||||
mov r2, r0 ; use background
|
||||
mov r3, r1
|
||||
bigcall Display_FillRect
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine Widget_SelectColors @global
|
||||
;
|
||||
; @param Z byte address of object (for LPM!)
|
||||
; @param Y pointer to Widget data in SDRAM
|
||||
; @return r1:r0 background color
|
||||
; @return r3:r2 foreground color
|
||||
; @clobbers R16
|
||||
|
||||
Widget_SelectColors:
|
||||
ldd r16, Y+WIDGET_SD_OFFS_FLAGS ; flags
|
||||
andi r16, (1<<WIDGET_FLAGS_PRESSED_BIT)
|
||||
brne Widget_SelectColors_pressed
|
||||
push zl
|
||||
push zh
|
||||
adiw zh:zl, WIDGET_OFFS_FRONTCOL_LO
|
||||
lpm r2, Z+
|
||||
lpm r3, Z+
|
||||
lpm r0, Z+
|
||||
lpm r1, Z
|
||||
pop zh
|
||||
pop zl
|
||||
rjmp Widget_SelectColors_ret
|
||||
|
||||
Widget_SelectColors_pressed:
|
||||
; background color
|
||||
ldi r16, LOW(STYLE_BUTTON_COL_BG_PRESSED)
|
||||
mov r0, r16
|
||||
ldi r16, HIGH(STYLE_BUTTON_COL_BG_PRESSED)
|
||||
mov r1, r16
|
||||
|
||||
; foreground color
|
||||
ldi r16, LOW(STYLE_BUTTON_COL_FG_PRESSED)
|
||||
mov r2, r16
|
||||
ldi r16, HIGH(STYLE_BUTTON_COL_FG_PRESSED)
|
||||
mov r3, r16
|
||||
|
||||
Widget_SelectColors_ret:
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine Widget_MakeAbsPos @global
|
||||
;
|
||||
; @param Z byte address of object (for LPM!)
|
||||
; @param r5:r4 X0
|
||||
; @param r7:r6 Y0
|
||||
; @clobbers r16, r17
|
||||
|
||||
Widget_MakeAbsPos:
|
||||
push zl
|
||||
push zh
|
||||
adiw zh:zl, WIDGET_OFFS_X_LO
|
||||
lpm r16, Z+
|
||||
lpm r17, Z+
|
||||
add r4, r16 ; adjust X
|
||||
adc r5, r17
|
||||
lpm r16, Z+
|
||||
lpm r17, Z+
|
||||
add r6, r16 ; adjust Y
|
||||
adc r7, r17
|
||||
pop zh
|
||||
pop zl
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine Widget_FillRect @global
|
||||
;
|
||||
; @param Z byte address of object (for LPM!)
|
||||
; @param r3:r2 color
|
||||
; @param r5:r4 X0
|
||||
; @param r7:r6 Y0
|
||||
; @param r9:r8 X1/W
|
||||
; @param r11:r10 Y1/H
|
||||
; @clobbers any, !Z
|
||||
|
||||
Widget_FillRect:
|
||||
rcall Widget_MakeAbsPos ; (R16, R17)
|
||||
bigcall Display_FillRect ; directly call graphics function
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine Widget_DrawBorder @global
|
||||
;
|
||||
; @param Z byte address of object (for LPM!)
|
||||
; @param r3:r2 color
|
||||
; @clobbers any, !Z
|
||||
|
||||
Widget_DrawBorder:
|
||||
rcall Widget_LoadDisplayRegs
|
||||
bigcall Display_DrawRect
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine Widget_DrawTextFlash @global
|
||||
;
|
||||
; @param Z byte address of object (for LPM!)
|
||||
; @param R5:R4 X relative to widget
|
||||
; @param R7:R6 Y relative to widget
|
||||
; @param R13:R12 byte address pointer to text in flash (for LPM!)
|
||||
; @clobbers any, !Z
|
||||
|
||||
Widget_DrawTextFlash:
|
||||
rcall Widget_LoadDisplayRegs
|
||||
rcall Widget_GetSdramPtr ; (none)
|
||||
rcall Widget_SelectColors
|
||||
rjmp Widget_DrawColoredTextFlash
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine Widget_DrawColoredTextFlash @global
|
||||
;
|
||||
; @param Z byte address of object (for LPM!)
|
||||
; @param R1:R0 background color
|
||||
; @param R3:R2 foreground color
|
||||
; @param R5:R4 X relative to widget
|
||||
; @param R7:R6 Y relative to widget
|
||||
; @param R13:R12 byte address pointer to text in flash (for LPM!)
|
||||
; @clobbers any, !Z
|
||||
|
||||
Widget_DrawColoredTextFlash:
|
||||
rcall widgetCalcAbsPosAndBorders
|
||||
push zl
|
||||
push zh
|
||||
mov zl, r12
|
||||
mov zh, r13
|
||||
Widget_DrawColoredTextFlash_loop:
|
||||
lpm r16, Z
|
||||
tst r16
|
||||
breq Widget_DrawColoredTextFlash_loopEnd
|
||||
rcall widgetDrawChar
|
||||
brcc Widget_DrawColoredTextFlash_loopEnd
|
||||
adiw zh:zl, 1
|
||||
rjmp Widget_DrawColoredTextFlash_loop
|
||||
Widget_DrawColoredTextFlash_loopEnd:
|
||||
mov r12, zl
|
||||
mov r13, zh
|
||||
pop zh
|
||||
pop zl
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine widgetCalcAbsPosAndBorders
|
||||
;
|
||||
; @param Z byte address of object (for LPM!)
|
||||
; @param R5:R4 X relative to widget
|
||||
; @param R7:R6 Y relative to widget
|
||||
; @return R9:R8 first X pos right of widget
|
||||
; @return R5:R4 X relative to screen
|
||||
; @return R7:R6 Y relative to screen
|
||||
; @return R9:R8 first X pos right of widget (abs)
|
||||
; @return R11:R10 first Y pos below widget (abs)
|
||||
; @clobbers r16, r17
|
||||
|
||||
widgetCalcAbsPosAndBorders:
|
||||
push zl
|
||||
push zh
|
||||
adiw zh:zl, WIDGET_OFFS_X_LO
|
||||
lpm r16, Z+
|
||||
lpm r17, Z+
|
||||
add r4, r16 ; adjust X
|
||||
adc r5, r17
|
||||
lpm r16, Z+
|
||||
lpm r17, Z+
|
||||
add r6, r16 ; adjust Y
|
||||
adc r7, r17
|
||||
lpm r8, Z+ ; WIDTH_LO
|
||||
lpm r9, Z+
|
||||
add r8, r4 ; convert width to first pos right of widget
|
||||
adc r9, r5
|
||||
lpm r10, Z+ ; HEIGHT_LO
|
||||
lpm r11, Z+
|
||||
add r10, r6 ; convert height to first pos below widget
|
||||
adc r11, r7
|
||||
pop zh
|
||||
pop zl
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine widgetDrawChar
|
||||
;
|
||||
; @param Z byte address of object (for LPM!)
|
||||
; @param R16 char to write
|
||||
; @param R5:R4 absolute X on screen
|
||||
; @param R7:R6 absolute Y on screen
|
||||
; @param R9:R8 first X pos right of windows
|
||||
; @return CFLAG set if char printed, cleared otherwise
|
||||
; @return R5:R4 X pos behind char
|
||||
; @clobbers any, !Y, !R6, !R7, !R8, !R9, !R10, !R11
|
||||
|
||||
widgetDrawChar:
|
||||
push zl
|
||||
push zh
|
||||
; save R16 (char to write)
|
||||
mov r12, r16
|
||||
|
||||
; get font to Z
|
||||
adiw zh:zl, WIDGET_OFFS_FONT_LO
|
||||
lpm r18, Z+
|
||||
lpm zh, Z
|
||||
mov zl, r18
|
||||
|
||||
; check whether the char fits inside window
|
||||
bigcall FONT_GetCharWidth ; r16=char width
|
||||
|
||||
clr r17
|
||||
add r16, r4 ; char width+X
|
||||
adc r17, r5
|
||||
sub r16, r8 ; check against window width
|
||||
sbc r17, r9
|
||||
brcc widgetDrawChar_ret ; not fit, jmp
|
||||
|
||||
; actually draw char
|
||||
mov r16, r12
|
||||
push r8
|
||||
push r9
|
||||
push r10
|
||||
push r11
|
||||
bigcall Display_DrawChar
|
||||
pop r11
|
||||
pop r10
|
||||
pop r9
|
||||
pop r8
|
||||
clr r16
|
||||
add r4, r18 ; increment X
|
||||
adc r5, r16
|
||||
sec ; write succeeded
|
||||
widgetDrawChar_ret:
|
||||
pop zh
|
||||
pop zl
|
||||
ret
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine Widget_Tree_Init @global
|
||||
;
|
||||
; @param Z byte address of root object (for LPM!)
|
||||
|
||||
Widget_Tree_Init:
|
||||
push zl
|
||||
push zh
|
||||
Widget_Tree_Init_loop:
|
||||
mov r16, zl
|
||||
or r16, zh
|
||||
breq Widget_Tree_Init_loopEnd
|
||||
rcall Widget_Init
|
||||
bigcall OBJ_GetBelow
|
||||
mov zl, r18
|
||||
mov zh, r19
|
||||
rjmp Widget_Tree_Init_loop
|
||||
Widget_Tree_Init_loopEnd:
|
||||
pop zh
|
||||
pop zl
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine Widget_Tree_Draw @global
|
||||
;
|
||||
; @param Z byte address of root object (for LPM!)
|
||||
|
||||
Widget_Tree_Draw:
|
||||
ldi r16, WIDGET_SIGNAL_DRAW
|
||||
clr r17
|
||||
bigcall OBJ_TreeAllHandleSignal
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user