started working on static gui
This commit is contained in:
16
avr/modules/lcd2/staticgui/0BUILD
Normal file
16
avr/modules/lcd2/staticgui/0BUILD
Normal file
@@ -0,0 +1,16 @@
|
||||
<?xml?>
|
||||
|
||||
<gwbuild>
|
||||
|
||||
<extradist>
|
||||
defs.asm
|
||||
dialog.asm
|
||||
main.asm
|
||||
style.asm
|
||||
titlewindow.asm
|
||||
window.asm
|
||||
</extradist>
|
||||
|
||||
</gwbuild>
|
||||
|
||||
|
||||
13
avr/modules/lcd2/staticgui/TODO
Normal file
13
avr/modules/lcd2/staticgui/TODO
Normal file
@@ -0,0 +1,13 @@
|
||||
|
||||
|
||||
- Screen
|
||||
- functions:
|
||||
- show
|
||||
- unshow
|
||||
- touch
|
||||
- key
|
||||
- activeAreas:
|
||||
- x, y, w, h (in FLASH)
|
||||
- only small variable data in SRAM, no need for heap!
|
||||
|
||||
|
||||
65
avr/modules/lcd2/staticgui/defs.asm
Normal file
65
avr/modules/lcd2/staticgui/defs.asm
Normal file
@@ -0,0 +1,65 @@
|
||||
; ***************************************************************************
|
||||
; 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
|
||||
|
||||
288
avr/modules/lcd2/staticgui/dialog.asm
Normal file
288
avr/modules/lcd2/staticgui/dialog.asm
Normal file
@@ -0,0 +1,288 @@
|
||||
; ***************************************************************************
|
||||
; 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
|
||||
|
||||
27
avr/modules/lcd2/staticgui/main.asm
Normal file
27
avr/modules/lcd2/staticgui/main.asm
Normal file
@@ -0,0 +1,27 @@
|
||||
; ***************************************************************************
|
||||
; 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
|
||||
24
avr/modules/lcd2/staticgui/style.asm
Normal file
24
avr/modules/lcd2/staticgui/style.asm
Normal file
@@ -0,0 +1,24 @@
|
||||
; ***************************************************************************
|
||||
; 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
|
||||
|
||||
158
avr/modules/lcd2/staticgui/titlewindow.asm
Normal file
158
avr/modules/lcd2/staticgui/titlewindow.asm
Normal file
@@ -0,0 +1,158 @@
|
||||
; ***************************************************************************
|
||||
; 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
|
||||
|
||||
512
avr/modules/lcd2/staticgui/window.asm
Normal file
512
avr/modules/lcd2/staticgui/window.asm
Normal file
@@ -0,0 +1,512 @@
|
||||
; ***************************************************************************
|
||||
; 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
|
||||
|
||||
Reference in New Issue
Block a user