add ressources, use signals for GuiApp.

makes it easier to extend.
This commit is contained in:
Martin Preuss
2026-01-14 21:19:46 +01:00
parent 10c3f3c40d
commit 99c58d13e2
9 changed files with 398 additions and 87 deletions

View File

@@ -25,7 +25,10 @@
.equ GUIAPP_SIZE = GUIAPP_OFFS_GUIAPP+6
; signals
.equ GUIAPP_SIGNAL_RAISE = OBJECT_SIGNAL_NEXTFREE+0 ; X=GUIAPP to raise
.equ GUIAPP_SIGNAL_RAISE = OBJECT_SIGNAL_NEXTFREE+0 ; app->cntrl: X=GUIAPP to raise
.equ GUIAPP_SIGNAL_SHOW = OBJECT_SIGNAL_NEXTFREE+1 ; cntrl->app
.equ GUIAPP_SIGNAL_HIDE = OBJECT_SIGNAL_NEXTFREE+2 ; cntrl->app
.equ GUIAPP_SIGNAL_NEXTFREE = OBJECT_SIGNAL_NEXTFREE+3
; SDRAM data for guiapp
.equ GUIAPP_SD_OFFS_FLAGS = 0
@@ -122,11 +125,11 @@ guiAppInitTimers_done:
; ---------------------------------------------------------------------------
; @routine GuiApp_Show
; @routine GuiApp_OnShow
;
; @param Z byte address of guiapp object (for LPM!)
GuiApp_Show:
GuiApp_OnShow:
push zl
push zh
adiw zh:zl, GUIAPP_OFFS_ROOTWIDGET_LO
@@ -134,10 +137,10 @@ GuiApp_Show:
lpm zh, Z
mov zl, r16
or r17, zh
breq GuiApp_Show_done
breq GuiApp_OnShow_done
ldi r16, (1<<WIDGET_FLAGS_ACTIVE_BIT) | (1<<WIDGET_FLAGS_DIRTY_BIT)
rcall Widget_AddFlagsDown
GuiApp_Show_done:
GuiApp_OnShow_done:
pop zh
pop zl
@@ -145,17 +148,18 @@ GuiApp_Show_done:
ldd r16, Y+GUIAPP_SD_OFFS_FLAGS
sbr r16, (1<<GUIAPP_FLAGS_ACTIVE_BIT)
std Y+GUIAPP_SD_OFFS_FLAGS, r16
sec
ret
; @end
; ---------------------------------------------------------------------------
; @routine GuiApp_Hide
; @routine GuiApp_OnHide
;
; @param Z byte address of guiapp object (for LPM!)
GuiApp_Hide:
GuiApp_OnHide:
push zl
push zh
adiw zh:zl, GUIAPP_OFFS_ROOTWIDGET_LO
@@ -163,10 +167,10 @@ GuiApp_Hide:
lpm zh, Z
mov zl, r16
or r17, zh
breq GuiApp_Hide_done
breq GuiApp_OnHide_done
ldi r16, (1<<WIDGET_FLAGS_ACTIVE_BIT) | (1<<WIDGET_FLAGS_DIRTY_BIT)
rcall Widget_SubFlagsDown
GuiApp_Hide_done:
GuiApp_OnHide_done:
pop zh
pop zl
@@ -174,30 +178,22 @@ GuiApp_Hide_done:
ldd r16, Y+GUIAPP_SD_OFFS_FLAGS
cbr r16, (1<<GUIAPP_FLAGS_ACTIVE_BIT)
std Y+GUIAPP_SD_OFFS_FLAGS, r16
sec
ret
; @end
; ---------------------------------------------------------------------------
; @routine GuiApp_Every100ms
; @routine GuiApp_OnTimer
;
; @param Z byte address of guiapp object (for LPM!)
GuiApp_Every100ms:
GuiApp_OnTimer:
; 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:
; TODO: send timer event to all widgets
pop zh
pop zl
@@ -205,29 +201,30 @@ GuiApp_Every100ms_done:
rcall GuiApp_GetSdramPtr
ldd r16, Y+GUIAPP_SD_OFFS_FLAGS
sbrs r16, GUIAPP_FLAGS_ACTIVE_BIT
rjmp GuiApp_Every100ms_ret
rjmp GuiApp_OnTimer_ret
ldd r16, Y+GUIAPP_SD_OFFS_DRAWTIMER
tst r16
breq GuiApp_Every100ms_ret
breq GuiApp_OnTimer_ret
dec r16
brne GuiApp_Every100ms_writeDrawTimer
brne GuiApp_OnTimer_writeDrawTimer
rcall guiAppDrawWidgets
ldi r16, GUIAPP_DRAWTIMER
GuiApp_Every100ms_writeDrawTimer:
GuiApp_OnTimer_writeDrawTimer:
std Y+GUIAPP_SD_OFFS_DRAWTIMER, r16
GuiApp_Every100ms_ret:
GuiApp_OnTimer_ret:
sec
ret
; @end
; ---------------------------------------------------------------------------
; @routine GuiApp_Touch
; @routine GuiApp_OnTouch
;
; @param Z byte address of guiapp object (for LPM!)
; @param X pointer to touch event in SDRAM
GuiApp_Touch:
GuiApp_OnTouch:
push zl
push zh
adiw zh:zl, GUIAPP_OFFS_ROOTWIDGET_LO
@@ -235,13 +232,14 @@ GuiApp_Touch:
lpm zh, Z
mov zl, r18
or r18, zh
breq GuiApp_Touch_done
breq GuiApp_OnTouch_done
ldi r16, WIDGET_SIGNAL_TOUCH
clr r17
rcall OBJ_TreeHandleSignal
GuiApp_Touch_done:
rcall OBJ_TreeHandleSignal ; TODO: let function only send TOUCH signal for widget with matching OPTS
GuiApp_OnTouch_done:
pop zh
pop zl
sec
ret
; @end

View File

@@ -82,7 +82,9 @@ GuiCntlr_ShowApp_changed:
mov zh, r19
or r18, r19
breq GuiCntlr_ShowApp_l1
bigcall GuiApp_Hide
ldi r16, WIDGET_SIGNAL_HIDE
clr r17
bigcall OBJ_HandleSignal
GuiCntlr_ShowApp_l1:
pop zh
pop zl
@@ -90,7 +92,9 @@ GuiCntlr_ShowApp_l1:
mov r16, zl
or r16, zh
breq GuiCntlr_ShowApp_l2
bigcall GuiApp_Show
ldi r16, WIDGET_SIGNAL_SHOW
clr r17
bigcall OBJ_HandleSignal
GuiCntlr_ShowApp_l2:
pop zh
pop zl
@@ -139,7 +143,9 @@ guiCntrlCheckTouch:
mov r16, zl
or r16, zh
breq guiCntrlCheckTouch_l1
bigcall GuiApp_Touch
ldi r16, WIDGET_SIGNAL_TOUCH
clr r17
bigcall OBJ_HandleSignal
guiCntrlCheckTouch_l1:
pop zh
pop zl
@@ -163,7 +169,10 @@ guiCntrlSendTimer_loop:
mov zh, r19
or r18, r19
breq guiCntrlSendTimer_loopEnd
bigcall GuiApp_Every100ms
; let child handle timer signal
ldi r16, OBJECT_SIGNAL_TIMER
clr r17
bigcall OBJ_HandleSignal
bigcall OBJ_GetNext
rjmp guiCntrlSendTimer_loop
guiCntrlSendTimer_loopEnd:
@@ -220,34 +229,7 @@ GuiCntlr_OnCreate:
; @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:
rcall GuiCntlr_ShowApp
sec
ret
; @end

View File

@@ -171,7 +171,7 @@ OBJ_EmitSignal_savedZ:
lpm r23, Z+
lpm zh, Z
mov zl, r23
rjmp objHandleSignal ; (any, !Z)
rjmp OBJ_HandleSignal ; (any, !Z)
OBJ_EmitSignal_ret:
ret
@@ -271,7 +271,7 @@ objectHandleSignalSaveInRegs:
push r17
push xl
push xh
rcall objHandleSignal
rcall OBJ_HandleSignal
pop xh
pop xl
pop r17
@@ -282,7 +282,7 @@ objectHandleSignalSaveInRegs:
; ---------------------------------------------------------------------------
; @routine objHandleSignal
; @routine OBJ_HandleSignal
;
; @param Z byte address of object (for LPM!)
; @param R16 signal number
@@ -292,17 +292,17 @@ objectHandleSignalSaveInRegs:
; @return CFLAG set if handled, cleared otherwise
; @clobbers any, !Z
objHandleSignal:
OBJ_HandleSignal:
push zl
push zh
rcall objGetHandlerFromSignalMap
brcc objHandleSignal_done
rcall objHandleSignal_jmpR19R18
objHandleSignal_done:
brcc OBJ_HandleSignal_done
rcall OBJ_HandleSignal_jmpR19R18
OBJ_HandleSignal_done:
pop zh
pop zl
ret
objHandleSignal_jmpR19R18:
OBJ_HandleSignal_jmpR19R18:
; jmp to r19:r18 via stack
push r18
push r19

View File

@@ -43,6 +43,7 @@
; widget opts_lo
.equ WIDGETS_OPTSLO_BORDER_BIT = 7
.equ WIDGETS_OPTSLO_INPUT_BIT = 6 ; TOUCH, KEY
.equ WIDGETS_OPTSLO_TIMER_BIT = 5
; widget flags
.equ WIDGET_FLAGS_ACTIVE_BIT = 7