avr: removed old lcd2/gui, replaced by lcd2/gui2.
This commit is contained in:
23
avr/modules/lcd2/gui/base/0BUILD
Normal file
23
avr/modules/lcd2/gui/base/0BUILD
Normal file
@@ -0,0 +1,23 @@
|
||||
<?xml?>
|
||||
|
||||
<gwbuild>
|
||||
|
||||
<extradist>
|
||||
button.asm
|
||||
guiapp.asm
|
||||
hlayout.asm
|
||||
imageview.asm
|
||||
label.asm
|
||||
layout.asm
|
||||
mainwindow.asm
|
||||
mclayout.asm
|
||||
object.asm
|
||||
rootwindow.asm
|
||||
valuelabel.asm
|
||||
vlayout.asm
|
||||
widget.asm
|
||||
</extradist>
|
||||
|
||||
</gwbuild>
|
||||
|
||||
|
||||
348
avr/modules/lcd2/gui/base/button.asm
Normal file
348
avr/modules/lcd2/gui/base/button.asm
Normal file
@@ -0,0 +1,348 @@
|
||||
; ***************************************************************************
|
||||
; 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_BUTTON_ASM
|
||||
#define AQH_AVR_GUI2_BUTTON_ASM
|
||||
|
||||
|
||||
; ***************************************************************************
|
||||
; defines
|
||||
|
||||
.equ BUTTON_OFFS_BEGIN = WIDGET_SIZE
|
||||
.equ BUTTON_OFFS_MODE = BUTTON_OFFS_BEGIN+0
|
||||
.equ BUTTON_OFFS_STATE = BUTTON_OFFS_BEGIN+1
|
||||
.equ BUTTON_OFFS_TIMER = BUTTON_OFFS_BEGIN+2
|
||||
.equ BUTTON_SIZE = BUTTON_OFFS_BEGIN+3
|
||||
|
||||
|
||||
.equ BUTTON_REPEAT_TIMER_WAITREPEAT = 10
|
||||
.equ BUTTON_REPEAT_TIMER_REPEAT = 7
|
||||
|
||||
; button modes
|
||||
.equ BUTTON_MODE_NORMAL = 0
|
||||
.equ BUTTON_MODE_REPEATED = 1
|
||||
|
||||
; button states
|
||||
.equ BUTTON_STATE_INACTIVE = 0
|
||||
.equ BUTTON_STATE_ACTIVE = 1
|
||||
.equ BUTTON_STATE_WAITREPEAT = 2
|
||||
.equ BUTTON_STATE_REPEATING = 3
|
||||
|
||||
|
||||
|
||||
; ***************************************************************************
|
||||
; code
|
||||
|
||||
.cseg
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine Button_new @global
|
||||
;
|
||||
; @return CFLAG set of okay, cleared otherwise
|
||||
; @return Y address of newly created object
|
||||
; @param X parent widget
|
||||
; @param r16 value for OBJECT_OFFS_OPTS
|
||||
; @param r17 value for WIDGET_OFFS_PACK
|
||||
; @param r20 mode
|
||||
; @clobbers any
|
||||
|
||||
Button_new:
|
||||
push r20
|
||||
ldi r24, LOW(BUTTON_SIZE)
|
||||
ldi r25, HIGH(BUTTON_SIZE)
|
||||
bigcall Object_Alloc ; (!r16, !r17, !X)
|
||||
pop r20
|
||||
brcc Button_new_ret
|
||||
rcall Button_Init ; (r16, r17, X)
|
||||
sec
|
||||
Button_new_ret:
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine Button_Init @global
|
||||
;
|
||||
; @param Y address of widget
|
||||
; @param X parent widget (if any)
|
||||
; @param r16 value for OBJECT_OFFS_OPTS
|
||||
; @param r17 value for WIDGET_OFFS_PACK
|
||||
; @param r20 mode
|
||||
; @clobbers r16, r17, X
|
||||
|
||||
Button_Init:
|
||||
push r20
|
||||
; call base class
|
||||
bigcall Widget_Init ; (r16, r17, X)
|
||||
pop r20
|
||||
|
||||
; setup button data
|
||||
std Y+BUTTON_OFFS_MODE, r20
|
||||
|
||||
; set input opts
|
||||
ldd r16, Y+OBJECT_OFFS_OPTS
|
||||
sbr r16, (1<<WIDGET_OPTS_INPUT_BIT)
|
||||
std Y+OBJECT_OFFS_OPTS, r16
|
||||
|
||||
; set default signal map
|
||||
ldi r16, LOW(Button_DefaultSignalmap*2)
|
||||
std Y+OBJECT_OFFS_SIGNALMAP_LO, r16
|
||||
ldi r16, HIGH(Button_DefaultSignalmap*2)
|
||||
std Y+OBJECT_OFFS_SIGNALMAP_HI, r16
|
||||
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine Button_OnTouchBegin @global
|
||||
;
|
||||
; @param Y address of widget
|
||||
; @param xl param1
|
||||
; @param xh param2
|
||||
; @return CFLAG set if signal handled
|
||||
; @clobbers any, !Y
|
||||
|
||||
Button_OnTouchBegin:
|
||||
ldi r16, (1<<WIDGET_FLAGS_ACTIVATED_BIT) | (1<<WIDGET_FLAGS_DIRTY_BIT)
|
||||
bigcall OBJ_AddFlagsDown ; (r17, r18, r19)
|
||||
|
||||
ldd r16, Y+BUTTON_OFFS_MODE
|
||||
cpi r16, BUTTON_MODE_REPEATED
|
||||
breq Button_OnTouchBegin_repeated
|
||||
ldi r16, BUTTON_STATE_ACTIVE
|
||||
std Y+BUTTON_OFFS_STATE, r16
|
||||
clr r16
|
||||
std Y+BUTTON_OFFS_TIMER, r16
|
||||
rjmp Button_OnTouchBegin_done
|
||||
Button_OnTouchBegin_repeated:
|
||||
ldi r16, BUTTON_STATE_WAITREPEAT
|
||||
std Y+BUTTON_OFFS_STATE, r16
|
||||
ldi r16, BUTTON_REPEAT_TIMER_WAITREPEAT
|
||||
std Y+BUTTON_OFFS_TIMER, r16
|
||||
Button_OnTouchBegin_done:
|
||||
sec
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine Button_OnTouchEnd @global
|
||||
;
|
||||
; @param Y address of widget
|
||||
; @param xl param1
|
||||
; @param xh param2
|
||||
; @return CFLAG set if signal handled
|
||||
; @clobbers any, !Y
|
||||
|
||||
Button_OnTouchEnd:
|
||||
ldi r16, (1<<WIDGET_FLAGS_ACTIVATED_BIT)
|
||||
bigcall OBJ_SubFlagsDown ; (r17, r18, r19)
|
||||
ldi r16, (1<<WIDGET_FLAGS_DIRTY_BIT)
|
||||
bigcall OBJ_AddFlagsDown ; (r17, r18, r19)
|
||||
clr r16
|
||||
std Y+BUTTON_OFFS_TIMER, r16
|
||||
ldd r16, Y+BUTTON_OFFS_STATE
|
||||
cpi r16, BUTTON_STATE_REPEATING
|
||||
breq Button_OnTouchEnd_done
|
||||
ldi r16, WIDGET_SIGNAL_COMMAND
|
||||
bigcall OBJ_EmitSignal
|
||||
Button_OnTouchEnd_done:
|
||||
ldi r16, BUTTON_STATE_INACTIVE
|
||||
std Y+BUTTON_OFFS_STATE, r16
|
||||
sec
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine Button_OnTouchMove @global
|
||||
;
|
||||
; @param Y address of widget
|
||||
; @param xl param1
|
||||
; @param xh param2
|
||||
; @return CFLAG set if signal handled
|
||||
; @clobbers any, !Y
|
||||
|
||||
Button_OnTouchMove:
|
||||
sec
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine Button_OnTimer @global
|
||||
;
|
||||
; @param Y address of widget
|
||||
; @param xl param1
|
||||
; @param xh param2
|
||||
; @return CFLAG set if signal handled
|
||||
; @clobbers any, !Y
|
||||
|
||||
Button_OnTimer:
|
||||
ldd r16, Y+BUTTON_OFFS_TIMER
|
||||
tst r16
|
||||
breq Button_OnTimer_ret
|
||||
dec r16
|
||||
std Y+BUTTON_OFFS_TIMER, r16
|
||||
brne Button_OnTimer_ret
|
||||
; timer elapsed
|
||||
ldd r17, Y+BUTTON_OFFS_STATE
|
||||
cpi r17, BUTTON_STATE_WAITREPEAT
|
||||
breq Button_OnTimer_waitRepeat
|
||||
cpi r17, BUTTON_STATE_REPEATING
|
||||
breq Button_OnTimer_repeating
|
||||
rjmp Button_OnTimer_ret
|
||||
Button_OnTimer_waitRepeat:
|
||||
ldi r17, BUTTON_STATE_REPEATING
|
||||
std Y+BUTTON_OFFS_STATE, r17
|
||||
Button_OnTimer_repeating:
|
||||
ldi r16, BUTTON_REPEAT_TIMER_REPEAT
|
||||
std Y+BUTTON_OFFS_TIMER, r16
|
||||
ldi r16, WIDGET_SIGNAL_COMMAND
|
||||
bigcall OBJ_EmitSignal
|
||||
Button_OnTimer_ret:
|
||||
sec
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine Button_OnGetDefaultWidth @global
|
||||
;
|
||||
; @param Y address of widget
|
||||
; @param r17 value requested
|
||||
; @param xl param1
|
||||
; @param xh param2
|
||||
; @return CFLAG set if signal handled
|
||||
; @return r19:r18 value
|
||||
; @clobbers any, !Y
|
||||
|
||||
Button_OnGetDefaultWidth:
|
||||
bigcall OBJ_GetFirstChild
|
||||
brcc Button_OnGetDefaultWidth_ret
|
||||
push yl
|
||||
push yh
|
||||
mov yl, r18
|
||||
mov yh, r19
|
||||
bigcall Widget_GetDefaultWidth
|
||||
pop yh
|
||||
pop yl
|
||||
Button_OnGetDefaultWidth_ret:
|
||||
sec
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine Button_OnGetDefaultHeight @global
|
||||
;
|
||||
; @param Y address of widget
|
||||
; @param xl param1
|
||||
; @param xh param2
|
||||
; @return CFLAG set if signal handled
|
||||
; @return r19:r18 value
|
||||
; @clobbers any, !Y
|
||||
|
||||
Button_OnGetDefaultHeight:
|
||||
bigcall OBJ_GetFirstChild
|
||||
brcc Button_OnGetDefaultHeight_ret
|
||||
push yl
|
||||
push yh
|
||||
mov yl, r18
|
||||
mov yh, r19
|
||||
bigcall Widget_GetDefaultHeight
|
||||
pop yh
|
||||
pop yl
|
||||
Button_OnGetDefaultHeight_ret:
|
||||
sec
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine Button_OnLayout @global
|
||||
;
|
||||
; @param Y address of widget
|
||||
; @return CFLAG set if signal handled
|
||||
; @clobbers any, !Y
|
||||
|
||||
Button_OnLayout:
|
||||
bigcall OBJ_GetFirstChild
|
||||
brcc Button_OnLayout_ret
|
||||
|
||||
ldd r16, Y+WIDGET_OFFS_WIDTH_LO
|
||||
ldd r17, Y+WIDGET_OFFS_WIDTH_HI
|
||||
ldd r20, Y+WIDGET_OFFS_HEIGHT_LO
|
||||
ldd r21, Y+WIDGET_OFFS_HEIGHT_HI
|
||||
push yl
|
||||
push yh
|
||||
mov yl, r18
|
||||
mov yh, r19
|
||||
std Y+WIDGET_OFFS_WIDTH_LO, r16
|
||||
std Y+WIDGET_OFFS_WIDTH_HI, r17
|
||||
std Y+WIDGET_OFFS_HEIGHT_LO, r20
|
||||
std Y+WIDGET_OFFS_HEIGHT_HI, r21
|
||||
clr r16
|
||||
std Y+WIDGET_OFFS_X_LO, r16
|
||||
std Y+WIDGET_OFFS_X_HI, r16
|
||||
std Y+WIDGET_OFFS_Y_LO, r16
|
||||
std Y+WIDGET_OFFS_Y_HI, r16
|
||||
; force layout and redraw
|
||||
ldd r16, Y+OBJECT_OFFS_FLAGS
|
||||
ori r16, (1<<WIDGET_FLAGS_LAYOUT_BIT) | (1<<WIDGET_FLAGS_DIRTY_BIT)
|
||||
std Y+OBJECT_OFFS_FLAGS, r16
|
||||
pop yh
|
||||
pop yl
|
||||
|
||||
Button_OnLayout_ret:
|
||||
ldd r16, Y+OBJECT_OFFS_FLAGS
|
||||
cbr r16, (1<<WIDGET_FLAGS_LAYOUT_BIT)
|
||||
std Y+OBJECT_OFFS_FLAGS, r16
|
||||
|
||||
sec
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
; ***************************************************************************
|
||||
; data in FLASH
|
||||
|
||||
Button_DefaultSignalmap:
|
||||
; header
|
||||
.dw Widget_DefaultSignalmap*2 ; next table to use
|
||||
; entries
|
||||
.db 0, OBJECT_SIGNAL_TIMER, LOW(Button_OnTimer), HIGH(Button_OnTimer)
|
||||
.db 0, WIDGET_SIGNAL_DRAW, LOW(Widget_OnDrawNop), HIGH(Widget_OnDrawNop)
|
||||
.db 0, WIDGET_SIGNAL_TOUCH, LOW(Widget_OnTouch), HIGH(Widget_OnTouch)
|
||||
.db 0, WIDGET_SIGNAL_TOUCH_BEGIN, LOW(Button_OnTouchBegin), HIGH(Button_OnTouchBegin)
|
||||
.db 0, WIDGET_SIGNAL_TOUCH_END, LOW(Button_OnTouchEnd), HIGH(Button_OnTouchEnd)
|
||||
.db 0, WIDGET_SIGNAL_TOUCH_MOVE, LOW(Button_OnTouchMove), HIGH(Button_OnTouchMove)
|
||||
.db 0, WIDGET_SIGNAL_LAYOUT, LOW(Button_OnLayout), HIGH(Button_OnLayout)
|
||||
.db WIDGET_VALUE_DEFAULT_WIDTH, WIDGET_SIGNAL_GETVALUE, LOW(Button_OnGetDefaultWidth), HIGH(Button_OnGetDefaultWidth)
|
||||
.db WIDGET_VALUE_DEFAULT_HEIGHT, WIDGET_SIGNAL_GETVALUE, LOW(Button_OnGetDefaultHeight), HIGH(Button_OnGetDefaultHeight)
|
||||
|
||||
.db 0, 0, 0, 0 ; end of table
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
775
avr/modules/lcd2/gui/base/guiapp.asm
Normal file
775
avr/modules/lcd2/gui/base/guiapp.asm
Normal file
@@ -0,0 +1,775 @@
|
||||
; ***************************************************************************
|
||||
; 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
|
||||
|
||||
.equ GUIAPP_WINDOWSTACK_ENTRIES = 8
|
||||
|
||||
; 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_CURRENTWINDOW_LO = GUIAPP_OFFS_BEGIN+4
|
||||
.equ GUIAPP_OFFS_CURRENTWINDOW_HI = GUIAPP_OFFS_BEGIN+5
|
||||
.equ GUIAPP_OFFS_TOUCHWIDGET_LO = GUIAPP_OFFS_BEGIN+6
|
||||
.equ GUIAPP_OFFS_TOUCHWIDGET_HI = GUIAPP_OFFS_BEGIN+7
|
||||
.equ GUIAPP_OFFS_GUITIMER = GUIAPP_OFFS_BEGIN+8
|
||||
.equ GUIAPP_OFFS_WINDOWSTACK_POS = GUIAPP_OFFS_BEGIN+9
|
||||
.equ GUIAPP_OFFS_WINDOWSTACK_BEGIN = GUIAPP_OFFS_BEGIN+10
|
||||
.equ GUIAPP_SIZE = GUIAPP_OFFS_WINDOWSTACK_BEGIN+(GUIAPP_WINDOWSTACK_ENTRIES*2)
|
||||
|
||||
|
||||
.equ GUIAPP_GUITIMER = 2
|
||||
|
||||
|
||||
|
||||
; ***************************************************************************
|
||||
; data
|
||||
|
||||
.dseg
|
||||
|
||||
guiapp_touch_event:
|
||||
.byte WIDGET_TOUCH_SIZE
|
||||
|
||||
|
||||
|
||||
; ***************************************************************************
|
||||
; code
|
||||
|
||||
.cseg
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine GuiApp_new @global
|
||||
;
|
||||
; @return CFLAG set of okay, cleared otherwise
|
||||
; @return Y address of newly created object
|
||||
; @param r16 value for OBJECT_OFFS_OPTS
|
||||
; @clobbers any
|
||||
|
||||
GuiApp_new:
|
||||
ldi r24, LOW(GUIAPP_SIZE)
|
||||
ldi r25, HIGH(GUIAPP_SIZE)
|
||||
bigcall Object_Alloc ; (!r16, !r17)
|
||||
brcc GuiApp_new_ret
|
||||
rcall GuiApp_Init ; (r16, r17, X)
|
||||
sec
|
||||
GuiApp_new_ret:
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine GuiApp_Init @global
|
||||
;
|
||||
; @param Y address of object in SDRAM
|
||||
; @param r16 value for OBJECT_OFFS_OPTS
|
||||
; @clobbers r16, r17, X
|
||||
|
||||
GuiApp_Init:
|
||||
; call base class
|
||||
bigcall OBJ_Init ; (r16, r17, X)
|
||||
|
||||
; set default signal map
|
||||
ldi r16, LOW(GuiApp_DefaultSignalmap*2)
|
||||
std Y+OBJECT_OFFS_SIGNALMAP_LO, r16
|
||||
ldi r16, HIGH(GuiApp_DefaultSignalmap*2)
|
||||
std Y+OBJECT_OFFS_SIGNALMAP_HI, r16
|
||||
|
||||
; create root window
|
||||
push yl
|
||||
push yh
|
||||
mov xl, yl
|
||||
mov xh, yh
|
||||
ldi r16, 0 ; opts
|
||||
ldi r17, 0 ; pack
|
||||
bigcall RootWindow_new
|
||||
|
||||
; always visible
|
||||
ldd r16, Y+OBJECT_OFFS_FLAGS
|
||||
sbr r16, (1<<WIDGET_FLAGS_VISIBLE_BIT) | (1<<WIDGET_FLAGS_LAYOUT_BIT) | (1<<WIDGET_FLAGS_DIRTY_BIT)
|
||||
std Y+OBJECT_OFFS_FLAGS, r16
|
||||
|
||||
mov xl, yl
|
||||
mov xh, yh
|
||||
pop yh
|
||||
pop yl
|
||||
brcc GuiApp_Init_ret
|
||||
|
||||
std Y+GUIAPP_OFFS_ROOTWINDOW_LO, xl
|
||||
std Y+GUIAPP_OFFS_ROOTWINDOW_HI, xh
|
||||
|
||||
ldi r16, GUIAPP_GUITIMER
|
||||
std Y+GUIAPP_OFFS_GUITIMER, r16
|
||||
|
||||
GuiApp_Init_ret:
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine GuiApp_Every100ms @global
|
||||
;
|
||||
; @param Y address of object in SDRAM
|
||||
|
||||
GuiApp_Every100ms:
|
||||
ldi r16, OBJECT_SIGNAL_TIMER
|
||||
clr r17
|
||||
bigcall OBJ_HandleSignal
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine GuiApp_MsgReceived @global
|
||||
;
|
||||
; @param Y address of object in SDRAM
|
||||
|
||||
GuiApp_MsgReceived:
|
||||
ldi r16, OBJECT_SIGNAL_RECVMSG
|
||||
clr r17
|
||||
bigcall OBJ_HandleSignal
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine GuiApp_PreventScreenSaver @global
|
||||
;
|
||||
; @param Y address of object in SDRAM
|
||||
; @clobbers any, !Y
|
||||
|
||||
GuiApp_PreventScreenSaver:
|
||||
rcall GuiApp_GetScreenSaver
|
||||
brcc GuiApp_PreventScreenSaver_ret
|
||||
push yl
|
||||
push yh
|
||||
mov yl, r18
|
||||
mov yh, r19
|
||||
ldi r16, WIDGET_SIGNAL_KEEPALIVE
|
||||
clr r17
|
||||
bigcall OBJ_HandleSignal
|
||||
pop yh
|
||||
pop yl
|
||||
GuiApp_PreventScreenSaver_ret:
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine GuiApp_GrabTouchEvents
|
||||
;
|
||||
; @param Y address of object in SDRAM
|
||||
; @param X byte address of widget grabbing touch events
|
||||
; @return CFLAG set if grabbed, cleared otherwise
|
||||
; @clobbers R16, R17
|
||||
|
||||
GuiApp_GrabTouchEvents:
|
||||
ldd r16, Y+GUIAPP_OFFS_TOUCHWIDGET_LO
|
||||
ldd r17, Y+GUIAPP_OFFS_TOUCHWIDGET_HI
|
||||
or r16, r17
|
||||
clc
|
||||
brne GuiApp_GrabTouchEvents_ret ; only grab if not already grabbed!
|
||||
std Y+GUIAPP_OFFS_TOUCHWIDGET_LO, xl
|
||||
std Y+GUIAPP_OFFS_TOUCHWIDGET_HI, xh
|
||||
sec
|
||||
GuiApp_GrabTouchEvents_ret:
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine GuiApp_UngrabTouchEvents
|
||||
;
|
||||
; @param Y address of object in SDRAM
|
||||
; @param X byte address of widget ungrabbing touch events
|
||||
; @return CFLAG set if ungrabbed, cleared otherwise
|
||||
; @clobbers R16, R17
|
||||
|
||||
GuiApp_UngrabTouchEvents:
|
||||
ldd r16, Y+GUIAPP_OFFS_TOUCHWIDGET_LO
|
||||
ldd r17, Y+GUIAPP_OFFS_TOUCHWIDGET_HI
|
||||
eor r16, xl
|
||||
eor r17, xh
|
||||
or r16, r17
|
||||
clc
|
||||
brne GuiApp_UngrabTouchEvents_ret ; only ungrab same widget!
|
||||
clr r16
|
||||
std Y+GUIAPP_OFFS_TOUCHWIDGET_LO, r16
|
||||
std Y+GUIAPP_OFFS_TOUCHWIDGET_HI, r16
|
||||
sec
|
||||
GuiApp_UngrabTouchEvents_ret:
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
; ***************************************************************************
|
||||
; getters and setters
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine GuiApp_GetRootWindow @global
|
||||
;
|
||||
; @param Y address of object in SDRAM
|
||||
; @param CFLAG set if response is not a NULL pointer
|
||||
; @return r19:r18 root window
|
||||
; @clobbers none
|
||||
|
||||
GuiApp_GetRootWindow:
|
||||
ldd r18, Y+GUIAPP_OFFS_ROOTWINDOW_LO
|
||||
ldd r19, Y+GUIAPP_OFFS_ROOTWINDOW_HI
|
||||
sec
|
||||
tst r18
|
||||
brne GuiApp_GetRootWindow_ret
|
||||
tst r19
|
||||
brne GuiApp_GetRootWindow_ret
|
||||
clc
|
||||
GuiApp_GetRootWindow_ret:
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine GuiApp_SetRootWindow @global
|
||||
;
|
||||
; @param Y address of object in SDRAM
|
||||
; @param X address of new window
|
||||
|
||||
GuiApp_SetRootWindow:
|
||||
std Y+GUIAPP_OFFS_ROOTWINDOW_LO, xl
|
||||
std Y+GUIAPP_OFFS_ROOTWINDOW_HI, xh
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine GuiApp_GetCurrentWindow @global
|
||||
;
|
||||
; @param Y address of object in SDRAM
|
||||
; @return CFLAG set if response is not a NULL pointer
|
||||
; @return r19:r18 current window
|
||||
; @clobbers none
|
||||
|
||||
GuiApp_GetCurrentWindow:
|
||||
ldd r18, Y+GUIAPP_OFFS_CURRENTWINDOW_LO
|
||||
ldd r19, Y+GUIAPP_OFFS_CURRENTWINDOW_HI
|
||||
sec
|
||||
tst r18
|
||||
brne GuiApp_GetCurrentWindow_ret
|
||||
tst r19
|
||||
brne GuiApp_GetCurrentWindow_ret
|
||||
clc
|
||||
GuiApp_GetCurrentWindow_ret:
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine GuiApp_GetScreenSaver @global
|
||||
;
|
||||
; @param Y address of object in SDRAM
|
||||
; @param CFLAG set if response is not a NULL pointer
|
||||
|
||||
GuiApp_GetScreenSaver:
|
||||
ldd r18, Y+GUIAPP_OFFS_SCREENSAVER_LO
|
||||
ldd r19, Y+GUIAPP_OFFS_SCREENSAVER_HI
|
||||
sec
|
||||
tst r18
|
||||
brne GuiApp_GetScreenSaver_ret
|
||||
tst r19
|
||||
brne GuiApp_GetScreenSaver_ret
|
||||
clc
|
||||
GuiApp_GetScreenSaver_ret:
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine GuiApp_SetScreenSaver @global
|
||||
;
|
||||
; @param Y address of object in SDRAM
|
||||
; @param X address of new window
|
||||
|
||||
GuiApp_SetScreenSaver:
|
||||
std Y+GUIAPP_OFFS_SCREENSAVER_LO, xl
|
||||
std Y+GUIAPP_OFFS_SCREENSAVER_HI, xh
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
; ***************************************************************************
|
||||
; signal handlers
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine GuiApp_OnDestroy @global
|
||||
;
|
||||
; @param Y address of object in SDRAM
|
||||
; @return CFLAG set if signal handled
|
||||
; @clobbers any, !Y
|
||||
|
||||
GuiApp_OnDestroy:
|
||||
; TODO (destroy rootWindow)
|
||||
|
||||
; Clear CFLAG so that destroy handlers of base classes are called
|
||||
; after this routine returns. This way the last routine called will be
|
||||
; OBJ_OnDestroy which then frees the whole SDRAM object on heap.
|
||||
clc
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine GuiApp_OnTimer
|
||||
;
|
||||
; @param Y address of object in SDRAM
|
||||
; @clobbers any, !Y
|
||||
|
||||
GuiApp_OnTimer:
|
||||
rcall guiAppCheckTouch ; (any, !Y)
|
||||
rcall guiAppSendTimerEvents ; (any, !Y)
|
||||
rcall guiAppCheckSendGuiEvents ; (any, !Y)
|
||||
sec
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine GuiApp_OnMsgReceived @global
|
||||
;
|
||||
; @param Y address of object in SDRAM
|
||||
; @param X pointer to message received in SDRAM
|
||||
|
||||
GuiApp_OnMsgReceived:
|
||||
rcall guiAppSendRootMsgEvents
|
||||
sec
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine GuiApp_OnTouch
|
||||
;
|
||||
; @param Y address of object in SDRAM
|
||||
; @param X pointer to touch object (see @ref WIDGET_TOUCH_OFFS_X_LO)
|
||||
; @clobbers any, !Y
|
||||
|
||||
GuiApp_OnTouch:
|
||||
rcall guiAppSendTouchEvents
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine GuiApp_EnterWindow
|
||||
;
|
||||
; @param Y address of object in SDRAM
|
||||
; @param X main window to enter
|
||||
; @return CFLAG set if new window active
|
||||
|
||||
GuiApp_EnterWindow:
|
||||
rcall GuiApp_GetCurrentWindow ; r19:r18=current window
|
||||
brcc GuiApp_EnterWindow_l1 ; jmp if no current window
|
||||
push xl
|
||||
push xh
|
||||
push yl
|
||||
push yh
|
||||
mov yl, r18
|
||||
mov yh, r19
|
||||
ldi r16, WIDGET_SIGNAL_HIDE
|
||||
clr r17
|
||||
bigcall OBJ_TreeHandleSignalChildenFirst
|
||||
mov xl, yl
|
||||
mov xh, yh
|
||||
pop yh
|
||||
pop yl
|
||||
rcall guiAppPushMainWindow ; push current window onto stack
|
||||
pop xh
|
||||
pop xl
|
||||
brcc GuiApp_EnterWindow_ret
|
||||
|
||||
GuiApp_EnterWindow_l1:
|
||||
rcall guiAppSetCurrentWindow
|
||||
push yl
|
||||
push yh
|
||||
mov yl, xl
|
||||
mov yh, xh
|
||||
ldi r16, WIDGET_SIGNAL_SHOW
|
||||
clr r17
|
||||
bigcall OBJ_TreeHandleSignal
|
||||
|
||||
pop yh
|
||||
pop yl
|
||||
sec
|
||||
GuiApp_EnterWindow_ret:
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine GuiApp_LeaveWindow
|
||||
;
|
||||
; @param Y address of object in SDRAM
|
||||
|
||||
GuiApp_LeaveWindow:
|
||||
rcall GuiApp_GetCurrentWindow ; r19:r18=current window
|
||||
brcc GuiApp_LeaveWindow_ret ; jmp if no current window
|
||||
push yl
|
||||
push yh
|
||||
mov yl, r18
|
||||
mov yh, r19
|
||||
ldi r16, WIDGET_SIGNAL_HIDE
|
||||
clr r17
|
||||
bigcall OBJ_TreeHandleSignalChildenFirst
|
||||
pop yh
|
||||
pop yl
|
||||
GuiApp_LeaveWindow_l1:
|
||||
rcall guiAppPopMainWindow ; X=popped window
|
||||
brcc GuiApp_LeaveWindow_noPrevious
|
||||
rcall guiAppSetCurrentWindow
|
||||
push yl
|
||||
push yh
|
||||
mov yl, xl
|
||||
mov yh, xh
|
||||
ldi r16, WIDGET_SIGNAL_SHOW
|
||||
clr r17
|
||||
bigcall OBJ_TreeHandleSignal
|
||||
pop yh
|
||||
pop yl
|
||||
rjmp GuiApp_LeaveWindow_ret
|
||||
GuiApp_LeaveWindow_noPrevious:
|
||||
clr xl
|
||||
clr xh
|
||||
rcall guiAppSetCurrentWindow
|
||||
|
||||
GuiApp_LeaveWindow_ret:
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine guiAppSetCurrentWindow
|
||||
;
|
||||
; @param Y address of object in SDRAM
|
||||
; @param X address of new window
|
||||
|
||||
guiAppSetCurrentWindow:
|
||||
std Y+GUIAPP_OFFS_CURRENTWINDOW_LO, xl
|
||||
std Y+GUIAPP_OFFS_CURRENTWINDOW_HI, xh
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine guiAppPushMainWindow
|
||||
;
|
||||
; @param Y address of object in SDRAM
|
||||
; @param X window to push on stack and activate
|
||||
; @return CFLAG set if pushed, cleared on error
|
||||
|
||||
guiAppPushMainWindow:
|
||||
ldd r16, Y+GUIAPP_OFFS_WINDOWSTACK_POS
|
||||
cpi r16, GUIAPP_WINDOWSTACK_ENTRIES
|
||||
brcc GuiApp_PushMainWindow_ret
|
||||
|
||||
mov zl, yl
|
||||
mov zh, yh
|
||||
adiw zh:zl, GUIAPP_OFFS_WINDOWSTACK_BEGIN
|
||||
clr r17
|
||||
lsl r16
|
||||
rol r17
|
||||
add zl, r16
|
||||
adc zh, r17
|
||||
st Z+, xl
|
||||
st Z, xh
|
||||
ldd r16, Y+GUIAPP_OFFS_WINDOWSTACK_POS
|
||||
inc r16
|
||||
std Y+GUIAPP_OFFS_WINDOWSTACK_POS, r16
|
||||
sec
|
||||
GuiApp_PushMainWindow_ret:
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine guiAppPopMainWindow
|
||||
;
|
||||
; @param Y address of object in SDRAM
|
||||
; @return CFLAG set if popped, cleared on error
|
||||
; @return X window popped from stack
|
||||
|
||||
guiAppPopMainWindow:
|
||||
ldd r16, Y+GUIAPP_OFFS_WINDOWSTACK_POS
|
||||
tst r16
|
||||
clc
|
||||
breq guiAppPopMainWindow_ret
|
||||
dec r16
|
||||
std Y+GUIAPP_OFFS_WINDOWSTACK_POS, r16
|
||||
|
||||
mov zl, yl
|
||||
mov zh, yh
|
||||
adiw zh:zl, GUIAPP_OFFS_WINDOWSTACK_BEGIN
|
||||
clr r17
|
||||
lsl r16
|
||||
rol r17
|
||||
add zl, r16
|
||||
adc zh, r17
|
||||
ld xl, Z+
|
||||
ld xh, Z
|
||||
sec
|
||||
guiAppPopMainWindow_ret:
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine guiAppSendTimerEvents
|
||||
;
|
||||
; @param Y ptr to GUIAPP
|
||||
; @clobbers any, !Y
|
||||
|
||||
guiAppSendTimerEvents:
|
||||
ldi r16, OBJECT_SIGNAL_TIMER
|
||||
clr r17
|
||||
ldi r20, (1<<OBJECT_OPTS_TIMER_BIT)
|
||||
ldi r21, (1<<OBJECT_OPTS_TIMER_BIT)
|
||||
rcall guiAppSendRootEventsIfOpts
|
||||
sec
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine guiAppCheckSendGuiEvents
|
||||
;
|
||||
; Send GUI events to current window if timer elapsed.
|
||||
;
|
||||
; @param Y ptr to GUIAPP
|
||||
; @clobbers any, !Y
|
||||
|
||||
guiAppCheckSendGuiEvents:
|
||||
push yl
|
||||
push yh
|
||||
rcall GuiApp_GetRootWindow
|
||||
brcc guiAppCheckSendGuiEvents_done
|
||||
|
||||
ldd r16, Y+GUIAPP_OFFS_GUITIMER
|
||||
tst r16
|
||||
breq guiAppCheckSendGuiEvents_done
|
||||
dec r16
|
||||
std Y+GUIAPP_OFFS_GUITIMER, r16
|
||||
brne guiAppCheckSendGuiEvents_done
|
||||
|
||||
; timer elapsed, send layout events, draw events
|
||||
push yl
|
||||
push yh
|
||||
mov yl, r18
|
||||
mov yh, r19
|
||||
ldi r16, WIDGET_SIGNAL_LAYOUT
|
||||
clr r17
|
||||
ldi r20, (1<<WIDGET_FLAGS_VISIBLE_BIT) | (1<<WIDGET_FLAGS_LAYOUT_BIT)
|
||||
bigcall OBJ_TreeHandleSignalIfFlagsSet ; (any, !Y)
|
||||
|
||||
ldi r16, WIDGET_SIGNAL_DRAW
|
||||
clr r17
|
||||
ldi r20, (1<<WIDGET_FLAGS_VISIBLE_BIT) | (1<<WIDGET_FLAGS_DIRTY_BIT)
|
||||
bigcall OBJ_TreeHandleSignalIfFlagsSet ; (any, !Y)
|
||||
|
||||
pop yh
|
||||
pop yl
|
||||
ldi r16, GUIAPP_GUITIMER
|
||||
std Y+GUIAPP_OFFS_GUITIMER, r16
|
||||
guiAppCheckSendGuiEvents_done:
|
||||
pop yh
|
||||
pop yl
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine guiAppSendTouchEvents
|
||||
;
|
||||
; Send touch events to current window or grabbing widget.
|
||||
;
|
||||
; @param Y ptr to GUIAPP
|
||||
; @param X pointer to touch object (see @ref WIDGET_TOUCH_OFFS_X_LO)
|
||||
; @clobbers any, !Y
|
||||
|
||||
guiAppSendTouchEvents:
|
||||
push yl
|
||||
push yh
|
||||
ldd r18, Y+GUIAPP_OFFS_TOUCHWIDGET_LO
|
||||
ldd r19, Y+GUIAPP_OFFS_TOUCHWIDGET_HI
|
||||
mov r16, r18
|
||||
or r16, r19
|
||||
breq guiAppSendTouchEvents_sendToAll
|
||||
mov yl, r18
|
||||
mov yh, r19
|
||||
ldi r16, WIDGET_SIGNAL_TOUCH
|
||||
clr r17
|
||||
bigcall OBJ_HandleSignal
|
||||
rjmp guiAppSendTouchEvents_done
|
||||
guiAppSendTouchEvents_sendToAll:
|
||||
rcall GuiApp_GetCurrentWindow ; r19:r18=current window (none)
|
||||
brcc guiAppSendTouchEvents_done
|
||||
; send touch signal
|
||||
mov yl, r18
|
||||
mov yh, r19
|
||||
ldi r16, WIDGET_SIGNAL_TOUCH
|
||||
clr r17
|
||||
ldi r20, (1<<WIDGET_OPTS_INPUT_BIT)
|
||||
ldi r21, (1<<WIDGET_OPTS_INPUT_BIT)
|
||||
bigcall OBJ_TreeHandleSignalIfMatchingOpts
|
||||
guiAppSendTouchEvents_done:
|
||||
pop yh
|
||||
pop yl
|
||||
; send keepAlive to screensaver
|
||||
rcall GuiApp_PreventScreenSaver
|
||||
sec
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine guiAppSendRootMsgEvents
|
||||
;
|
||||
; Send touch events to root window.
|
||||
;
|
||||
; @param Y ptr to GUIAPP
|
||||
; @param X pointer to message received in SDRAM
|
||||
; @clobbers any, !Y
|
||||
|
||||
guiAppSendRootMsgEvents:
|
||||
ldi r16, OBJECT_SIGNAL_RECVMSG
|
||||
adiw xh:xl, NETMSG_OFFS_CMD
|
||||
ld r17, X
|
||||
sbiw xh:xl, NETMSG_OFFS_CMD
|
||||
ldi r20, (1<<OBJECT_OPTS_MSGRECV_BIT)
|
||||
ldi r21, (1<<OBJECT_OPTS_MSGRECV_BIT)
|
||||
rcall guiAppSendRootEventsIfOpts
|
||||
sec
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine guiAppSendRootEventsIfOpts
|
||||
;
|
||||
; Send events to all widgets with matching OPTS_LO.
|
||||
;
|
||||
; @param Y ptr to GUIAPP
|
||||
; @param R16 signal number
|
||||
; @param R17 selector
|
||||
; @param xl param1
|
||||
; @param xh param2
|
||||
; @param r20 mask for OBJECT_OFFS_OPTS
|
||||
; @param r21 value for OBJECT_OFFS_OPTS to match
|
||||
; @clobbers any, !Y
|
||||
|
||||
guiAppSendRootEventsIfOpts:
|
||||
push yl
|
||||
push yh
|
||||
rcall GuiApp_GetRootWindow ; r19:r18=root window (none)
|
||||
brcc guiAppSendRootEventsIfOpts_done
|
||||
; send signal to root window and all below
|
||||
mov yl, r18
|
||||
mov yh, r19
|
||||
bigcall OBJ_TreeHandleSignalIfMatchingOpts
|
||||
guiAppSendRootEventsIfOpts_done:
|
||||
pop yh
|
||||
pop yl
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine guiAppCheckTouch
|
||||
;
|
||||
; @param Y ptr to GUIAPP
|
||||
; @clobbers any, !Y
|
||||
|
||||
guiAppCheckTouch:
|
||||
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 guiAppCheckTouch_ret
|
||||
ldi xl, LOW(guiapp_touch_event)
|
||||
ldi xh, HIGH(guiapp_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)
|
||||
; send touch signal
|
||||
ldi r16, WIDGET_SIGNAL_TOUCH
|
||||
clr r17
|
||||
bigcall OBJ_HandleSignal
|
||||
guiAppCheckTouch_ret:
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
; ***************************************************************************
|
||||
; data in FLASH
|
||||
|
||||
GuiApp_DefaultSignalmap:
|
||||
; header
|
||||
.dw Object_DefaultSignalmap*2 ; next table to use
|
||||
; entries
|
||||
.db 0, OBJECT_SIGNAL_TIMER, LOW(GuiApp_OnTimer), HIGH(GuiApp_OnTimer)
|
||||
.db 0, OBJECT_SIGNAL_RECVMSG, LOW(GuiApp_OnMsgReceived), HIGH(GuiApp_OnMsgReceived)
|
||||
.db 0, WIDGET_SIGNAL_TOUCH, LOW(GuiApp_OnTouch), HIGH(GuiApp_OnTouch)
|
||||
.db 0, OBJECT_SIGNAL_DESTROY, LOW(GuiApp_OnDestroy), HIGH(GuiApp_OnDestroy)
|
||||
.db 0, 0, 0, 0 ; end of table
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
387
avr/modules/lcd2/gui/base/hlayout.asm
Normal file
387
avr/modules/lcd2/gui/base/hlayout.asm
Normal file
@@ -0,0 +1,387 @@
|
||||
; ***************************************************************************
|
||||
; 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_HLAYOUT_ASM
|
||||
#define AQH_AVR_GUI2_HLAYOUT_ASM
|
||||
|
||||
|
||||
; ***************************************************************************
|
||||
; defines
|
||||
|
||||
.equ HLAYOUT_OFFS_BEGIN = WIDGET_SIZE
|
||||
.equ HLAYOUT_OFFS_MODE = HLAYOUT_OFFS_BEGIN+0
|
||||
.equ HLAYOUT_SIZE = HLAYOUT_OFFS_BEGIN+1
|
||||
|
||||
|
||||
; values for HLAYOUT_OFFS_MODE
|
||||
.equ HLAYOUT_MODE_EXPAND = 0
|
||||
.equ HLAYOUT_MODE_SPREAD = 1
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
; ***************************************************************************
|
||||
; code
|
||||
|
||||
.cseg
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine HLayout_new @global
|
||||
;
|
||||
; @return CFLAG set of okay, cleared otherwise
|
||||
; @return Y address of newly created object
|
||||
; @param X parent widget
|
||||
; @param r16 value for OBJECT_OFFS_OPTS
|
||||
; @param r17 value for WIDGET_OFFS_PACK
|
||||
; @param r20 layout mode (HLAYOUT_MODE_EXPAND, HLAYOUT_MODE_SPREAD)
|
||||
; @clobbers any
|
||||
|
||||
HLayout_new:
|
||||
push r20
|
||||
ldi r24, LOW(HLAYOUT_SIZE)
|
||||
ldi r25, HIGH(HLAYOUT_SIZE)
|
||||
bigcall Object_Alloc ; (!r16, !r17, !X)
|
||||
pop r20
|
||||
brcc HLayout_new_ret
|
||||
rcall HLayout_Init ; (r16, r17, X)
|
||||
sec
|
||||
HLayout_new_ret:
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine HLayout_Init @global
|
||||
;
|
||||
; @param Y address of widget
|
||||
; @param X parent widget (if any)
|
||||
; @param r16 value for OBJECT_OFFS_OPTS
|
||||
; @param r17 value for WIDGET_OFFS_PACK
|
||||
; @param r20 layout mode (HLAYOUT_MODE_EXPAND, HLAYOUT_MODE_SPREAD)
|
||||
; @clobbers r16, r17, X
|
||||
|
||||
HLayout_Init:
|
||||
push r20
|
||||
; call base class
|
||||
bigcall Widget_Init ; (r16, r17, X)
|
||||
pop r20
|
||||
|
||||
; set widget-specific data
|
||||
std Y+HLAYOUT_OFFS_MODE, r20
|
||||
|
||||
; set default signal map
|
||||
ldi r16, LOW(HLayout_DefaultSignalmap*2)
|
||||
std Y+OBJECT_OFFS_SIGNALMAP_LO, r16
|
||||
ldi r16, HIGH(HLayout_DefaultSignalmap*2)
|
||||
std Y+OBJECT_OFFS_SIGNALMAP_HI, r16
|
||||
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine HLayout_OnLayout
|
||||
;
|
||||
; @param Y pointer to widget
|
||||
; @clobbers any, !Y
|
||||
|
||||
HLayout_OnLayout:
|
||||
; create and preset context
|
||||
rcall LayoutCtx_CreateContextFor1D ; X=ctx, r16=num of children
|
||||
brcc HLayout_OnLayout_ret
|
||||
; do layout
|
||||
mov r25, r16
|
||||
rcall hLayoutHorizontally
|
||||
rcall hLayoutVertically
|
||||
; release layout context
|
||||
bigcall LayoutCtx_free
|
||||
; force re-drawing of this widget, clear layout bit
|
||||
ldd r16, Y+OBJECT_OFFS_FLAGS
|
||||
sbr r16, (1<<WIDGET_FLAGS_DIRTY_BIT)
|
||||
cbr r16, (1<<WIDGET_FLAGS_LAYOUT_BIT)
|
||||
std Y+OBJECT_OFFS_FLAGS, r16
|
||||
HLayout_OnLayout_ret:
|
||||
sec
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine HLayout_OnGetDefaultHeight
|
||||
;
|
||||
; @param Y pointer to widget
|
||||
; @return r19:r18 value
|
||||
; @clobbers any, !Y
|
||||
|
||||
HLayout_OnGetDefaultHeight:
|
||||
rcall Layout_SetDefaultHeights
|
||||
rcall Layout_GetMaxTmp
|
||||
bigcall Widget_AddOuterStyleBorders ; (r20, r21)
|
||||
sec
|
||||
ret
|
||||
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine HLayout_OnGetDefaultWidth
|
||||
;
|
||||
; @param Y pointer to widget
|
||||
; @return r19:r18 value
|
||||
; @clobbers any, !Y
|
||||
|
||||
HLayout_OnGetDefaultWidth:
|
||||
rcall Layout_SetDefaultWidths
|
||||
rcall Layout_SumTmpValues ; r19:r18=default width
|
||||
sec
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine hLayoutVertically
|
||||
;
|
||||
; @param Y pointer to widget
|
||||
; @param X layout context
|
||||
; @param r25 number of children
|
||||
; @clobbers any, !X, !Y
|
||||
|
||||
hLayoutVertically:
|
||||
rcall hLayoutPrepareVertical ; (any, !R25, !X, !Y)
|
||||
rcall hLayoutReadLayoutWriteVertical ; (r16-r24)
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine hLayoutPrepareVertical
|
||||
;
|
||||
; @param Y pointer to widget
|
||||
; @param X layout context
|
||||
; @param r25 number of children
|
||||
; @clobbers any, !R25, !X, !Y,
|
||||
|
||||
hLayoutPrepareVertical:
|
||||
push xl
|
||||
push xh
|
||||
push yl
|
||||
push yh
|
||||
push r25
|
||||
rcall Layout_SetDefaultHeights
|
||||
pop r25
|
||||
pop yh
|
||||
pop yl
|
||||
pop xh
|
||||
pop xl
|
||||
|
||||
ldd r20, Y+WIDGET_OFFS_HEIGHT_LO
|
||||
ldd r21, Y+WIDGET_OFFS_HEIGHT_HI
|
||||
adiw xh:xl, LAYOUT_CTX_OFFS_TOTALSIZE_LO
|
||||
st X+, r20
|
||||
st X, r21
|
||||
sbiw xh:xl, (LAYOUT_CTX_OFFS_TOTALSIZE_LO+1)
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine hLayoutReadLayoutWriteVertical
|
||||
;
|
||||
; @param Y pointer to widget
|
||||
; @param X layout context
|
||||
; @param r25 number of children
|
||||
; @clobbers r16-r24
|
||||
|
||||
hLayoutReadLayoutWriteVertical:
|
||||
; read positions and flags into new layout context
|
||||
bigcall LayoutCtx_ReadYDimsContiguous ; (R16, r18, r19, Z)
|
||||
|
||||
; layout
|
||||
adiw xh:xl, LAYOUT_CTX_OFFS_BORDERS
|
||||
ld r18, X
|
||||
clr r19
|
||||
sbiw xh:xl, LAYOUT_CTX_OFFS_BORDERS
|
||||
bigcall LayoutCtx_SetFixedPos ; (r24)
|
||||
mov r22, r18 ; save border
|
||||
|
||||
bigcall LayoutCtx_GetMaxSize ; r19:r18=max default size (r18, r19, r20, r21, r24)
|
||||
ldd r16, Y+WIDGET_OFFS_PACK
|
||||
andi r16, (1<<WIDGET_PACK_VSELF1_BIT) | (1<<WIDGET_PACK_VSELF0_BIT)
|
||||
cpi r16, (WIDGET_PACK_FILLED<<WIDGET_PACK_VSELF0_BIT)
|
||||
brne vLayoutReadLayoutWriteVertical_setSize
|
||||
; use full possible width
|
||||
adiw xh:xl, LAYOUT_CTX_OFFS_TOTALSIZE_LO
|
||||
ld r18, X+
|
||||
ld r19, X
|
||||
sbiw xh:xl, (LAYOUT_CTX_OFFS_TOTALSIZE_LO+1)
|
||||
clr r23
|
||||
lsl r22
|
||||
rol r23
|
||||
sub r18, r22
|
||||
sbc r19, r23
|
||||
vLayoutReadLayoutWriteVertical_setSize:
|
||||
bigcall LayoutCtx_SetFixedSize ; (r24)
|
||||
|
||||
; pack
|
||||
bigcall LayoutCtx_PackYContiguous ; (R16, r18, r19, Z)
|
||||
ret
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
; read positions and flags into new layout context
|
||||
bigcall LayoutCtx_ReadYDimsContiguous ; (R16, r18, r19, Z)
|
||||
|
||||
; layout
|
||||
bigcall LayoutCtx_GetMaxSize ; r19:r18=max default size (r18, r19, r20, r21, r24)
|
||||
bigcall LayoutCtx_SetFixedSize ; (r24)
|
||||
adiw xh:xl, LAYOUT_CTX_OFFS_BORDERS
|
||||
ld r18, X
|
||||
clr r19
|
||||
sbiw xh:xl, LAYOUT_CTX_OFFS_BORDERS
|
||||
bigcall LayoutCtx_SetFixedPos ; (r24)
|
||||
|
||||
; pack
|
||||
bigcall LayoutCtx_PackYContiguous ; (R16, r18, r19, Z)
|
||||
|
||||
; write back dims
|
||||
; bigcall LayoutCtx_WriteYDimsContiguous ; (R16, r18, r19, Z)
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine hLayoutHorizontally
|
||||
;
|
||||
; @param Y pointer to widget
|
||||
; @param X layout context
|
||||
; @param r25 number of children
|
||||
; @clobbers any, !Y
|
||||
|
||||
hLayoutHorizontally:
|
||||
rcall hLayoutPrepareHorizontal ; (any, !R25, !X, !Y)
|
||||
rcall hLayoutReadLayoutWriteHorizontal ; (r16-r24)
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine hLayoutPrepareHorizontal
|
||||
;
|
||||
; @param Y pointer to widget
|
||||
; @param X layout context
|
||||
; @param r25 number of children
|
||||
; @clobbers any, !R25, !X, !Y,
|
||||
|
||||
hLayoutPrepareHorizontal:
|
||||
push xl
|
||||
push xh
|
||||
push yl
|
||||
push yh
|
||||
push r25
|
||||
rcall Layout_SetDefaultWidths ; (any, !Y)
|
||||
pop r25
|
||||
pop yh
|
||||
pop yl
|
||||
pop xh
|
||||
pop xl
|
||||
|
||||
; setup layout context for horizontal operations
|
||||
ldd r20, Y+WIDGET_OFFS_WIDTH_LO
|
||||
ldd r21, Y+WIDGET_OFFS_WIDTH_HI
|
||||
adiw xh:xl, LAYOUT_CTX_OFFS_TOTALSIZE_LO
|
||||
st X+, r20
|
||||
st X, r21
|
||||
sbiw xh:xl, (LAYOUT_CTX_OFFS_TOTALSIZE_LO+1)
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine hLayoutReadLayoutWriteHorizontal
|
||||
;
|
||||
; @param Y pointer to widget
|
||||
; @param X layout context
|
||||
; @param r25 number of children
|
||||
; @clobbers r16-r24
|
||||
|
||||
hLayoutReadLayoutWriteHorizontal:
|
||||
; read X positions and flags into new layout context
|
||||
bigcall LayoutCtx_ReadXDimsContiguous ; (R16, r18, r19, Z)
|
||||
|
||||
; layout
|
||||
push r25
|
||||
ldd r24, Y+HLAYOUT_OFFS_MODE
|
||||
cpi r24, HLAYOUT_MODE_SPREAD
|
||||
breq hLayoutReadLayoutWriteHorizontal_spread
|
||||
bigcall LayoutCtx_LayoutExpand ; (r16-r25)
|
||||
rjmp hLayoutReadLayoutWriteHorizontal_pack
|
||||
hLayoutReadLayoutWriteHorizontal_spread:
|
||||
bigcall LayoutCtx_LayoutSpread ; (r16-r25)
|
||||
hLayoutReadLayoutWriteHorizontal_pack:
|
||||
pop r25
|
||||
|
||||
; pack
|
||||
push r25
|
||||
bigcall LayoutCtx_PackXContiguous ; (r16-r21, r24, r25)
|
||||
pop r25
|
||||
|
||||
; write back dims
|
||||
; bigcall LayoutCtx_WriteXDimsContiguous ; (r16, r18, r19, r24)
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
; ***************************************************************************
|
||||
; data in FLASH
|
||||
|
||||
HLayout_DefaultSignalmap:
|
||||
; header
|
||||
.dw Widget_DefaultSignalmap*2 ; next table to use
|
||||
; entries
|
||||
.db 0, WIDGET_SIGNAL_LAYOUT, LOW(HLayout_OnLayout), HIGH(HLayout_OnLayout)
|
||||
.db WIDGET_VALUE_DEFAULT_WIDTH, WIDGET_SIGNAL_GETVALUE, LOW(HLayout_OnGetDefaultWidth), HIGH(HLayout_OnGetDefaultWidth)
|
||||
.db WIDGET_VALUE_DEFAULT_HEIGHT, WIDGET_SIGNAL_GETVALUE, LOW(HLayout_OnGetDefaultHeight), HIGH(HLayout_OnGetDefaultHeight)
|
||||
|
||||
.db 0, 0, 0, 0 ; end of table
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
354
avr/modules/lcd2/gui/base/imageview.asm
Normal file
354
avr/modules/lcd2/gui/base/imageview.asm
Normal file
@@ -0,0 +1,354 @@
|
||||
; ***************************************************************************
|
||||
; 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_IMAGEVIEW_ASM
|
||||
#define AQH_AVR_GUI2_IMAGEVIEW_ASM
|
||||
|
||||
|
||||
; ***************************************************************************
|
||||
; defines
|
||||
|
||||
.equ IMAGEVIEW_OFFS_BEGIN = WIDGET_SIZE
|
||||
.equ IMAGEVIEW_OFFS_RESSOURCEID_LO = IMAGEVIEW_OFFS_BEGIN+0
|
||||
.equ IMAGEVIEW_OFFS_RESSOURCEID_HI = IMAGEVIEW_OFFS_BEGIN+1
|
||||
.equ IMAGEVIEW_OFFS_BGCOLOR_LO = IMAGEVIEW_OFFS_BEGIN+2
|
||||
.equ IMAGEVIEW_OFFS_BGCOLOR_HI = IMAGEVIEW_OFFS_BEGIN+3
|
||||
.equ IMAGEVIEW_SIZE = IMAGEVIEW_OFFS_BEGIN+4
|
||||
|
||||
|
||||
.equ IMAGEVIEW_VALUE_BGCOL = WIDGET_VALUE_NEXTFREE+0
|
||||
.equ IMAGEVIEW_VALUE_NEXTFREE = WIDGET_VALUE_NEXTFREE+1
|
||||
|
||||
|
||||
|
||||
; ***************************************************************************
|
||||
; code
|
||||
|
||||
.cseg
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine ImageView_new @global
|
||||
;
|
||||
; @return CFLAG set of okay, cleared otherwise
|
||||
; @return Y address of newly created object
|
||||
; @param X parent widget
|
||||
; @param r16 value for OBJECT_OFFS_OPTS
|
||||
; @param r17 value for WIDGET_OFFS_PACK
|
||||
; @param r21:r20 ressource id for image
|
||||
; @clobbers any
|
||||
|
||||
ImageView_new:
|
||||
ldi r24, LOW(IMAGEVIEW_SIZE)
|
||||
ldi r25, HIGH(IMAGEVIEW_SIZE)
|
||||
push r20
|
||||
push r21
|
||||
bigcall Object_Alloc ; (!r16, !r17, !X)
|
||||
pop r21
|
||||
pop r20
|
||||
brcc ImageView_new_ret
|
||||
rcall ImageView_Init ; (r16, r17, X)
|
||||
sec
|
||||
ImageView_new_ret:
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine ImageView_Init @global
|
||||
;
|
||||
; @param Y address of widget
|
||||
; @param X parent widget (if any)
|
||||
; @param r16 value for OBJECT_OFFS_OPTS
|
||||
; @param r17 value for WIDGET_OFFS_PACK
|
||||
; @param r21:r20 ressource id for image
|
||||
; @clobbers r16, r17, X
|
||||
|
||||
ImageView_Init:
|
||||
push r20
|
||||
push r21
|
||||
; call base class
|
||||
bigcall Widget_Init ; (r16, r17, X)
|
||||
pop r21
|
||||
pop r20
|
||||
|
||||
; setup label data
|
||||
std Y+IMAGEVIEW_OFFS_RESSOURCEID_LO, r20
|
||||
std Y+IMAGEVIEW_OFFS_RESSOURCEID_HI, r21
|
||||
|
||||
; set default signal map
|
||||
ldi r16, LOW(ImageView_DefaultSignalmap*2)
|
||||
std Y+OBJECT_OFFS_SIGNALMAP_LO, r16
|
||||
ldi r16, HIGH(ImageView_DefaultSignalmap*2)
|
||||
std Y+OBJECT_OFFS_SIGNALMAP_HI, r16
|
||||
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine ImageView_SetRessourceId @global
|
||||
;
|
||||
; @param Y address of widget
|
||||
; @param X id of text ressource
|
||||
; @clobbers r16, r17, r18, r19
|
||||
|
||||
ImageView_SetRessourceId:
|
||||
std Y+IMAGEVIEW_OFFS_RESSOURCEID_LO, xl
|
||||
std Y+IMAGEVIEW_OFFS_RESSOURCEID_HI, xh
|
||||
ldd r16, Y+OBJECT_OFFS_FLAGS
|
||||
ori r16, (1<<WIDGET_FLAGS_DIRTY_BIT)
|
||||
std Y+OBJECT_OFFS_FLAGS, r16
|
||||
; force layout of this and all parent widgets
|
||||
ldi r16, (1<<WIDGET_FLAGS_LAYOUT_BIT)
|
||||
bigcall OBJ_AddFlagsUp ; (r17, r18, r19)
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine ImageView_OnDraw @global
|
||||
;
|
||||
; @param Y address of widget
|
||||
; @clobbers any, !Y
|
||||
|
||||
ImageView_OnDraw:
|
||||
ldd r16, Y+OBJECT_OFFS_FLAGS
|
||||
andi r16, (1<<WIDGET_FLAGS_DIRTY_BIT)
|
||||
breq ImageView_OnDraw_ret
|
||||
|
||||
; bigcall Widget_Clear
|
||||
rcall imageViewDraw
|
||||
|
||||
ldd r16, Y+OBJECT_OFFS_OPTS
|
||||
andi r16, (1<<WIDGET_OPTS_BORDER_BIT)
|
||||
breq ImageView_OnDraw_done
|
||||
bigcall Widget_DrawBorder
|
||||
|
||||
ImageView_OnDraw_done:
|
||||
ldd r16, Y+OBJECT_OFFS_FLAGS
|
||||
cbr r16, (1<<WIDGET_FLAGS_DIRTY_BIT)
|
||||
std Y+OBJECT_OFFS_FLAGS, r16
|
||||
|
||||
ImageView_OnDraw_ret:
|
||||
sec
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine ImageView_OnGetDefaultWidth @global
|
||||
;
|
||||
; @param Y address of widget
|
||||
; @param r17 value requested
|
||||
; @param xl param1
|
||||
; @param xh param2
|
||||
; @return CFLAG set if signal handled
|
||||
; @return r19:r18 value
|
||||
; @clobbers any, !Y
|
||||
|
||||
ImageView_OnGetDefaultWidth:
|
||||
rcall imageViewGetRessource
|
||||
brcs ImageView_OnGetDefaultWidth_getImageWidth
|
||||
ldi r18, 1
|
||||
clr r19
|
||||
rjmp ImageView_OnGetDefaultWidth_addBorders
|
||||
ImageView_OnGetDefaultWidth_getImageWidth:
|
||||
rcall imageViewGetImageWidth
|
||||
mov r18, r12
|
||||
mov r19, r13
|
||||
ImageView_OnGetDefaultWidth_addBorders:
|
||||
bigcall Widget_AddOuterStyleBorders ; (r20, r21)
|
||||
sec
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine ImageView_OnGetDefaultHeight @global
|
||||
;
|
||||
; @param Y address of widget
|
||||
; @param xl param1
|
||||
; @param xh param2
|
||||
; @return CFLAG set if signal handled
|
||||
; @return r19:r18 value
|
||||
; @clobbers any, !Y
|
||||
|
||||
ImageView_OnGetDefaultHeight:
|
||||
rcall imageViewGetRessource
|
||||
brcs ImageView_OnGetDefaultHeight_getImageHeight
|
||||
ldi r18, 1
|
||||
clr r19
|
||||
rjmp ImageView_OnGetDefaultHeight_addBorders
|
||||
ImageView_OnGetDefaultHeight_getImageHeight:
|
||||
rcall imageViewGetImageHeight
|
||||
mov r18, r12
|
||||
mov r19, r13
|
||||
ImageView_OnGetDefaultHeight_addBorders:
|
||||
bigcall Widget_AddOuterStyleBorders ; (r20, r21)
|
||||
sec
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine ImageView_OnDraw @global
|
||||
;
|
||||
; @param Y address of widget
|
||||
; @clobbers any, !Y
|
||||
|
||||
imageViewDraw:
|
||||
rcall imageViewGetRessource
|
||||
brcc imageViewDraw_ret
|
||||
rcall imageViewAlignContentXY ; (r17, r18, r19, r20, r21, Z)
|
||||
ldd r0, Y+IMAGEVIEW_OFFS_BGCOLOR_LO
|
||||
ldd r1, Y+IMAGEVIEW_OFFS_BGCOLOR_HI
|
||||
; select background color
|
||||
mov r16, r0
|
||||
or r16, r1
|
||||
breq imageViewDraw_useStyleColors
|
||||
ldd r16, Y+OBJECT_OFFS_FLAGS
|
||||
sbrc r16, WIDGET_FLAGS_ACTIVATED_BIT
|
||||
rjmp imageViewDraw_useStyleColors
|
||||
rjmp imageViewDraw_draw
|
||||
imageViewDraw_useStyleColors:
|
||||
bigcall Widget_SelectColors ; (R16)
|
||||
imageViewDraw_draw:
|
||||
bigcall Widget_DrawImage
|
||||
imageViewDraw_ret:
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine ImageView_OnSetBgCol @global
|
||||
;
|
||||
; @param Y address of widget
|
||||
; @param X new background color
|
||||
; @clobbers any, !Y
|
||||
|
||||
ImageView_OnSetBgCol:
|
||||
std Y+IMAGEVIEW_OFFS_BGCOLOR_LO, xl
|
||||
std Y+IMAGEVIEW_OFFS_BGCOLOR_HI, xh
|
||||
|
||||
ldd r16, Y+OBJECT_OFFS_FLAGS
|
||||
ori r16, (1<<WIDGET_FLAGS_DIRTY_BIT)
|
||||
std Y+OBJECT_OFFS_FLAGS, r16
|
||||
sec
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine imageViewGetRessource
|
||||
;
|
||||
; @param Y address of widget
|
||||
; @return CFLAG set if ressource found, cleared on error
|
||||
; @return Z pointer to ressource
|
||||
|
||||
imageViewGetRessource:
|
||||
ldd r16, Y+IMAGEVIEW_OFFS_RESSOURCEID_LO
|
||||
ldd r17, Y+IMAGEVIEW_OFFS_RESSOURCEID_HI
|
||||
ldi zl, LOW(RESSOURCE_ADDR*2)
|
||||
ldi zh, HIGH(RESSOURCE_ADDR*2)
|
||||
bigcall RES_GetRessource ; (r16, r17, r18)
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine imageViewAlignContentXY
|
||||
;
|
||||
; @param Y address of widget
|
||||
; @param Z byte address pointer to image (for LPM!)
|
||||
; @return R5:R4 X
|
||||
; @return R7:R6 Y
|
||||
; @clobbers r17, r18, r19, r20, r21, Z
|
||||
|
||||
imageViewAlignContentXY:
|
||||
rcall imageViewGetImageWidth ; R13:R12=width (r16, r17, r18, Z)
|
||||
bigcall Widget_PackContentX ; R5:R4=X (r17, r18, r19, r20, r21)
|
||||
|
||||
rcall imageViewGetImageHeight ; R13:R12=height (r16, r17, r18, Z)
|
||||
bigcall Widget_PackContentY ; R7:R6=Y (r17, r18, r19, r20, r21)
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine imageViewGetImageWidth
|
||||
;
|
||||
; @param Y address of widget
|
||||
; @return Z byte address pointer to text in FLASH
|
||||
; @return r13:r12 image width
|
||||
; @clobbers r16, r17, r18, Z
|
||||
|
||||
imageViewGetImageWidth:
|
||||
adiw zh:zl, RES_IMAGE_OFFS_WIDTH_LO
|
||||
lpm r12, Z+
|
||||
lpm r13, Z
|
||||
sbiw zh:zl, (RES_IMAGE_OFFS_WIDTH_LO+1)
|
||||
sec
|
||||
imageViewGetImageWidth_ret:
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine imageViewGetImageHeight
|
||||
;
|
||||
; @param Y address of widget
|
||||
; @param Z byte address pointer to image ressource
|
||||
; @return r13:r12 image height
|
||||
; @clobbers r16, r17, r18
|
||||
|
||||
imageViewGetImageHeight:
|
||||
adiw zh:zl, RES_IMAGE_OFFS_HEIGHT_LO
|
||||
lpm r12, Z+
|
||||
lpm r13, Z
|
||||
sbiw zh:zl, (RES_IMAGE_OFFS_HEIGHT_LO+1)
|
||||
sec
|
||||
imageViewGetImageHeight_ret:
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
; ***************************************************************************
|
||||
; data in FLASH
|
||||
|
||||
ImageView_DefaultSignalmap:
|
||||
; header
|
||||
.dw Widget_DefaultSignalmap*2 ; next table to use
|
||||
; entries
|
||||
.db 0, WIDGET_SIGNAL_DRAW, LOW(ImageView_OnDraw), HIGH(ImageView_OnDraw)
|
||||
.db WIDGET_VALUE_DEFAULT_WIDTH, WIDGET_SIGNAL_GETVALUE, LOW(ImageView_OnGetDefaultWidth), HIGH(ImageView_OnGetDefaultWidth)
|
||||
.db WIDGET_VALUE_DEFAULT_HEIGHT, WIDGET_SIGNAL_GETVALUE, LOW(ImageView_OnGetDefaultHeight), HIGH(ImageView_OnGetDefaultHeight)
|
||||
.db IMAGEVIEW_VALUE_BGCOL, WIDGET_SIGNAL_SETVALUE, LOW(ImageView_OnSetBgCol), HIGH(ImageView_OnSetBgCol)
|
||||
|
||||
.db 0, 0, 0, 0 ; end of table
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
272
avr/modules/lcd2/gui/base/label.asm
Normal file
272
avr/modules/lcd2/gui/base/label.asm
Normal file
@@ -0,0 +1,272 @@
|
||||
; ***************************************************************************
|
||||
; 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
|
||||
|
||||
.equ LABEL_OFFS_BEGIN = WIDGET_SIZE
|
||||
.equ LABEL_OFFS_TEXTRES_LO = LABEL_OFFS_BEGIN+0
|
||||
.equ LABEL_OFFS_TEXTRES_HI = LABEL_OFFS_BEGIN+1
|
||||
.equ LABEL_SIZE = LABEL_OFFS_BEGIN+2
|
||||
|
||||
|
||||
|
||||
|
||||
; ***************************************************************************
|
||||
; code
|
||||
|
||||
.cseg
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine Label_new @global
|
||||
;
|
||||
; @return CFLAG set of okay, cleared otherwise
|
||||
; @return Y address of newly created object
|
||||
; @param X parent widget
|
||||
; @param r16 value for OBJECT_OFFS_OPTS
|
||||
; @param r17 value for WIDGET_OFFS_PACK
|
||||
; @param r21:r20 ressource id for label text
|
||||
; @clobbers any
|
||||
|
||||
Label_new:
|
||||
ldi r24, LOW(LABEL_SIZE)
|
||||
ldi r25, HIGH(LABEL_SIZE)
|
||||
push r20
|
||||
push r21
|
||||
bigcall Object_Alloc ; (!r16, !r17, !X)
|
||||
pop r21
|
||||
pop r20
|
||||
brcc Label_new_ret
|
||||
rcall Label_Init ; (r16, r17, X)
|
||||
sec
|
||||
Label_new_ret:
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine Label_Init @global
|
||||
;
|
||||
; @param Y address of widget
|
||||
; @param X parent widget (if any)
|
||||
; @param r16 value for OBJECT_OFFS_OPTS
|
||||
; @param r17 value for WIDGET_OFFS_PACK
|
||||
; @param r21:r20 ressource id for label text
|
||||
; @clobbers r16, r17, X
|
||||
|
||||
Label_Init:
|
||||
push r20
|
||||
push r21
|
||||
; call base class
|
||||
bigcall Widget_Init ; (r16, r17, X)
|
||||
pop r21
|
||||
pop r20
|
||||
|
||||
; setup label data
|
||||
std Y+LABEL_OFFS_TEXTRES_LO, r20
|
||||
std Y+LABEL_OFFS_TEXTRES_HI, r21
|
||||
|
||||
; set default signal map
|
||||
ldi r16, LOW(Label_DefaultSignalmap*2)
|
||||
std Y+OBJECT_OFFS_SIGNALMAP_LO, r16
|
||||
ldi r16, HIGH(Label_DefaultSignalmap*2)
|
||||
std Y+OBJECT_OFFS_SIGNALMAP_HI, r16
|
||||
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine Label_SetTextRessourceId @global
|
||||
;
|
||||
; @param Y address of widget
|
||||
; @param X id of text ressource
|
||||
; @clobbers r16, r17, r18, r19
|
||||
|
||||
Label_SetTextRessourceId:
|
||||
std Y+LABEL_OFFS_TEXTRES_LO, xl
|
||||
std Y+LABEL_OFFS_TEXTRES_HI, xh
|
||||
ldd r16, Y+OBJECT_OFFS_FLAGS
|
||||
ori r16, (1<<WIDGET_FLAGS_DIRTY_BIT)
|
||||
std Y+OBJECT_OFFS_FLAGS, r16
|
||||
; force layout of this and all parent widgets
|
||||
ldi r16, (1<<WIDGET_FLAGS_LAYOUT_BIT)
|
||||
bigcall OBJ_AddFlagsUp ; (r17, r18, r19)
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine Label_OnDraw @global
|
||||
;
|
||||
; @param Y address of widget
|
||||
; @param xl param1
|
||||
; @param xh param2
|
||||
; @clobbers any, !Y
|
||||
|
||||
Label_OnDraw:
|
||||
ldd r16, Y+OBJECT_OFFS_FLAGS
|
||||
andi r16, (1<<WIDGET_FLAGS_DIRTY_BIT)
|
||||
breq Label_OnDraw_ret
|
||||
|
||||
bigcall Widget_Clear
|
||||
rcall labelWriteText
|
||||
|
||||
ldd r16, Y+OBJECT_OFFS_OPTS
|
||||
andi r16, (1<<WIDGET_OPTS_BORDER_BIT)
|
||||
breq Label_OnDraw_done
|
||||
bigcall Widget_DrawBorder
|
||||
|
||||
Label_OnDraw_done:
|
||||
ldd r16, Y+OBJECT_OFFS_FLAGS
|
||||
cbr r16, (1<<WIDGET_FLAGS_DIRTY_BIT)
|
||||
std Y+OBJECT_OFFS_FLAGS, r16
|
||||
|
||||
Label_OnDraw_ret:
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine Label_OnGetDefaultWidth @global
|
||||
;
|
||||
; @param Y address of widget
|
||||
; @param r17 value requested
|
||||
; @param xl param1
|
||||
; @param xh param2
|
||||
; @return CFLAG set if signal handled
|
||||
; @return r19:r18 value
|
||||
; @clobbers any, !Y
|
||||
|
||||
Label_OnGetDefaultWidth:
|
||||
rcall labelCalcTextWidth
|
||||
mov r18, r12
|
||||
mov r19, r13
|
||||
bigcall Widget_AddOuterStyleBorders ; (r20, r21)
|
||||
sec
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine Label_OnGetDefaultHeight @global
|
||||
;
|
||||
; @param Y address of widget
|
||||
; @param xl param1
|
||||
; @param xh param2
|
||||
; @return CFLAG set if signal handled
|
||||
; @return r19:r18 value
|
||||
; @clobbers any, !Y
|
||||
|
||||
Label_OnGetDefaultHeight:
|
||||
bigcall Widget_GetCharHeight ; R16=char height
|
||||
mov r18, r16
|
||||
clr r19
|
||||
bigcall Widget_AddOuterStyleBorders ; (r20, r21)
|
||||
sec
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine Label_OnDraw @global
|
||||
;
|
||||
; @param Y address of widget
|
||||
; @clobbers any, !Y
|
||||
|
||||
labelWriteText:
|
||||
rcall labelAlignTextXY ; (r8, r9, r10, r11, r12, r13, r14, r15, r16, r17, r18, r19)
|
||||
bigcall Widget_DrawTextFlash ; (any, !Y)
|
||||
labelWriteText_ret:
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine labelAlignTextXY
|
||||
;
|
||||
; @param Y address of widget
|
||||
; @param R13:R12 width of object to align
|
||||
; @return R5:R4 X
|
||||
; @return R7:R6 Y
|
||||
; @return Z byte address pointer to text in FLASH
|
||||
; @clobbers r8, r9, r10, r11, r12, r13, r14, r15, r16, r17, r18, r19, r20, r21, r22, r23, r24, r25
|
||||
|
||||
labelAlignTextXY:
|
||||
rcall labelCalcTextWidth ; Z=text, R13:R12=text width (r16, r17, r18)
|
||||
bigcall Widget_PackContentX ; R5:R4=X (r17, r18, r19, r20, r21)
|
||||
|
||||
bigcall Widget_GetCharHeight ; R16=char height
|
||||
mov r12, r16
|
||||
clr r13
|
||||
bigcall Widget_PackContentY ; R7:R6=Y (r17, r18, r19, r20, r21)
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine labelCalcTextWidth
|
||||
;
|
||||
; @param Y address of widget
|
||||
; @return Z byte address pointer to text in FLASH
|
||||
; @return r13:r12 width of string
|
||||
; @clobbers r16, r17, r18
|
||||
|
||||
labelCalcTextWidth:
|
||||
; get text from ressource id
|
||||
ldd r16, Y+LABEL_OFFS_TEXTRES_LO
|
||||
ldd r17, Y+LABEL_OFFS_TEXTRES_HI
|
||||
ldi zl, LOW(RESSOURCE_ADDR*2)
|
||||
ldi zh, HIGH(RESSOURCE_ADDR*2)
|
||||
bigcall RES_GetRessource ; (r16, r17, r18)
|
||||
brcc labelCalcTextWidth_ret
|
||||
|
||||
bigcall Widget_GetCharWidth ; R16=char width
|
||||
mov r18, r16
|
||||
bigcall Widget_CalcStringWidthFLASH ; r13:r12=size (r16)
|
||||
sec
|
||||
labelCalcTextWidth_ret:
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ***************************************************************************
|
||||
; data in FLASH
|
||||
|
||||
Label_DefaultSignalmap:
|
||||
; header
|
||||
.dw Widget_DefaultSignalmap*2 ; next table to use
|
||||
; entries
|
||||
.db 0, WIDGET_SIGNAL_DRAW, LOW(Label_OnDraw), HIGH(Label_OnDraw)
|
||||
.db WIDGET_VALUE_DEFAULT_WIDTH, WIDGET_SIGNAL_GETVALUE, LOW(Label_OnGetDefaultWidth), HIGH(Label_OnGetDefaultWidth)
|
||||
.db WIDGET_VALUE_DEFAULT_HEIGHT, WIDGET_SIGNAL_GETVALUE, LOW(Label_OnGetDefaultHeight), HIGH(Label_OnGetDefaultHeight)
|
||||
|
||||
.db 0, 0, 0, 0 ; end of table
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
1771
avr/modules/lcd2/gui/base/layout.asm
Normal file
1771
avr/modules/lcd2/gui/base/layout.asm
Normal file
File diff suppressed because it is too large
Load Diff
327
avr/modules/lcd2/gui/base/mainwindow.asm
Normal file
327
avr/modules/lcd2/gui/base/mainwindow.asm
Normal file
@@ -0,0 +1,327 @@
|
||||
; ***************************************************************************
|
||||
; 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 = VLAYOUT_SIZE
|
||||
; no data for now
|
||||
.equ MAINWINDOW_SIZE = MAINWINDOW_OFFS_BEGIN+0
|
||||
|
||||
|
||||
; index of sub-windows
|
||||
.equ MAINWINDOW_CHILDIDX_TITLE = 0
|
||||
.equ MAINWINDOW_CHILDIDX_CONTENT = 1
|
||||
|
||||
|
||||
|
||||
; ***************************************************************************
|
||||
; code
|
||||
|
||||
.cseg
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine MainWindow_new @global
|
||||
;
|
||||
; @return CFLAG set of okay, cleared otherwise
|
||||
; @return Y address of newly created object
|
||||
; @param X parent widget
|
||||
; @param r16 value for OBJECT_OFFS_OPTS
|
||||
; @param r17 value for WIDGET_OFFS_PACK
|
||||
; @param r21:r20 ressource id for title
|
||||
; @clobbers any
|
||||
|
||||
MainWindow_new:
|
||||
push r20
|
||||
push r21
|
||||
ldi r24, LOW(MAINWINDOW_SIZE)
|
||||
ldi r25, HIGH(MAINWINDOW_SIZE)
|
||||
bigcall Object_Alloc ; (!r16, !r17, !X)
|
||||
pop r21
|
||||
pop r20
|
||||
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
|
||||
; @param X parent widget (if any)
|
||||
; @param r16 value for OBJECT_OFFS_OPTS
|
||||
; @param r17 value for WIDGET_OFFS_PACK
|
||||
; @param r21:r20 ressource id for title
|
||||
; @clobbers r16, r17, X
|
||||
|
||||
MainWindow_Init:
|
||||
push r20
|
||||
push r21
|
||||
; call base class
|
||||
ldi r20, VLAYOUT_MODE_EXPAND
|
||||
bigcall VLayout_Init ; (r16, r17, X)
|
||||
pop r21
|
||||
pop r20
|
||||
|
||||
; set default signal map
|
||||
ldi r16, LOW(MainWindow_DefaultSignalmap*2)
|
||||
std Y+OBJECT_OFFS_SIGNALMAP_LO, r16
|
||||
ldi r16, HIGH(MainWindow_DefaultSignalmap*2)
|
||||
std Y+OBJECT_OFFS_SIGNALMAP_HI, r16
|
||||
|
||||
; set style which has no spacing and no borders so needs no drawing because
|
||||
; the children fill the screen completely
|
||||
ldi r16, LOW(MainWindow_DefaultStyle*2)
|
||||
std Y+WIDGET_OFFS_STYLE_LO, r16
|
||||
ldi r16, HIGH(MainWindow_DefaultStyle*2)
|
||||
std Y+WIDGET_OFFS_STYLE_HI, r16
|
||||
|
||||
bigcall Widget_SetFullScreen ; (R16)
|
||||
|
||||
; create sub widgets
|
||||
rcall mainWindowCreateTitleWidget
|
||||
rcall mainWindowCreateContentWidget
|
||||
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine MainWindow_GetContentWidget @global
|
||||
;
|
||||
; @param Y address of widget
|
||||
; @param X parent widget (if any)
|
||||
; @return CFLAG set, if found, cleared otherwise
|
||||
; @return r19:r18 resulting object
|
||||
; @clobbers r16
|
||||
|
||||
MainWindow_GetContentWidget:
|
||||
ldi r16, MAINWINDOW_CHILDIDX_CONTENT
|
||||
bigcall OBJ_GetChildAt
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine MainWindow_GetContentWidget @global
|
||||
;
|
||||
; @param Y address of widget
|
||||
; @param X parent widget (if any)
|
||||
; @return CFLAG set, if found, cleared otherwise
|
||||
; @return r19:r18 resulting object
|
||||
; @clobbers r16
|
||||
|
||||
MainWindow_GetFirstChildOfContentWidget:
|
||||
push yl
|
||||
push yh
|
||||
bigcall MainWindow_GetContentWidget ; r19:r18=content window (R16)
|
||||
brcc MainWindow_GetFirstChildOfContentWidget_popRet
|
||||
mov yl, r18
|
||||
mov yh, r19
|
||||
bigcall OBJ_GetFirstChild ; get first child
|
||||
MainWindow_GetFirstChildOfContentWidget_popRet:
|
||||
pop yh
|
||||
pop yl
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
; ***************************************************************************
|
||||
; signal handlers
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine MainWindow_OnGetDefaultWidth @global
|
||||
;
|
||||
; @param Y address of widget
|
||||
; @param r17 value requested
|
||||
; @param xl param1
|
||||
; @param xh param2
|
||||
; @return CFLAG set if signal handled
|
||||
; @return r19:r18 value
|
||||
; @clobbers any, !Y
|
||||
|
||||
MainWindow_OnGetDefaultWidth:
|
||||
ldi r18, LOW(DISPLAY_WIDTH)
|
||||
ldi r19, HIGH(DISPLAY_WIDTH)
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine MainWindow_OnGetDefaultHeight @global
|
||||
;
|
||||
; @param Y address of widget
|
||||
; @param r17 value requested
|
||||
; @param xl param1
|
||||
; @param xh param2
|
||||
; @return CFLAG set if signal handled
|
||||
; @return r19:r18 value
|
||||
; @clobbers any, !Y
|
||||
|
||||
MainWindow_OnGetDefaultHeight:
|
||||
ldi r18, LOW(DISPLAY_HEIGHT)
|
||||
ldi r19, HIGH(DISPLAY_HEIGHT)
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine mainWindowCreateTitleWidget
|
||||
;
|
||||
; @param Y address of main window widget
|
||||
; @param r21:r20 ressource id for title
|
||||
; @return CFLAG set of okay, cleared otherwise
|
||||
|
||||
mainWindowCreateTitleWidget:
|
||||
; create title widget
|
||||
push yl
|
||||
push yh
|
||||
mov xl, yl
|
||||
mov xh, yh
|
||||
ldi r16, 0
|
||||
ldi r17, (WIDGET_PACK_FILLED<<WIDGET_PACK_HSELF0_BIT) | (WIDGET_PACK_BEGIN<<WIDGET_PACK_VSELF0_BIT) | \
|
||||
(WIDGET_PACK_BEGIN <<WIDGET_PACK_HCONTENT0_BIT) | (WIDGET_PACK_CENTER<<WIDGET_PACK_VCONTENT0_BIT)
|
||||
bigcall Label_new
|
||||
brcc mainWindowCreateTitleWidget_done
|
||||
; set style for title widget
|
||||
ldi r16, LOW(MainWindow_TitleStyle*2)
|
||||
std Y+WIDGET_OFFS_STYLE_LO, r16
|
||||
ldi r16, HIGH(MainWindow_TitleStyle*2)
|
||||
std Y+WIDGET_OFFS_STYLE_HI, r16
|
||||
sec
|
||||
mainWindowCreateTitleWidget_done:
|
||||
pop yh
|
||||
pop yl
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine mainWindowCreateContentWidget
|
||||
;
|
||||
; @param Y address of main window widget
|
||||
; @param r21:r20 ressource id for title
|
||||
; @return CFLAG set of okay, cleared otherwise
|
||||
|
||||
mainWindowCreateContentWidget:
|
||||
; create content widget
|
||||
push yl
|
||||
push yh
|
||||
mov xl, yl
|
||||
mov xh, yh
|
||||
ldi r16, 0 ; OPTS
|
||||
ldi r17, (WIDGET_PACK_FILLED<<WIDGET_PACK_HSELF0_BIT) | (WIDGET_PACK_FILLED<<WIDGET_PACK_VSELF0_BIT) ; PACK
|
||||
ldi r20, VLAYOUT_MODE_EXPAND
|
||||
bigcall VLayout_new
|
||||
brcc mainWindowCreateContentWidget_done
|
||||
; set style for title widget
|
||||
ldi r16, LOW(MainWindow_ContentStyle*2)
|
||||
std Y+WIDGET_OFFS_STYLE_LO, r16
|
||||
ldi r16, HIGH(MainWindow_ContentStyle*2)
|
||||
std Y+WIDGET_OFFS_STYLE_HI, r16
|
||||
mainWindowCreateContentWidget_done:
|
||||
pop yh
|
||||
pop yl
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
; ***************************************************************************
|
||||
; data in FLASH
|
||||
|
||||
MainWindow_DefaultSignalmap:
|
||||
; header
|
||||
.dw VLayout_DefaultSignalmap*2 ; next table to use
|
||||
; entries
|
||||
.db 0, WIDGET_SIGNAL_DRAW, LOW(Widget_OnDrawNop), HIGH(Widget_OnDrawNop)
|
||||
.db WIDGET_VALUE_DEFAULT_WIDTH, WIDGET_SIGNAL_GETVALUE, LOW(MainWindow_OnGetDefaultWidth), HIGH(MainWindow_OnGetDefaultWidth)
|
||||
.db WIDGET_VALUE_DEFAULT_HEIGHT, WIDGET_SIGNAL_GETVALUE, LOW(MainWindow_OnGetDefaultHeight), HIGH(MainWindow_OnGetDefaultHeight)
|
||||
|
||||
.db 0, 0, 0, 0 ; end of table
|
||||
|
||||
|
||||
|
||||
MainWindow_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, 0 ; outerBorderSize, innerBorderSize
|
||||
.dw ili9341Font12x16_1*2 ; font
|
||||
.db 12, 16 ; charWidth, charHeight
|
||||
|
||||
|
||||
|
||||
MainWindow_TitleStyle:
|
||||
.dw STYLE_WIN_TITLE_FOREGROUND ; frontCol_norm
|
||||
.dw STYLE_WIN_TITLE_BACKGROUND ; 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 2, 1 ; outerBorderSize, innerBorderSize
|
||||
.dw ili9341Font12x16_1*2 ; font
|
||||
.db 12, 16 ; charWidth, charHeight
|
||||
|
||||
|
||||
|
||||
; this is the defining style for most windows because normally
|
||||
; the style of the parent will be propagated to newly created child widgets.
|
||||
|
||||
MainWindow_ContentStyle:
|
||||
.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 2, 1 ; outerBorderSize, innerBorderSize
|
||||
.dw ili9341Font12x16_1*2 ; font
|
||||
.db 12, 16 ; charWidth, charHeight
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
278
avr/modules/lcd2/gui/base/mclayout.asm
Normal file
278
avr/modules/lcd2/gui/base/mclayout.asm
Normal file
@@ -0,0 +1,278 @@
|
||||
; ***************************************************************************
|
||||
; 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_MCLAYOUT_ASM
|
||||
#define AQH_AVR_GUI2_MCLAYOUT_ASM
|
||||
|
||||
|
||||
; ***************************************************************************
|
||||
; defines
|
||||
|
||||
.equ MCLAYOUT_OFFS_BEGIN = WIDGET_SIZE
|
||||
.equ MCLAYOUT_OFFS_MODE = MCLAYOUT_OFFS_BEGIN+0
|
||||
.equ MCLAYOUT_OFFS_COLUMNS = MCLAYOUT_OFFS_BEGIN+1
|
||||
.equ MCLAYOUT_SIZE = MCLAYOUT_OFFS_BEGIN+2
|
||||
|
||||
|
||||
|
||||
; ***************************************************************************
|
||||
; code
|
||||
|
||||
.cseg
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine MCLayout_new @global
|
||||
;
|
||||
; @return CFLAG set of okay, cleared otherwise
|
||||
; @return Y address of newly created object
|
||||
; @param X parent widget
|
||||
; @param r16 value for OBJECT_OFFS_OPTS
|
||||
; @param r17 value for WIDGET_OFFS_PACK
|
||||
; @param r20 number of columns or rows (depending on mode in r20)
|
||||
; @clobbers any
|
||||
|
||||
MCLayout_new:
|
||||
push r20
|
||||
ldi r24, LOW(MCLAYOUT_SIZE)
|
||||
ldi r25, HIGH(MCLAYOUT_SIZE)
|
||||
bigcall Object_Alloc ; (!r16, !r17, !X)
|
||||
pop r20
|
||||
brcc MCLayout_new_ret
|
||||
rcall MCLayout_Init ; (r16, r17, X)
|
||||
sec
|
||||
MCLayout_new_ret:
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine MCLayout_Init @global
|
||||
;
|
||||
; @param Y address of widget
|
||||
; @param X parent widget (if any)
|
||||
; @param r16 value for OBJECT_OFFS_OPTS
|
||||
; @param r17 value for WIDGET_OFFS_PACK
|
||||
; @param r20 number of columns or rows (depending on mode in r20)
|
||||
; @clobbers r16, r17, X
|
||||
|
||||
MCLayout_Init:
|
||||
push r20
|
||||
; call base class
|
||||
bigcall Widget_Init ; (r16, r17, X)
|
||||
pop r20
|
||||
|
||||
; set widget-specific data
|
||||
std Y+MCLAYOUT_OFFS_COLUMNS, r20
|
||||
|
||||
; set default signal map
|
||||
ldi r16, LOW(MCLayout_DefaultSignalmap*2)
|
||||
std Y+OBJECT_OFFS_SIGNALMAP_LO, r16
|
||||
ldi r16, HIGH(MCLayout_DefaultSignalmap*2)
|
||||
std Y+OBJECT_OFFS_SIGNALMAP_HI, r16
|
||||
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine MCLayout_OnGetDefaultHeight
|
||||
;
|
||||
; @param Y pointer to widget
|
||||
; @return r19:r18 value
|
||||
; @clobbers any, !Y
|
||||
|
||||
MCLayout_OnGetDefaultHeight:
|
||||
; rcall Layout_SetDefaultHeights
|
||||
; rcall Layout_GetMaxTmp
|
||||
; bigcall Widget_AddOuterStyleBorders ; (r20, r21)
|
||||
ldi r18, 10
|
||||
clr r19
|
||||
sec
|
||||
ret
|
||||
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine MCLayout_OnGetDefaultWidth
|
||||
;
|
||||
; @param Y pointer to widget
|
||||
; @return r19:r18 value
|
||||
; @clobbers any, !Y
|
||||
|
||||
MCLayout_OnGetDefaultWidth:
|
||||
; rcall Layout_SetDefaultWidths
|
||||
; rcall Layout_SumTmpValues ; r19:r18=default width
|
||||
ldi r18, 10
|
||||
clr r19
|
||||
sec
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine MCLayout_OnLayout
|
||||
;
|
||||
; @param Y pointer to widget
|
||||
; @clobbers any, !Y
|
||||
|
||||
MCLayout_OnLayout:
|
||||
ldd r25, Y+MCLAYOUT_OFFS_COLUMNS
|
||||
rcall Layout_CountChildrenSkipped ; r16=number of rows used (r18, r19)
|
||||
|
||||
mov r24, r16 ; store for later
|
||||
ldd r17, Y+MCLAYOUT_OFFS_COLUMNS
|
||||
cp r16, r17
|
||||
brcc MCLayout_OnLayout_mkCtx
|
||||
mov r16, r17
|
||||
MCLayout_OnLayout_mkCtx:
|
||||
; create and preset context
|
||||
push r24 ; num of children
|
||||
rcall LayoutCtx_CreateContextForN ; X=ctx (any, !R16, !Y)
|
||||
pop r24
|
||||
brcc MCLayout_OnLayout_ret
|
||||
|
||||
push r24 ; num of children
|
||||
ldd r24, Y+MCLAYOUT_OFFS_COLUMNS
|
||||
rcall mcLayoutHorizontally
|
||||
pop r24
|
||||
rcall mcLayoutVertically
|
||||
|
||||
; release layout context
|
||||
bigcall LayoutCtx_free
|
||||
|
||||
; force re-drawing of this widget, clear layout bit
|
||||
ldd r16, Y+OBJECT_OFFS_FLAGS
|
||||
sbr r16, (1<<WIDGET_FLAGS_DIRTY_BIT)
|
||||
cbr r16, (1<<WIDGET_FLAGS_LAYOUT_BIT)
|
||||
std Y+OBJECT_OFFS_FLAGS, r16
|
||||
MCLayout_OnLayout_ret:
|
||||
sec
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine mcLayoutVertically
|
||||
;
|
||||
; @param Y pointer to widget
|
||||
; @param X layout context
|
||||
; @param r24 number of rows
|
||||
; @clobbers any, !X, !Y
|
||||
|
||||
mcLayoutVertically:
|
||||
; prepare
|
||||
push xl
|
||||
push xh
|
||||
push r24
|
||||
rcall Layout_SetDefaultHeights ; (any, !Y)
|
||||
pop r24
|
||||
pop xh
|
||||
pop xl
|
||||
|
||||
ldd r20, Y+WIDGET_OFFS_HEIGHT_LO
|
||||
ldd r21, Y+WIDGET_OFFS_HEIGHT_HI
|
||||
adiw xh:xl, LAYOUT_CTX_OFFS_TOTALSIZE_LO
|
||||
st X+, r20
|
||||
st X, r21
|
||||
sbiw xh:xl, (LAYOUT_CTX_OFFS_TOTALSIZE_LO+1)
|
||||
adiw xh:xl, LAYOUT_CTX_OFFS_NUMITEMS
|
||||
st X, r24
|
||||
sbiw xh:xl, LAYOUT_CTX_OFFS_NUMITEMS
|
||||
|
||||
; read positions and flags into new layout context
|
||||
ldd r25, Y+MCLAYOUT_OFFS_COLUMNS
|
||||
bigcall LayoutCtx_ReadYMaxDimsVertical ; (r16-r20, Z)
|
||||
|
||||
; layout
|
||||
bigcall LayoutCtx_LayoutExpand ; (r16-r25)
|
||||
|
||||
; pack
|
||||
ldd r25, Y+MCLAYOUT_OFFS_COLUMNS
|
||||
rcall LayoutCtx_PackYVertical ; (r16, r18, r19, r24, Z)
|
||||
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine mcLayoutHorizontally
|
||||
;
|
||||
; @param Y pointer to widget
|
||||
; @param X layout context
|
||||
; @param r24 number of items to use
|
||||
; @clobbers any, !Y
|
||||
|
||||
mcLayoutHorizontally:
|
||||
; prepare
|
||||
push xl
|
||||
push xh
|
||||
push r24
|
||||
rcall Layout_SetDefaultWidths ; (any, !Y)
|
||||
pop r24
|
||||
pop xh
|
||||
pop xl
|
||||
|
||||
; setup layout context for horizontal operations
|
||||
ldd r20, Y+WIDGET_OFFS_WIDTH_LO
|
||||
ldd r21, Y+WIDGET_OFFS_WIDTH_HI
|
||||
adiw xh:xl, LAYOUT_CTX_OFFS_TOTALSIZE_LO
|
||||
st X+, r20
|
||||
st X, r21
|
||||
sbiw xh:xl, (LAYOUT_CTX_OFFS_TOTALSIZE_LO+1)
|
||||
adiw xh:xl, LAYOUT_CTX_OFFS_NUMITEMS
|
||||
st X, r24
|
||||
sbiw xh:xl, LAYOUT_CTX_OFFS_NUMITEMS
|
||||
|
||||
; read positions and flags into new layout context
|
||||
ldd r25, Y+MCLAYOUT_OFFS_COLUMNS
|
||||
bigcall LayoutCtx_ReadXMaxDimsHorizontal ; (r16-r20, Z)
|
||||
|
||||
; layout
|
||||
bigcall LayoutCtx_LayoutExpand ; (r16-r25)
|
||||
|
||||
; pack
|
||||
ldd r25, Y+MCLAYOUT_OFFS_COLUMNS
|
||||
rcall LayoutCtx_PackXHorizontal ; (r16, r18, r19, r24, Z)
|
||||
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
; ***************************************************************************
|
||||
; data in FLASH
|
||||
|
||||
MCLayout_DefaultSignalmap:
|
||||
; header
|
||||
.dw Widget_DefaultSignalmap*2 ; next table to use
|
||||
; entries
|
||||
.db 0, WIDGET_SIGNAL_LAYOUT, LOW(MCLayout_OnLayout), HIGH(MCLayout_OnLayout)
|
||||
.db WIDGET_VALUE_DEFAULT_WIDTH, WIDGET_SIGNAL_GETVALUE, LOW(MCLayout_OnGetDefaultWidth), HIGH(MCLayout_OnGetDefaultWidth)
|
||||
.db WIDGET_VALUE_DEFAULT_HEIGHT, WIDGET_SIGNAL_GETVALUE, LOW(MCLayout_OnGetDefaultHeight), HIGH(MCLayout_OnGetDefaultHeight)
|
||||
|
||||
.db 0, 0, 0, 0 ; end of table
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
1055
avr/modules/lcd2/gui/base/object.asm
Normal file
1055
avr/modules/lcd2/gui/base/object.asm
Normal file
File diff suppressed because it is too large
Load Diff
181
avr/modules/lcd2/gui/base/rootwindow.asm
Normal file
181
avr/modules/lcd2/gui/base/rootwindow.asm
Normal file
@@ -0,0 +1,181 @@
|
||||
; ***************************************************************************
|
||||
; 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
|
||||
; @param r17 value for WIDGET_OFFS_PACK
|
||||
; @param X pointer to GUIAPP
|
||||
; @clobbers any
|
||||
|
||||
RootWindow_new:
|
||||
ldi r24, LOW(ROOTWINDOW_SIZE)
|
||||
ldi r25, HIGH(ROOTWINDOW_SIZE)
|
||||
bigcall Object_Alloc ; (!r16, !r17, !X)
|
||||
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
|
||||
; @param r17 value for WIDGET_OFFS_PACK
|
||||
; @param X pointer to GUIAPP
|
||||
; @clobbers r16, r17, X
|
||||
|
||||
RootWindow_Init:
|
||||
push xl
|
||||
push xh
|
||||
clr xl
|
||||
clr xh
|
||||
; call base class
|
||||
bigcall Widget_Init ; (r16, r17, X)
|
||||
pop xh
|
||||
pop xl
|
||||
|
||||
std Y+ROOTWINDOW_OFFS_GUIAPP_LO, xl
|
||||
std Y+ROOTWINDOW_OFFS_GUIAPP_HI, xh
|
||||
|
||||
bigcall Widget_SetFullScreen ; (R16)
|
||||
|
||||
; 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
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
; ***************************************************************************
|
||||
; signal handlers
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine RootWindow_OnLayout
|
||||
;
|
||||
; @param Y pointer to widget
|
||||
; @clobbers any, !Y
|
||||
|
||||
RootWindow_OnLayout:
|
||||
push yl
|
||||
push yh
|
||||
bigcall OBJ_GetFirstChild
|
||||
brcc RootWindow_OnLayout_done
|
||||
RootWindow_OnLayout_loop:
|
||||
mov yl, r18
|
||||
mov yh, r19
|
||||
; all children are MainWindow, set to fullscreen
|
||||
bigcall Widget_SetFullScreen ; (R16)
|
||||
bigcall OBJ_GetNext
|
||||
brcs RootWindow_OnLayout_loop
|
||||
RootWindow_OnLayout_done:
|
||||
pop yh
|
||||
pop yl
|
||||
|
||||
ldd r17, Y+OBJECT_OFFS_FLAGS
|
||||
cbr r17, (1<<WIDGET_FLAGS_LAYOUT_BIT)
|
||||
std Y+OBJECT_OFFS_FLAGS, r17
|
||||
|
||||
sec
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
; ***************************************************************************
|
||||
; data in FLASH
|
||||
|
||||
RootWindow_DefaultSignalmap:
|
||||
; header
|
||||
.dw Widget_DefaultSignalmap*2 ; next table to use
|
||||
; entries
|
||||
.db 0, WIDGET_SIGNAL_DRAW, LOW(Widget_OnDrawNop), HIGH(Widget_OnDrawNop)
|
||||
.db 0, WIDGET_SIGNAL_LAYOUT, LOW(RootWindow_OnLayout), HIGH(RootWindow_OnLayout)
|
||||
.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, 0 ; outerBorderSize, innerBorderSize
|
||||
.dw ili9341Font12x16_1*2 ; font
|
||||
.db 12, 16 ; charWidth, charHeight
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
281
avr/modules/lcd2/gui/base/valuelabel.asm
Normal file
281
avr/modules/lcd2/gui/base/valuelabel.asm
Normal file
@@ -0,0 +1,281 @@
|
||||
; ***************************************************************************
|
||||
; 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_VALUELABEL_ASM
|
||||
#define AQH_AVR_GUI2_VALUELABEL_ASM
|
||||
|
||||
|
||||
; ***************************************************************************
|
||||
; defines
|
||||
|
||||
.equ VLABEL_OFFS_BEGIN = WIDGET_SIZE
|
||||
.equ VLABEL_OFFS_VALUE_LO = VLABEL_OFFS_BEGIN+0
|
||||
.equ VLABEL_OFFS_VALUE_HI = VLABEL_OFFS_BEGIN+1
|
||||
.equ VLABEL_OFFS_POSTKOMMADIGITS = VLABEL_OFFS_BEGIN+2
|
||||
.equ VLABEL_SIZE = VLABEL_OFFS_BEGIN+3
|
||||
|
||||
|
||||
.equ VLABEL_VALUE = WIDGET_VALUE_NEXTFREE+0
|
||||
.equ VLABEL_VALUE_NEXTFREE = WIDGET_VALUE_NEXTFREE+1
|
||||
|
||||
|
||||
|
||||
; ***************************************************************************
|
||||
; code
|
||||
|
||||
.cseg
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine ValueLabel_new @global
|
||||
;
|
||||
; @return CFLAG set of okay, cleared otherwise
|
||||
; @return Y address of newly created object
|
||||
; @param X parent widget
|
||||
; @param r16 value for OBJECT_OFFS_OPTS
|
||||
; @param r17 value for WIDGET_OFFS_PACK
|
||||
; @param r20 number of postkomma digits
|
||||
; @clobbers any
|
||||
|
||||
ValueLabel_new:
|
||||
push r20
|
||||
ldi r24, LOW(VLABEL_SIZE)
|
||||
ldi r25, HIGH(VLABEL_SIZE)
|
||||
bigcall Object_Alloc ; (!r16, !r17, !X)
|
||||
pop r20
|
||||
brcc ValueLabel_new_ret
|
||||
rcall ValueLabel_Init ; (r16, r17, X)
|
||||
sec
|
||||
ValueLabel_new_ret:
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine ValueLabel_Init @global
|
||||
;
|
||||
; @param Y address of widget
|
||||
; @param X parent widget (if any)
|
||||
; @param r16 value for OBJECT_OFFS_OPTS
|
||||
; @param r17 value for WIDGET_OFFS_PACK
|
||||
; @param r20 number of postkomma digits
|
||||
; @clobbers r16, r17, X
|
||||
|
||||
ValueLabel_Init:
|
||||
push r20
|
||||
; call base class
|
||||
bigcall Widget_Init ; (r16, r17, X)
|
||||
pop r20
|
||||
|
||||
; setup valueLabel data
|
||||
std Y+VLABEL_OFFS_POSTKOMMADIGITS, r20
|
||||
|
||||
; set default signal map
|
||||
ldi r16, LOW(ValueLabel_DefaultSignalmap*2)
|
||||
std Y+OBJECT_OFFS_SIGNALMAP_LO, r16
|
||||
ldi r16, HIGH(ValueLabel_DefaultSignalmap*2)
|
||||
std Y+OBJECT_OFFS_SIGNALMAP_HI, r16
|
||||
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine ValueLabel_SetValue @global
|
||||
;
|
||||
; @param Y address of widget
|
||||
; @param X new value
|
||||
|
||||
ValueLabel_SetValue:
|
||||
ldi r17, VLABEL_VALUE
|
||||
bigjmp Widget_SetValue ; (any, !Y)
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine ValueLabel_OnSetValue @global
|
||||
;
|
||||
; @param Y address of widget
|
||||
; @param X new value
|
||||
; @return CFLAG set if signal handled
|
||||
; @clobbers r17
|
||||
|
||||
ValueLabel_OnSetValue:
|
||||
std Y+VLABEL_OFFS_VALUE_LO, xl
|
||||
std Y+VLABEL_OFFS_VALUE_HI, xh
|
||||
|
||||
ldd r17, Y+OBJECT_OFFS_FLAGS
|
||||
ori r17, (1<<WIDGET_FLAGS_DIRTY_BIT)
|
||||
std Y+OBJECT_OFFS_FLAGS, r17
|
||||
|
||||
sec
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine ValueLabel_OnDraw @global
|
||||
;
|
||||
; @param Y address of widget
|
||||
; @param xl param1
|
||||
; @param xh param2
|
||||
; @clobbers any, !Y
|
||||
|
||||
ValueLabel_OnDraw:
|
||||
ldd r16, Y+OBJECT_OFFS_FLAGS
|
||||
andi r16, (1<<WIDGET_FLAGS_DIRTY_BIT)
|
||||
breq ValueLabel_OnDraw_ret
|
||||
|
||||
bigcall Widget_Clear
|
||||
rcall valueLabelWriteValue
|
||||
|
||||
ldd r16, Y+OBJECT_OFFS_OPTS
|
||||
andi r16, (1<<WIDGET_OPTS_BORDER_BIT)
|
||||
breq ValueLabel_OnDraw_done
|
||||
bigcall Widget_DrawBorder
|
||||
|
||||
ValueLabel_OnDraw_done:
|
||||
ldd r16, Y+OBJECT_OFFS_FLAGS
|
||||
cbr r16, (1<<WIDGET_FLAGS_DIRTY_BIT)
|
||||
std Y+OBJECT_OFFS_FLAGS, r16
|
||||
|
||||
ValueLabel_OnDraw_ret:
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine ValueLabel_OnGetDefaultWidth @global
|
||||
;
|
||||
; @param Y address of widget
|
||||
; @param r17 value requested
|
||||
; @param xl param1
|
||||
; @param xh param2
|
||||
; @return CFLAG set if signal handled
|
||||
; @return r19:r18 value
|
||||
; @clobbers any, !Y
|
||||
|
||||
ValueLabel_OnGetDefaultWidth:
|
||||
rcall valueLabelCalcTextWidth
|
||||
mov r18, r12
|
||||
mov r19, r13
|
||||
bigcall Widget_AddOuterStyleBorders ; (r20, r21)
|
||||
sec
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine ValueLabel_OnGetDefaultHeight @global
|
||||
;
|
||||
; @param Y address of widget
|
||||
; @param xl param1
|
||||
; @param xh param2
|
||||
; @return CFLAG set if signal handled
|
||||
; @return r19:r18 value
|
||||
; @clobbers any, !Y
|
||||
|
||||
ValueLabel_OnGetDefaultHeight:
|
||||
bigcall Widget_GetCharHeight ; R16=char height
|
||||
mov r18, r16
|
||||
clr r19
|
||||
bigcall Widget_AddOuterStyleBorders ; (r20, r21)
|
||||
sec
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine valueLabelWriteValue
|
||||
;
|
||||
; @param Y address of widget
|
||||
; @clobbers any, !Y
|
||||
|
||||
valueLabelWriteValue:
|
||||
rcall valueLabelAlignTextXY ; X=ptr to text (r8, r9, r10, r11, r12, r13, r14, r15, r16, r17, r18, r19)
|
||||
bigcall Widget_DrawTextRam ; (any, !Y)
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine valueLabelAlignTextXY
|
||||
;
|
||||
; @param Y address of widget
|
||||
; @param R13:R12 width of object to align
|
||||
; @return R5:R4 X
|
||||
; @return R7:R6 Y
|
||||
; @return X pointer to text in SDRAM
|
||||
; @clobbers r8, r9, r10, r11, r12, r13, r14, r15, r16, r17, r18, r19, r20, r21, r22, r23, r24, r25
|
||||
|
||||
valueLabelAlignTextXY:
|
||||
rcall valueLabelCalcTextWidth ; X=ptr to text in SDRAM, R13:R12=text width (r16, r17, r18)
|
||||
push xl
|
||||
push xh
|
||||
bigcall Widget_PackContentX ; R5:R4=X (r17, r18, r19, r20, r21)
|
||||
|
||||
bigcall Widget_GetCharHeight ; R16=char height
|
||||
mov r12, r16
|
||||
clr r13
|
||||
bigcall Widget_PackContentY ; R7:R6=Y (r17, r18, r19, r20, r21)
|
||||
pop xh
|
||||
pop xl
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine valueLabelCalcTextWidth
|
||||
;
|
||||
; @param Y address of widget
|
||||
; @return X pointer to text in SDRAM
|
||||
; @return r13:r12 width of string
|
||||
; @clobbers r16, r17, r18
|
||||
|
||||
valueLabelCalcTextWidth:
|
||||
ldd r20, Y+VLABEL_OFFS_VALUE_LO
|
||||
ldd r21, Y+VLABEL_OFFS_VALUE_HI
|
||||
ldd r24, Y+VLABEL_OFFS_POSTKOMMADIGITS
|
||||
bigcall IntToAscii ; X=pointer to text
|
||||
bigcall Widget_GetCharWidth ; R16=char width
|
||||
mov r18, r16
|
||||
bigcall Widget_CalcStringWidthSDRAM ; r13:r12=size (r16)
|
||||
valueLabelCalcTextWidth_ret:
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ***************************************************************************
|
||||
; data in FLASH
|
||||
|
||||
ValueLabel_DefaultSignalmap:
|
||||
; header
|
||||
.dw Widget_DefaultSignalmap*2 ; next table to use
|
||||
; entries
|
||||
.db 0, WIDGET_SIGNAL_DRAW, LOW(ValueLabel_OnDraw), HIGH(ValueLabel_OnDraw)
|
||||
.db VLABEL_VALUE, WIDGET_SIGNAL_SETVALUE, LOW(ValueLabel_OnSetValue), HIGH(ValueLabel_OnSetValue)
|
||||
.db WIDGET_VALUE_DEFAULT_WIDTH, WIDGET_SIGNAL_GETVALUE, LOW(ValueLabel_OnGetDefaultWidth), HIGH(ValueLabel_OnGetDefaultWidth)
|
||||
.db WIDGET_VALUE_DEFAULT_HEIGHT, WIDGET_SIGNAL_GETVALUE, LOW(ValueLabel_OnGetDefaultHeight), HIGH(ValueLabel_OnGetDefaultHeight)
|
||||
|
||||
.db 0, 0, 0, 0 ; end of table
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
355
avr/modules/lcd2/gui/base/vlayout.asm
Normal file
355
avr/modules/lcd2/gui/base/vlayout.asm
Normal file
@@ -0,0 +1,355 @@
|
||||
; ***************************************************************************
|
||||
; 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_VLAYOUT_ASM
|
||||
#define AQH_AVR_GUI2_VLAYOUT_ASM
|
||||
|
||||
|
||||
; ***************************************************************************
|
||||
; defines
|
||||
|
||||
.equ VLAYOUT_OFFS_BEGIN = WIDGET_SIZE
|
||||
.equ VLAYOUT_OFFS_MODE = VLAYOUT_OFFS_BEGIN+0
|
||||
.equ VLAYOUT_SIZE = VLAYOUT_OFFS_BEGIN+1
|
||||
|
||||
|
||||
; values for VLAYOUT_OFFS_MODE
|
||||
.equ VLAYOUT_MODE_EXPAND = 0
|
||||
.equ VLAYOUT_MODE_SPREAD = 1
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
; ***************************************************************************
|
||||
; code
|
||||
|
||||
.cseg
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine VLayout_new @global
|
||||
;
|
||||
; @return CFLAG set of okay, cleared otherwise
|
||||
; @return Y address of newly created object
|
||||
; @param X parent widget
|
||||
; @param r16 value for OBJECT_OFFS_OPTS
|
||||
; @param r17 value for WIDGET_OFFS_PACK
|
||||
; @param r20 layout mode (VLAYOUT_MODE_EXPAND, VLAYOUT_MODE_SPREAD)
|
||||
; @clobbers any
|
||||
|
||||
VLayout_new:
|
||||
push r20
|
||||
ldi r24, LOW(VLAYOUT_SIZE)
|
||||
ldi r25, HIGH(VLAYOUT_SIZE)
|
||||
bigcall Object_Alloc ; (!r16, !r17, !X)
|
||||
pop r20
|
||||
brcc VLayout_new_ret
|
||||
rcall VLayout_Init ; (r16, r17, X)
|
||||
sec
|
||||
VLayout_new_ret:
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine VLayout_Init @global
|
||||
;
|
||||
; @param Y address of widget
|
||||
; @param X parent widget (if any)
|
||||
; @param r16 value for OBJECT_OFFS_OPTS
|
||||
; @param r17 value for WIDGET_OFFS_PACK
|
||||
; @param r20 layout mode (VLAYOUT_MODE_EXPAND, VLAYOUT_MODE_SPREAD)
|
||||
; @clobbers r16, r17, X
|
||||
|
||||
VLayout_Init:
|
||||
push r20
|
||||
; call base class
|
||||
bigcall Widget_Init ; (r16, r17, X)
|
||||
pop r20
|
||||
|
||||
; set widget-specific data
|
||||
std Y+VLAYOUT_OFFS_MODE, r20
|
||||
|
||||
; set default signal map
|
||||
ldi r16, LOW(VLayout_DefaultSignalmap*2)
|
||||
std Y+OBJECT_OFFS_SIGNALMAP_LO, r16
|
||||
ldi r16, HIGH(VLayout_DefaultSignalmap*2)
|
||||
std Y+OBJECT_OFFS_SIGNALMAP_HI, r16
|
||||
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine VLayout_OnLayout
|
||||
;
|
||||
; @param Y pointer to widget
|
||||
; @clobbers any, !Y
|
||||
|
||||
VLayout_OnLayout:
|
||||
; create and preset context
|
||||
rcall LayoutCtx_CreateContextFor1D ; X=ctx, r16=num of children
|
||||
brcc VLayout_OnLayout_ret
|
||||
; do layout
|
||||
mov r25, r16
|
||||
rcall vLayoutHorizontally
|
||||
rcall vLayoutVertically
|
||||
|
||||
; release layout context
|
||||
bigcall LayoutCtx_free
|
||||
; force re-drawing of this widget, clear layout bit
|
||||
ldd r16, Y+OBJECT_OFFS_FLAGS
|
||||
sbr r16, (1<<WIDGET_FLAGS_DIRTY_BIT)
|
||||
cbr r16, (1<<WIDGET_FLAGS_LAYOUT_BIT)
|
||||
std Y+OBJECT_OFFS_FLAGS, r16
|
||||
VLayout_OnLayout_ret:
|
||||
sec
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine VLayout_OnGetDefaultHeight
|
||||
;
|
||||
; @param Y pointer to widget
|
||||
; @return r19:r18 value
|
||||
; @clobbers any, !Y
|
||||
|
||||
VLayout_OnGetDefaultHeight:
|
||||
rcall Layout_SetDefaultHeights
|
||||
rcall Layout_SumTmpValues ; r19:r18=default width
|
||||
sec
|
||||
ret
|
||||
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine VLayout_OnGetDefaultWidth
|
||||
;
|
||||
; @param Y pointer to widget
|
||||
; @return r19:r18 value
|
||||
; @clobbers any, !Y
|
||||
|
||||
VLayout_OnGetDefaultWidth:
|
||||
rcall Layout_SetDefaultWidths
|
||||
rcall Layout_GetMaxTmp
|
||||
bigcall Widget_AddOuterStyleBorders ; (r20, r21)
|
||||
|
||||
sec
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine vLayoutHorizontally
|
||||
;
|
||||
; @param Y pointer to widget
|
||||
; @param X layout context
|
||||
; @param r25 number of children
|
||||
; @clobbers any, !Y
|
||||
|
||||
vLayoutHorizontally:
|
||||
rcall vLayoutPrepareHorizontal ; (any, !R25, !X, !Y)
|
||||
rcall vLayoutReadLayoutWriteHorizontal ; (r16-r24)
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine vLayoutPrepareHorizontal
|
||||
;
|
||||
; @param Y pointer to widget
|
||||
; @param X layout context
|
||||
; @param r25 number of children
|
||||
; @clobbers any, !R25, !X, !Y,
|
||||
|
||||
vLayoutPrepareHorizontal:
|
||||
push xl
|
||||
push xh
|
||||
push yl
|
||||
push yh
|
||||
push r25
|
||||
rcall Layout_SetDefaultWidths
|
||||
pop r25
|
||||
pop yh
|
||||
pop yl
|
||||
pop xh
|
||||
pop xl
|
||||
|
||||
ldd r20, Y+WIDGET_OFFS_WIDTH_LO
|
||||
ldd r21, Y+WIDGET_OFFS_WIDTH_HI
|
||||
adiw xh:xl, LAYOUT_CTX_OFFS_TOTALSIZE_LO
|
||||
st X+, r20
|
||||
st X, r21
|
||||
sbiw xh:xl, (LAYOUT_CTX_OFFS_TOTALSIZE_LO+1)
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine vLayoutReadLayoutWriteHorizontal
|
||||
;
|
||||
; @param Y pointer to widget
|
||||
; @param X layout context
|
||||
; @param r25 number of children
|
||||
; @clobbers r16-r24
|
||||
|
||||
vLayoutReadLayoutWriteHorizontal:
|
||||
; read positions and flags into new layout context
|
||||
bigcall LayoutCtx_ReadXDimsContiguous ; (R16, r18, r19, Z)
|
||||
|
||||
; layout
|
||||
adiw xh:xl, LAYOUT_CTX_OFFS_BORDERS
|
||||
ld r18, X
|
||||
clr r19
|
||||
sbiw xh:xl, LAYOUT_CTX_OFFS_BORDERS
|
||||
bigcall LayoutCtx_SetFixedPos ; (r24)
|
||||
mov r22, r18 ; save border
|
||||
|
||||
bigcall LayoutCtx_GetMaxSize ; r19:r18=max default size (r18, r19, r20, r21, r24)
|
||||
ldd r16, Y+WIDGET_OFFS_PACK
|
||||
andi r16, (1<<WIDGET_PACK_HSELF1_BIT) | (1<<WIDGET_PACK_HSELF0_BIT)
|
||||
cpi r16, WIDGET_PACK_FILLED
|
||||
brne vLayoutReadLayoutWriteHorizontal_setSize
|
||||
; use full possible width
|
||||
adiw xh:xl, LAYOUT_CTX_OFFS_TOTALSIZE_LO
|
||||
ld r18, X+
|
||||
ld r19, X
|
||||
sbiw xh:xl, (LAYOUT_CTX_OFFS_TOTALSIZE_LO+1)
|
||||
clr r23
|
||||
lsl r22
|
||||
rol r23
|
||||
sub r18, r22
|
||||
sbc r19, r23
|
||||
vLayoutReadLayoutWriteHorizontal_setSize:
|
||||
bigcall LayoutCtx_SetFixedSize ; (r24)
|
||||
|
||||
; pack
|
||||
bigcall LayoutCtx_PackXContiguous ; (R16, r18, r19, Z)
|
||||
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine vLayoutVertically
|
||||
;
|
||||
; @param Y pointer to widget
|
||||
; @param X layout context
|
||||
; @param r25 number of children
|
||||
; @clobbers any, !X, !Y
|
||||
|
||||
vLayoutVertically:
|
||||
rcall vLayoutPrepareVertical ; (any, !R25, !X, !Y)
|
||||
rcall vLayoutReadLayoutWriteVertical ; (r16-r24)
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine vLayoutPrepareVertical
|
||||
;
|
||||
; @param Y pointer to widget
|
||||
; @param X layout context
|
||||
; @param r25 number of children
|
||||
; @clobbers any, !R25, !X, !Y,
|
||||
|
||||
vLayoutPrepareVertical:
|
||||
push xl
|
||||
push xh
|
||||
push yl
|
||||
push yh
|
||||
push r25
|
||||
rcall Layout_SetDefaultHeights ; (any, !Y)
|
||||
pop r25
|
||||
pop yh
|
||||
pop yl
|
||||
pop xh
|
||||
pop xl
|
||||
|
||||
; setup layout context for horizontal operations
|
||||
ldd r20, Y+WIDGET_OFFS_HEIGHT_LO
|
||||
ldd r21, Y+WIDGET_OFFS_HEIGHT_HI
|
||||
adiw xh:xl, LAYOUT_CTX_OFFS_TOTALSIZE_LO
|
||||
st X+, r20
|
||||
st X, r21
|
||||
sbiw xh:xl, (LAYOUT_CTX_OFFS_TOTALSIZE_LO+1)
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine vLayoutReadLayoutWriteVertical
|
||||
;
|
||||
; @param Y pointer to widget
|
||||
; @param X layout context
|
||||
; @param r25 number of children
|
||||
; @clobbers r16-r24
|
||||
|
||||
vLayoutReadLayoutWriteVertical:
|
||||
; read X positions and flags into new layout context
|
||||
bigcall LayoutCtx_ReadYDimsContiguous ; (R16, r18, r19, Z)
|
||||
|
||||
; layout
|
||||
push r25
|
||||
ldd r24, Y+VLAYOUT_OFFS_MODE
|
||||
cpi r24, VLAYOUT_MODE_SPREAD
|
||||
breq vLayoutReadLayoutWriteVertical_spread
|
||||
bigcall LayoutCtx_LayoutExpand ; (r16-r25)
|
||||
rjmp vLayoutReadLayoutWriteVertical_pack
|
||||
vLayoutReadLayoutWriteVertical_spread:
|
||||
bigcall LayoutCtx_LayoutSpread ; (r16-r25)
|
||||
vLayoutReadLayoutWriteVertical_pack:
|
||||
pop r25
|
||||
|
||||
; pack
|
||||
push r25
|
||||
bigcall LayoutCtx_PackYContiguous ; (r16-r21, r24, r25)
|
||||
pop r25
|
||||
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
; ***************************************************************************
|
||||
; data in FLASH
|
||||
|
||||
VLayout_DefaultSignalmap:
|
||||
; header
|
||||
.dw Widget_DefaultSignalmap*2 ; next table to use
|
||||
; entries
|
||||
.db 0, WIDGET_SIGNAL_LAYOUT, LOW(VLayout_OnLayout), HIGH(VLayout_OnLayout)
|
||||
.db WIDGET_VALUE_DEFAULT_WIDTH, WIDGET_SIGNAL_GETVALUE, LOW(VLayout_OnGetDefaultWidth), HIGH(VLayout_OnGetDefaultWidth)
|
||||
.db WIDGET_VALUE_DEFAULT_HEIGHT, WIDGET_SIGNAL_GETVALUE, LOW(VLayout_OnGetDefaultHeight), HIGH(VLayout_OnGetDefaultHeight)
|
||||
|
||||
.db 0, 0, 0, 0 ; end of table
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
1558
avr/modules/lcd2/gui/base/widget.asm
Normal file
1558
avr/modules/lcd2/gui/base/widget.asm
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user