avr: removed old GUI code, renamed gui2 to gui
This commit is contained in:
@@ -272,24 +272,6 @@
|
||||
.include "modules/lcd2/font/main.asm"
|
||||
#endif
|
||||
|
||||
#ifdef MODULES_WIN
|
||||
.include "common/list.asm"
|
||||
.include "common/tree.asm"
|
||||
.include "modules/lcd2/win/defs.asm"
|
||||
.include "modules/lcd2/win/object.asm"
|
||||
.include "modules/lcd2/win/widget.asm"
|
||||
.include "modules/lcd2/win/gui.asm"
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#ifdef MODULES_GUI
|
||||
.include "modules/lcd2/gui/defs.asm"
|
||||
.include "modules/lcd2/gui/main.asm"
|
||||
.include "modules/lcd2/gui/window.asm"
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef MODULES_FONT_8X8
|
||||
.include "modules/lcd2/font/defs.asm"
|
||||
.include "modules/lcd2/font/font8x8.asm"
|
||||
|
||||
@@ -184,10 +184,6 @@ onSystemTimerTick:
|
||||
bigcall Brightness_Every100ms
|
||||
#endif
|
||||
|
||||
#ifdef MODULES_GUI
|
||||
bigcall GUI_Every100ms
|
||||
#endif
|
||||
|
||||
#ifdef MODULES_XPT2046
|
||||
bigcall XPT2046_Every100ms
|
||||
#endif
|
||||
|
||||
@@ -201,10 +201,6 @@ initModules:
|
||||
bigcall XPT2046_Init
|
||||
#endif
|
||||
|
||||
#ifdef MODULES_GUI
|
||||
bigcall GUI_Init
|
||||
#endif
|
||||
|
||||
#ifdef MODULES_BRIGHTNESS
|
||||
bigcall Brightness_Init
|
||||
#endif
|
||||
|
||||
@@ -44,6 +44,13 @@
|
||||
|
||||
<extradist>
|
||||
data.asm
|
||||
g_app.asm
|
||||
g_win_climate.asm
|
||||
g_win_eepromdump.asm
|
||||
g_win_network.asm
|
||||
g_win_screensaver.asm
|
||||
main.asm
|
||||
style.asm
|
||||
</extradist>
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
; ***************************************************************************
|
||||
; copyright : (C) 2025 by Martin Preuss
|
||||
; copyright : (C) 2026 by Martin Preuss
|
||||
; email : martin@libchipcard.de
|
||||
;
|
||||
; ***************************************************************************
|
||||
@@ -290,17 +290,17 @@ test:
|
||||
|
||||
.include "style.asm"
|
||||
|
||||
.include "modules/lcd2/gui2/generic/object.asm"
|
||||
.include "modules/lcd2/gui2/generic/widget.asm"
|
||||
.include "modules/lcd2/gui2/generic/rootwidget.asm"
|
||||
.include "modules/lcd2/gui2/generic/label.asm"
|
||||
.include "modules/lcd2/gui2/generic/button.asm"
|
||||
.include "modules/lcd2/gui2/generic/imageview.asm"
|
||||
.include "modules/lcd2/gui2/generic/valuelabel.asm"
|
||||
.include "modules/lcd2/gui2/generic/guiapp.asm"
|
||||
.include "modules/lcd2/gui2/generic/screensaver.asm"
|
||||
.include "modules/lcd2/gui2/sensorwatch.asm"
|
||||
.include "modules/lcd2/gui2/eepromdump.asm"
|
||||
.include "modules/lcd2/gui/generic/object.asm"
|
||||
.include "modules/lcd2/gui/generic/widget.asm"
|
||||
.include "modules/lcd2/gui/generic/rootwidget.asm"
|
||||
.include "modules/lcd2/gui/generic/label.asm"
|
||||
.include "modules/lcd2/gui/generic/button.asm"
|
||||
.include "modules/lcd2/gui/generic/imageview.asm"
|
||||
.include "modules/lcd2/gui/generic/valuelabel.asm"
|
||||
.include "modules/lcd2/gui/generic/guiapp.asm"
|
||||
.include "modules/lcd2/gui/generic/screensaver.asm"
|
||||
.include "modules/lcd2/gui/sensorwatch.asm"
|
||||
.include "modules/lcd2/gui/eepromdump.asm"
|
||||
|
||||
.include "g_app.asm"
|
||||
.include "g_win_climate.asm"
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
<subdirs>
|
||||
font
|
||||
gui2
|
||||
gui
|
||||
ili9341
|
||||
xpt2046
|
||||
</subdirs>
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
|
||||
Current GUI is gui2.
|
||||
Current GUI is gui.
|
||||
|
||||
@@ -3,12 +3,7 @@
|
||||
<gwbuild>
|
||||
|
||||
<extradist>
|
||||
defs.asm
|
||||
dialog.asm
|
||||
main.asm
|
||||
style.asm
|
||||
titlewindow.asm
|
||||
window.asm
|
||||
sensorwatch.asm
|
||||
</extradist>
|
||||
|
||||
</gwbuild>
|
||||
|
||||
@@ -1,13 +1,136 @@
|
||||
|
||||
- sensor watch:
|
||||
- SDRAM vars:
|
||||
- change limits
|
||||
- SENSORWATCH_SD_OFFS_UPPERLIMIT_WARN_LO
|
||||
- SENSORWATCH_SD_OFFS_LOWERLIMIT_WARN_LO
|
||||
- SENSORWATCH_SD_OFFS_UPPERLIMIT_CRIT_LO
|
||||
- SENSORWATCH_SD_OFFS_LOWERLIMIT_CRIT_LO
|
||||
- add private flags (HAVE_VALUE, USE_UPPERWARNLIMIT, USE_LOWERWARNLIMIT, USE_UPPERCRITLIMIT, USE_LOWERCRITLIMIT)
|
||||
|
||||
|
||||
- Screen
|
||||
- functions:
|
||||
- show
|
||||
- unshow
|
||||
- touch
|
||||
- key
|
||||
- activeAreas:
|
||||
- x, y, w, h (in FLASH)
|
||||
- only small variable data in SRAM, no need for heap!
|
||||
- new pages:
|
||||
- main window
|
||||
- buttons for climate, netstats, light, doors
|
||||
- about window (version, logo etc)
|
||||
- lights
|
||||
- mode: on, off, auto
|
||||
- color: R, G, B, W
|
||||
- calibrate screen
|
||||
|
||||
- digitEdit
|
||||
- arrow_up, below digit, below arrow_down
|
||||
|
||||
|
||||
- label:
|
||||
- use ressource id instead of pointer to text!
|
||||
|
||||
|
||||
- print hex numbers (bytes, words, dwords)
|
||||
- room value:
|
||||
- bits 0-2: cardinal number (0-7, as in "Buero 1")
|
||||
- bits 7-3: room type number (32)
|
||||
- Flur
|
||||
- Wohnzimmer
|
||||
- Schlafzimmer
|
||||
- Kueche
|
||||
- Buero
|
||||
- Kinderzimmer
|
||||
- Abstellraum
|
||||
- Bad
|
||||
|
||||
- new classes:
|
||||
- choice
|
||||
- "< TEXT >" (choose by clicking buttons left/right)
|
||||
- roomLabel (uses room value to print a string)
|
||||
- flashingLabel
|
||||
- use timer to blink/flash label, e.g. when values change
|
||||
|
||||
|
||||
- widgets:
|
||||
- value (flashingLabel)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
- imageViewer (use code from testWin)
|
||||
- generate bigger images (96x96 px)
|
||||
- light
|
||||
- window_open
|
||||
- window_closed
|
||||
|
||||
|--------------------------------------|
|
||||
| CO2-Value Temp Humidity |
|
||||
| |--------| |--------| |--------| |
|
||||
| | Cloud | | Temp | | Hum | |
|
||||
| | | | | | | |
|
||||
| |--------| |--------| |--------| |
|
||||
| |
|
||||
| |-----------| |---| |
|
||||
| | 1 7 : 4 5 | | S | |
|
||||
| |-----------| |---| |
|
||||
| |
|
||||
|--------------------------------------|
|
||||
|
||||
|
||||
|
||||
|--------------------------------------|
|
||||
| CO2-Value Temp Humidity |
|
||||
| |--------| |--------| |--------| |
|
||||
| | Cloud | | Temp | | Hum | |
|
||||
| | | | | | | |
|
||||
| |--------| |--------| |--------| |
|
||||
| |
|
||||
| |---| |---| |---| |---| |---| |
|
||||
| | < | | N | | L | | ? | | > | |
|
||||
| |---| |---| |---| |---| |---| |
|
||||
| |
|
||||
|--------------------------------------|
|
||||
|
||||
Object:
|
||||
- next
|
||||
- parent
|
||||
- firstChild
|
||||
- options (2 bytes)
|
||||
- signal handling
|
||||
- targetAddr (like in FOX)
|
||||
- selector
|
||||
- handlerMap:
|
||||
- selector/signal (00: end), handlerAddr
|
||||
Widgets:
|
||||
- x (2 bytes)
|
||||
- y (2 bytes)
|
||||
- width (2 bytes)
|
||||
- height (2 bytes)
|
||||
- font (2 bytes)
|
||||
- frontColor (2 bytes)
|
||||
- backColor (2 bytes)
|
||||
|
||||
Labels:
|
||||
- text
|
||||
|
||||
|
||||
Signals:
|
||||
- CREATE
|
||||
- DESTROY
|
||||
- SHOW
|
||||
- HIDE
|
||||
- DRAW
|
||||
- TIMER
|
||||
- TOUCH
|
||||
[- KEY]
|
||||
- USER = 16
|
||||
|
||||
|
||||
|
||||
OBJ:
|
||||
- SDRAM pointer hierher verschieben
|
||||
- speichere dort:
|
||||
- FLAGS_LO, FLAGS_HI (2 bytes)
|
||||
- NEXT, PARENT, CHILD (6 bytes)
|
||||
|
||||
- OBJ_AddNeighbour()
|
||||
- OBJ_AddChild()
|
||||
- OBJ_Unlink()
|
||||
|
||||
@@ -1,262 +0,0 @@
|
||||
; ***************************************************************************
|
||||
; copyright : (C) 2025 by Martin Preuss
|
||||
; email : martin@libchipcard.de
|
||||
;
|
||||
; ***************************************************************************
|
||||
; * This file is part of the project "AqHome". *
|
||||
; * Please see toplevel file COPYING of that project for license details. *
|
||||
; ***************************************************************************
|
||||
|
||||
#ifndef AQH_AVR_GUI_BUTTON_ASM
|
||||
#define AQH_AVR_GUI_BUTTON_ASM
|
||||
|
||||
|
||||
.equ BUTTON_STATE_DOWN_BIT = 0
|
||||
.equ BUTTON_STATE_ACTIVATED_BIT = 1
|
||||
|
||||
|
||||
|
||||
.cseg
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine Button_Draw_Up @global
|
||||
;
|
||||
; Draw button in state "UP".
|
||||
;
|
||||
; @param Y pointer to window in SDRAM
|
||||
; @param Z pointer to button data in FLASH (byte address for LPM)
|
||||
; @clobbers any, !Y
|
||||
|
||||
Button_Draw_Up:
|
||||
clr r14
|
||||
rjmp buttonDraw
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine Button_Draw_Down @global
|
||||
;
|
||||
; Draw button in state "DOWN".
|
||||
;
|
||||
; @param Y pointer to window in SDRAM
|
||||
; @param Z pointer to button data in FLASH (byte address for LPM)
|
||||
; @clobbers any, !Y
|
||||
|
||||
Button_Draw_Down:
|
||||
ldi r16, 1
|
||||
mov r14, r16
|
||||
rjmp buttonDraw
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine Button_HandleTouch @global
|
||||
;
|
||||
; @param r18 flags
|
||||
; @param r19 current state of button (bit 0: pressed, bit 1: activated)
|
||||
; @param r5:r4 x
|
||||
; @param r7:r6 Y
|
||||
; @param Z pointer to button data in FLASH
|
||||
; @return r19 new state of button (0=normal, 1=pressed)
|
||||
|
||||
Button_HandleTouch:
|
||||
cbr r19, (1<<BUTTON_STATE_ACTIVATED_BIT) ; clear activated bit
|
||||
; check for press change event
|
||||
mov r17, r18
|
||||
andi r17, (1<<DISPLAY_IFLAGS_CHGPRESS_BIT)
|
||||
breq Button_HandleTouch_ret
|
||||
; press changed
|
||||
mov r17, r18
|
||||
andi r17, (1<<DISPLAY_IFLAGS_PRESSED_BIT)
|
||||
breq Button_HandleTouch_up
|
||||
; touch came down
|
||||
push zl
|
||||
push zh
|
||||
push r19
|
||||
bigcall Window_IsPointInRect
|
||||
pop r19
|
||||
pop zh
|
||||
pop zl
|
||||
brcc Button_HandleTouch_ret
|
||||
tst r19
|
||||
brne Button_HandleTouch_ret ; already down, jmp
|
||||
sbr r19, (1<<BUTTON_STATE_DOWN_BIT) ; button now down
|
||||
push zl
|
||||
push zh
|
||||
push r19
|
||||
rcall Button_Draw_Down
|
||||
pop r19
|
||||
pop zh
|
||||
pop zl
|
||||
rjmp Button_HandleTouch_ret
|
||||
Button_HandleTouch_up:
|
||||
; touch came up
|
||||
tst r19
|
||||
breq Button_HandleTouch_ret ; already up, jmp
|
||||
cbr r19, (1<<BUTTON_STATE_DOWN_BIT)
|
||||
push zl
|
||||
push zh
|
||||
push r19
|
||||
rcall Button_Draw_Up
|
||||
pop r19
|
||||
pop zh
|
||||
pop zl
|
||||
push zl
|
||||
push zh
|
||||
push r19
|
||||
bigcall Window_IsPointInRect
|
||||
pop r19
|
||||
pop zh
|
||||
pop zl
|
||||
brcc Button_HandleTouch_ret
|
||||
; touch ended over button
|
||||
sbr r19, (1<<BUTTON_STATE_ACTIVATED_BIT) ; set activated bit
|
||||
Button_HandleTouch_ret:
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine buttonDraw
|
||||
;
|
||||
; @param Y pointer to window in SDRAM
|
||||
; @param Z pointer to button data in FLASH (byte address for LPM)
|
||||
; @param r14 0 if normal, 1 if pressed state
|
||||
; @clobbers any, !Y
|
||||
|
||||
buttonDraw:
|
||||
lpm r4, Z+ ; X
|
||||
lpm r5, Z+
|
||||
lpm r6, Z+ ; Y
|
||||
lpm r7, Z+
|
||||
lpm r8, Z+ ; W
|
||||
lpm r9, Z+
|
||||
lpm r10, Z+ ; H
|
||||
lpm r11, Z+
|
||||
lpm r12, Z+ ; text
|
||||
lpm r13, Z+
|
||||
|
||||
rcall buttonClearBackground
|
||||
rcall buttonDrawBorder
|
||||
rcall buttonDrawText
|
||||
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine buttonClearBackground
|
||||
;
|
||||
; @param Y pointer to window in SDRAM
|
||||
; @param r5:r4 X
|
||||
; @param r7:r6 Y
|
||||
; @param r9:r8 W
|
||||
; @param r11:r10 H
|
||||
; @param r14 0 if normal, 1 if pressed state
|
||||
; @clobbers any, !Y, !Z
|
||||
|
||||
buttonClearBackground:
|
||||
tst r14
|
||||
brne buttonClearBackground_bgDown
|
||||
ldi r16, LOW(STYLE_BUTTON_COL_BG_NORM)
|
||||
mov r2, r16
|
||||
ldi r16, HIGH(STYLE_BUTTON_COL_BG_NORM)
|
||||
mov r3, r16
|
||||
rjmp buttonClearBackground_bgFill
|
||||
buttonClearBackground_bgDown:
|
||||
ldi r16, LOW(STYLE_BUTTON_COL_BG_PRESSED)
|
||||
mov r2, r16
|
||||
ldi r16, HIGH(STYLE_BUTTON_COL_BG_PRESSED)
|
||||
mov r3, r16
|
||||
buttonClearBackground_bgFill:
|
||||
bigcall Display_FillRect
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine buttonDrawBorder
|
||||
;
|
||||
; @param Y pointer to window in SDRAM
|
||||
; @param r5:r4 X
|
||||
; @param r7:r6 Y
|
||||
; @param r9:r8 W
|
||||
; @param r11:r10 H
|
||||
; @param r14 0 if normal, 1 if pressed state
|
||||
; @clobbers any, !Y, !Z
|
||||
|
||||
buttonDrawBorder:
|
||||
ldi r16, LOW(STYLE_BUTTON_COL_BORDER)
|
||||
mov r2, r16
|
||||
ldi r16, HIGH(STYLE_BUTTON_COL_BORDER)
|
||||
mov r3, r16
|
||||
bigcall Display_DrawRect
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine buttonDrawText
|
||||
;
|
||||
; @param Y pointer to window in SDRAM
|
||||
; @param r5:r4 X
|
||||
; @param r7:r6 Y
|
||||
; @param r9:r8 W
|
||||
; @param r11:r10 H
|
||||
; @param r13:r12 Text in FLASH
|
||||
; @param r14 0 if normal, 1 if pressed state
|
||||
; @clobbers any, !Y, !Z
|
||||
|
||||
buttonDrawText:
|
||||
ldi r16, 2
|
||||
clr r17
|
||||
add r4, r16 ; x+=2
|
||||
adc r5, r17
|
||||
add r6, r16 ; y+=2
|
||||
adc r7, r17
|
||||
|
||||
; set text colors
|
||||
tst r14
|
||||
brne buttonDrawText_down
|
||||
; set background color
|
||||
ldi r16, LOW(STYLE_BUTTON_COL_BG_NORM)
|
||||
mov r0, r16
|
||||
ldi r16, HIGH(STYLE_BUTTON_COL_BG_NORM)
|
||||
mov r1, r16
|
||||
; set foreground color
|
||||
ldi r16, LOW(STYLE_BUTTON_COL_FG_NORM)
|
||||
mov r2, r16
|
||||
ldi r16, HIGH(STYLE_BUTTON_COL_FG_NORM)
|
||||
mov r3, r16
|
||||
rjmp buttonDrawText_draw
|
||||
buttonDrawText_down:
|
||||
; set background color
|
||||
ldi r16, LOW(STYLE_BUTTON_COL_BG_PRESSED)
|
||||
mov r0, r16
|
||||
ldi r16, HIGH(STYLE_BUTTON_COL_BG_PRESSED)
|
||||
mov r1, r16
|
||||
|
||||
; set foreground color
|
||||
ldi r16, LOW(STYLE_BUTTON_COL_FG_PRESSED)
|
||||
mov r2, r16
|
||||
ldi r16, HIGH(STYLE_BUTTON_COL_FG_PRESSED)
|
||||
mov r3, r16
|
||||
buttonDrawText_draw:
|
||||
mov zl, r12
|
||||
mov zh, r13
|
||||
bigcall Window_DrawColorTextFlash
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
@@ -1,52 +0,0 @@
|
||||
; ***************************************************************************
|
||||
; copyright : (C) 2025 by Martin Preuss
|
||||
; email : martin@libchipcard.de
|
||||
;
|
||||
; ***************************************************************************
|
||||
; * This file is part of the project "AqHome". *
|
||||
; * Please see toplevel file COPYING of that project for license details. *
|
||||
; ***************************************************************************
|
||||
|
||||
#ifndef AQH_AVR_GUI_DEFS_ASM
|
||||
#define AQH_AVR_GUI_DEFS_ASM
|
||||
|
||||
|
||||
.equ WINRECT_OFFS_X_LO = 0
|
||||
.equ WINRECT_OFFS_X_HI = 1
|
||||
.equ WINRECT_OFFS_Y_LO = 2
|
||||
.equ WINRECT_OFFS_Y_HI = 3
|
||||
.equ WINRECT_OFFS_WIDTH_LO = 4
|
||||
.equ WINRECT_OFFS_WIDTH_HI = 5
|
||||
.equ WINRECT_OFFS_HEIGHT_LO = 6
|
||||
.equ WINRECT_OFFS_HEIGHT_HI = 7
|
||||
.equ WINRECT_SIZE = 8
|
||||
|
||||
|
||||
|
||||
.equ WIN_OFFS_X_LO = 0
|
||||
.equ WIN_OFFS_X_HI = 1
|
||||
.equ WIN_OFFS_Y_LO = 2
|
||||
.equ WIN_OFFS_Y_HI = 3
|
||||
.equ WIN_OFFS_WIDTH_LO = 4
|
||||
.equ WIN_OFFS_WIDTH_HI = 5
|
||||
.equ WIN_OFFS_HEIGHT_LO = 6
|
||||
.equ WIN_OFFS_HEIGHT_HI = 7
|
||||
.equ WIN_OFFS_BG_COL_LO = 8
|
||||
.equ WIN_OFFS_BG_COL_HI = 9
|
||||
.equ WIN_OFFS_FG_COL_LO = 10
|
||||
.equ WIN_OFFS_FG_COL_HI = 11
|
||||
.equ WIN_OFFS_FONT_LO = 12 ;byte address!
|
||||
.equ WIN_OFFS_FONT_HI = 13
|
||||
.equ WIN_SIZE = 14
|
||||
|
||||
|
||||
|
||||
.equ WIN_EVENT_DESTROY = 1
|
||||
.equ WIN_EVENT_SHOW = 2
|
||||
.equ WIN_EVENT_HIDE = 3
|
||||
.equ WIN_EVENT_DRAW = 4
|
||||
.equ WIN_EVENT_TIMER = 5
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,314 +0,0 @@
|
||||
; ***************************************************************************
|
||||
; copyright : (C) 2025 by Martin Preuss
|
||||
; email : martin@libchipcard.de
|
||||
;
|
||||
; ***************************************************************************
|
||||
; * This file is part of the project "AqHome". *
|
||||
; * Please see toplevel file COPYING of that project for license details. *
|
||||
; ***************************************************************************
|
||||
|
||||
#ifndef AQHOME_AVR_MODS_GUI_DIALOG_ASM
|
||||
#define AQHOME_AVR_MODS_GUI_DIALOG_ASM
|
||||
|
||||
|
||||
|
||||
; ***************************************************************************
|
||||
; defines
|
||||
|
||||
.equ DIALOG_MAX_ACTIVE = 8
|
||||
|
||||
.equ DIALOG_OFFS_HANDLER_LO = 0
|
||||
.equ DIALOG_OFFS_HANDLER_HI = 1
|
||||
.equ DIALOG_OFFS_OPTIONS = 2
|
||||
.equ DIALOG_OFFS_COUNTER = 3
|
||||
.equ DIALOG_SIZE = 4
|
||||
|
||||
|
||||
.equ DIALOG_OPT_ACTIVE_BIT = 7
|
||||
|
||||
|
||||
.equ DIALOG_FN_INIT = 0
|
||||
.equ DIALOG_FN_FINI = 1
|
||||
.equ DIALOG_FN_SHOW = 2
|
||||
.equ DIALOG_FN_HIDE = 3
|
||||
.equ DIALOG_FN_TOUCH = 4
|
||||
.equ DIALOG_FN_TIMER = 5
|
||||
|
||||
|
||||
|
||||
; ***************************************************************************
|
||||
; data
|
||||
|
||||
.dseg
|
||||
|
||||
dialogCurrent: .byte 2
|
||||
dialogStack: .byte DIALOG_MAX_ACTIVE*2
|
||||
dialogStackPos: .byte 1
|
||||
|
||||
dialogWindow: .byte WIN_SIZE
|
||||
|
||||
|
||||
|
||||
; ***************************************************************************
|
||||
; code
|
||||
|
||||
.cseg
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine GraphApp_Init @global
|
||||
;
|
||||
|
||||
DialogMgr_Init:
|
||||
clr r16
|
||||
sts dialogStackPos, r16
|
||||
sts dialogCurrent, r16
|
||||
sts dialogCurrent+1, r16
|
||||
|
||||
ldi yl, LOW(dialogWindow)
|
||||
ldi yh, HIGH(dialogWindow)
|
||||
bigcall TitleWindow_Init
|
||||
|
||||
ldi zl, LOW(STYLE_WIN_FONT*2)
|
||||
ldi zh, HIGH(STYLE_WIN_FONT*2)
|
||||
std Y+WIN_OFFS_FONT_LO, zl
|
||||
std Y+WIN_OFFS_FONT_HI, zh
|
||||
|
||||
bigcall TitleWindow_SetFullSize
|
||||
bigcall TitleWindow_SetStyleColors
|
||||
|
||||
bigcall Window_Clear
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine DialogMgr_Every100ms @global
|
||||
;
|
||||
; Handle display touch events
|
||||
; Send timer event to every app in the stack (started with last added app).
|
||||
|
||||
DialogMgr_Every100ms:
|
||||
; check for touch input changes
|
||||
rcall 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 DialogMgr_Every100ms_sendTimer
|
||||
mov r18, r16
|
||||
ldi r23, DIALOG_FN_TOUCH
|
||||
rcall DialogMgr_CallCurrentHandler
|
||||
DialogMgr_Every100ms_sendTimer:
|
||||
; send timer event to all dialogs in stack
|
||||
ldi xl, LOW(dialogStack)
|
||||
ldi xh, HIGH(dialogStack)
|
||||
|
||||
lds r16, dialogStackPos
|
||||
mov r17, r16
|
||||
add r16, r16
|
||||
add xl, r16
|
||||
adc xh, r16
|
||||
sub xh, r16
|
||||
|
||||
DialogMgr_Every100ms_loop:
|
||||
tst r17
|
||||
breq DialogMgr_Every100ms_ret
|
||||
ld yh, -X
|
||||
ld yl, -X
|
||||
push xl
|
||||
push xh
|
||||
push r17
|
||||
ldi r23, DIALOG_FN_TIMER
|
||||
rcall DialogMgr_CallHandler
|
||||
pop r17
|
||||
pop xh
|
||||
pop xl
|
||||
dec r17
|
||||
rjmp DialogMgr_Every100ms_loop
|
||||
DialogMgr_Every100ms_ret:
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine DialogMgr_CallHandler @global
|
||||
;
|
||||
; @param Y pointer to app data
|
||||
; @param R23 number of function to call
|
||||
; @clobbers R16, R17, R22, X (any)
|
||||
|
||||
DialogMgr_CallHandler:
|
||||
tst yl
|
||||
brne DialogMgr_CallHandler_go
|
||||
tst yh
|
||||
breq DialogMgr_CallHandler_ret
|
||||
DialogMgr_CallHandler_go:
|
||||
ldi xl, LOW(dialogWindow)
|
||||
ldi xh, HIGH(dialogWindow)
|
||||
ldd r16, Y+DIALOG_OFFS_HANDLER_LO
|
||||
ldd r17, Y+DIALOG_OFFS_HANDLER_HI
|
||||
mov r22, r16
|
||||
and r22, r17
|
||||
breq DialogMgr_CallHandler_ret
|
||||
push r16
|
||||
push r17
|
||||
DialogMgr_CallHandler_ret:
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine DialogMgr_CallCurrentHandler @global
|
||||
;
|
||||
; @param X pointer to window
|
||||
; @param R23 number of function to call
|
||||
; @clobbers R22 (any)
|
||||
|
||||
DialogMgr_CallCurrentHandler:
|
||||
lds yl, dialogCurrent
|
||||
lds yh, dialogCurrent+1
|
||||
rjmp DialogMgr_CallHandler
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine DialogMgr_PushDialog @global
|
||||
;
|
||||
; @param Y pointer to app data
|
||||
;
|
||||
DialogMgr_PushDialog:
|
||||
lds r16, dialogStackPos
|
||||
cpi r16, DIALOG_MAX_ACTIVE
|
||||
brcc DialogMgr_PushDialog_ret
|
||||
|
||||
tst r16
|
||||
brne DialogMgr_PushDialog_push
|
||||
; deactivate previous app
|
||||
push yl
|
||||
push yh
|
||||
lds yl, dialogCurrent
|
||||
lds yh, dialogCurrent+1
|
||||
ldi r23, DIALOG_FN_HIDE
|
||||
rcall DialogMgr_CallHandler
|
||||
ldd r17, Y+DIALOG_OFFS_OPTIONS
|
||||
cbr r17, (1<<DIALOG_OPT_ACTIVE_BIT)
|
||||
std Y+DIALOG_OFFS_OPTIONS, r17
|
||||
pop yh
|
||||
pop yl
|
||||
|
||||
DialogMgr_PushDialog_push:
|
||||
lds r16, dialogStackPos
|
||||
mov r17, r16
|
||||
add r17, r17 ; *2
|
||||
push xl
|
||||
push xh
|
||||
ldi xl, LOW(dialogStack)
|
||||
ldi xh, HIGH(dialogStack)
|
||||
add xl, r17
|
||||
adc xh, r17
|
||||
sub xh, r17
|
||||
st X+, yl
|
||||
st X, yh
|
||||
pop xh
|
||||
pop xl
|
||||
inc r16
|
||||
sts dialogStackPos, r16
|
||||
sts dialogCurrent, yl
|
||||
sts dialogCurrent+1, yh
|
||||
; activate new app
|
||||
ldd r17, Y+DIALOG_OFFS_OPTIONS
|
||||
ori r17, (1<<DIALOG_OPT_ACTIVE_BIT)
|
||||
std Y+DIALOG_OFFS_OPTIONS, r17
|
||||
|
||||
ldi r23, DIALOG_FN_SHOW
|
||||
rcall DialogMgr_CallHandler
|
||||
sec
|
||||
DialogMgr_PushDialog_ret:
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine DialogMgr_PopDialog @global
|
||||
;
|
||||
; @return CFLAG set if app popped from stack, cleared otherwise
|
||||
; @return Y app popped from stack (if CFLAG set)
|
||||
|
||||
DialogMgr_PopDialog:
|
||||
lds r16, dialogStackPos
|
||||
tst r16
|
||||
clc
|
||||
brne DialogMgr_PopDialog_ret
|
||||
; deactivate previous app
|
||||
push yl
|
||||
push yh
|
||||
lds yl, dialogCurrent
|
||||
lds yh, dialogCurrent+1
|
||||
ldi r23, DIALOG_FN_HIDE
|
||||
rcall DialogMgr_CallHandler
|
||||
ldd r17, Y+DIALOG_OFFS_OPTIONS
|
||||
cbr r17, (1<<DIALOG_OPT_ACTIVE_BIT)
|
||||
std Y+DIALOG_OFFS_OPTIONS, r17
|
||||
pop yh
|
||||
pop yl
|
||||
|
||||
lds r16, dialogStackPos
|
||||
dec r16
|
||||
sts dialogStackPos, r16
|
||||
brne DialogMgr_PopDialog_pop
|
||||
clr r16
|
||||
sts dialogCurrent, r16
|
||||
sts dialogCurrent+1, r16
|
||||
sec
|
||||
rjmp DialogMgr_PopDialog_ret
|
||||
DialogMgr_PopDialog_pop:
|
||||
push xl
|
||||
push xh
|
||||
ldi xl, LOW(dialogStack)
|
||||
ldi xh, HIGH(dialogStack)
|
||||
add xl, r16
|
||||
adc xh, r16
|
||||
sub xh, r16
|
||||
ld yl, X+
|
||||
ld yh, X
|
||||
sts dialogCurrent, yl
|
||||
sts dialogCurrent+1, yh
|
||||
pop xh
|
||||
pop xl
|
||||
; activate new active app
|
||||
ldd r17, Y+DIALOG_OFFS_OPTIONS
|
||||
ori r17, (1<<DIALOG_OPT_ACTIVE_BIT)
|
||||
std Y+DIALOG_OFFS_OPTIONS, r17
|
||||
ldi r23, DIALOG_FN_SHOW
|
||||
rcall DialogMgr_CallHandler
|
||||
sec
|
||||
DialogMgr_PopDialog_ret:
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine Dialog_Init @global
|
||||
;
|
||||
; @param Y pointer to screen object in SDRAM
|
||||
; @clobbers R16, R17, X
|
||||
|
||||
Dialog_Init:
|
||||
mov xl, yl
|
||||
mov xh, yh
|
||||
ldi r17, DIALOG_SIZE
|
||||
clr r16
|
||||
bigcall Utils_FillSram ; (R17, X)
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
|
||||
#endif ; AQHOME_AVR_MODS_GUI_DIALOG_ASM
|
||||
|
||||
@@ -1,27 +0,0 @@
|
||||
; ***************************************************************************
|
||||
; copyright : (C) 2025 by Martin Preuss
|
||||
; email : martin@libchipcard.de
|
||||
;
|
||||
; ***************************************************************************
|
||||
; * This file is part of the project "AqHome". *
|
||||
; * Please see toplevel file COPYING of that project for license details. *
|
||||
; ***************************************************************************
|
||||
|
||||
#ifndef AQH_AVR_GUI_MAIN_ASM
|
||||
#define AQH_AVR_GUI_MAIN_ASM
|
||||
|
||||
|
||||
GUI_Init:
|
||||
sec
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
GUI_Every100ms:
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
@@ -1,32 +0,0 @@
|
||||
; ***************************************************************************
|
||||
; copyright : (C) 2025 by Martin Preuss
|
||||
; email : martin@libchipcard.de
|
||||
;
|
||||
; ***************************************************************************
|
||||
; * This file is part of the project "AqHome". *
|
||||
; * Please see toplevel file COPYING of that project for license details. *
|
||||
; ***************************************************************************
|
||||
|
||||
#ifndef AQH_AVR_GUI_STYLE_ASM
|
||||
#define AQH_AVR_GUI_STYLE_ASM
|
||||
|
||||
|
||||
.equ STYLE_WIN_TITLE_BACKGROUND = DISPLAY_COLOR_NAVY
|
||||
.equ STYLE_WIN_TITLE_FOREGROUND = DISPLAY_COLOR_WHITE
|
||||
.equ STYLE_BUTTON_COL_BORDER = DISPLAY_COLOR_BLACK
|
||||
.equ STYLE_BUTTON_COL_BG_NORM = DISPLAY_COLOR_WHITE
|
||||
.equ STYLE_BUTTON_COL_BG_PRESSED = DISPLAY_COLOR_NAVY
|
||||
.equ STYLE_BUTTON_COL_FG_NORM = DISPLAY_COLOR_BLACK
|
||||
.equ STYLE_BUTTON_COL_FG_PRESSED = DISPLAY_COLOR_WHITE
|
||||
|
||||
.equ STYLE_WIN_BACKGROUND = DISPLAY_COLOR_LIGHTGREY
|
||||
.equ STYLE_WIN_FOREGROUND = DISPLAY_COLOR_BLACK
|
||||
.equ STYLE_WIN_FONT = ili9341Font12x16_1
|
||||
.equ STYLE_WIN_FONT_WIDTH = 12
|
||||
.equ STYLE_WIN_FONT_HEIGHT = 16
|
||||
|
||||
.equ STYLE_WIN_TITLE_HEIGHT = (STYLE_WIN_FONT_HEIGHT+4)
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,231 +0,0 @@
|
||||
; ***************************************************************************
|
||||
; copyright : (C) 2025 by Martin Preuss
|
||||
; email : martin@libchipcard.de
|
||||
;
|
||||
; ***************************************************************************
|
||||
; * This file is part of the project "AqHome". *
|
||||
; * Please see toplevel file COPYING of that project for license details. *
|
||||
; ***************************************************************************
|
||||
|
||||
#ifndef AQH_AVR_GUI_TITLEWINDOW_ASM
|
||||
#define AQH_AVR_GUI_TITLEWINDOW_ASM
|
||||
|
||||
|
||||
|
||||
.equ TITLEWINDOW_OFFS_SELF = 0
|
||||
.equ TITLEWINDOW_OFFS_TITLEPTR_LO = WIN_SIZE
|
||||
.equ TITLEWINDOW_OFFS_TITLEPTR_HI = WIN_SIZE+1
|
||||
.equ TITLEWINDOW_OFFS_TITLEWIN = TITLEWINDOW_OFFS_TITLEPTR_HI+1
|
||||
.equ TITLEWINDOW_OFFS_CONTENTWIN = TITLEWINDOW_OFFS_TITLEWIN+WIN_SIZE
|
||||
.equ TITLEWINDOW_SIZE = TITLEWINDOW_OFFS_CONTENTWIN+WIN_SIZE
|
||||
|
||||
|
||||
|
||||
.cseg
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine TitleWindow_Init @global
|
||||
;
|
||||
; @param Y pointer to titledwindow data (size=TITLEWINDOW_SIZE)
|
||||
|
||||
TitleWindow_Init:
|
||||
rcall Window_Init
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine TitleWindow_SetFont @global
|
||||
;
|
||||
; @param Y pointer to screen object in SDRAM
|
||||
; @param Z pointer to font
|
||||
; @clobbers any, !Y
|
||||
|
||||
TitleWindow_SetFont:
|
||||
std Y+WIN_OFFS_FONT_LO, zl
|
||||
std Y+WIN_OFFS_FONT_HI, zh
|
||||
|
||||
; setup title window
|
||||
adiw yh:yl, TITLEWINDOW_OFFS_TITLEWIN
|
||||
std Y+WIN_OFFS_FONT_LO, zl
|
||||
std Y+WIN_OFFS_FONT_HI, zh
|
||||
sbiw yh:yl, TITLEWINDOW_OFFS_TITLEWIN
|
||||
|
||||
; setup content window
|
||||
adiw yh:yl, TITLEWINDOW_OFFS_CONTENTWIN
|
||||
std Y+WIN_OFFS_FONT_LO, zl
|
||||
std Y+WIN_OFFS_FONT_HI, zh
|
||||
sbiw yh:yl, TITLEWINDOW_OFFS_CONTENTWIN
|
||||
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine TitleWindow_SetPosAndSize @global
|
||||
;
|
||||
; @param Y pointer to screen object in SDRAM
|
||||
; @param R5:R4 X (abs)
|
||||
; @param R7:R6 Y (abs)
|
||||
; @param R9:R8 W
|
||||
; @param R11:R10 H
|
||||
; @clobbers any, !Y
|
||||
|
||||
TitleWindow_SetPosAndSize:
|
||||
std Y+WIN_OFFS_X_LO, r4
|
||||
std Y+WIN_OFFS_X_HI, r5
|
||||
std Y+WIN_OFFS_Y_LO, r6
|
||||
std Y+WIN_OFFS_Y_HI, r7
|
||||
std Y+WIN_OFFS_WIDTH_LO, r8
|
||||
std Y+WIN_OFFS_WIDTH_HI, r9
|
||||
std Y+WIN_OFFS_HEIGHT_LO, r10
|
||||
std Y+WIN_OFFS_HEIGHT_HI, r11
|
||||
|
||||
; setup title window
|
||||
adiw yh:yl, TITLEWINDOW_OFFS_TITLEWIN
|
||||
std Y+WIN_OFFS_X_LO, r4
|
||||
std Y+WIN_OFFS_X_HI, r5
|
||||
std Y+WIN_OFFS_Y_LO, r6
|
||||
std Y+WIN_OFFS_Y_HI, r7
|
||||
std Y+WIN_OFFS_WIDTH_LO, r8
|
||||
std Y+WIN_OFFS_WIDTH_HI, r9
|
||||
ldi r16, LOW(STYLE_WIN_TITLE_HEIGHT)
|
||||
ldi r17, HIGH(STYLE_WIN_TITLE_HEIGHT)
|
||||
std Y+WIN_OFFS_HEIGHT_LO, r16
|
||||
std Y+WIN_OFFS_HEIGHT_HI, r17
|
||||
sbiw yh:yl, TITLEWINDOW_OFFS_TITLEWIN
|
||||
|
||||
; setup content window
|
||||
adiw yh:yl, TITLEWINDOW_OFFS_CONTENTWIN
|
||||
std Y+WIN_OFFS_X_LO, r4
|
||||
std Y+WIN_OFFS_X_HI, r5
|
||||
ldi r16, LOW(STYLE_WIN_TITLE_HEIGHT)
|
||||
ldi r17, HIGH(STYLE_WIN_TITLE_HEIGHT)
|
||||
add r16, r6
|
||||
adc r16, r7
|
||||
std Y+WIN_OFFS_Y_LO, r16
|
||||
std Y+WIN_OFFS_Y_HI, r17
|
||||
std Y+WIN_OFFS_WIDTH_LO, r8
|
||||
std Y+WIN_OFFS_WIDTH_HI, r9
|
||||
mov r16, r10
|
||||
mov r17, r11
|
||||
subi r16, LOW(STYLE_WIN_TITLE_HEIGHT)
|
||||
sbci r17, HIGH(STYLE_WIN_TITLE_HEIGHT)
|
||||
std Y+WIN_OFFS_HEIGHT_LO, r16
|
||||
std Y+WIN_OFFS_HEIGHT_HI, r17
|
||||
sbiw yh:yl, TITLEWINDOW_OFFS_CONTENTWIN
|
||||
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine TitleWindow_SetFullSize @global
|
||||
;
|
||||
; @param Y pointer to screen object in SDRAM
|
||||
; @clobbers any, !Y
|
||||
|
||||
TitleWindow_SetFullSize:
|
||||
clr r4
|
||||
clr r5
|
||||
clr r6
|
||||
clr r7
|
||||
ldi r16, LOW(DISPLAY_WIDTH)
|
||||
mov r8, r16
|
||||
ldi r16, HIGH(DISPLAY_WIDTH)
|
||||
mov r9, r16
|
||||
ldi r16, LOW(DISPLAY_HEIGHT)
|
||||
mov r10, r16
|
||||
ldi r16, HIGH(DISPLAY_HEIGHT)
|
||||
mov r11, r16
|
||||
rcall TitleWindow_SetPosAndSize
|
||||
ret
|
||||
; @enb
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine TitleWindow_SetStyleColors @global
|
||||
;
|
||||
; @param Y pointer to screen object in SDRAM
|
||||
; @clobbers any, !Y
|
||||
|
||||
TitleWindow_SetStyleColors:
|
||||
ldi r16, LOW(STYLE_WIN_BACKGROUND)
|
||||
ldi r17, HIGH(STYLE_WIN_BACKGROUND)
|
||||
std Y+WIN_OFFS_BG_COL_LO, r16
|
||||
std Y+WIN_OFFS_BG_COL_HI, r17
|
||||
ldi r16, LOW(STYLE_WIN_FOREGROUND)
|
||||
ldi r17, HIGH(STYLE_WIN_FOREGROUND)
|
||||
std Y+WIN_OFFS_FG_COL_LO, r16
|
||||
std Y+WIN_OFFS_FG_COL_HI, r17
|
||||
|
||||
; setup title window
|
||||
adiw yh:yl, TITLEWINDOW_OFFS_TITLEWIN
|
||||
ldi r16, LOW(STYLE_WIN_TITLE_BACKGROUND)
|
||||
ldi r17, HIGH(STYLE_WIN_TITLE_BACKGROUND)
|
||||
std Y+WIN_OFFS_BG_COL_LO, r16
|
||||
std Y+WIN_OFFS_BG_COL_HI, r17
|
||||
ldi r16, LOW(STYLE_WIN_TITLE_FOREGROUND)
|
||||
ldi r17, HIGH(STYLE_WIN_TITLE_FOREGROUND)
|
||||
std Y+WIN_OFFS_FG_COL_LO, r16
|
||||
std Y+WIN_OFFS_FG_COL_HI, r17
|
||||
sbiw yh:yl, TITLEWINDOW_OFFS_TITLEWIN
|
||||
|
||||
; setup content window
|
||||
adiw yh:yl, TITLEWINDOW_OFFS_CONTENTWIN
|
||||
ldi r16, LOW(STYLE_WIN_BACKGROUND)
|
||||
ldi r17, HIGH(STYLE_WIN_BACKGROUND)
|
||||
std Y+WIN_OFFS_BG_COL_LO, r16
|
||||
std Y+WIN_OFFS_BG_COL_HI, r17
|
||||
ldi r16, LOW(STYLE_WIN_FOREGROUND)
|
||||
ldi r17, HIGH(STYLE_WIN_FOREGROUND)
|
||||
std Y+WIN_OFFS_FG_COL_LO, r16
|
||||
std Y+WIN_OFFS_FG_COL_HI, r17
|
||||
sbiw yh:yl, TITLEWINDOW_OFFS_CONTENTWIN
|
||||
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine TitleWindow_Draw @global
|
||||
;
|
||||
; @param Y pointer to titledwindow data (size=TITLEWINDOW_SIZE)
|
||||
|
||||
TitleWindow_Draw:
|
||||
; draw title window
|
||||
adiw yh:yl, TITLEWINDOW_OFFS_TITLEWIN
|
||||
rcall Window_Clear
|
||||
sbiw yh:yl, TITLEWINDOW_OFFS_TITLEWIN
|
||||
|
||||
; write header
|
||||
ldd zl, Y+TITLEWINDOW_OFFS_TITLEPTR_LO
|
||||
ldd zh, Y+TITLEWINDOW_OFFS_TITLEPTR_HI
|
||||
adiw yh:yl, TITLEWINDOW_OFFS_TITLEWIN
|
||||
ldi r16, 5
|
||||
mov r4, r16
|
||||
clr r5
|
||||
ldi r16, 2
|
||||
mov r6, r16
|
||||
clr r7
|
||||
rcall Window_DrawTextFlash
|
||||
sbiw yh:yl, TITLEWINDOW_OFFS_TITLEWIN
|
||||
|
||||
; clear content window
|
||||
adiw yh:yl, TITLEWINDOW_OFFS_CONTENTWIN
|
||||
rcall Window_Clear
|
||||
sbiw yh:yl, TITLEWINDOW_OFFS_CONTENTWIN
|
||||
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
@@ -1,157 +0,0 @@
|
||||
; ***************************************************************************
|
||||
; copyright : (C) 2025 by Martin Preuss
|
||||
; email : martin@libchipcard.de
|
||||
;
|
||||
; ***************************************************************************
|
||||
; * This file is part of the project "AqHome". *
|
||||
; * Please see toplevel file COPYING of that project for license details. *
|
||||
; ***************************************************************************
|
||||
|
||||
#ifndef AQH_AVR_GUI_TITLEWINDOW2_ASM
|
||||
#define AQH_AVR_GUI_TITLEWINDOW2_ASM
|
||||
|
||||
|
||||
.cseg
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine TitleWindow_Init @global
|
||||
;
|
||||
; @param Y pointer to titledwindow data (size=TITLEWINDOW_SIZE)
|
||||
|
||||
TitleWindow_Init:
|
||||
bigcall Window_Init
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine TitleWindow_SetFullSize @global
|
||||
;
|
||||
; @param Y pointer to screen object in SDRAM
|
||||
; @clobbers any, !Y
|
||||
|
||||
TitleWindow_SetFullSize:
|
||||
clr r16
|
||||
std Y+WIN_OFFS_X_LO, r16
|
||||
std Y+WIN_OFFS_X_HI, r16
|
||||
std Y+WIN_OFFS_Y_LO, r16
|
||||
std Y+WIN_OFFS_Y_HI, r16
|
||||
|
||||
ldi r16, LOW(DISPLAY_WIDTH)
|
||||
std Y+WIN_OFFS_WIDTH_LO, r16
|
||||
ldi r16, HIGH(DISPLAY_WIDTH)
|
||||
std Y+WIN_OFFS_WIDTH_HI, r16
|
||||
|
||||
ldi r16, LOW(DISPLAY_HEIGHT)
|
||||
std Y+WIN_OFFS_HEIGHT_LO, r16
|
||||
ldi r16, HIGH(DISPLAY_HEIGHT)
|
||||
std Y+WIN_OFFS_HEIGHT_HI, r16
|
||||
|
||||
ret
|
||||
; @enb
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine TitleWindow_SetStyleColors @global
|
||||
;
|
||||
; @param Y pointer to screen object in SDRAM
|
||||
; @clobbers any, !Y
|
||||
|
||||
TitleWindow_SetStyleColors:
|
||||
ldi r16, LOW(STYLE_WIN_BACKGROUND)
|
||||
ldi r17, HIGH(STYLE_WIN_BACKGROUND)
|
||||
std Y+WIN_OFFS_BG_COL_LO, r16
|
||||
std Y+WIN_OFFS_BG_COL_HI, r17
|
||||
ldi r16, LOW(STYLE_WIN_FOREGROUND)
|
||||
ldi r17, HIGH(STYLE_WIN_FOREGROUND)
|
||||
std Y+WIN_OFFS_FG_COL_LO, r16
|
||||
std Y+WIN_OFFS_FG_COL_HI, r17
|
||||
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine TitleWindow_DrawTitle @global
|
||||
;
|
||||
; @param Y pointer to screen object in SDRAM
|
||||
; @param Z pointer to title
|
||||
; @clobbers any, !Y
|
||||
|
||||
TitleWindow_DrawTitle:
|
||||
; fill background of title area
|
||||
clr r4
|
||||
clr r5
|
||||
clr r6
|
||||
clr r7
|
||||
ldd r8, Y+WIN_OFFS_WIDTH_LO
|
||||
ldd r9, Y+WIN_OFFS_WIDTH_HI
|
||||
ldi r16, LOW(STYLE_WIN_TITLE_HEIGHT)
|
||||
ldi r17, HIGH(STYLE_WIN_TITLE_HEIGHT)
|
||||
mov r10, r16
|
||||
mov r11, r17
|
||||
ldi r16, LOW(STYLE_WIN_TITLE_BACKGROUND)
|
||||
mov r2, r16
|
||||
ldi r16, HIGH(STYLE_WIN_TITLE_BACKGROUND)
|
||||
mov r3, r16
|
||||
rcall Window_FillRect
|
||||
|
||||
; draw title
|
||||
ldi r16, 5 ; X
|
||||
mov r4, r16
|
||||
clr r5
|
||||
ldi r16, 2 ; Y
|
||||
mov r6, r16
|
||||
clr r7
|
||||
|
||||
ldi r16, LOW(STYLE_WIN_TITLE_BACKGROUND)
|
||||
mov r0, r16
|
||||
ldi r16, HIGH(STYLE_WIN_TITLE_BACKGROUND)
|
||||
mov r1, r16
|
||||
|
||||
ldi r16, LOW(STYLE_WIN_TITLE_FOREGROUND)
|
||||
mov r2, r16
|
||||
ldi r16, HIGH(STYLE_WIN_TITLE_FOREGROUND)
|
||||
mov r3, r16
|
||||
bigcall Window_DrawColorTextFlash
|
||||
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine TitleWindow_ClearContentArea @global
|
||||
;
|
||||
; @param Y pointer to screen object in SDRAM
|
||||
; @clobbers any, !Y
|
||||
|
||||
TitleWindow_ClearContentArea:
|
||||
clr r4
|
||||
clr r5
|
||||
ldi r16, LOW(STYLE_WIN_TITLE_HEIGHT)
|
||||
mov r6, r16
|
||||
ldi r16, HIGH(STYLE_WIN_TITLE_HEIGHT)
|
||||
mov r7, r16
|
||||
ldd r8, Y+WIN_OFFS_WIDTH_LO
|
||||
ldd r9, Y+WIN_OFFS_WIDTH_HI
|
||||
ldi r16, LOW(STYLE_WIN_TITLE_HEIGHT)
|
||||
ldi r17, HIGH(STYLE_WIN_TITLE_HEIGHT)
|
||||
ldd r10, Y+WIN_OFFS_HEIGHT_LO
|
||||
ldd r11, Y+WIN_OFFS_HEIGHT_HI
|
||||
sub r10, r16
|
||||
sbc r11, r17
|
||||
ldi r16, LOW(STYLE_WIN_BACKGROUND)
|
||||
ldd r2, Y+WIN_OFFS_BG_COL_LO
|
||||
ldd r3, Y+WIN_OFFS_BG_COL_HI
|
||||
rcall Window_FillRect
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
@@ -1,558 +0,0 @@
|
||||
; ***************************************************************************
|
||||
; copyright : (C) 2025 by Martin Preuss
|
||||
; email : martin@libchipcard.de
|
||||
;
|
||||
; ***************************************************************************
|
||||
; * This file is part of the project "AqHome". *
|
||||
; * Please see toplevel file COPYING of that project for license details. *
|
||||
; ***************************************************************************
|
||||
|
||||
#ifndef AQH_AVR_GUI_WINDOW_ASM
|
||||
#define AQH_AVR_GUI_WINDOW_ASM
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine Window_Init @global
|
||||
;
|
||||
; @param Y pointer to screen object in SDRAM
|
||||
; @clobbers R16, R17, X
|
||||
|
||||
Window_Init:
|
||||
mov xl, yl
|
||||
mov xh, yh
|
||||
ldi r17, WIN_SIZE
|
||||
clr r16
|
||||
bigcall Utils_FillSram ; (R17, X)
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine Window_Clear @global
|
||||
;
|
||||
; @param Y pointer to screen object in SDRAM
|
||||
; @clobbers any, !Y
|
||||
|
||||
Window_Clear:
|
||||
ldd r2, Y+WIN_OFFS_BG_COL_LO ; background color low
|
||||
ldd r3, Y+WIN_OFFS_BG_COL_HI ; background color high
|
||||
ldd r4, Y+WIN_OFFS_X_LO ; X low
|
||||
ldd r5, Y+WIN_OFFS_X_HI ; X high
|
||||
ldd r6, Y+WIN_OFFS_Y_LO ; Y low
|
||||
ldd r7, Y+WIN_OFFS_Y_HI ; Y high
|
||||
ldd r8, Y+WIN_OFFS_WIDTH_LO ; width low
|
||||
ldd r9, Y+WIN_OFFS_WIDTH_HI ; width high
|
||||
ldd r10, Y+WIN_OFFS_HEIGHT_LO ; height low
|
||||
ldd r11, Y+WIN_OFFS_HEIGHT_HI ; height high
|
||||
bigcall Display_FillRect
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine Window_FillRect @global
|
||||
;
|
||||
; @param Y pointer to screen object in SDRAM
|
||||
; @param r3:r2 color
|
||||
; @param r5:r4 X0
|
||||
; @param r7:r6 Y0
|
||||
; @param r9:r8 X1/W
|
||||
; @param r11:r10 Y1/H
|
||||
; @clobbers any, !Y
|
||||
|
||||
Window_FillRect:
|
||||
ldd r16, Y+WIN_OFFS_X_LO ; make absolute coords
|
||||
ldd r17, Y+WIN_OFFS_X_HI
|
||||
add r4, r16
|
||||
adc r5, r17
|
||||
ldd r16, Y+WIN_OFFS_Y_LO
|
||||
ldd r17, Y+WIN_OFFS_Y_HI
|
||||
add r6, r16
|
||||
adc r7, r17
|
||||
bigcall Display_FillRect ; directly call graphics function
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine Window_IsPointInRect @global
|
||||
;
|
||||
; @param Z pointer WINRECT object in FLASH (see @ref WINRECT_OFFS_X_LO)
|
||||
; @param R5:R4 X (dest)
|
||||
; @param R7:R6 Y (dest)
|
||||
; @clobbers r16, r17, r18, r19, r20, r21, Z
|
||||
|
||||
Window_IsPointInRect:
|
||||
; check X
|
||||
lpm r16, Z+ ; X
|
||||
lpm r17, Z+
|
||||
mov r18, r4 ; X
|
||||
mov r19, r5
|
||||
sub r18, r16
|
||||
sbc r19, r17 ; r19:r18=X pos relative to rectangle
|
||||
brcs Window_IsPointInRect_clcRet
|
||||
; check Y
|
||||
lpm r16, Z+ ; Y
|
||||
lpm r17, Z+
|
||||
mov r20, r6 ; Y
|
||||
mov r21, r7
|
||||
sub r20, r16
|
||||
sbc r21, r17 ; r21:r20=Y pos relative to rectangle
|
||||
brcs Window_IsPointInRect_clcRet
|
||||
; check width
|
||||
lpm r16, Z+ ; width
|
||||
lpm r17, Z+
|
||||
cp r18, r16 ; width > rel X?
|
||||
cpc r19, r17
|
||||
brcc Window_IsPointInRect_ret
|
||||
; check height
|
||||
lpm r16, Z+ ; height
|
||||
lpm r17, Z+
|
||||
cp r20, r16 ; height > rel Y?
|
||||
cpc r21, r17
|
||||
rjmp Window_IsPointInRect_ret ; CF set if inside rect
|
||||
Window_IsPointInRect_clcRet:
|
||||
clc
|
||||
Window_IsPointInRect_ret:
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine Window_DrawTextFlash @global
|
||||
;
|
||||
; @param Y pointer to screen object in SDRAM
|
||||
; @param R5:R4 X (dest)
|
||||
; @param R7:R6 Y (dest)
|
||||
; @return R5:R4 X pos behind string
|
||||
|
||||
; @clobbers any, !Y, !R6, !R7
|
||||
|
||||
Window_DrawTextFlash:
|
||||
ldd r0, Y+WIN_OFFS_BG_COL_LO
|
||||
ldd r1, Y+WIN_OFFS_BG_COL_HI
|
||||
ldd r2, Y+WIN_OFFS_FG_COL_LO
|
||||
ldd r3, Y+WIN_OFFS_FG_COL_HI
|
||||
|
||||
rjmp Window_DrawColorTextFlash
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine Window_DrawColorTextFlash @global
|
||||
;
|
||||
; @param Y pointer to screen object in SDRAM
|
||||
; @param Z pointer to null-terminated string
|
||||
; @param R1:R0 background color
|
||||
; @param R3:R2 foreground color
|
||||
; @param R5:R4 X (dest)
|
||||
; @param R7:R6 Y (dest)
|
||||
; @return R5:R4 X pos behind string
|
||||
|
||||
; @clobbers any, !Y, !R6, !R7
|
||||
|
||||
Window_DrawColorTextFlash:
|
||||
rcall winCalcAbsPosAndBorders ; (R18, R19)
|
||||
Window_DrawColorTextFlash_loop:
|
||||
lpm r16, Z
|
||||
tst r16
|
||||
breq Window_DrawColorTextFlash_loopEnd
|
||||
rcall winDrawChar
|
||||
brcc Window_DrawColorTextFlash_loopEnd
|
||||
adiw zh:zl, 1 ; next char
|
||||
rjmp Window_DrawColorTextFlash_loop
|
||||
Window_DrawColorTextFlash_loopEnd:
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine Window_DrawCharAt @global
|
||||
;
|
||||
; @param Y pointer to screen object in SDRAM
|
||||
; @param R16 char to write
|
||||
; @param R5:R4 X (dest)
|
||||
; @param R7:R6 Y (dest)
|
||||
; @return R5:R4 X pos behind char
|
||||
; @clobbers any, !Y
|
||||
|
||||
Window_DrawCharAt:
|
||||
rcall winCalcAbsPosAndBorders
|
||||
|
||||
ldd r0, Y+WIN_OFFS_BG_COL_LO
|
||||
ldd r1, Y+WIN_OFFS_BG_COL_HI
|
||||
ldd r2, Y+WIN_OFFS_FG_COL_LO
|
||||
ldd r3, Y+WIN_OFFS_FG_COL_HI
|
||||
|
||||
rjmp winDrawChar
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine winCalcAbsPosAndBorders
|
||||
;
|
||||
; @param Y pointer to screen object in SDRAM
|
||||
; @param R5:R4 X relative to window
|
||||
; @param R7:R6 Y relative to window
|
||||
; @return R9:R8 first X pos right of windows
|
||||
; @return R5:R4 X relative to screen
|
||||
; @return R7:R6 Y relative to screen
|
||||
; @return R9:R8 first X pos right of window (abs)
|
||||
; @return R11:R10 first Y pos below window (abs)
|
||||
; @clobbers r18, r19
|
||||
|
||||
winCalcAbsPosAndBorders:
|
||||
; calc abs X pos
|
||||
ldd r18, Y+WIN_OFFS_X_LO
|
||||
ldd r19, Y+WIN_OFFS_X_HI
|
||||
add r4, r18 ; add X of window
|
||||
adc r5, r19
|
||||
|
||||
; calc first X pos behind window
|
||||
ldd r8, Y+WIN_OFFS_WIDTH_LO
|
||||
ldd r9, Y+WIN_OFFS_WIDTH_HI
|
||||
add r8, r18
|
||||
adc r9, r19
|
||||
|
||||
; calc abs Y pos
|
||||
ldd r18, Y+WIN_OFFS_Y_LO
|
||||
ldd r19, Y+WIN_OFFS_Y_HI
|
||||
add r6, r18 ; add Y of window
|
||||
adc r7, r19
|
||||
|
||||
; calc first Y pos behind window
|
||||
ldd r10, Y+WIN_OFFS_HEIGHT_LO
|
||||
ldd r11, Y+WIN_OFFS_HEIGHT_HI
|
||||
add r10, r18
|
||||
adc r11, r19
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine winDrawChar
|
||||
;
|
||||
; @param Y pointer to screen object in SDRAM
|
||||
; @param R16 char to write
|
||||
; @param R5:R4 absolute X on screen
|
||||
; @param R7:R6 absolute Y on screen
|
||||
; @param R9:R8 first X pos right of windows
|
||||
; @return R5:R4 X pos behind char
|
||||
; @clobbers any, !Y, !R6, !R7, !R8, !R9, !R10, !R11
|
||||
|
||||
winDrawChar:
|
||||
push zl
|
||||
push zh
|
||||
mov r12, r16
|
||||
ldd zl, Y+WIN_OFFS_FONT_LO
|
||||
ldd zh, Y+WIN_OFFS_FONT_HI
|
||||
|
||||
; check whether the char fits inside window
|
||||
bigcall FONT_GetCharWidth ; r16=char width
|
||||
|
||||
clr r17
|
||||
add r16, r4 ; char width+X
|
||||
adc r17, r5
|
||||
sub r16, r8 ; check against window width
|
||||
sbc r17, r9
|
||||
brcc winDrawChar_ret ; not fit, jmp
|
||||
|
||||
; actually draw char
|
||||
mov r16, r12
|
||||
push r8
|
||||
push r9
|
||||
push r10
|
||||
push r11
|
||||
bigcall Display_DrawChar
|
||||
pop r11
|
||||
pop r10
|
||||
pop r9
|
||||
pop r8
|
||||
clr r16
|
||||
add r4, r18 ; increment X
|
||||
adc r5, r16
|
||||
sec ; write succeeded
|
||||
winDrawChar_ret:
|
||||
pop zh
|
||||
pop zl
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine Window_WriteHexWordAt @global
|
||||
;
|
||||
; @param Y pointer to screen object in SDRAM
|
||||
; @param R17:R16 word to write
|
||||
; @param R5:R4 X (dest)
|
||||
; @param R7:R6 Y (dest)
|
||||
; @return R5:R4 X pos behind string
|
||||
; @clobbers any, !Y
|
||||
|
||||
Window_WriteHexWordAt:
|
||||
push r16
|
||||
mov r16, r17
|
||||
rcall Window_WriteHexByteAt
|
||||
pop r16
|
||||
rcall Window_WriteHexByteAt
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine Window_WriteHexByteAt @global
|
||||
;
|
||||
; @param Y pointer to screen object in SDRAM
|
||||
; @param R16 byte to write
|
||||
; @param R5:R4 X (dest)
|
||||
; @param R7:R6 Y (dest)
|
||||
; @return R5:R4 X pos behind string
|
||||
; @clobbers any, !Y
|
||||
|
||||
Window_WriteHexByteAt:
|
||||
push r16
|
||||
swap r16
|
||||
rcall winWriteNibble
|
||||
pop r16
|
||||
rcall winWriteNibble
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
winWriteNibble:
|
||||
push r4
|
||||
push r5
|
||||
push r6
|
||||
push r7
|
||||
rcall winNibbleToAscii ; write high nibble (r16, r17)
|
||||
rcall Window_DrawCharAt ; draw
|
||||
pop r7
|
||||
pop r6
|
||||
pop r5
|
||||
pop r4
|
||||
clr r17
|
||||
add r4, r18
|
||||
adc r5, r17
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine winNibbleToAscii
|
||||
;
|
||||
; Convert a nibble to an ASCII char.
|
||||
; @return R16 ASCII representation of that nibble (e.g. '0' for 0)
|
||||
; @param R16 byte (in bits 0-3)
|
||||
; @clobbers r16, r17
|
||||
|
||||
winNibbleToAscii:
|
||||
andi r16, 0xf
|
||||
cpi r16, 10
|
||||
brcs winNibbleToAscii_l1
|
||||
ldi r17, 7
|
||||
add r16, r17
|
||||
winNibbleToAscii_l1:
|
||||
ldi r17, '0'
|
||||
add r16, r17
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#if 0
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine Window_DrawTextFlash @global
|
||||
;
|
||||
; @param Y pointer to screen object in SDRAM
|
||||
; @param R5:R4 X (dest)
|
||||
; @param R7:R6 Y (dest)
|
||||
; @return R5:R4 X pos behind string
|
||||
; @return R7:R6 Y pos behind string
|
||||
; @clobbers any, !Y
|
||||
|
||||
Window_DrawTextFlash:
|
||||
; calc abs X pos
|
||||
ldd r18, Y+WIN_OFFS_X_LO
|
||||
ldd r19, Y+WIN_OFFS_X_HI
|
||||
add r4, r18 ; add X of window
|
||||
adc r5, r19
|
||||
|
||||
; calc first X pos behind window
|
||||
ldd r8, Y+WIN_OFFS_WIDTH_LO
|
||||
ldd r9, Y+WIN_OFFS_WIDTH_HI
|
||||
add r8, r18
|
||||
adc r9, r19
|
||||
|
||||
; calc abs Y pos
|
||||
ldd r18, Y+WIN_OFFS_Y_LO
|
||||
ldd r19, Y+WIN_OFFS_Y_HI
|
||||
add r6, r18 ; add Y of window
|
||||
adc r7, r19
|
||||
|
||||
; calc first Y pos behind window
|
||||
ldd r10, Y+WIN_OFFS_HEIGHT_LO
|
||||
ldd r11, Y+WIN_OFFS_HEIGHT_HI
|
||||
add r10, r18
|
||||
adc r11, r19
|
||||
|
||||
Window_DrawTextFlash_loop:
|
||||
push zl
|
||||
push zh
|
||||
rcall winCalcLengthWordFlash
|
||||
pop zh
|
||||
pop zl
|
||||
mov r18, r4
|
||||
mov r19, r5
|
||||
add r18, r12
|
||||
adc r19, r13
|
||||
sub r18, r8
|
||||
sbc r19, r9
|
||||
brcs Window_DrawTextFlash_xOkay
|
||||
; we need to go to the beginning of the next line
|
||||
rcall Window_DrawTextFlash_nextLine
|
||||
brcc Window_DrawTextFlash_loopEnd ; outside the window, jmp
|
||||
Window_DrawTextFlash_xOkay:
|
||||
rcall winDrawWordFlash ; Z points at blank/0 byte after call
|
||||
lpm r16, Z+
|
||||
tst r16 ; end of string?
|
||||
breq Window_DrawTextFlash_loopEnd
|
||||
cpi r16, 13
|
||||
breq Window_DrawTextFlash_handle13
|
||||
; insert other handled chars here
|
||||
; write blank char
|
||||
push zl
|
||||
push zh
|
||||
ldd zl, Y+WIN_OFFS_FONT_LO
|
||||
ldd zh, Y+WIN_OFFS_FONT_HI
|
||||
ldi r16, 32 ; space
|
||||
bigcall Display_DrawChar
|
||||
pop zh
|
||||
pop zl
|
||||
add r4, r8 ; increment X
|
||||
adc r5, r9
|
||||
|
||||
|
||||
rjmp Window_DrawTextFlash_loopNext
|
||||
Window_DrawTextFlash_handle13:
|
||||
rcall Window_DrawTextFlash_nextLine
|
||||
Window_DrawTextFlash_loopNext:
|
||||
rjmp Window_DrawTextFlash_loop
|
||||
Window_DrawTextFlash_nextLine:
|
||||
push zl
|
||||
push zh
|
||||
ldd zl, Y+WIN_OFFS_FONT_LO
|
||||
ldd zh, Y+WIN_OFFS_FONT_HI
|
||||
bigcall FONT_GetCharWidth ; r16=char width
|
||||
pop zh
|
||||
pop zl
|
||||
ldd r4, Y+WIN_OFFS_X_LO ; X=left border
|
||||
ldd r5, Y+WIN_OFFS_X_HI
|
||||
clr r17
|
||||
add r6, r16 ; increment Y by font height
|
||||
adc r7, r17
|
||||
mov r16, r6 ; check against lower border of window
|
||||
mov r17, r7
|
||||
sub r16, r10
|
||||
sbc r17, r11 ; CF set if inside window, cleared otherwise
|
||||
ret
|
||||
Window_DrawTextFlash_loopEnd:
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine winDrawWordFlash
|
||||
;
|
||||
; @param Y pointer to screen object in SDRAM
|
||||
; @param Z pointer to string in FLASH
|
||||
; @param R1:R0 background color
|
||||
; @param R3:R2 foreground color
|
||||
; @param R5:R4 X (dest)
|
||||
; @param R7:R6 Y (dest)
|
||||
; @return r5:r4 next X pos
|
||||
; @return Z pointer to next char behind current word
|
||||
; @clobbers any, !Y, !r1-r15
|
||||
|
||||
winDrawWordFlash:
|
||||
winDrawWordFlash_loop:
|
||||
lpm r16, Z
|
||||
cpi r16, 33
|
||||
brcs winDrawWordFlash_ret
|
||||
push zl
|
||||
push zh
|
||||
ldd zl, Y+WIN_OFFS_FONT_LO
|
||||
ldd zh, Y+WIN_OFFS_FONT_HI
|
||||
bigcall Display_DrawChar
|
||||
pop zh
|
||||
pop zl
|
||||
clr r16
|
||||
add r4, r18 ; increment X
|
||||
adc r5, r16
|
||||
adiw zh:zl, 1
|
||||
rjmp winDrawWordFlash_loop
|
||||
winDrawWordFlash_ret:
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine winCalcLengthWordFlash
|
||||
;
|
||||
; @param Y pointer to screen object in SDRAM
|
||||
; @param Z pointer to string in FLASH
|
||||
; @return r13:r12 width of next word in pixels
|
||||
; @return Z pointer to next char behind current word
|
||||
; @clobbers any, !Y, !r1-r11, !r14, !r15
|
||||
|
||||
winCalcLengthWordFlash:
|
||||
clr r12
|
||||
clr r13
|
||||
winCalcLengthWordFlash_loop:
|
||||
lpm r16, Z
|
||||
cpi r16, 33
|
||||
brcs winCalcLengthWordFlash_ret
|
||||
push zl
|
||||
push zh
|
||||
ldd zl, Y+WIN_OFFS_FONT_LO
|
||||
ldd zh, Y+WIN_OFFS_FONT_HI
|
||||
bigcall FONT_GetCharWidth ; r16=char width
|
||||
clr r17
|
||||
add r12, r16
|
||||
adc r13, r17
|
||||
pop zh
|
||||
pop zl
|
||||
brcs winCalcLengthWordFlash_error
|
||||
adiw zh:zl, 1 ; next char
|
||||
rjmp winCalcLengthWordFlash_loop
|
||||
winCalcLengthWordFlash_error:
|
||||
ldi r12, 0xff
|
||||
ldi r13, 0xff
|
||||
winCalcLengthWordFlash_ret:
|
||||
ret
|
||||
; @end
|
||||
|
||||
#endif ; if 0
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
<?xml?>
|
||||
|
||||
<gwbuild>
|
||||
|
||||
<extradist>
|
||||
sensorwatch.asm
|
||||
</extradist>
|
||||
|
||||
</gwbuild>
|
||||
|
||||
|
||||
@@ -1,136 +0,0 @@
|
||||
|
||||
- sensor watch:
|
||||
- SDRAM vars:
|
||||
- change limits
|
||||
- SENSORWATCH_SD_OFFS_UPPERLIMIT_WARN_LO
|
||||
- SENSORWATCH_SD_OFFS_LOWERLIMIT_WARN_LO
|
||||
- SENSORWATCH_SD_OFFS_UPPERLIMIT_CRIT_LO
|
||||
- SENSORWATCH_SD_OFFS_LOWERLIMIT_CRIT_LO
|
||||
- add private flags (HAVE_VALUE, USE_UPPERWARNLIMIT, USE_LOWERWARNLIMIT, USE_UPPERCRITLIMIT, USE_LOWERCRITLIMIT)
|
||||
|
||||
|
||||
- new pages:
|
||||
- main window
|
||||
- buttons for climate, netstats, light, doors
|
||||
- about window (version, logo etc)
|
||||
- lights
|
||||
- mode: on, off, auto
|
||||
- color: R, G, B, W
|
||||
- calibrate screen
|
||||
|
||||
- digitEdit
|
||||
- arrow_up, below digit, below arrow_down
|
||||
|
||||
|
||||
- label:
|
||||
- use ressource id instead of pointer to text!
|
||||
|
||||
|
||||
- print hex numbers (bytes, words, dwords)
|
||||
- room value:
|
||||
- bits 0-2: cardinal number (0-7, as in "Buero 1")
|
||||
- bits 7-3: room type number (32)
|
||||
- Flur
|
||||
- Wohnzimmer
|
||||
- Schlafzimmer
|
||||
- Kueche
|
||||
- Buero
|
||||
- Kinderzimmer
|
||||
- Abstellraum
|
||||
- Bad
|
||||
|
||||
- new classes:
|
||||
- choice
|
||||
- "< TEXT >" (choose by clicking buttons left/right)
|
||||
- roomLabel (uses room value to print a string)
|
||||
- flashingLabel
|
||||
- use timer to blink/flash label, e.g. when values change
|
||||
|
||||
|
||||
- widgets:
|
||||
- value (flashingLabel)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
- imageViewer (use code from testWin)
|
||||
- generate bigger images (96x96 px)
|
||||
- light
|
||||
- window_open
|
||||
- window_closed
|
||||
|
||||
|--------------------------------------|
|
||||
| CO2-Value Temp Humidity |
|
||||
| |--------| |--------| |--------| |
|
||||
| | Cloud | | Temp | | Hum | |
|
||||
| | | | | | | |
|
||||
| |--------| |--------| |--------| |
|
||||
| |
|
||||
| |-----------| |---| |
|
||||
| | 1 7 : 4 5 | | S | |
|
||||
| |-----------| |---| |
|
||||
| |
|
||||
|--------------------------------------|
|
||||
|
||||
|
||||
|
||||
|--------------------------------------|
|
||||
| CO2-Value Temp Humidity |
|
||||
| |--------| |--------| |--------| |
|
||||
| | Cloud | | Temp | | Hum | |
|
||||
| | | | | | | |
|
||||
| |--------| |--------| |--------| |
|
||||
| |
|
||||
| |---| |---| |---| |---| |---| |
|
||||
| | < | | N | | L | | ? | | > | |
|
||||
| |---| |---| |---| |---| |---| |
|
||||
| |
|
||||
|--------------------------------------|
|
||||
|
||||
Object:
|
||||
- next
|
||||
- parent
|
||||
- firstChild
|
||||
- options (2 bytes)
|
||||
- signal handling
|
||||
- targetAddr (like in FOX)
|
||||
- selector
|
||||
- handlerMap:
|
||||
- selector/signal (00: end), handlerAddr
|
||||
Widgets:
|
||||
- x (2 bytes)
|
||||
- y (2 bytes)
|
||||
- width (2 bytes)
|
||||
- height (2 bytes)
|
||||
- font (2 bytes)
|
||||
- frontColor (2 bytes)
|
||||
- backColor (2 bytes)
|
||||
|
||||
Labels:
|
||||
- text
|
||||
|
||||
|
||||
Signals:
|
||||
- CREATE
|
||||
- DESTROY
|
||||
- SHOW
|
||||
- HIDE
|
||||
- DRAW
|
||||
- TIMER
|
||||
- TOUCH
|
||||
[- KEY]
|
||||
- USER = 16
|
||||
|
||||
|
||||
|
||||
OBJ:
|
||||
- SDRAM pointer hierher verschieben
|
||||
- speichere dort:
|
||||
- FLAGS_LO, FLAGS_HI (2 bytes)
|
||||
- NEXT, PARENT, CHILD (6 bytes)
|
||||
|
||||
- OBJ_AddNeighbour()
|
||||
- OBJ_AddChild()
|
||||
- OBJ_Unlink()
|
||||
@@ -1,16 +0,0 @@
|
||||
<?xml?>
|
||||
|
||||
<gwbuild>
|
||||
|
||||
<extradist>
|
||||
defs.asm
|
||||
dialog.asm
|
||||
main.asm
|
||||
style.asm
|
||||
titlewindow.asm
|
||||
window.asm
|
||||
</extradist>
|
||||
|
||||
</gwbuild>
|
||||
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
|
||||
|
||||
- Screen
|
||||
- functions:
|
||||
- show
|
||||
- unshow
|
||||
- touch
|
||||
- key
|
||||
- activeAreas:
|
||||
- x, y, w, h (in FLASH)
|
||||
- only small variable data in SRAM, no need for heap!
|
||||
|
||||
|
||||
@@ -1,65 +0,0 @@
|
||||
; ***************************************************************************
|
||||
; copyright : (C) 2025 by Martin Preuss
|
||||
; email : martin@libchipcard.de
|
||||
;
|
||||
; ***************************************************************************
|
||||
; * This file is part of the project "AqHome". *
|
||||
; * Please see toplevel file COPYING of that project for license details. *
|
||||
; ***************************************************************************
|
||||
|
||||
#ifndef AQH_AVR_STATICGUI_DEFS_ASM
|
||||
#define AQH_AVR_STATICGUI_DEFS_ASM
|
||||
|
||||
|
||||
; all offsets in byte size (to be used with LPM)
|
||||
.equ WIN_F_OFFS_X_LO = 0
|
||||
.equ WIN_F_OFFS_X_HI = 1
|
||||
.equ WIN_F_OFFS_Y_LO = 2
|
||||
.equ WIN_F_OFFS_Y_HI = 3
|
||||
.equ WIN_F_OFFS_WIDTH_LO = 4
|
||||
.equ WIN_F_OFFS_WIDTH_HI = 5
|
||||
.equ WIN_F_OFFS_HEIGHT_LO = 6
|
||||
.equ WIN_F_OFFS_HEIGHT_HI = 7
|
||||
.equ WIN_F_SIZE = 8
|
||||
|
||||
.equ COLORWIN_F_OFFS_WIN = WIN_F_SIZE
|
||||
.equ COLORWIN_F_OFFS_BG_COLOR_LO = WIN_F_SIZE
|
||||
.equ COLORWIN_F_OFFS_BG_COLOR_HI = WIN_F_SIZE+1
|
||||
.equ COLORWIN_F_OFFS_FG_COLOR_LO = WIN_F_SIZE+2
|
||||
.equ COLORWIN_F_OFFS_FG_COLOR_HI = WIN_F_SIZE+3
|
||||
.equ COLORWIN_F_SIZE = WIN_F_SIZE+4
|
||||
|
||||
.equ TEXTWIN_F_OFFS_WIN = COLORWIN_F_SIZE
|
||||
.equ TEXTWIN_F_OFFS_FONT_LO = COLORWIN_F_SIZE
|
||||
.equ TEXTWIN_F_OFFS_FONT_HI = COLORWIN_F_SIZE+1
|
||||
.equ TEXTWIN_F_SIZE = COLORWIN_F_SIZE+2
|
||||
|
||||
|
||||
|
||||
.equ WIN_OFFS_X_LO = 0
|
||||
.equ WIN_OFFS_X_HI = 1
|
||||
.equ WIN_OFFS_Y_LO = 2
|
||||
.equ WIN_OFFS_Y_HI = 3
|
||||
.equ WIN_OFFS_WIDTH_LO = 4
|
||||
.equ WIN_OFFS_WIDTH_HI = 5
|
||||
.equ WIN_OFFS_HEIGHT_LO = 6
|
||||
.equ WIN_OFFS_HEIGHT_HI = 7
|
||||
.equ WIN_OFFS_BG_COL_LO = 8
|
||||
.equ WIN_OFFS_BG_COL_HI = 9
|
||||
.equ WIN_OFFS_FG_COL_LO = 10
|
||||
.equ WIN_OFFS_FG_COL_HI = 11
|
||||
.equ WIN_OFFS_FONT_LO = 12 ;byte address!
|
||||
.equ WIN_OFFS_FONT_HI = 13
|
||||
.equ WIN_SIZE = 14
|
||||
|
||||
|
||||
|
||||
.equ WIN_EVENT_DESTROY = 1
|
||||
.equ WIN_EVENT_SHOW = 2
|
||||
.equ WIN_EVENT_HIDE = 3
|
||||
.equ WIN_EVENT_DRAW = 4
|
||||
.equ WIN_EVENT_TIMER = 5
|
||||
|
||||
|
||||
#endif ; AQH_AVR_STATICGUI_DEFS_ASM
|
||||
|
||||
@@ -1,288 +0,0 @@
|
||||
; ***************************************************************************
|
||||
; copyright : (C) 2025 by Martin Preuss
|
||||
; email : martin@libchipcard.de
|
||||
;
|
||||
; ***************************************************************************
|
||||
; * This file is part of the project "AqHome". *
|
||||
; * Please see toplevel file COPYING of that project for license details. *
|
||||
; ***************************************************************************
|
||||
|
||||
#ifndef AQHOME_AVR_MODS_STATICGUI_DIALOG_ASM
|
||||
#define AQHOME_AVR_MODS_STATICGUI_DIALOG_ASM
|
||||
|
||||
|
||||
|
||||
; ***************************************************************************
|
||||
; defines
|
||||
|
||||
.equ DIALOG_MAX_ACTIVE = 8
|
||||
|
||||
.equ DIALOG_OFFS_HANDLER_LO = 0
|
||||
.equ DIALOG_OFFS_HANDLER_HI = 1
|
||||
.equ DIALOG_OFFS_OPTIONS = 2
|
||||
.equ DIALOG_OFFS_COUNTER = 3
|
||||
.equ DIALOG_SIZE = 4
|
||||
|
||||
|
||||
.equ DIALOG_OPT_ACTIVE_BIT = 7
|
||||
|
||||
|
||||
.equ DIALOG_FN_INIT = 0
|
||||
.equ DIALOG_FN_FINI = 1
|
||||
.equ DIALOG_FN_SHOW = 2
|
||||
.equ DIALOG_FN_HIDE = 3
|
||||
.equ DIALOG_FN_DRAW = 4
|
||||
.equ DIALOG_FN_TOUCH = 5
|
||||
.equ DIALOG_FN_TIMER = 6
|
||||
|
||||
|
||||
|
||||
; ***************************************************************************
|
||||
; data
|
||||
|
||||
.dseg
|
||||
|
||||
dialogCurrent: .byte 2
|
||||
dialogStack: .byte DIALOG_MAX_ACTIVE*2
|
||||
dialogStackPos: .byte 1
|
||||
|
||||
dialogWindow: .byte WIN_SIZE
|
||||
|
||||
|
||||
|
||||
; ***************************************************************************
|
||||
; code
|
||||
|
||||
.cseg
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine GraphApp_Init @global
|
||||
;
|
||||
|
||||
DialogMgr_Init:
|
||||
clr r16
|
||||
sts dialogStackPos, r16
|
||||
sts dialogCurrent, r16
|
||||
sts dialogCurrent+1, r16
|
||||
|
||||
ldi yl, LOW(dialogWindow)
|
||||
ldi yh, HIGH(dialogWindow)
|
||||
bigcall TitleWindow_Init
|
||||
|
||||
ldi zl, LOW(ili9341Font12x20_1*2)
|
||||
ldi zh, HIGH(ili9341Font12x20_1*2)
|
||||
std Y+WIN_OFFS_FONT_LO, zl
|
||||
std Y+WIN_OFFS_FONT_HI, zh
|
||||
|
||||
bigcall TitleWindow_SetFullSize
|
||||
bigcall TitleWindow_SetStyleColors
|
||||
|
||||
bigcall Window_Clear
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine DialogMgr_Every100ms @global
|
||||
;
|
||||
; Handle display touch events
|
||||
; Send timer event to every app in the stack (started with last added app).
|
||||
|
||||
DialogMgr_Every100ms:
|
||||
; check for touch input changes
|
||||
rcall 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 DialogMgr_Every100ms_sendTimer
|
||||
ldi r23, DIALOG_FN_TOUCH
|
||||
rcall DialogMgr_CallCurrentHandler
|
||||
DialogMgr_Every100ms_sendTimer:
|
||||
; send timer event to all dialogs in stack
|
||||
ldi xl, LOW(dialogStack)
|
||||
ldi xh, HIGH(dialogStack)
|
||||
|
||||
lds r16, dialogStackPos
|
||||
mov r17, r16
|
||||
add r16, r16
|
||||
add xl, r16
|
||||
adc xh, r16
|
||||
sub xh, r16
|
||||
|
||||
DialogMgr_Every100ms_loop:
|
||||
tst r17
|
||||
breq DialogMgr_Every100ms_ret
|
||||
ld yh, -X
|
||||
ld yl, -X
|
||||
push xl
|
||||
push xh
|
||||
push r17
|
||||
ldi r23, DIALOG_FN_TIMER
|
||||
rcall DialogMgr_CallHandler
|
||||
pop r17
|
||||
pop xh
|
||||
pop xl
|
||||
dec r17
|
||||
rjmp DialogMgr_Every100ms_loop
|
||||
DialogMgr_Every100ms_ret:
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine DialogMgr_CallHandler @global
|
||||
;
|
||||
; @param Y pointer to app data
|
||||
; @param R23 number of function to call
|
||||
; @clobbers R16, R17, R22, X (any)
|
||||
|
||||
DialogMgr_CallHandler:
|
||||
ldi xl, LOW(dialogWindow)
|
||||
ldi xh, HIGH(dialogWindow)
|
||||
ldd r16, Y+DIALOG_OFFS_HANDLER_LO
|
||||
ldd r17, Y+DIALOG_OFFS_HANDLER_HI
|
||||
mov r22, r16
|
||||
and r22, r17
|
||||
breq DialogMgr_CallHandler_ret
|
||||
push r16
|
||||
push r17
|
||||
DialogMgr_CallHandler_ret:
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine DialogMgr_CallCurrentHandler @global
|
||||
;
|
||||
; @param X pointer to window
|
||||
; @param R23 number of function to call
|
||||
; @clobbers R22 (any)
|
||||
|
||||
DialogMgr_CallCurrentHandler:
|
||||
lds yl, dialogCurrent
|
||||
lds yh, dialogCurrent+1
|
||||
rjmp DialogMgr_CallHandler
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine DialogMgr_PushDialog @global
|
||||
;
|
||||
; @param Y pointer to app data
|
||||
;
|
||||
DialogMgr_PushDialog:
|
||||
lds r16, dialogStackPos
|
||||
cpi r16, DIALOG_MAX_ACTIVE
|
||||
brcc DialogMgr_PushDialog_ret
|
||||
|
||||
tst r16
|
||||
brne DialogMgr_PushDialog_push
|
||||
; deactivate previous app
|
||||
push yl
|
||||
push yh
|
||||
lds yl, dialogCurrent
|
||||
lds yh, dialogCurrent+1
|
||||
ldi r23, DIALOG_FN_HIDE
|
||||
rcall DialogMgr_CallHandler
|
||||
ldd r17, Y+DIALOG_OFFS_OPTIONS
|
||||
cbr r17, (1<<DIALOG_OPT_ACTIVE_BIT)
|
||||
std Y+DIALOG_OFFS_OPTIONS, r17
|
||||
pop yh
|
||||
pop yl
|
||||
|
||||
DialogMgr_PushDialog_push:
|
||||
lds r16, dialogStackPos
|
||||
add r17, r17 ; *2
|
||||
push xl
|
||||
push xh
|
||||
ldi xl, LOW(dialogStack)
|
||||
ldi xh, HIGH(dialogStack)
|
||||
add xl, r17
|
||||
adc xh, r17
|
||||
sub xh, r17
|
||||
st X+, yl
|
||||
st X, yh
|
||||
pop xh
|
||||
pop xl
|
||||
inc r16
|
||||
sts dialogStackPos, r16
|
||||
; activate new app
|
||||
ldd r17, Y+DIALOG_OFFS_OPTIONS
|
||||
ori r17, (1<<DIALOG_OPT_ACTIVE_BIT)
|
||||
std Y+DIALOG_OFFS_OPTIONS, r17
|
||||
ldi r23, DIALOG_FN_SHOW
|
||||
rcall DialogMgr_CallHandler
|
||||
sec
|
||||
DialogMgr_PushDialog_ret:
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine DialogMgr_PopDialog @global
|
||||
;
|
||||
; @return CFLAG set if app popped from stack, cleared otherwise
|
||||
; @return Y app popped from stack (if CFLAG set)
|
||||
|
||||
DialogMgr_PopDialog:
|
||||
lds r16, dialogStackPos
|
||||
tst r16
|
||||
clc
|
||||
brne DialogMgr_PopDialog_ret
|
||||
; deactivate previous app
|
||||
push yl
|
||||
push yh
|
||||
lds yl, dialogCurrent
|
||||
lds yh, dialogCurrent+1
|
||||
ldi r23, DIALOG_FN_HIDE
|
||||
rcall DialogMgr_CallHandler
|
||||
ldd r17, Y+DIALOG_OFFS_OPTIONS
|
||||
cbr r17, (1<<DIALOG_OPT_ACTIVE_BIT)
|
||||
std Y+DIALOG_OFFS_OPTIONS, r17
|
||||
pop yh
|
||||
pop yl
|
||||
|
||||
lds r16, dialogStackPos
|
||||
dec r16
|
||||
sts dialogStackPos, r16
|
||||
brne DialogMgr_PopDialog_pop
|
||||
clr r16
|
||||
sts dialogCurrent, r16
|
||||
sts dialogCurrent+1, r16
|
||||
sec
|
||||
rjmp DialogMgr_PopDialog_ret
|
||||
DialogMgr_PopDialog_pop:
|
||||
push xl
|
||||
push xh
|
||||
ldi xl, LOW(dialogStack)
|
||||
ldi xh, HIGH(dialogStack)
|
||||
add xl, r16
|
||||
adc xh, r16
|
||||
sub xh, r16
|
||||
ld yl, X+
|
||||
ld yh, X
|
||||
sts dialogCurrent, yl
|
||||
sts dialogCurrent+1, yh
|
||||
pop xh
|
||||
pop xl
|
||||
; activate new active app
|
||||
ldd r17, Y+DIALOG_OFFS_OPTIONS
|
||||
ori r17, (1<<DIALOG_OPT_ACTIVE_BIT)
|
||||
std Y+DIALOG_OFFS_OPTIONS, r17
|
||||
ldi r23, DIALOG_FN_SHOW
|
||||
rcall DialogMgr_CallHandler
|
||||
sec
|
||||
DialogMgr_PopDialog_ret:
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
|
||||
#endif ; AQHOME_AVR_MODS_STATICGUI_DIALOG_ASM
|
||||
|
||||
@@ -1,27 +0,0 @@
|
||||
; ***************************************************************************
|
||||
; copyright : (C) 2025 by Martin Preuss
|
||||
; email : martin@libchipcard.de
|
||||
;
|
||||
; ***************************************************************************
|
||||
; * This file is part of the project "AqHome". *
|
||||
; * Please see toplevel file COPYING of that project for license details. *
|
||||
; ***************************************************************************
|
||||
|
||||
#ifndef AQH_AVR_STATICGUI_MAIN_ASM
|
||||
#define AQH_AVR_STATICGUI_MAIN_ASM
|
||||
|
||||
|
||||
GUI_Init:
|
||||
sec
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
GUI_Every100ms:
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
#endif ; AQH_AVR_STATICGUI_MAIN_ASM
|
||||
@@ -1,24 +0,0 @@
|
||||
; ***************************************************************************
|
||||
; copyright : (C) 2025 by Martin Preuss
|
||||
; email : martin@libchipcard.de
|
||||
;
|
||||
; ***************************************************************************
|
||||
; * This file is part of the project "AqHome". *
|
||||
; * Please see toplevel file COPYING of that project for license details. *
|
||||
; ***************************************************************************
|
||||
|
||||
#ifndef AQH_AVR_STATICGUI_STYLE_ASM
|
||||
#define AQH_AVR_STATICGUI_STYLE_ASM
|
||||
|
||||
|
||||
.equ STYLE_WIN_TITLE_BACKGROUND = DISPLAY_COLOR_NAVY
|
||||
.equ STYLE_WIN_TITLE_FOREGROUND = DISPLAY_COLOR_WHITE
|
||||
.equ STYLE_WIN_BACKGROUND = DISPLAY_COLOR_LIGHTGREY
|
||||
.equ STYLE_WIN_FOREGROUND = DISPLAY_COLOR_BLACK
|
||||
.equ STYLE_WIN_FONT = ili9341Font12x20_1
|
||||
|
||||
.equ STYLE_WIN_TITLE_HEIGHT = 24
|
||||
|
||||
|
||||
#endif ; AQH_AVR_STATICGUI_STYLE_ASM
|
||||
|
||||
@@ -1,158 +0,0 @@
|
||||
; ***************************************************************************
|
||||
; copyright : (C) 2025 by Martin Preuss
|
||||
; email : martin@libchipcard.de
|
||||
;
|
||||
; ***************************************************************************
|
||||
; * This file is part of the project "AqHome". *
|
||||
; * Please see toplevel file COPYING of that project for license details. *
|
||||
; ***************************************************************************
|
||||
|
||||
#ifndef AQH_AVR_STATICGUI_TITLEWINDOW_ASM
|
||||
#define AQH_AVR_STATICGUI_TITLEWINDOW_ASM
|
||||
|
||||
|
||||
.cseg
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine TitleWindow_Init @global
|
||||
;
|
||||
; @param Y pointer to titledwindow data (size=TITLEWINDOW_SIZE)
|
||||
|
||||
TitleWindow_Init:
|
||||
bigcall Window_Init
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine TitleWindow_SetFullSize @global
|
||||
;
|
||||
; @param Y pointer to screen object in SDRAM
|
||||
; @clobbers any, !Y
|
||||
|
||||
TitleWindow_SetFullSize:
|
||||
clr r16
|
||||
std Y+WIN_OFFS_X_LO, r16
|
||||
std Y+WIN_OFFS_X_HI, r16
|
||||
std Y+WIN_OFFS_Y_LO, r16
|
||||
std Y+WIN_OFFS_Y_HI, r16
|
||||
|
||||
ldi r16, LOW(DISPLAY_WIDTH)
|
||||
std Y+WIN_OFFS_WIDTH_LO, r16
|
||||
ldi r16, HIGH(DISPLAY_WIDTH)
|
||||
std Y+WIN_OFFS_WIDTH_HI, r16
|
||||
|
||||
ldi r16, LOW(DISPLAY_HEIGHT)
|
||||
std Y+WIN_OFFS_HEIGHT_LO, r16
|
||||
ldi r16, HIGH(DISPLAY_HEIGHT)
|
||||
std Y+WIN_OFFS_HEIGHT_HI, r16
|
||||
|
||||
ret
|
||||
; @enb
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine TitleWindow_SetStyleColors @global
|
||||
;
|
||||
; @param Y pointer to screen object in SDRAM
|
||||
; @clobbers any, !Y
|
||||
|
||||
TitleWindow_SetStyleColors:
|
||||
ldi r16, LOW(STYLE_WIN_BACKGROUND)
|
||||
ldi r17, HIGH(STYLE_WIN_BACKGROUND)
|
||||
std Y+WIN_OFFS_BG_COL_LO, r16
|
||||
std Y+WIN_OFFS_BG_COL_HI, r17
|
||||
ldi r16, LOW(STYLE_WIN_FOREGROUND)
|
||||
ldi r17, HIGH(STYLE_WIN_FOREGROUND)
|
||||
std Y+WIN_OFFS_FG_COL_LO, r16
|
||||
std Y+WIN_OFFS_FG_COL_HI, r17
|
||||
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine TitleWindow_DrawTitle @global
|
||||
;
|
||||
; @param Y pointer to screen object in SDRAM
|
||||
; @param Z pointer to title
|
||||
; @clobbers any, !Y
|
||||
|
||||
TitleWindow_DrawTitle:
|
||||
; fill background of title area
|
||||
clr r4
|
||||
clr r5
|
||||
clr r6
|
||||
clr r7
|
||||
ldd r8, Y+WIN_OFFS_WIDTH_LO
|
||||
ldd r9, Y+WIN_OFFS_WIDTH_HI
|
||||
ldi r16, LOW(STYLE_WIN_TITLE_HEIGHT)
|
||||
ldi r17, HIGH(STYLE_WIN_TITLE_HEIGHT)
|
||||
mov r10, r16
|
||||
mov r11, r17
|
||||
ldi r16, LOW(STYLE_WIN_TITLE_BACKGROUND)
|
||||
mov r2, r16
|
||||
ldi r16, HIGH(STYLE_WIN_TITLE_BACKGROUND)
|
||||
mov r3, r16
|
||||
rcall Window_FillRect
|
||||
|
||||
; draw title
|
||||
ldi r16, 5 ; X
|
||||
mov r4, r16
|
||||
clr r5
|
||||
ldi r16, 2 ; Y
|
||||
mov r6, r16
|
||||
clr r7
|
||||
|
||||
ldi r16, LOW(STYLE_WIN_TITLE_BACKGROUND)
|
||||
mov r0, r16
|
||||
ldi r16, HIGH(STYLE_WIN_TITLE_BACKGROUND)
|
||||
mov r1, r16
|
||||
|
||||
ldi r16, LOW(STYLE_WIN_TITLE_FOREGROUND)
|
||||
mov r2, r16
|
||||
ldi r16, HIGH(STYLE_WIN_TITLE_FOREGROUND)
|
||||
mov r3, r16
|
||||
bigcall Window_DrawColorTextFlash
|
||||
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine TitleWindow_ClearContentArea @global
|
||||
;
|
||||
; @param Y pointer to screen object in SDRAM
|
||||
; @clobbers any, !Y
|
||||
|
||||
TitleWindow_ClearContentArea:
|
||||
clr r4
|
||||
clr r5
|
||||
ldi r16, LOW(STYLE_WIN_TITLE_HEIGHT)
|
||||
mov r6, r16
|
||||
ldi r16, HIGH(STYLE_WIN_TITLE_HEIGHT)
|
||||
mov r7, r16
|
||||
ldd r8, Y+WIN_OFFS_WIDTH_LO
|
||||
ldd r9, Y+WIN_OFFS_WIDTH_HI
|
||||
ldi r16, LOW(STYLE_WIN_TITLE_HEIGHT)
|
||||
ldi r17, HIGH(STYLE_WIN_TITLE_HEIGHT)
|
||||
ldd r10, Y+WIN_OFFS_HEIGHT_LO
|
||||
ldd r11, Y+WIN_OFFS_HEIGHT_HI
|
||||
sub r10, r16
|
||||
sbc r11, r17
|
||||
ldi r16, LOW(STYLE_WIN_BACKGROUND)
|
||||
ldd r2, Y+WIN_OFFS_BG_COL_LO
|
||||
ldd r3, Y+WIN_OFFS_BG_COL_HI
|
||||
rcall Window_FillRect
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
#endif ; AQH_AVR_STATICGUI_TITLEWINDOW2_ASM
|
||||
|
||||
@@ -1,512 +0,0 @@
|
||||
; ***************************************************************************
|
||||
; copyright : (C) 2025 by Martin Preuss
|
||||
; email : martin@libchipcard.de
|
||||
;
|
||||
; ***************************************************************************
|
||||
; * This file is part of the project "AqHome". *
|
||||
; * Please see toplevel file COPYING of that project for license details. *
|
||||
; ***************************************************************************
|
||||
|
||||
#ifndef AQH_AVR_STATICGUI_WINDOW_ASM
|
||||
#define AQH_AVR_STATICGUI_WINDOW_ASM
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine Window_Init @global
|
||||
;
|
||||
; @param Y pointer to screen object in SDRAM
|
||||
; @clobbers R16, R17, X
|
||||
|
||||
Window_Init:
|
||||
mov xl, yl
|
||||
mov xh, yh
|
||||
ldi r17, WIN_SIZE
|
||||
clr r16
|
||||
bigcall Utils_FillSram ; (R17, X)
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine Window_Clear @global
|
||||
;
|
||||
; @param Y pointer to screen object in SDRAM
|
||||
; @clobbers any, !Y
|
||||
|
||||
Window_Clear:
|
||||
ldd r2, Y+WIN_OFFS_BG_COL_LO ; background color low
|
||||
ldd r3, Y+WIN_OFFS_BG_COL_HI ; background color high
|
||||
ldd r4, Y+WIN_OFFS_X_LO ; X low
|
||||
ldd r5, Y+WIN_OFFS_X_HI ; X high
|
||||
ldd r6, Y+WIN_OFFS_Y_LO ; Y low
|
||||
ldd r7, Y+WIN_OFFS_Y_HI ; Y high
|
||||
ldd r8, Y+WIN_OFFS_WIDTH_LO ; width low
|
||||
ldd r9, Y+WIN_OFFS_WIDTH_HI ; width high
|
||||
ldd r10, Y+WIN_OFFS_HEIGHT_LO ; height low
|
||||
ldd r11, Y+WIN_OFFS_HEIGHT_HI ; height high
|
||||
bigcall Display_FillRect
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine Window_FillRect @global
|
||||
;
|
||||
; @param Y pointer to screen object in SDRAM
|
||||
; @param r3:r2 color
|
||||
; @param r5:r4 X0
|
||||
; @param r7:r6 Y0
|
||||
; @param r9:r8 X1/W
|
||||
; @param r11:r10 Y1/H
|
||||
; @clobbers any, !Y
|
||||
|
||||
Window_FillRect:
|
||||
ldd r16, Y+WIN_OFFS_X_LO ; make absolute coords
|
||||
ldd r17, Y+WIN_OFFS_X_HI
|
||||
add r4, r16
|
||||
adc r5, r17
|
||||
ldd r16, Y+WIN_OFFS_Y_LO
|
||||
ldd r17, Y+WIN_OFFS_Y_HI
|
||||
add r6, r16
|
||||
adc r7, r17
|
||||
bigcall Display_FillRect ; directly call graphics function
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine Window_DrawTextFlash @global
|
||||
;
|
||||
; @param Y pointer to screen object in SDRAM
|
||||
; @param R5:R4 X (dest)
|
||||
; @param R7:R6 Y (dest)
|
||||
; @return R5:R4 X pos behind string
|
||||
|
||||
; @clobbers any, !Y, !R6, !R7
|
||||
|
||||
Window_DrawTextFlash:
|
||||
ldd r0, Y+WIN_OFFS_BG_COL_LO
|
||||
ldd r1, Y+WIN_OFFS_BG_COL_HI
|
||||
ldd r2, Y+WIN_OFFS_FG_COL_LO
|
||||
ldd r3, Y+WIN_OFFS_FG_COL_HI
|
||||
|
||||
rjmp Window_DrawColorTextFlash
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine Window_DrawColorTextFlash @global
|
||||
;
|
||||
; @param Y pointer to screen object in SDRAM
|
||||
; @param R1:R0 background color
|
||||
; @param R3:R2 foreground color
|
||||
; @param R5:R4 X (dest)
|
||||
; @param R7:R6 Y (dest)
|
||||
; @return R5:R4 X pos behind string
|
||||
|
||||
; @clobbers any, !Y, !R6, !R7
|
||||
|
||||
Window_DrawColorTextFlash:
|
||||
rcall winCalcAbsPosAndBorders ; (R18, R19)
|
||||
Window_DrawColorTextFlash_loop:
|
||||
lpm r16, Z
|
||||
tst r16
|
||||
breq Window_DrawColorTextFlash_loopEnd
|
||||
rcall winDrawChar
|
||||
brcc Window_DrawColorTextFlash_loopEnd
|
||||
adiw zh:zl, 1 ; next char
|
||||
rjmp Window_DrawColorTextFlash_loop
|
||||
Window_DrawColorTextFlash_loopEnd:
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine Window_DrawCharAt @global
|
||||
;
|
||||
; @param Y pointer to screen object in SDRAM
|
||||
; @param R16 char to write
|
||||
; @param R5:R4 X (dest)
|
||||
; @param R7:R6 Y (dest)
|
||||
; @return R5:R4 X pos behind char
|
||||
; @clobbers any, !Y
|
||||
|
||||
Window_DrawCharAt:
|
||||
rcall winCalcAbsPosAndBorders
|
||||
|
||||
ldd r0, Y+WIN_OFFS_BG_COL_LO
|
||||
ldd r1, Y+WIN_OFFS_BG_COL_HI
|
||||
ldd r2, Y+WIN_OFFS_FG_COL_LO
|
||||
ldd r3, Y+WIN_OFFS_FG_COL_HI
|
||||
|
||||
rjmp winDrawChar
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine winCalcAbsPosAndBorders
|
||||
;
|
||||
; @param Y pointer to screen object in SDRAM
|
||||
; @param R5:R4 X relative to window
|
||||
; @param R7:R6 Y relative to window
|
||||
; @return R9:R8 first X pos right of windows
|
||||
; @return R5:R4 X relative to screen
|
||||
; @return R7:R6 Y relative to screen
|
||||
; @return R9:R8 first X pos right of window (abs)
|
||||
; @return R11:R10 first Y pos below window (abs)
|
||||
; @clobbers r18, r19
|
||||
|
||||
winCalcAbsPosAndBorders:
|
||||
; calc abs X pos
|
||||
ldd r18, Y+WIN_OFFS_X_LO
|
||||
ldd r19, Y+WIN_OFFS_X_HI
|
||||
add r4, r18 ; add X of window
|
||||
adc r5, r19
|
||||
|
||||
; calc first X pos behind window
|
||||
ldd r8, Y+WIN_OFFS_WIDTH_LO
|
||||
ldd r9, Y+WIN_OFFS_WIDTH_HI
|
||||
add r8, r18
|
||||
adc r9, r19
|
||||
|
||||
; calc abs Y pos
|
||||
ldd r18, Y+WIN_OFFS_Y_LO
|
||||
ldd r19, Y+WIN_OFFS_Y_HI
|
||||
add r6, r18 ; add Y of window
|
||||
adc r7, r19
|
||||
|
||||
; calc first Y pos behind window
|
||||
ldd r10, Y+WIN_OFFS_HEIGHT_LO
|
||||
ldd r11, Y+WIN_OFFS_HEIGHT_HI
|
||||
add r10, r18
|
||||
adc r11, r19
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine winDrawChar
|
||||
;
|
||||
; @param Y pointer to screen object in SDRAM
|
||||
; @param R16 char to write
|
||||
; @param R5:R4 absolute X on screen
|
||||
; @param R7:R6 absolute Y on screen
|
||||
; @param R9:R8 first X pos right of windows
|
||||
; @return R5:R4 X pos behind char
|
||||
; @clobbers any, !Y, !R6, !R7
|
||||
|
||||
winDrawChar:
|
||||
push zl
|
||||
push zh
|
||||
mov r12, r16
|
||||
ldd zl, Y+WIN_OFFS_FONT_LO
|
||||
ldd zh, Y+WIN_OFFS_FONT_HI
|
||||
|
||||
; check whether the char fits inside window
|
||||
bigcall FONT_GetCharWidth ; r16=char width
|
||||
|
||||
clr r17
|
||||
add r16, r4 ; char width+X
|
||||
adc r17, r5
|
||||
sub r16, r8 ; check against window width
|
||||
sbc r17, r9
|
||||
brcc winDrawChar_ret ; not fit, jmp
|
||||
|
||||
; actually draw char
|
||||
mov r16, r12
|
||||
push r8
|
||||
push r9
|
||||
push r10
|
||||
push r11
|
||||
bigcall Display_DrawChar
|
||||
pop r11
|
||||
pop r10
|
||||
pop r9
|
||||
pop r8
|
||||
clr r16
|
||||
add r4, r18 ; increment X
|
||||
adc r5, r16
|
||||
sec ; write succeeded
|
||||
winDrawChar_ret:
|
||||
pop zh
|
||||
pop zl
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine Window_WriteHexWordAt @global
|
||||
;
|
||||
; @param Y pointer to screen object in SDRAM
|
||||
; @param R17:R16 word to write
|
||||
; @param R5:R4 X (dest)
|
||||
; @param R7:R6 Y (dest)
|
||||
; @return R5:R4 X pos behind string
|
||||
; @clobbers any, !Y
|
||||
|
||||
Window_WriteHexWordAt:
|
||||
push r16
|
||||
mov r16, r17
|
||||
rcall Window_WriteHexByteAt
|
||||
pop r16
|
||||
rcall Window_WriteHexByteAt
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine Window_WriteHexByteAt @global
|
||||
;
|
||||
; @param Y pointer to screen object in SDRAM
|
||||
; @param R16 byte to write
|
||||
; @param R5:R4 X (dest)
|
||||
; @param R7:R6 Y (dest)
|
||||
; @return R5:R4 X pos behind string
|
||||
; @clobbers any, !Y
|
||||
|
||||
Window_WriteHexByteAt:
|
||||
push r16
|
||||
swap r16
|
||||
rcall winWriteNibble
|
||||
pop r16
|
||||
rcall winWriteNibble
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
winWriteNibble:
|
||||
push r4
|
||||
push r5
|
||||
push r6
|
||||
push r7
|
||||
rcall winNibbleToAscii ; write high nibble (r16, r17)
|
||||
rcall Window_DrawCharAt ; draw
|
||||
pop r7
|
||||
pop r6
|
||||
pop r5
|
||||
pop r4
|
||||
clr r17
|
||||
add r4, r18
|
||||
adc r5, r17
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine winNibbleToAscii
|
||||
;
|
||||
; Convert a nibble to an ASCII char.
|
||||
; @return R16 ASCII representation of that nibble (e.g. '0' for 0)
|
||||
; @param R16 byte (in bits 0-3)
|
||||
; @clobbers r16, r17
|
||||
|
||||
winNibbleToAscii:
|
||||
andi r16, 0xf
|
||||
cpi r16, 10
|
||||
brcs winNibbleToAscii_l1
|
||||
ldi r17, 7
|
||||
add r16, r17
|
||||
winNibbleToAscii_l1:
|
||||
ldi r17, '0'
|
||||
add r16, r17
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#if 0
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine Window_DrawTextFlash @global
|
||||
;
|
||||
; @param Y pointer to screen object in SDRAM
|
||||
; @param R5:R4 X (dest)
|
||||
; @param R7:R6 Y (dest)
|
||||
; @return R5:R4 X pos behind string
|
||||
; @return R7:R6 Y pos behind string
|
||||
; @clobbers any, !Y
|
||||
|
||||
Window_DrawTextFlash:
|
||||
; calc abs X pos
|
||||
ldd r18, Y+WIN_OFFS_X_LO
|
||||
ldd r19, Y+WIN_OFFS_X_HI
|
||||
add r4, r18 ; add X of window
|
||||
adc r5, r19
|
||||
|
||||
; calc first X pos behind window
|
||||
ldd r8, Y+WIN_OFFS_WIDTH_LO
|
||||
ldd r9, Y+WIN_OFFS_WIDTH_HI
|
||||
add r8, r18
|
||||
adc r9, r19
|
||||
|
||||
; calc abs Y pos
|
||||
ldd r18, Y+WIN_OFFS_Y_LO
|
||||
ldd r19, Y+WIN_OFFS_Y_HI
|
||||
add r6, r18 ; add Y of window
|
||||
adc r7, r19
|
||||
|
||||
; calc first Y pos behind window
|
||||
ldd r10, Y+WIN_OFFS_HEIGHT_LO
|
||||
ldd r11, Y+WIN_OFFS_HEIGHT_HI
|
||||
add r10, r18
|
||||
adc r11, r19
|
||||
|
||||
Window_DrawTextFlash_loop:
|
||||
push zl
|
||||
push zh
|
||||
rcall winCalcLengthWordFlash
|
||||
pop zh
|
||||
pop zl
|
||||
mov r18, r4
|
||||
mov r19, r5
|
||||
add r18, r12
|
||||
adc r19, r13
|
||||
sub r18, r8
|
||||
sbc r19, r9
|
||||
brcs Window_DrawTextFlash_xOkay
|
||||
; we need to go to the beginning of the next line
|
||||
rcall Window_DrawTextFlash_nextLine
|
||||
brcc Window_DrawTextFlash_loopEnd ; outside the window, jmp
|
||||
Window_DrawTextFlash_xOkay:
|
||||
rcall winDrawWordFlash ; Z points at blank/0 byte after call
|
||||
lpm r16, Z+
|
||||
tst r16 ; end of string?
|
||||
breq Window_DrawTextFlash_loopEnd
|
||||
cpi r16, 13
|
||||
breq Window_DrawTextFlash_handle13
|
||||
; insert other handled chars here
|
||||
; write blank char
|
||||
push zl
|
||||
push zh
|
||||
ldd zl, Y+WIN_OFFS_FONT_LO
|
||||
ldd zh, Y+WIN_OFFS_FONT_HI
|
||||
ldi r16, 32 ; space
|
||||
bigcall Display_DrawChar
|
||||
pop zh
|
||||
pop zl
|
||||
add r4, r8 ; increment X
|
||||
adc r5, r9
|
||||
|
||||
|
||||
rjmp Window_DrawTextFlash_loopNext
|
||||
Window_DrawTextFlash_handle13:
|
||||
rcall Window_DrawTextFlash_nextLine
|
||||
Window_DrawTextFlash_loopNext:
|
||||
rjmp Window_DrawTextFlash_loop
|
||||
Window_DrawTextFlash_nextLine:
|
||||
push zl
|
||||
push zh
|
||||
ldd zl, Y+WIN_OFFS_FONT_LO
|
||||
ldd zh, Y+WIN_OFFS_FONT_HI
|
||||
bigcall FONT_GetCharWidth ; r16=char width
|
||||
pop zh
|
||||
pop zl
|
||||
ldd r4, Y+WIN_OFFS_X_LO ; X=left border
|
||||
ldd r5, Y+WIN_OFFS_X_HI
|
||||
clr r17
|
||||
add r6, r16 ; increment Y by font height
|
||||
adc r7, r17
|
||||
mov r16, r6 ; check against lower border of window
|
||||
mov r17, r7
|
||||
sub r16, r10
|
||||
sbc r17, r11 ; CF set if inside window, cleared otherwise
|
||||
ret
|
||||
Window_DrawTextFlash_loopEnd:
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine winDrawWordFlash
|
||||
;
|
||||
; @param Y pointer to screen object in SDRAM
|
||||
; @param Z pointer to string in FLASH
|
||||
; @param R1:R0 background color
|
||||
; @param R3:R2 foreground color
|
||||
; @param R5:R4 X (dest)
|
||||
; @param R7:R6 Y (dest)
|
||||
; @return r5:r4 next X pos
|
||||
; @return Z pointer to next char behind current word
|
||||
; @clobbers any, !Y, !r1-r15
|
||||
|
||||
winDrawWordFlash:
|
||||
winDrawWordFlash_loop:
|
||||
lpm r16, Z
|
||||
cpi r16, 33
|
||||
brcs winDrawWordFlash_ret
|
||||
push zl
|
||||
push zh
|
||||
ldd zl, Y+WIN_OFFS_FONT_LO
|
||||
ldd zh, Y+WIN_OFFS_FONT_HI
|
||||
bigcall Display_DrawChar
|
||||
pop zh
|
||||
pop zl
|
||||
clr r16
|
||||
add r4, r18 ; increment X
|
||||
adc r5, r16
|
||||
adiw zh:zl, 1
|
||||
rjmp winDrawWordFlash_loop
|
||||
winDrawWordFlash_ret:
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine winCalcLengthWordFlash
|
||||
;
|
||||
; @param Y pointer to screen object in SDRAM
|
||||
; @param Z pointer to string in FLASH
|
||||
; @return r13:r12 width of next word in pixels
|
||||
; @return Z pointer to next char behind current word
|
||||
; @clobbers any, !Y, !r1-r11, !r14, !r15
|
||||
|
||||
winCalcLengthWordFlash:
|
||||
clr r12
|
||||
clr r13
|
||||
winCalcLengthWordFlash_loop:
|
||||
lpm r16, Z
|
||||
cpi r16, 33
|
||||
brcs winCalcLengthWordFlash_ret
|
||||
push zl
|
||||
push zh
|
||||
ldd zl, Y+WIN_OFFS_FONT_LO
|
||||
ldd zh, Y+WIN_OFFS_FONT_HI
|
||||
bigcall FONT_GetCharWidth ; r16=char width
|
||||
clr r17
|
||||
add r12, r16
|
||||
adc r13, r17
|
||||
pop zh
|
||||
pop zl
|
||||
brcs winCalcLengthWordFlash_error
|
||||
adiw zh:zl, 1 ; next char
|
||||
rjmp winCalcLengthWordFlash_loop
|
||||
winCalcLengthWordFlash_error:
|
||||
ldi r12, 0xff
|
||||
ldi r13, 0xff
|
||||
winCalcLengthWordFlash_ret:
|
||||
ret
|
||||
; @end
|
||||
|
||||
#endif ; if 0
|
||||
|
||||
|
||||
|
||||
#endif ; AQH_AVR_STATICGUI_WINDOW_ASM
|
||||
|
||||
@@ -1,115 +0,0 @@
|
||||
; ***************************************************************************
|
||||
; copyright : (C) 2025 by Martin Preuss
|
||||
; email : martin@libchipcard.de
|
||||
;
|
||||
; ***************************************************************************
|
||||
; * This file is part of the project "AqHome". *
|
||||
; * Please see toplevel file COPYING of that project for license details. *
|
||||
; ***************************************************************************
|
||||
|
||||
#ifndef AQH_AVR_WIN_DEFS_H
|
||||
#define AQH_AVR_WIN_DEFS_H
|
||||
|
||||
|
||||
; tree/list data
|
||||
.equ OBJ_OFFS_TREE = 0
|
||||
|
||||
; object data
|
||||
.equ OBJ_OFFS_OBJECT = OBJ_OFFS_TREE+TREE_SIZE
|
||||
.equ OBJ_OFFS_HANDLERFN_LO = OBJ_OFFS_OBJECT
|
||||
.equ OBJ_OFFS_HANDLERFN_HI = OBJ_OFFS_OBJECT+1
|
||||
.equ OBJ_OFFS_TARGET_LO = OBJ_OFFS_OBJECT+2
|
||||
.equ OBJ_OFFS_TARGET_HI = OBJ_OFFS_OBJECT+3
|
||||
.equ OBJ_OFFS_IDFORTARGET = OBJ_OFFS_OBJECT+4
|
||||
.equ OBJ_OFFS_OPTIONS = OBJ_OFFS_OBJECT+5
|
||||
.equ OBJ_SIZE = OBJ_OFFS_OBJECT+6
|
||||
|
||||
; widget data
|
||||
.equ WID_OFFS_WIDGET = OBJ_SIZE
|
||||
.equ WID_OFFS_OPTIONS1 = WID_OFFS_WIDGET+0
|
||||
.equ WID_OFFS_OPTIONS2 = WID_OFFS_WIDGET+1
|
||||
.equ WID_OFFS_ABS_X_LO = WID_OFFS_WIDGET+2
|
||||
.equ WID_OFFS_ABS_X_HI = WID_OFFS_WIDGET+3
|
||||
.equ WID_OFFS_ABS_Y_LO = WID_OFFS_WIDGET+4
|
||||
.equ WID_OFFS_ABS_Y_HI = WID_OFFS_WIDGET+5
|
||||
.equ WID_OFFS_REL_X_LO = WID_OFFS_WIDGET+6
|
||||
.equ WID_OFFS_REL_X_HI = WID_OFFS_WIDGET+7
|
||||
.equ WID_OFFS_REL_Y_LO = WID_OFFS_WIDGET+8
|
||||
.equ WID_OFFS_REL_Y_HI = WID_OFFS_WIDGET+9
|
||||
.equ WID_OFFS_WIDTH_LO = WID_OFFS_WIDGET+10
|
||||
.equ WID_OFFS_WIDTH_HI = WID_OFFS_WIDGET+11
|
||||
.equ WID_OFFS_HEIGHT_LO = WID_OFFS_WIDGET+12
|
||||
.equ WID_OFFS_HEIGHT_HI = WID_OFFS_WIDGET+13
|
||||
.equ WID_OFFS_BG_COL_LO = WID_OFFS_WIDGET+14
|
||||
.equ WID_OFFS_BG_COL_HI = WID_OFFS_WIDGET+15
|
||||
.equ WID_OFFS_FG_COL_LO = WID_OFFS_WIDGET+16
|
||||
.equ WID_OFFS_FG_COL_HI = WID_OFFS_WIDGET+17
|
||||
.equ WID_OFFS_FONT_LO = WID_OFFS_WIDGET+18
|
||||
.equ WID_OFFS_FONT_HI = WID_OFFS_WIDGET+19
|
||||
.equ WID_OFFS_BORDER_TOP = WID_OFFS_WIDGET+20
|
||||
.equ WID_OFFS_BORDER_BOT = WID_OFFS_WIDGET+21
|
||||
.equ WID_OFFS_BORDER_LEFT = WID_OFFS_WIDGET+22
|
||||
.equ WID_OFFS_BORDER_RIGHT = WID_OFFS_WIDGET+23
|
||||
|
||||
.equ WID_SIZE = WID_OFFS_WIDGET+24
|
||||
|
||||
|
||||
|
||||
.equ WID_OPTIONS0_BIT_VISIBLE = 0 ; OBJ_OFFS_OPTIONS
|
||||
.equ WID_OPTIONS0_BIT_DIRTY = 1
|
||||
.equ WID_OPTIONS0_BIT_LAYOUT = 2
|
||||
.equ WID_OPTIONS0_BIT_DATAINSDRAM = 3 ; text or other data is in SDRAM, not in flash
|
||||
|
||||
.equ WID_OPTIONS1_BIT_STRETCH_X = 0 ; WID_OFFS_OPTIONS1
|
||||
.equ WID_OPTIONS1_BIT_STRETCH_Y = 1
|
||||
|
||||
.equ WID_OPTIONS1_BIT_HALIGN0 = 2 ; 00: left, 01: right, 11: center
|
||||
.equ WID_OPTIONS1_BIT_HALIGN1 = 3
|
||||
|
||||
.equ WID_OPTIONS1_BIT_VALIGN0 = 4 ; 00: top, 01: bottom, 11: center
|
||||
.equ WID_OPTIONS1_BIT_VALIGN1 = 5
|
||||
|
||||
.equ WID_OPTIONS1_BIT_FIXED_WIDTH = 6
|
||||
.equ WID_OPTIONS1_BIT_FIXED_HEIGHT = 7
|
||||
|
||||
|
||||
.equ WID_OPTIONS2_BIT_EQUAL_WIDTH = 0
|
||||
.equ WID_OPTIONS2_BIT_EQUAL_HEIGHT = 1
|
||||
|
||||
|
||||
; Signals
|
||||
|
||||
.equ OBJ_SIGNAL_DESTROY = 0
|
||||
.equ OBJ_SIGNAL_GETVALUE = 1
|
||||
.equ OBJ_SIGNAL_SETVALUE = 2
|
||||
.equ OBJ_SIGNAL_TIMER = 3
|
||||
.equ OBJ_SIGNAL_NEXTFREE = 4
|
||||
|
||||
.equ WID_SIGNAL_SHOW = OBJ_SIGNAL_NEXTFREE
|
||||
.equ WID_SIGNAL_HIDE = OBJ_SIGNAL_NEXTFREE+1
|
||||
.equ WID_SIGNAL_DRAW = OBJ_SIGNAL_NEXTFREE+2
|
||||
.equ WID_SIGNAL_LAYOUT = OBJ_SIGNAL_NEXTFREE+3
|
||||
.equ WID_SIGNAL_TOUCH = OBJ_SIGNAL_NEXTFREE+4
|
||||
.equ WID_SIGNAL_MOUSE = OBJ_SIGNAL_NEXTFREE+5
|
||||
.equ WID_SIGNAL_KEY = OBJ_SIGNAL_NEXTFREE+6
|
||||
.equ WID_SIGNAL_GETMINWIDTH = OBJ_SIGNAL_NEXTFREE+7
|
||||
.equ WID_SIGNAL_GETMINHEIGHT = OBJ_SIGNAL_NEXTFREE+8
|
||||
.equ WID_SIGNAL_NEXTFREE = OBJ_SIGNAL_NEXTFREE+9
|
||||
|
||||
|
||||
|
||||
.equ TIMER_OFFS_LIST = 0
|
||||
.equ TIMER_OFFS_TIMER = LIST_SIZE
|
||||
.equ TIMER_OFFS_VALUE_LO = TIMER_OFFS_TIMER
|
||||
.equ TIMER_OFFS_VALUE_HI = TIMER_OFFS_TIMER+1
|
||||
.equ TIMER_OFFS_RELOAD_LO = TIMER_OFFS_TIMER+2
|
||||
.equ TIMER_OFFS_RELOAD_HI = TIMER_OFFS_TIMER+3
|
||||
.equ TIMER_OFFS_OPTIONS = TIMER_OFFS_TIMER+4
|
||||
.equ TIMER_OFFS_SIGNAL = TIMER_OFFS_TIMER+5
|
||||
.equ TIMER_SIZE = TIMER_OFFS_TIMER+6
|
||||
|
||||
|
||||
|
||||
|
||||
#endif ; AQH_AVR_WIN_H
|
||||
|
||||
@@ -1,22 +0,0 @@
|
||||
; ***************************************************************************
|
||||
; copyright : (C) 2025 by Martin Preuss
|
||||
; email : martin@libchipcard.de
|
||||
;
|
||||
; ***************************************************************************
|
||||
; * This file is part of the project "AqHome". *
|
||||
; * Please see toplevel file COPYING of that project for license details. *
|
||||
; ***************************************************************************
|
||||
|
||||
|
||||
.dseg
|
||||
|
||||
guiRootWidget: .byte 2
|
||||
|
||||
|
||||
|
||||
.cseg
|
||||
|
||||
GUI_Init:
|
||||
ret
|
||||
; @end
|
||||
|
||||
@@ -1,263 +0,0 @@
|
||||
; ***************************************************************************
|
||||
; copyright : (C) 2025 by Martin Preuss
|
||||
; email : martin@libchipcard.de
|
||||
;
|
||||
; ***************************************************************************
|
||||
; * This file is part of the project "AqHome". *
|
||||
; * Please see toplevel file COPYING of that project for license details. *
|
||||
; ***************************************************************************
|
||||
|
||||
#ifndef AQH_AVR_WIN_OBJECT_H
|
||||
#define AQH_AVR_WIN_OBJECT_H
|
||||
|
||||
|
||||
.cseg
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine OBJ_Init @global
|
||||
;
|
||||
; Generally every object only reports its signals to a single other object
|
||||
; (called the target). However, every object can receive signals from multiple
|
||||
; sender objects. To allow this the target assigns its own id (called idForTarget)
|
||||
; to the new object in order to determine who sent the signal and to act accordingly.
|
||||
; There are system signals which don't use idForTarget (like OBJ_SIGNAL_DESTROY).
|
||||
;
|
||||
; @param Y pointer to object in SRAM
|
||||
; @param r18 options
|
||||
; @clobbers r16, r17, X
|
||||
|
||||
OBJ_Init:
|
||||
mov xl, yl
|
||||
mov xh, yh
|
||||
clr r16
|
||||
ldi r17, OBJ_OFFS_SIZE
|
||||
bigcall Utils_FillSram ; (R17, X)
|
||||
bigcall Tree_InitObject ; (R16)
|
||||
std Y+OBJ_OFFS_OPTIONS, r18
|
||||
ldi r16, LOW(OBJ_DefaultHandler)
|
||||
std Y+OBJ_OFFS_HANDLERFN_LO, r16
|
||||
ldi r16, HIGH(OBJ_DefaultHandler)
|
||||
std Y+OBJ_OFFS_HANDLERFN_HI, r16
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine OBJ_SetTarget @global
|
||||
;
|
||||
; @param r19 srcIdForTarget
|
||||
; @param X pointer to target
|
||||
; @clobbers none
|
||||
|
||||
OBJ_SetTarget:
|
||||
std Y+OBJ_OFFS_TARGET_LO, xl
|
||||
std Y+OBJ_OFFS_TARGET_HI, xh
|
||||
std Y+OBJ_OFFS_IDFORTARGET, r19
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine OBJ_SetHandler @global
|
||||
;
|
||||
; @param Y pointer to object SRAM
|
||||
; @param Z pointer to handler function (word address)
|
||||
; @clobbers none
|
||||
|
||||
OBJ_SetHandler:
|
||||
std Y+OBJ_OFFS_HANDLERFN_LO, zl
|
||||
std Y+OBJ_OFFS_HANDLERFN_HI, zh
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine OBJ_GetHandler @global
|
||||
;
|
||||
; @param Y pointer to object SRAM
|
||||
; @return Z pointer to handler function (word address)
|
||||
; @clobbers none
|
||||
|
||||
OBJ_GetHandler:
|
||||
ldd zl, Y+OBJ_OFFS_HANDLERFN_LO
|
||||
ldd zh, Y+OBJ_OFFS_HANDLERFN_HI
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine OBJ_DefaultHandler @global
|
||||
;
|
||||
; This is a default signal handler which does nothing.
|
||||
;
|
||||
; @param Y pointer to object SRAM
|
||||
; @param r18 signal
|
||||
; @param r19 srcIdForTarget
|
||||
; @param R20 1st param
|
||||
; @param R21 2nd param
|
||||
; @param X 3rd param
|
||||
; @clobbers any
|
||||
|
||||
OBJ_DefaultHandler:
|
||||
clc
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine OBJ_Fini @global
|
||||
;
|
||||
; This routine calls OBJ_Fini on every child object, Then it sends the signal
|
||||
; OBJ_SIGNAL_DESTROY to this object allowing it to release all its ressources
|
||||
; (including memory space if using heap or other dynamic ressources).
|
||||
;
|
||||
; @param Y pointer to object in SRAM
|
||||
; @clobbers any, !Y
|
||||
|
||||
OBJ_Fini:
|
||||
; fini children
|
||||
push yl
|
||||
push yh
|
||||
bigcall Tree_GetFirstChildObject ; (none)
|
||||
OBJ_Fini_loop:
|
||||
mov r16, xl
|
||||
or r16, xh
|
||||
breq OBJ_Fini_loopEnd
|
||||
mov yl, xl
|
||||
mov yh, xh
|
||||
bigcall Tree_GetNextSibling
|
||||
push xl ; next
|
||||
push xh ; next
|
||||
rcall OBJ_Fini
|
||||
pop xh ; next
|
||||
pop xl ; next
|
||||
rjmp OBJ_Fini_loop
|
||||
OBJ_Fini_loopEnd:
|
||||
pop yh
|
||||
pop yl
|
||||
|
||||
bigcall Tree_UnlinkObject ; (r16, r17, x)
|
||||
|
||||
push yl
|
||||
push yh
|
||||
ldi r18, OBJ_SIGNAL_DESTROY
|
||||
clr r19
|
||||
rcall OBJ_Handler
|
||||
pop yh ; probably no longer usable pointer,
|
||||
pop yl ; especially if using heap!
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine OBJ_Handler @global
|
||||
;
|
||||
; Signal handler for an object. A signal can have up to 3 parameters
|
||||
; conveyed in registers R20, R21 and X.
|
||||
;
|
||||
; @param Y pointer to object SRAM
|
||||
; @param r18 signal
|
||||
; @param r19 srcIdForTarget
|
||||
; @param R20 1st param
|
||||
; @param R21 2nd param
|
||||
; @param X 3rd param
|
||||
|
||||
OBJ_Handler:
|
||||
ldd r17, Y+OBJ_OFFS_HANDLERFN_LO
|
||||
push r17
|
||||
ldd r17, Y+OBJ_OFFS_HANDLERFN_HI
|
||||
push r17
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine OBJ_ForwardSignalToChildren @global
|
||||
;
|
||||
; Signal handler for an object. A signal can have up to 3 parameters
|
||||
; conveyed in registers R18, R19 and X.
|
||||
;
|
||||
; @param Y pointer to object SRAM
|
||||
; @param r18 signal
|
||||
; @param R20 1st param
|
||||
; @param R21 2nd param
|
||||
; @param X 3rd param
|
||||
; @clobbers any, !r18, !r20, !r21, !Y
|
||||
|
||||
OBJ_ForwardSignalToChildren:
|
||||
push yl
|
||||
push yh
|
||||
bigcall Tree_GetFirstChildObject ; (none)
|
||||
OBJ_ForwardSignalToChildren_loop:
|
||||
clc
|
||||
mov r17, xl
|
||||
or r17, xh
|
||||
breq OBJ_ForwardSignalToChildren_loopEnd
|
||||
mov yl, xl
|
||||
mov yh, xh
|
||||
push r18
|
||||
push r20
|
||||
push r21
|
||||
push xl
|
||||
push xh
|
||||
push yl
|
||||
push yh
|
||||
clr r19 ; srcId for target set to 0 (this is a direct call to the handler)
|
||||
rcall OBJ_Handler
|
||||
pop yh
|
||||
pop yl
|
||||
pop xh
|
||||
pop xl
|
||||
pop r21
|
||||
pop r20
|
||||
pop r18
|
||||
rcall Tree_GetNextSibling
|
||||
rjmp OBJ_ForwardSignalToChildren_loop
|
||||
OBJ_ForwardSignalToChildren_loopEnd:
|
||||
pop yh
|
||||
pop yl
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine OBJ_EmitSignal @global
|
||||
;
|
||||
; @param Y pointer to object SRAM
|
||||
; @param r18 signal
|
||||
; @param R20 1st param
|
||||
; @param R21 2nd param
|
||||
; @param X 3rd param
|
||||
; @clobbers any, !Y
|
||||
|
||||
OBJ_EmitSignal:
|
||||
push yl
|
||||
push yh
|
||||
ldd r16, Y+OBJ_OFFS_TARGET_LO
|
||||
ldd r17, Y+OBJ_OFFS_TARGET_HI
|
||||
ldd r19, Y+OBJ_OFFS_IDFORTARGET
|
||||
mov yl, r16
|
||||
mov yh, r17
|
||||
or r16, r17
|
||||
breq OBJ_EmitSignal_end
|
||||
rcall OBJ_Handler
|
||||
OBJ_EmitSignal_end:
|
||||
pop yh
|
||||
pop yl
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
#endif ; AQH_AVR_WIN_OBJECT_H
|
||||
|
||||
@@ -1,770 +0,0 @@
|
||||
; ***************************************************************************
|
||||
; copyright : (C) 2025 by Martin Preuss
|
||||
; email : martin@libchipcard.de
|
||||
;
|
||||
; ***************************************************************************
|
||||
; * This file is part of the project "AqHome". *
|
||||
; * Please see toplevel file COPYING of that project for license details. *
|
||||
; ***************************************************************************
|
||||
|
||||
|
||||
; ***************************************************************************
|
||||
; defs
|
||||
|
||||
.equ WID_WIDGET_INTER_BORDER = 2
|
||||
|
||||
|
||||
|
||||
; ***************************************************************************
|
||||
; code
|
||||
|
||||
.cseg
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine WID_Widget_new @global
|
||||
;
|
||||
; @param Y pointer to window SRAM
|
||||
; @param X pointer to parent
|
||||
; @param r18 WID_OFFS_OPTIONS1
|
||||
; @param r19 WID_OFFS_OPTIONS2
|
||||
|
||||
WID_Widget_Init:
|
||||
push r18
|
||||
push r19
|
||||
push xl
|
||||
push xh
|
||||
ldi zl, LOW(WID_Widget_Handler)
|
||||
ldi zh, HIGH(WID_Widget_Handler)
|
||||
clr r17
|
||||
rcall OBJ_Init
|
||||
pop xh
|
||||
pop xl
|
||||
pop r19
|
||||
pop r18
|
||||
std Y+WID_OFFS_OPTIONS1, r18
|
||||
std Y+WID_OFFS_OPTIONS2, r19
|
||||
mov r16, xl
|
||||
or r16, xh
|
||||
breq WID_Widget_noParent
|
||||
; copy defaults from parent
|
||||
adiw xh:xl, WID_OFFS_BG_COL_LO
|
||||
ld r16, X+ ; WID_OFFS_BG_COL_LO
|
||||
std Y+WID_OFFS_BG_COL_LO, r16
|
||||
ld r16, X+ ; WID_OFFS_BG_COL_HI
|
||||
std Y+WID_OFFS_BG_COL_HI, r16
|
||||
ld r16, X+ ; WID_OFFS_FG_COL_LO
|
||||
std Y+WID_OFFS_FG_COL_LO, r16
|
||||
ld r16, X+ ; WID_OFFS_FG_COL_HI
|
||||
std Y+WID_OFFS_FG_COL_HI, r16
|
||||
ld r16, X+ ; WID_OFFS_FONT_LO
|
||||
std Y+WID_OFFS_FONT_LO, r16
|
||||
ld r16, X+ ; WID_OFFS_FONT_HI
|
||||
std Y+WID_OFFS_FONT_HI, r16
|
||||
rjmp WID_Widget_end
|
||||
WID_Widget_noParent: ; preset without parent
|
||||
clr r16
|
||||
std Y+WID_OFFS_FONT_LO, r16
|
||||
std Y+WID_OFFS_FONT_HI, r16
|
||||
|
||||
std Y+WID_OFFS_FG_COL_LO, r16 ; foreground black
|
||||
std Y+WID_OFFS_FG_COL_HI, r16
|
||||
dec r16
|
||||
std Y+WID_OFFS_BG_COL_LO, r16 ; background white
|
||||
std Y+WID_OFFS_BG_COL_HI, r16
|
||||
|
||||
ldi r16, 2 ; default borders
|
||||
std Y+WID_OFFS_BORDER_TOP, r16
|
||||
std Y+WID_OFFS_BORDER_BOT, r16
|
||||
std Y+WID_OFFS_BORDER_LEFT, r16
|
||||
std Y+WID_OFFS_BORDER_RIGHT, r16
|
||||
WID_Widget_end:
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine WID_Widget_Handler
|
||||
;
|
||||
; Signal handler for an object. A signal can have up to 3 parameters
|
||||
; conveyed in registers R18, R19 and X.
|
||||
;
|
||||
; @param Y pointer to object SRAM
|
||||
; @param r16 signal
|
||||
; @param R18 1st param
|
||||
; @param R19 2nd param
|
||||
; @param X 3rd param
|
||||
; @clobbers any, !Y
|
||||
|
||||
WID_Widget_Handler:
|
||||
cpi r16, WID_SIGNAL_GETMINWIDTH
|
||||
breq WID_Widget_Handler_getMinWidth
|
||||
cpi r16, WID_SIGNAL_GETMINHEIGHT
|
||||
breq WID_Widget_Handler_getMinHeight
|
||||
cpi r16, WID_SIGNAL_LAYOUT
|
||||
breq WID_Widget_Handler_layout
|
||||
cpi r16, WID_SIGNAL_DRAW
|
||||
breq WID_Widget_Handler_draw
|
||||
; for now just forward signal to all children
|
||||
WID_Widget_Handler_forward:
|
||||
rcall OBJ_ForwardSignalToChildren
|
||||
ret
|
||||
WID_Widget_Handler_getMinWidth:
|
||||
rjmp widgetGetMinWidth
|
||||
WID_Widget_Handler_getMinHeight:
|
||||
rjmp widgetGetMinHeight
|
||||
WID_Widget_Handler_layout:
|
||||
rjmp widgetLayout
|
||||
WID_Widget_Handler_draw:
|
||||
rjmp wDraw
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
|
||||
wDraw:
|
||||
ldd r16, Y+OBJ_OFFS_OPTIONS
|
||||
sbrs r16, WID_OPTIONS0_BIT_VISIBLE ; only draw visible widgets
|
||||
rjmp wDraw_ret
|
||||
cbr r16, (1<<WID_OPTIONS0_BIT_DIRTY)
|
||||
std Y+OBJ_OFFS_OPTIONS, r16
|
||||
|
||||
; fill window background
|
||||
ldd r2, Y+WID_OFFS_BG_COL_LO
|
||||
ldd r3, Y+WID_OFFS_BG_COL_HI
|
||||
ldd r4, Y+WID_OFFS_ABS_X_LO
|
||||
ldd r5, Y+WID_OFFS_ABS_X_HI
|
||||
ldd r6, Y+WID_OFFS_ABS_Y_LO
|
||||
ldd r7, Y+WID_OFFS_ABS_Y_HI
|
||||
ldd r8, Y+WID_OFFS_WIDTH_LO
|
||||
ldd r9, Y+WID_OFFS_WIDTH_HI
|
||||
ldd r10, Y+WID_OFFS_HEIGHT_LO
|
||||
ldd r11, Y+WID_OFFS_HEIGHT_HI
|
||||
bigcall ILI9341_FillRect
|
||||
wDraw_ret:
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
|
||||
widgetLayout:
|
||||
rjmp wVLayout
|
||||
|
||||
|
||||
|
||||
wVLayout:
|
||||
rcall wSetChildrenWidthsFromMinWidths
|
||||
rcall wSetChildrenHeightsFromMinHeights
|
||||
|
||||
; count number of expandable children
|
||||
ldi r16, (1<<WID_OPTIONS1_BIT_STRETCH_Y) ; value
|
||||
ldi r17, (1<<WID_OPTIONS1_BIT_STRETCH_Y) ; mask
|
||||
rcall widgetCountVisibleChildrenWithOptions1 ; r18=number of matching visible children (r24, r25, X)
|
||||
tst r18
|
||||
breq wVLayout_Ydone ; no expandable children, nothing to distribute
|
||||
; determine full height needed by all children
|
||||
push r18 ; number of visible expandable child widgets
|
||||
clr r17 ; mask=0 -> count all visible children
|
||||
rcall wGetSumOfMatchingVisibleChildrenHeights ; r19:r18=sum of all children heights
|
||||
pop r22
|
||||
clr r23 ; r23:r22=number of visible expandable children
|
||||
; calculate number of bytes to add to each expandable child widget
|
||||
ldd r20, Y+WID_OFFS_HEIGHT_LO ; total height
|
||||
ldd r21, Y+WID_OFFS_HEIGHT_HI
|
||||
clr r16
|
||||
ldd r17, Y+WID_OFFS_BORDER_TOP ; subtract top border
|
||||
sub r20, r17
|
||||
sbc r21, r16
|
||||
brcs wVLayout_heightTooSmall ; jmp if too small
|
||||
ldd r17, Y+WID_OFFS_BORDER_BOT ; subtract bottom border
|
||||
sub r20, r17
|
||||
sbc r21, r16
|
||||
brcs wVLayout_heightTooSmall ; jmp if too small
|
||||
|
||||
sub r20, r18 ; r21:r20 = HEIGHT-SUM_OF_VIS_CHILDREN_HEIGHTS
|
||||
sbc r21, r19
|
||||
brcc wVLayout_heightTooSmall
|
||||
breq wVLayout_yDone ; nothing to distribute
|
||||
bigcall Utils_Divu16_16_16 ; r17:r16 = r21:r20 / r23:r22
|
||||
; add additional pixel to heights of expandable child widgets
|
||||
rcall wAddToHeightsOfExpandableVisibleChildren
|
||||
|
||||
wVLayout_yDone:
|
||||
rcall wSetRelYFromHeightInVisibleChildren
|
||||
rcall wAlignChildrenHorizontally
|
||||
; rcall wSetAbsoluteCoords call in GUI loop after calling layout on all widgets
|
||||
wVLayout_heightTooSmall:
|
||||
; TODO: how to handle this case?
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
wSetAbsoluteCoords:
|
||||
push yl
|
||||
push yh
|
||||
wSetAbsoluteCoords_loop:
|
||||
ldd r18, Y+OBJ_OFFS_OPTIONS
|
||||
andi r18, WID_OPTIONS0_BIT_VISIBLE
|
||||
breq wSetAbsoluteCoords_nextSibling
|
||||
push yl
|
||||
push yh
|
||||
bigcall Tree_GetParentObject
|
||||
clr r18
|
||||
clr r19
|
||||
clr r20
|
||||
clr r21
|
||||
mov r17, xl
|
||||
or r17, xh
|
||||
breq wSetAbsoluteCoords_r1820set
|
||||
mov yl, xl
|
||||
mov yh, xh
|
||||
ldd r18, Y+WID_OFFS_ABS_X_LO
|
||||
ldd r19, Y+WID_OFFS_ABS_X_HI
|
||||
ldd r20, Y+WID_OFFS_ABS_Y_LO
|
||||
ldd r21, Y+WID_OFFS_ABS_Y_HI
|
||||
wSetAbsoluteCoords_r1820set:
|
||||
pop yh
|
||||
pop yl
|
||||
; handle X
|
||||
ldd r16, Y+WID_OFFS_REL_X_LO
|
||||
ldd r17, Y+WID_OFFS_REL_X_HI
|
||||
add r16, r18
|
||||
adc r17, r19
|
||||
std Y+WID_OFFS_ABS_X_LO, r16
|
||||
std Y+WID_OFFS_ABS_X_HI, r17
|
||||
; handle Y
|
||||
ldd r16, Y+WID_OFFS_REL_Y_LO
|
||||
ldd r17, Y+WID_OFFS_REL_Y_HI
|
||||
add r16, r20
|
||||
adc r17, r21
|
||||
std Y+WID_OFFS_ABS_Y_LO, r16
|
||||
std Y+WID_OFFS_ABS_Y_HI, r17
|
||||
bigcall Tree_GetObjectBelow
|
||||
rjmp wSetAbsoluteCoords_loopEnd
|
||||
wSetAbsoluteCoords_nextSibling:
|
||||
bigcall Tree_GetNextSibling
|
||||
wSetAbsoluteCoords_loopEnd:
|
||||
mov r17, xl
|
||||
or r17, xh
|
||||
breq wSetAbsoluteCoords_end
|
||||
mov yl, xl
|
||||
mov yh, xh
|
||||
rjmp wSetAbsoluteCoords_loop
|
||||
wSetAbsoluteCoords_end:
|
||||
pop yh
|
||||
pop yl
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine wAlignChildrenHorizontally
|
||||
;
|
||||
; Horizontally align children within the width of the parent widget.
|
||||
; Only changes Y+WID_OFFS_REL_X_LO/HI.
|
||||
;
|
||||
; @param Y pointer to object SRAM
|
||||
; @clobbers r16, r17, r18, r19, r24, r25
|
||||
|
||||
wAlignChildrenHorizontally:
|
||||
push yl
|
||||
push yh
|
||||
ldd r24, Y+WID_OFFS_WIDTH_LO ; parent width
|
||||
ldd r25, Y+WID_OFFS_WIDTH_HI
|
||||
ldd r19, Y+WID_OFFS_BORDER_LEFT ; subtract left border
|
||||
mov r16, r19
|
||||
clr r17
|
||||
sub r24, r16
|
||||
sbc r25, r17
|
||||
ldd r16, Y+WID_OFFS_BORDER_RIGHT ; subtract right border
|
||||
sub r24, r16
|
||||
sbc r25, r17 ; r25:r24=parent width minus lateral borders, r19=left border
|
||||
rcall Tree_GetFirstChildObject ; (none)
|
||||
wAlignChildrenHorizontally_loop:
|
||||
mov r17, xl
|
||||
or r17, xh
|
||||
breq wAlignChildrenHorizontally_loopEnd
|
||||
mov yl, xl
|
||||
mov yh, yl
|
||||
ldd r18, Y+OBJ_OFFS_OPTIONS
|
||||
andi r18, WID_OPTIONS0_BIT_VISIBLE
|
||||
breq wAlignChildrenHorizontally_loopNext
|
||||
push r24
|
||||
push r25
|
||||
push r19
|
||||
rcall wAlignHorizontally
|
||||
pop r19
|
||||
add r24, r19
|
||||
adc r25, r19
|
||||
sub r25, r19
|
||||
std Y+WID_OFFS_REL_X_LO, r24
|
||||
std Y+WID_OFFS_REL_X_HI, r25
|
||||
pop r25
|
||||
pop r24
|
||||
wAlignChildrenHorizontally_loopNext:
|
||||
rcall Tree_GetNextSibling ; (none)
|
||||
rjmp wAlignChildrenHorizontally_loop
|
||||
wAlignChildrenHorizontally_loopEnd:
|
||||
pop yh
|
||||
pop yl
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine wAlignHorizontally
|
||||
;
|
||||
; @param r25:r24 parent width minus lateral borders
|
||||
; @return r25:r24 proposed X position relative to parent
|
||||
; @clobbers r16, r17
|
||||
|
||||
wAlignHorizontally:
|
||||
ldd r16, Y+WID_OFFS_OPTIONS1
|
||||
sbrc r16, WID_OPTIONS1_BIT_STRETCH_X
|
||||
rjmp wAlignHorizontally_stretch
|
||||
andi r16, (WID_OPTIONS1_BIT_HALIGN0 | WID_OPTIONS1_BIT_HALIGN1)
|
||||
cpi r16, (0<<WID_OPTIONS1_BIT_HALIGN1) | (0<<WID_OPTIONS1_BIT_HALIGN0)
|
||||
breq wAlignHorizontally_left
|
||||
cpi r16, (0<<WID_OPTIONS1_BIT_HALIGN1) | (1<<WID_OPTIONS1_BIT_HALIGN0)
|
||||
breq wAlignHorizontally_right
|
||||
wAlignHorizontally_center:
|
||||
ldd r16, Y+WID_OFFS_WIDTH_LO
|
||||
ldd r17, Y+WID_OFFS_WIDTH_HI
|
||||
sub r24, r16
|
||||
sbc r25, r17
|
||||
lsr r25
|
||||
ror r24
|
||||
ret
|
||||
wAlignHorizontally_left:
|
||||
clr r24
|
||||
clr r25
|
||||
ret
|
||||
wAlignHorizontally_right:
|
||||
ldd r16, Y+WID_OFFS_WIDTH_LO
|
||||
ldd r17, Y+WID_OFFS_WIDTH_HI
|
||||
sub r24, r16
|
||||
sbc r25, r17
|
||||
wAlignHorizontally_stretch:
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine wSetRelYFromHeightInVisibleChildren
|
||||
;
|
||||
; @param Y pointer to object SRAM
|
||||
; @clobbers r17, r18, r19, r24, r25, X
|
||||
|
||||
wSetRelYFromHeightInVisibleChildren:
|
||||
push yl
|
||||
push yh
|
||||
ldd r24, Y+WID_OFFS_BORDER_TOP
|
||||
clr r25
|
||||
rcall Tree_GetFirstChildObject ; (none)
|
||||
wSetRelYFromHeightInVisibleChildren_loop:
|
||||
mov r17, xl
|
||||
or r17, xh
|
||||
breq wSetRelYFromHeightInVisibleChildren_loopEnd
|
||||
mov yl, xl
|
||||
mov yh, yl
|
||||
ldd r18, Y+OBJ_OFFS_OPTIONS
|
||||
andi r18, WID_OPTIONS0_BIT_VISIBLE
|
||||
breq wSetRelYFromHeightInVisibleChildren_loopNext
|
||||
std Y+WID_OFFS_REL_Y_LO, r24
|
||||
std Y+WID_OFFS_REL_Y_HI, r25
|
||||
ldd r18, Y+WID_OFFS_WIDTH_LO
|
||||
ldd r19, Y+WID_OFFS_WIDTH_HI
|
||||
add r24, r18 ; TODO: handle carry later
|
||||
adc r25, r19
|
||||
adiw r25:r24, WID_WIDGET_INTER_BORDER
|
||||
wSetRelYFromHeightInVisibleChildren_loopNext:
|
||||
rcall Tree_GetNextSibling ; (none)
|
||||
rjmp wSetRelYFromHeightInVisibleChildren_loop
|
||||
wSetRelYFromHeightInVisibleChildren_loopEnd:
|
||||
mov r18, r24
|
||||
mov r19, r25
|
||||
pop yh
|
||||
pop yl
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine widgetGetMinWidth
|
||||
;
|
||||
; @return r19:r18 minimum width of widget
|
||||
; @clobbers any, !Y
|
||||
|
||||
widgetGetMinWidth:
|
||||
ldi r16, WID_SIGNAL_GETMINWIDTH
|
||||
rjmp widgetGetLargestChildMinSize
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine widgetGetMinHeight
|
||||
;
|
||||
; @return r19:r18 minimum height of widget
|
||||
; @clobbers any, !Y
|
||||
|
||||
widgetGetMinHeight:
|
||||
ldi r16, WID_SIGNAL_GETMINHEIGHT
|
||||
rjmp widgetSumOfChildrenMinSize
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine widgetSumOfChildrenMinSize
|
||||
;
|
||||
; @param r16 signal to send (WID_SIGNAL_GETMINWIDTH, WID_SIGNAL_GETMINHEIGHT)
|
||||
; @return r19:r18 minimum width or height of widget
|
||||
; @clobbers any, !Y
|
||||
|
||||
widgetSumOfChildrenMinSize:
|
||||
push yl
|
||||
push yh
|
||||
rcall Tree_GetFirstChildObject ; (none)
|
||||
clr r24
|
||||
clr r25
|
||||
widgetSumOfChildrenMinSize_loop:
|
||||
mov r17, xl
|
||||
or r17, xh
|
||||
breq widgetSumOfChildrenMinSize_loopEnd
|
||||
mov yl, xl
|
||||
mov yh, yl
|
||||
ldd r18, Y+OBJ_OFFS_OPTIONS
|
||||
andi r18, WID_OPTIONS0_BIT_VISIBLE
|
||||
breq widgetSumOfChildrenMinSize_loopNext
|
||||
push r16
|
||||
push r24
|
||||
push r25
|
||||
ldi r18, 1 ; default value for when the signal is not handled
|
||||
ldi r19, 0 ; default value for when the signal is not handled
|
||||
rcall OBJ_Handler ; ask child for its minimum size
|
||||
pop r25
|
||||
pop r24
|
||||
pop r16
|
||||
add r24, r18 ; TODO: handle carry later
|
||||
adc r25, r19
|
||||
adiw r25:r24, WID_WIDGET_INTER_BORDER
|
||||
widgetSumOfChildrenMinSize_loopNext:
|
||||
rcall Tree_GetNextSibling ; (none)
|
||||
rjmp widgetSumOfChildrenMinSize_loop
|
||||
widgetSumOfChildrenMinSize_loopEnd:
|
||||
mov r18, r24
|
||||
mov r19, r25
|
||||
pop yh
|
||||
pop yl
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine widgetGetLargestChildMinSize
|
||||
;
|
||||
; @param r16 signal to send (WID_SIGNAL_GETMINWIDTH, WID_SIGNAL_GETMINHEIGHT)
|
||||
; @return r19:r18 minimum width or height of widget
|
||||
; @clobbers any, !Y
|
||||
|
||||
widgetGetLargestChildMinSize:
|
||||
push yl
|
||||
push yh
|
||||
rcall Tree_GetFirstChildObject ; (none)
|
||||
clr r24
|
||||
clr r25
|
||||
widgetGetLargestChildMinSize_loop:
|
||||
mov r17, xl
|
||||
or r17, xh
|
||||
breq widgetGetLargestChildMinSize_loopEnd
|
||||
mov yl, xl
|
||||
mov yh, yl
|
||||
ldd r18, Y+OBJ_OFFS_OPTIONS
|
||||
andi r18, WID_OPTIONS0_BIT_VISIBLE
|
||||
breq widgetGetLargestChildMinSize_loopNext
|
||||
push r16
|
||||
push r24
|
||||
push r25
|
||||
ldi r18, 1 ; default value for when the signal is not handled
|
||||
ldi r19, 0 ; default value for when the signal is not handled
|
||||
rcall OBJ_Handler ; ask child for its minimum size
|
||||
pop r25
|
||||
pop r24
|
||||
pop r16
|
||||
sub r24, r18
|
||||
sbc r25, r19
|
||||
add r24, r18
|
||||
adc r25, r19
|
||||
brcc widgetGetLargestChildMinSize_loopNext
|
||||
mov r24, r18
|
||||
mov r25, r19
|
||||
widgetGetLargestChildMinSize_loopNext:
|
||||
rcall Tree_GetNextSibling ; (none)
|
||||
rjmp widgetGetLargestChildMinSize_loop
|
||||
widgetGetLargestChildMinSize_loopEnd:
|
||||
mov r18, r24
|
||||
mov r19, r25
|
||||
pop yh
|
||||
pop yl
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine widgetCountVisibleChildrenWithOptions1
|
||||
;
|
||||
; Count visible direct children with a matching WID_OFFS_OPTIONS1 field.
|
||||
;
|
||||
; @param r16 option1 value combination wanted
|
||||
; @param r17 option1 mask of bits to match
|
||||
; @return r18 number of matching direct children
|
||||
; @clobbers r18, r24, r25, X
|
||||
|
||||
widgetCountVisibleChildrenWithOptions1:
|
||||
push yl
|
||||
push yh
|
||||
rcall Tree_GetFirstChildObject ; (none)
|
||||
clr r24
|
||||
widgetCountVisibleChildrenWithOptions1_loop:
|
||||
mov r25, xl
|
||||
or r25, xh
|
||||
breq widgetCountVisibleChildrenWithOptions1_loopEnd
|
||||
mov yl, xl
|
||||
mov yh, yl
|
||||
ldd r18, Y+OBJ_OFFS_OPTIONS
|
||||
andi r18, WID_OPTIONS0_BIT_VISIBLE
|
||||
breq widgetCountVisibleChildrenWithOptions1_next
|
||||
ldd r18, Y+WID_OFFS_OPTIONS1
|
||||
eor r18, r17
|
||||
and r18, r16
|
||||
brne widgetCountVisibleChildrenWithOptions1_next
|
||||
inc r24
|
||||
widgetCountVisibleChildrenWithOptions1_next:
|
||||
rcall Tree_GetNextSibling ; (none)
|
||||
rjmp widgetSumOfChildrenMinSize_loop
|
||||
widgetCountVisibleChildrenWithOptions1_loopEnd:
|
||||
mov r18, r24
|
||||
pop yh
|
||||
pop yl
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine wGetSumOfMatchingVisibleChildrenHeights
|
||||
;
|
||||
; Add heights of all matching visible children.
|
||||
;
|
||||
; @param r16 option1 value combination wanted
|
||||
; @param r17 option1 mask of bits to match
|
||||
; @return r19:r18 sum of widths of all visible direct children
|
||||
; @clobbers r24, r25, X
|
||||
|
||||
wGetSumOfMatchingVisibleChildrenHeights:
|
||||
push yl
|
||||
push yh
|
||||
rcall Tree_GetFirstChildObject ; (none)
|
||||
clr r24
|
||||
clr r25
|
||||
wGetSumOfMatchingVisibleChildrenHeights_loop:
|
||||
mov r18, xl
|
||||
or r18, xh
|
||||
breq wGetSumOfMatchingVisibleChildrenHeights_loopEnd
|
||||
mov yl, xl
|
||||
mov yh, yl
|
||||
ldd r18, Y+OBJ_OFFS_OPTIONS
|
||||
andi r18, WID_OPTIONS0_BIT_VISIBLE
|
||||
breq wGetSumOfMatchingVisibleChildrenHeights_next
|
||||
ldd r18, Y+WID_OFFS_OPTIONS1
|
||||
eor r18, r17
|
||||
and r18, r16
|
||||
brne wGetSumOfMatchingVisibleChildrenHeights_next
|
||||
ldd r18, Y+WID_OFFS_HEIGHT_LO
|
||||
ldd r19, Y+WID_OFFS_HEIGHT_HI
|
||||
add r24, r18
|
||||
adc r25, r19
|
||||
wGetSumOfMatchingVisibleChildrenHeights_next:
|
||||
rcall Tree_GetNextSibling ; (none)
|
||||
rjmp wGetSumOfMatchingVisibleChildrenHeights_loop
|
||||
wGetSumOfMatchingVisibleChildrenHeights_loopEnd:
|
||||
mov r18, r24
|
||||
mov r19, r25
|
||||
pop yh
|
||||
pop yl
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine wAddToWidthsOfExpandableVisibleChildren
|
||||
;
|
||||
; @param Y = pointer to widget data in SRAM
|
||||
; @param r17:r16 number to add to the widths of all visible X-expandable children
|
||||
; @clobbers r18, r19, X
|
||||
|
||||
wAddToWidthsOfExpandableVisibleChildren:
|
||||
push yl
|
||||
push yh
|
||||
rcall Tree_GetFirstChildObject ; (none)
|
||||
wAddToWidthsOfExpandableVisibleChildren_loop:
|
||||
mov r18, xl
|
||||
or r18, xh
|
||||
breq wAddToWidthsOfExpandableVisibleChildren_loopEnd
|
||||
mov yl, xl
|
||||
mov yh, yl
|
||||
ldd r18, Y+OBJ_OFFS_OPTIONS
|
||||
andi r18, WID_OPTIONS0_BIT_VISIBLE
|
||||
breq wAddToWidthsOfExpandableVisibleChildren_next
|
||||
ldd r18, Y+WID_OFFS_OPTIONS1
|
||||
andi r18, WID_OPTIONS1_BIT_STRETCH_X
|
||||
breq wAddToWidthsOfExpandableVisibleChildren_next
|
||||
ldd r18, Y+WID_OFFS_WIDTH_LO
|
||||
ldd r19, Y+WID_OFFS_WIDTH_HI
|
||||
add r18, r16
|
||||
adc r19, r17
|
||||
std Y+WID_OFFS_WIDTH_LO, r18
|
||||
std Y+WID_OFFS_WIDTH_HI, r19
|
||||
wAddToWidthsOfExpandableVisibleChildren_next:
|
||||
rcall Tree_GetNextSibling ; (none)
|
||||
rjmp wAddToWidthsOfExpandableVisibleChildren_loop
|
||||
wAddToWidthsOfExpandableVisibleChildren_loopEnd:
|
||||
pop yh
|
||||
pop yl
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine wAddToHeightsOfExpandableVisibleChildren
|
||||
;
|
||||
; @param Y = pointer to widget data in SRAM
|
||||
; @param r17:r16 number to add to the heights of all visible Y-expandable children
|
||||
; @clobbers r18, r19, X
|
||||
|
||||
wAddToHeightsOfExpandableVisibleChildren:
|
||||
push yl
|
||||
push yh
|
||||
rcall Tree_GetFirstChildObject ; (none)
|
||||
wAddToHeightsOfExpandableVisibleChildren_loop:
|
||||
mov r18, xl
|
||||
or r18, xh
|
||||
breq wAddToHeightsOfExpandableVisibleChildren_loopEnd
|
||||
mov yl, xl
|
||||
mov yh, yl
|
||||
ldd r18, Y+OBJ_OFFS_OPTIONS
|
||||
andi r18, WID_OPTIONS0_BIT_VISIBLE
|
||||
breq wAddToHeightsOfExpandableVisibleChildren_next
|
||||
ldd r18, Y+WID_OFFS_OPTIONS1
|
||||
andi r18, WID_OPTIONS1_BIT_STRETCH_Y
|
||||
breq wAddToHeightsOfExpandableVisibleChildren_next
|
||||
ldd r18, Y+WID_OFFS_HEIGHT_LO
|
||||
ldd r19, Y+WID_OFFS_HEIGHT_HI
|
||||
add r18, r16
|
||||
adc r19, r17
|
||||
std Y+WID_OFFS_HEIGHT_LO, r18
|
||||
std Y+WID_OFFS_HEIGHT_HI, r19
|
||||
wAddToHeightsOfExpandableVisibleChildren_next:
|
||||
rcall Tree_GetNextSibling ; (none)
|
||||
rjmp wAddToHeightsOfExpandableVisibleChildren_loop
|
||||
wAddToHeightsOfExpandableVisibleChildren_loopEnd:
|
||||
pop yh
|
||||
pop yl
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine wSetChildrenWidthsFromMinWidths
|
||||
;
|
||||
; @clobbers any, !Y
|
||||
|
||||
wSetChildrenWidthsFromMinWidths:
|
||||
push yl
|
||||
push yh
|
||||
rcall Tree_GetFirstChildObject ; (none)
|
||||
wSetChildrenWidthsFromMinWidths_loop:
|
||||
mov r17, xl
|
||||
or r17, xh
|
||||
breq wSetChildrenWidthsFromMinWidths_loopEnd
|
||||
mov yl, xl
|
||||
mov yh, yl
|
||||
ldd r18, Y+OBJ_OFFS_OPTIONS
|
||||
sbrs r18, WID_OPTIONS0_BIT_VISIBLE
|
||||
rjmp wSetChildrenWidthsFromMinWidths_loopNext ; jump if not visible
|
||||
sbrc r18, WID_OPTIONS1_BIT_FIXED_WIDTH
|
||||
rjmp wSetChildrenWidthsFromMinWidths_loopNext ; jump if fixed width
|
||||
ldi r16, WID_SIGNAL_GETMINWIDTH
|
||||
ldi r18, 1 ; default value for when the signal is not handled
|
||||
ldi r19, 0 ; default value for when the signal is not handled
|
||||
rcall OBJ_Handler ; ask child for its minimum size
|
||||
std Y+WID_OFFS_WIDTH_LO, r18
|
||||
std Y+WID_OFFS_WIDTH_HI, r19
|
||||
wSetChildrenWidthsFromMinWidths_loopNext:
|
||||
rcall Tree_GetNextSibling ; (none)
|
||||
rjmp wSetChildrenWidthsFromMinWidths_loop
|
||||
wSetChildrenWidthsFromMinWidths_loopEnd:
|
||||
pop yh
|
||||
pop yl
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine wSetChildrenHeightsFromMinHeights
|
||||
;
|
||||
; @clobbers any, !Y
|
||||
|
||||
wSetChildrenHeightsFromMinHeights:
|
||||
push yl
|
||||
push yh
|
||||
rcall Tree_GetFirstChildObject ; (none)
|
||||
wSetChildrenHeightsFromMinHeights_loop:
|
||||
mov r17, xl
|
||||
or r17, xh
|
||||
breq wSetChildrenHeightsFromMinHeights_loopEnd
|
||||
mov yl, xl
|
||||
mov yh, yl
|
||||
ldd r18, Y+OBJ_OFFS_OPTIONS
|
||||
sbrs r18, WID_OPTIONS0_BIT_VISIBLE
|
||||
rjmp wSetChildrenHeightsFromMinHeights_loopNext ; jump if not visible
|
||||
sbrc r18, WID_OPTIONS1_BIT_FIXED_HEIGHT
|
||||
rjmp wSetChildrenHeightsFromMinHeights_loopNext ; jump if fixed height
|
||||
ldi r16, WID_SIGNAL_GETMINHEIGHT
|
||||
ldi r18, 1 ; default value for when the signal is not handled
|
||||
ldi r19, 0 ; default value for when the signal is not handled
|
||||
rcall OBJ_Handler ; ask child for its minimum size
|
||||
std Y+WID_OFFS_HEIGHT_LO, r18
|
||||
std Y+WID_OFFS_HEIGHT_HI, r19
|
||||
wSetChildrenHeightsFromMinHeights_loopNext:
|
||||
rcall Tree_GetNextSibling ; (none)
|
||||
rjmp wSetChildrenHeightsFromMinHeights_loop
|
||||
wSetChildrenHeightsFromMinHeights_loopEnd:
|
||||
pop yh
|
||||
pop yl
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,234 +0,0 @@
|
||||
; ***************************************************************************
|
||||
; copyright : (C) 2025 by Martin Preuss
|
||||
; email : martin@libchipcard.de
|
||||
;
|
||||
; ***************************************************************************
|
||||
; * This file is part of the project "AqHome". *
|
||||
; * Please see toplevel file COPYING of that project for license details. *
|
||||
; ***************************************************************************
|
||||
|
||||
#ifndef AQH_AVR_WIN_WIDGET_H
|
||||
#define AQH_AVR_WIN_WIDGET_H
|
||||
|
||||
|
||||
|
||||
; ***************************************************************************
|
||||
; defs
|
||||
|
||||
|
||||
|
||||
; ***************************************************************************
|
||||
; code
|
||||
|
||||
.cseg
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine Widget_Init @global
|
||||
;
|
||||
; @param Y pointer to window SRAM
|
||||
; @param X pointer to parent
|
||||
; @param r18 OBJ options
|
||||
; @param r19 WID_OFFS_OPTIONS1
|
||||
; @param r20 WID_OFFS_OPTIONS2
|
||||
; @clobbers r16, r17, X, Z
|
||||
|
||||
Widget_Init:
|
||||
push r19
|
||||
push r20
|
||||
push xl
|
||||
push xh
|
||||
ldi zl, LOW(Widget_Handler) ; handler
|
||||
ldi zh, HIGH(Widget_Handler)
|
||||
rcall OBJ_Init ; (r16, r17, X)
|
||||
pop xh
|
||||
pop xl
|
||||
pop r20
|
||||
pop r19
|
||||
|
||||
; store options
|
||||
std Y+WID_OFFS_OPTIONS1, r19
|
||||
std Y+WID_OFFS_OPTIONS2, r20
|
||||
|
||||
; set basic handler
|
||||
ldi zl, LOW(Widget_Handler) ; handler
|
||||
ldi zh, HIGH(Widget_Handler)
|
||||
rcall OBJ_SetHandler
|
||||
|
||||
mov r16, xl
|
||||
or r16, xh
|
||||
breq Widget_noParent
|
||||
|
||||
; copy defaults from parent
|
||||
adiw xh:xl, WID_OFFS_BG_COL_LO
|
||||
ld r16, X+ ; WID_OFFS_BG_COL_LO
|
||||
std Y+WID_OFFS_BG_COL_LO, r16
|
||||
ld r16, X+ ; WID_OFFS_BG_COL_HI
|
||||
std Y+WID_OFFS_BG_COL_HI, r16
|
||||
ld r16, X+ ; WID_OFFS_FG_COL_LO
|
||||
std Y+WID_OFFS_FG_COL_LO, r16
|
||||
ld r16, X+ ; WID_OFFS_FG_COL_HI
|
||||
std Y+WID_OFFS_FG_COL_HI, r16
|
||||
ld r16, X+ ; WID_OFFS_FONT_LO
|
||||
std Y+WID_OFFS_FONT_LO, r16
|
||||
ld r16, X+ ; WID_OFFS_FONT_HI
|
||||
std Y+WID_OFFS_FONT_HI, r16
|
||||
rjmp Widget_end
|
||||
|
||||
Widget_noParent: ; preset without parent
|
||||
clr r16
|
||||
std Y+WID_OFFS_FONT_LO, r16
|
||||
std Y+WID_OFFS_FONT_HI, r16
|
||||
|
||||
std Y+WID_OFFS_FG_COL_LO, r16 ; foreground black
|
||||
std Y+WID_OFFS_FG_COL_HI, r16
|
||||
dec r16
|
||||
std Y+WID_OFFS_BG_COL_LO, r16 ; background white
|
||||
std Y+WID_OFFS_BG_COL_HI, r16
|
||||
|
||||
ldi r16, 2 ; default borders
|
||||
std Y+WID_OFFS_BORDER_TOP, r16
|
||||
std Y+WID_OFFS_BORDER_BOT, r16
|
||||
std Y+WID_OFFS_BORDER_LEFT, r16
|
||||
std Y+WID_OFFS_BORDER_RIGHT, r16
|
||||
Widget_end:
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine Widget_Handler @global
|
||||
;
|
||||
; Signal handler for an object. A signal can have up to 3 parameters
|
||||
; conveyed in registers R18, R19 and X.
|
||||
;
|
||||
; @param Y pointer to object SRAM
|
||||
; @param r18 signal
|
||||
; @param r19 srcIdForTarget
|
||||
; @param R20 1st param
|
||||
; @param R21 2nd param
|
||||
; @param X 3rd param
|
||||
; @clobbers any, !Y
|
||||
|
||||
Widget_Handler:
|
||||
cpi r18, OBJ_SIGNAL_DESTROY
|
||||
breq Widget_Handler_destroy
|
||||
cpi r18, WID_SIGNAL_DRAW
|
||||
breq Widget_Handler_draw
|
||||
clc
|
||||
rjmp Widget_Handler_ret
|
||||
Widget_Handler_destroy:
|
||||
; nothing to do here (for HEAP objects we would call Heap_Free)
|
||||
rjmp Widget_Handler_secRet
|
||||
Widget_Handler_draw:
|
||||
rcall Widget_Draw
|
||||
Widget_Handler_secRet:
|
||||
sec
|
||||
Widget_Handler_ret:
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine Widget_Draw @global
|
||||
;
|
||||
; @param Y pointer to object SRAM
|
||||
; @clobbers
|
||||
|
||||
Widget_Draw:
|
||||
ldd r16, Y+OBJ_OFFS_OPTIONS
|
||||
sbrs r16, WID_OPTIONS0_BIT_VISIBLE ; only draw visible widgets
|
||||
rjmp widgetDraw_ret
|
||||
cbr r16, (1<<WID_OPTIONS0_BIT_DIRTY)
|
||||
std Y+OBJ_OFFS_OPTIONS, r16
|
||||
|
||||
; fill window background
|
||||
ldd r2, Y+WID_OFFS_BG_COL_LO
|
||||
ldd r3, Y+WID_OFFS_BG_COL_HI
|
||||
ldd r4, Y+WID_OFFS_ABS_X_LO
|
||||
ldd r5, Y+WID_OFFS_ABS_X_HI
|
||||
ldd r6, Y+WID_OFFS_ABS_Y_LO
|
||||
ldd r7, Y+WID_OFFS_ABS_Y_HI
|
||||
ldd r8, Y+WID_OFFS_WIDTH_LO
|
||||
ldd r9, Y+WID_OFFS_WIDTH_HI
|
||||
ldd r10, Y+WID_OFFS_HEIGHT_LO
|
||||
ldd r11, Y+WID_OFFS_HEIGHT_HI
|
||||
bigcall Display_FillRect
|
||||
widgetDraw_ret:
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine Widget_SetAbsoluteCoords @global
|
||||
;
|
||||
|
||||
Widget_SetAbsoluteCoords:
|
||||
push yl
|
||||
push yh
|
||||
Widget_SetAbsoluteCoords_loop:
|
||||
ldd r18, Y+OBJ_OFFS_OPTIONS
|
||||
andi r18, WID_OPTIONS0_BIT_VISIBLE
|
||||
breq Widget_SetAbsoluteCoords_nextSibling
|
||||
push yl
|
||||
push yh
|
||||
bigcall Tree_GetParentObject
|
||||
clr r18
|
||||
clr r19
|
||||
clr r20
|
||||
clr r21
|
||||
mov r17, xl
|
||||
or r17, xh
|
||||
breq Widget_SetAbsoluteCoords_r1820set
|
||||
mov yl, xl
|
||||
mov yh, xh
|
||||
ldd r18, Y+WID_OFFS_ABS_X_LO
|
||||
ldd r19, Y+WID_OFFS_ABS_X_HI
|
||||
ldd r20, Y+WID_OFFS_ABS_Y_LO
|
||||
ldd r21, Y+WID_OFFS_ABS_Y_HI
|
||||
Widget_SetAbsoluteCoords_r1820set:
|
||||
pop yh
|
||||
pop yl
|
||||
; handle X
|
||||
ldd r16, Y+WID_OFFS_REL_X_LO
|
||||
ldd r17, Y+WID_OFFS_REL_X_HI
|
||||
add r16, r18
|
||||
adc r17, r19
|
||||
std Y+WID_OFFS_ABS_X_LO, r16
|
||||
std Y+WID_OFFS_ABS_X_HI, r17
|
||||
; handle Y
|
||||
ldd r16, Y+WID_OFFS_REL_Y_LO
|
||||
ldd r17, Y+WID_OFFS_REL_Y_HI
|
||||
add r16, r20
|
||||
adc r17, r21
|
||||
std Y+WID_OFFS_ABS_Y_LO, r16
|
||||
std Y+WID_OFFS_ABS_Y_HI, r17
|
||||
bigcall Tree_GetObjectBelow
|
||||
rjmp Widget_SetAbsoluteCoords_loopEnd
|
||||
Widget_SetAbsoluteCoords_nextSibling:
|
||||
bigcall Tree_GetNextSibling
|
||||
Widget_SetAbsoluteCoords_loopEnd:
|
||||
mov r17, xl
|
||||
or r17, xh
|
||||
breq Widget_SetAbsoluteCoords_end
|
||||
mov yl, xl
|
||||
mov yh, xh
|
||||
rjmp Widget_SetAbsoluteCoords_loop
|
||||
Widget_SetAbsoluteCoords_end:
|
||||
pop yh
|
||||
pop yl
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif ; AQH_AVR_WIN_WIDGET_H
|
||||
|
||||
|
||||
Reference in New Issue
Block a user