277 lines
5.9 KiB
NASM
277 lines
5.9 KiB
NASM
; ***************************************************************************
|
|
; copyright : (C) 2026 by Martin Preuss
|
|
; email : martin@libchipcard.de
|
|
;
|
|
; ***************************************************************************
|
|
; * This file is part of the project "AqHome". *
|
|
; * Please see toplevel file COPYING of that project for license details. *
|
|
; ***************************************************************************
|
|
|
|
#ifndef AQH_AVR_GUI2_GUICNTRL_ASM
|
|
#define AQH_AVR_GUI2_GUICNTRL_ASM
|
|
|
|
|
|
; ***************************************************************************
|
|
; defines
|
|
|
|
|
|
|
|
; ***************************************************************************
|
|
; data
|
|
|
|
.dseg
|
|
|
|
guicntl_touch_event:
|
|
.byte WIDGET_DATA_TOUCH_SIZE
|
|
|
|
guicntl_current_app:
|
|
.byte 2
|
|
|
|
|
|
|
|
; ***************************************************************************
|
|
; code
|
|
|
|
.cseg
|
|
|
|
|
|
|
|
|
|
; ---------------------------------------------------------------------------
|
|
; @routine GuiApp_ShowFirstChild @global
|
|
;
|
|
; @param Z byte address of guiapp object (for LPM!)
|
|
|
|
GuiCntrl_ShowFirstApp:
|
|
; select first child (GuiApp) as current app
|
|
bigcall OBJ_GetFirstChild
|
|
mov xl, r18
|
|
mov xh, r19
|
|
or r18, r19
|
|
breq GuiCntrl_ShowFirstApp_ret
|
|
rcall GuiCntlr_ShowApp
|
|
GuiCntrl_ShowFirstApp_ret:
|
|
ret
|
|
; @end
|
|
|
|
|
|
|
|
; ---------------------------------------------------------------------------
|
|
; @routine GuiCntrl_ShowApp @global
|
|
;
|
|
; @param Z byte address of object (for LPM!)
|
|
; @param X byte address of object to raise (for LPM!)
|
|
; @return CFLAG set if signal handled
|
|
; @clobbers any, !Z
|
|
|
|
GuiCntlr_ShowApp:
|
|
lds r18, guicntl_current_app
|
|
lds r19, guicntl_current_app+1
|
|
|
|
cp r18, xl
|
|
brne GuiCntlr_ShowApp_changed
|
|
cp r19, xh
|
|
breq GuiCntlr_ShowApp_secRet ; already current app
|
|
GuiCntlr_ShowApp_changed:
|
|
push zl
|
|
push zh
|
|
push xl
|
|
push xh
|
|
; hide previous app
|
|
mov zl, r18
|
|
mov zh, r19
|
|
or r18, r19
|
|
breq GuiCntlr_ShowApp_l1
|
|
ldi r16, WIDGET_SIGNAL_HIDE
|
|
clr r17
|
|
bigcall OBJ_HandleSignal
|
|
GuiCntlr_ShowApp_l1:
|
|
pop zh
|
|
pop zl
|
|
; show new app
|
|
mov r16, zl
|
|
or r16, zh
|
|
breq GuiCntlr_ShowApp_l2
|
|
ldi r16, WIDGET_SIGNAL_SHOW
|
|
clr r17
|
|
bigcall OBJ_HandleSignal
|
|
GuiCntlr_ShowApp_l2:
|
|
pop zh
|
|
pop zl
|
|
GuiCntlr_ShowApp_secRet:
|
|
sec
|
|
ret
|
|
; @end
|
|
|
|
|
|
|
|
; ---------------------------------------------------------------------------
|
|
; @routine GuiCntrl_Every100ms @global
|
|
;
|
|
; @param Z byte address of guiapp object (for LPM!)
|
|
|
|
GuiCntrl_Every100ms:
|
|
rcall guiCntrlCheckTouch
|
|
rcall guiCntrlSendTimer
|
|
ret
|
|
; @end
|
|
|
|
|
|
|
|
; ---------------------------------------------------------------------------
|
|
; @routine GuiCntrl_Every100ms @global
|
|
;
|
|
; @param Z byte address of guiapp object (for LPM!)
|
|
; @param X ptr to msg received
|
|
|
|
GuiCntrl_MsgReceived:
|
|
push zl
|
|
push zh
|
|
bigcall OBJ_GetFirstChild
|
|
GuiCntrl_MsgReceived_loop:
|
|
mov zl, r18
|
|
mov zh, r19
|
|
or r18, r19
|
|
breq GuiCntrl_MsgReceived_loopEnd
|
|
; let child handle msg signal
|
|
ldi r16, OBJECT_SIGNAL_RECVMSG
|
|
clr r17
|
|
push xl
|
|
push xh
|
|
bigcall OBJ_HandleSignal
|
|
pop xh
|
|
pop xl
|
|
bigcall OBJ_GetNext
|
|
rjmp GuiCntrl_MsgReceived_loop
|
|
GuiCntrl_MsgReceived_loopEnd:
|
|
pop zh
|
|
pop zl
|
|
sec
|
|
ret
|
|
; @end
|
|
|
|
|
|
|
|
; ---------------------------------------------------------------------------
|
|
; @routine guiCntrlCheckTouch
|
|
;
|
|
; @param Z byte address of guiapp object (for LPM!)
|
|
|
|
guiCntrlCheckTouch:
|
|
bigcall Display_InputGetState ; r16=flags, r5:r4=x, r7:r6=y
|
|
mov r17, r16
|
|
andi r17, (1<<DISPLAY_IFLAGS_CHGCOORD_BIT) | (1<<DISPLAY_IFLAGS_CHGPRESS_BIT)
|
|
breq guiCntrlCheckTouch_ret
|
|
ldi xl, LOW(guicntl_touch_event)
|
|
ldi xh, HIGH(guicntl_touch_event)
|
|
st X+, r4 ; X
|
|
st X+, r5
|
|
st X+, r6 ; Y
|
|
st X+, r7
|
|
st X, r16 ; flags
|
|
sbiw xh:xl, 4 ; (4 times incremented)
|
|
push zl
|
|
push zh
|
|
lds zl, guicntl_current_app
|
|
lds zh, guicntl_current_app+1
|
|
mov r16, zl
|
|
or r16, zh
|
|
breq guiCntrlCheckTouch_l1
|
|
ldi r16, WIDGET_SIGNAL_TOUCH
|
|
clr r17
|
|
bigcall OBJ_HandleSignal
|
|
guiCntrlCheckTouch_l1:
|
|
pop zh
|
|
pop zl
|
|
guiCntrlCheckTouch_ret:
|
|
ret
|
|
; @end
|
|
|
|
|
|
|
|
; ---------------------------------------------------------------------------
|
|
; @routine guiCntrlSendTimer
|
|
;
|
|
; @param Z byte address of guiapp object (for LPM!)
|
|
|
|
guiCntrlSendTimer:
|
|
push zl
|
|
push zh
|
|
bigcall OBJ_GetFirstChild
|
|
guiCntrlSendTimer_loop:
|
|
mov zl, r18
|
|
mov zh, r19
|
|
or r18, r19
|
|
breq guiCntrlSendTimer_loopEnd
|
|
; let child handle timer signal
|
|
ldi r16, OBJECT_SIGNAL_TIMER
|
|
clr r17
|
|
bigcall OBJ_HandleSignal
|
|
bigcall OBJ_GetNext
|
|
rjmp guiCntrlSendTimer_loop
|
|
guiCntrlSendTimer_loopEnd:
|
|
pop zh
|
|
pop zl
|
|
ret
|
|
; @end
|
|
|
|
|
|
|
|
; ---------------------------------------------------------------------------
|
|
; @routine GuiApp_Init @global
|
|
;
|
|
; @param Z byte address of guiapp object (for LPM!)
|
|
|
|
GuiCntrl_Init:
|
|
clr r16
|
|
sts guicntl_current_app, r16
|
|
sts guicntl_current_app+1, r16
|
|
ret
|
|
; @end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
; +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
|
; signal handlers (to directly be used in signal maps)
|
|
; +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
|
|
|
|
|
; ---------------------------------------------------------------------------
|
|
; @routine GuiCntrl_OnCreate @global
|
|
;
|
|
; @param Z byte address of object (for LPM!)
|
|
; @return CFLAG set if signal handled
|
|
; @clobbers any, !Z
|
|
|
|
GuiCntlr_OnCreate:
|
|
rcall GuiCntrl_Init
|
|
sec
|
|
ret
|
|
; @end
|
|
|
|
|
|
|
|
; ---------------------------------------------------------------------------
|
|
; @routine GuiCntrl_OnRaise @global
|
|
;
|
|
; @param Z byte address of object (for LPM!)
|
|
; @param X byte address of object to raise (for LPM!)
|
|
; @return CFLAG set if signal handled
|
|
; @clobbers any, !Z
|
|
|
|
GuiCntlr_OnRaise:
|
|
rcall GuiCntlr_ShowApp
|
|
sec
|
|
ret
|
|
; @end
|
|
|
|
|
|
|
|
|
|
|
|
#endif
|
|
|