more work on dialogs.
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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<<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)
|
||||
|
||||
@@ -109,7 +119,7 @@ DialogMgr_Every100ms_loop:
|
||||
push xh
|
||||
push r17
|
||||
ldi r23, DIALOG_FN_TIMER
|
||||
rcall DialogMgr_CallCurrentHandler
|
||||
rcall DialogMgr_CallHandler
|
||||
pop r17
|
||||
pop xh
|
||||
pop xl
|
||||
@@ -129,6 +139,11 @@ DialogMgr_Every100ms_ret:
|
||||
; @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
|
||||
@@ -186,6 +201,7 @@ DialogMgr_PushDialog:
|
||||
|
||||
DialogMgr_PushDialog_push:
|
||||
lds r16, dialogStackPos
|
||||
mov r17, r16
|
||||
add r17, r17 ; *2
|
||||
push xl
|
||||
push xh
|
||||
@@ -200,10 +216,13 @@ DialogMgr_PushDialog_push:
|
||||
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
|
||||
@@ -273,6 +292,23 @@ DialogMgr_PopDialog_ret:
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @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
|
||||
|
||||
|
||||
@@ -13,6 +13,12 @@
|
||||
|
||||
.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_LIGHTGREY
|
||||
.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 = ili9341Font12x20_1
|
||||
|
||||
@@ -78,6 +78,51 @@ Window_FillRect:
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @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
|
||||
;
|
||||
@@ -103,6 +148,7 @@ Window_DrawTextFlash:
|
||||
; @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)
|
||||
|
||||
@@ -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
|
||||
;
|
||||
|
||||
@@ -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
|
||||
;
|
||||
; @return r19:r18 current Y
|
||||
|
||||
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.
|
||||
; Get current state, clears stored flags DISPLAY_IFLAGS_CHGCOORD_BIT
|
||||
; and DISPLAY_IFLAGS_CHGPRESS_BIT.
|
||||
;
|
||||
; @return r16 flags
|
||||
; @clobbers r17
|
||||
; @return r5:r4 X
|
||||
; @return r7:r6 Y
|
||||
; @clobber r17
|
||||
|
||||
Display_InputGetFlagsResetChg:
|
||||
Display_InputGetState:
|
||||
lds r16, xpt2046Flags
|
||||
mov r17, r16
|
||||
cbr r17, (1<<DISPLAY_IFLAGS_CHGCOORD_BIT) | (1<<DISPLAY_IFLAGS_CHGPRESS_BIT)
|
||||
sts xpt2046Flags, r17
|
||||
lds r4, xpt2046CurrentX
|
||||
lds r5, xpt2046CurrentX+1
|
||||
lds r6, xpt2046CurrentY
|
||||
lds r7, xpt2046CurrentY+1
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user