From fbcfd65e7fb4a82ee6591d280ba14040d895f5fd Mon Sep 17 00:00:00 2001 From: Martin Preuss Date: Mon, 17 Nov 2025 23:01:26 +0100 Subject: [PATCH] more work on dialogs. --- avr/modules/lcd2/gui/defs.asm | 11 ++++++ avr/modules/lcd2/gui/dialog.asm | 44 ++++++++++++++++++++--- avr/modules/lcd2/gui/style.asm | 18 ++++++---- avr/modules/lcd2/gui/window.asm | 48 ++++++++++++++++++++++++- avr/modules/lcd2/ili9341/graphops.asm | 51 +++++++++++++++++++++++++++ avr/modules/lcd2/xpt2046/main.asm | 48 +++++++------------------ 6 files changed, 174 insertions(+), 46 deletions(-) diff --git a/avr/modules/lcd2/gui/defs.asm b/avr/modules/lcd2/gui/defs.asm index bb3347f..201997b 100644 --- a/avr/modules/lcd2/gui/defs.asm +++ b/avr/modules/lcd2/gui/defs.asm @@ -11,6 +11,17 @@ #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 diff --git a/avr/modules/lcd2/gui/dialog.asm b/avr/modules/lcd2/gui/dialog.asm index ba4001c..b9b9d8f 100644 --- a/avr/modules/lcd2/gui/dialog.asm +++ b/avr/modules/lcd2/gui/dialog.asm @@ -31,9 +31,8 @@ .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 +.equ DIALOG_FN_TOUCH = 4 +.equ DIALOG_FN_TIMER = 5 @@ -87,9 +86,20 @@ DialogMgr_Init: ; --------------------------------------------------------------------------- ; @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< 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 ; @@ -102,7 +147,8 @@ Window_DrawTextFlash: ; --------------------------------------------------------------------------- ; @routine Window_DrawColorTextFlash @global ; -; @param Y pointer to screen object in SDRAM +; @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) diff --git a/avr/modules/lcd2/ili9341/graphops.asm b/avr/modules/lcd2/ili9341/graphops.asm index 0bf376c..51dfc85 100644 --- a/avr/modules/lcd2/ili9341/graphops.asm +++ b/avr/modules/lcd2/ili9341/graphops.asm @@ -63,6 +63,57 @@ Display_FillRect_loopW: +; --------------------------------------------------------------------------- +; @routine Display_DrawRect @global +; +; @param r3:r2 color +; @param r5:r4 X0 +; @param r7:r6 Y0 +; @param r9:r8 X1/W +; @param r11:r10 Y1/H + +Display_DrawRect: + push r15 + in r15, SREG + cli + + ; upper H line + rcall Display_DrawHLine + push r6 ; save Y0 + push r7 + add r6, r10 + adc r7, r11 + ldi r16, 1 + sub r6, r16 + sbc r7, r16 + add r7, r16 + ; lower H line + rcall Display_DrawHLine + pop r7 + pop r6 + + ; left H line + rcall Display_DrawVLine + push r4 ; save X0 + push r5 + add r4, r8 + adc r5, r9 + ldi r16, 1 + sub r4, r16 + sbc r5, r16 + add r5, r16 + ; right H line + rcall Display_DrawVLine + pop r5 + pop r4 + + out SREG, r15 + pop r15 + ret +; @end + + + ; --------------------------------------------------------------------------- ; @routine Display_DrawHLine @global ; diff --git a/avr/modules/lcd2/xpt2046/main.asm b/avr/modules/lcd2/xpt2046/main.asm index a1c0867..e8299b0 100644 --- a/avr/modules/lcd2/xpt2046/main.asm +++ b/avr/modules/lcd2/xpt2046/main.asm @@ -16,9 +16,7 @@ ; controllers. ; ; Implements: -; - Display_InputGetFlagsResetChg -; - Display_InputGetCurrentX -; - Display_InputGetCurrentY +; - Display_InputGetState ; Defines: ; - DISPLAY_IFLAGS_PRESSED_BIT ; - DISPLAY_IFLAGS_CHGCOORD_BIT @@ -133,45 +131,25 @@ XPT2046_Every100ms_store: ; --------------------------------------------------------------------------- -; @routine Display_InputGetCurrentX @global +; @routine Display_InputGetState @global ; -; @return r19:r18 current X - -Display_InputGetCurrentX: - lds r18, xpt2046CurrentX - lds r19, xpt2046CurrentX+1 - ret -; @end - - - -; --------------------------------------------------------------------------- -; @routine Display_InputGetCurrentY @global +; Get current state, clears stored flags DISPLAY_IFLAGS_CHGCOORD_BIT +; and DISPLAY_IFLAGS_CHGPRESS_BIT. ; -; @return r19:r18 current Y +; @return r16 flags +; @return r5:r4 X +; @return r7:r6 Y +; @clobber r17 -Display_InputGetCurrentY: - lds r18, xpt2046CurrentY - lds r19, xpt2046CurrentY+1 - ret -; @end - - - -; --------------------------------------------------------------------------- -; @routine Display_InputGetFlagsResetChg @global -; -; Return flags, clear stored flags DISPLAY_IFLAGS_CHGCOORD_BIT and -; DISPLAY_IFLAGS_CHGPRESS_BIT. -; -; @return r16 flags -; @clobbers r17 - -Display_InputGetFlagsResetChg: +Display_InputGetState: lds r16, xpt2046Flags mov r17, r16 cbr r17, (1<