c03, gui2: new GUI now basically works.
This commit is contained in:
384
avr/devices/c03/test/a_c03.asm
Normal file
384
avr/devices/c03/test/a_c03.asm
Normal file
@@ -0,0 +1,384 @@
|
|||||||
|
; ***************************************************************************
|
||||||
|
; 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_A_C03_ASM
|
||||||
|
#define AQH_AVR_A_C03_ASM
|
||||||
|
|
||||||
|
|
||||||
|
; ***************************************************************************
|
||||||
|
; defines
|
||||||
|
|
||||||
|
.equ C03APP_OFFS_BEGIN = GUIAPP_SIZE
|
||||||
|
.equ C03APP_OFFS_WMENU_LO = C03APP_OFFS_BEGIN+0
|
||||||
|
.equ C03APP_OFFS_WMENU_HI = C03APP_OFFS_BEGIN+1
|
||||||
|
.equ C03APP_OFFS_WCLIMATE_LO = C03APP_OFFS_BEGIN+2
|
||||||
|
.equ C03APP_OFFS_WCLIMATE_HI = C03APP_OFFS_BEGIN+3
|
||||||
|
.equ C03APP_OFFS_WLIGHT_LO = C03APP_OFFS_BEGIN+4
|
||||||
|
.equ C03APP_OFFS_WLIGHT_HI = C03APP_OFFS_BEGIN+5
|
||||||
|
.equ C03APP_OFFS_WWINDOWS_LO = C03APP_OFFS_BEGIN+6
|
||||||
|
.equ C03APP_OFFS_WWINDOWS_HI = C03APP_OFFS_BEGIN+7
|
||||||
|
.equ C03APP_OFFS_WDEBUG_LO = C03APP_OFFS_BEGIN+8
|
||||||
|
.equ C03APP_OFFS_WDEBUG_HI = C03APP_OFFS_BEGIN+9
|
||||||
|
.equ C03APP_SIZE = C03APP_OFFS_BEGIN+10
|
||||||
|
|
||||||
|
|
||||||
|
; selectors for main windows
|
||||||
|
.equ C03APP_SEL_BACK = 1
|
||||||
|
.equ C03APP_SEL_MENU = 2
|
||||||
|
.equ C03APP_SEL_CLIMATE = 3
|
||||||
|
.equ C03APP_SEL_LIGHT = 4
|
||||||
|
.equ C03APP_SEL_WINDOWS = 5
|
||||||
|
.equ C03APP_SEL_DEBUG = 6
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
; ***************************************************************************
|
||||||
|
; data
|
||||||
|
|
||||||
|
.dseg
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
; ***************************************************************************
|
||||||
|
; code
|
||||||
|
|
||||||
|
.cseg
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
; ---------------------------------------------------------------------------
|
||||||
|
; @routine C03App_new @global
|
||||||
|
;
|
||||||
|
; @return CFLAG set of okay, cleared otherwise
|
||||||
|
; @return Y address of newly created object
|
||||||
|
; @param r16 value for OBJECT_OFFS_OPTS
|
||||||
|
; @clobbers any
|
||||||
|
|
||||||
|
C03App_new:
|
||||||
|
ldi r24, LOW(C03APP_SIZE)
|
||||||
|
ldi r25, HIGH(C03APP_SIZE)
|
||||||
|
bigcall Object_Alloc ; (!r16, !r17)
|
||||||
|
brcc C03App_new_ret
|
||||||
|
rcall C03App_Init ; (r16, r17, X)
|
||||||
|
sec
|
||||||
|
C03App_new_ret:
|
||||||
|
ret
|
||||||
|
; @end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
; ---------------------------------------------------------------------------
|
||||||
|
; @routine C03App_Init @global
|
||||||
|
;
|
||||||
|
; @param Y address of object in SDRAM
|
||||||
|
; @param r16 value for OBJECT_OFFS_OPTS
|
||||||
|
|
||||||
|
C03App_Init:
|
||||||
|
; call base class
|
||||||
|
bigcall GuiApp_Init ; (r16, r17, X)
|
||||||
|
|
||||||
|
; set default signal map
|
||||||
|
ldi r16, LOW(C03App_DefaultSignalmap*2)
|
||||||
|
std Y+OBJECT_OFFS_SIGNALMAP_LO, r16
|
||||||
|
ldi r16, HIGH(C03App_DefaultSignalmap*2)
|
||||||
|
std Y+OBJECT_OFFS_SIGNALMAP_HI, r16
|
||||||
|
|
||||||
|
; create main windows
|
||||||
|
rcall c03AppCreateWinMenu ; (!Y)
|
||||||
|
rcall c03AppCreateWinClimate ; (!Y)
|
||||||
|
|
||||||
|
; enter menu window
|
||||||
|
rcall C03App_EnterMenuWin
|
||||||
|
sec
|
||||||
|
ret
|
||||||
|
; @end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
; ---------------------------------------------------------------------------
|
||||||
|
; @routine c03AppCreateWinMenu
|
||||||
|
;
|
||||||
|
; @clobbers !X
|
||||||
|
|
||||||
|
c03AppCreateWinMenu:
|
||||||
|
push yl
|
||||||
|
push yh
|
||||||
|
bigcall MenuWin_new
|
||||||
|
mov xl, yl
|
||||||
|
mov xh, yh
|
||||||
|
pop yh
|
||||||
|
pop yl
|
||||||
|
brcc c03AppCreateWinMenu_ret
|
||||||
|
std Y+C03APP_OFFS_WMENU_LO, xl
|
||||||
|
std Y+C03APP_OFFS_WMENU_HI, xh
|
||||||
|
ldi r16, C03APP_SEL_MENU
|
||||||
|
rcall c03AppSetTargetAndSelector
|
||||||
|
sec
|
||||||
|
c03AppCreateWinMenu_ret:
|
||||||
|
ret
|
||||||
|
; @end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
; ---------------------------------------------------------------------------
|
||||||
|
; @routine c03AppCreateWinClimate
|
||||||
|
;
|
||||||
|
; @clobbers !X
|
||||||
|
|
||||||
|
c03AppCreateWinClimate:
|
||||||
|
push yl
|
||||||
|
push yh
|
||||||
|
bigcall ClimateWin_new
|
||||||
|
mov xl, yl
|
||||||
|
mov xh, yh
|
||||||
|
pop yh
|
||||||
|
pop yl
|
||||||
|
brcc c03AppCreateWinClimate_ret
|
||||||
|
std Y+C03APP_OFFS_WCLIMATE_LO, xl
|
||||||
|
std Y+C03APP_OFFS_WCLIMATE_HI, xh
|
||||||
|
ldi r16, C03APP_SEL_CLIMATE
|
||||||
|
rcall c03AppSetTargetAndSelector
|
||||||
|
sec
|
||||||
|
c03AppCreateWinClimate_ret:
|
||||||
|
ret
|
||||||
|
; @end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
; ---------------------------------------------------------------------------
|
||||||
|
; @routine c03AppSetTargetAndSelector
|
||||||
|
;
|
||||||
|
; @param r16 selector
|
||||||
|
; @param X pointer to new main window to set target/selector to
|
||||||
|
; @clobbers none
|
||||||
|
|
||||||
|
c03AppSetTargetAndSelector:
|
||||||
|
adiw xh:xl, OBJECT_OFFS_SELECTOR
|
||||||
|
st X, r16
|
||||||
|
sbiw xh:xl, OBJECT_OFFS_SELECTOR
|
||||||
|
adiw xh:xl, OBJECT_OFFS_TARGET_LO
|
||||||
|
st X+, yl ; set target
|
||||||
|
st X, yh
|
||||||
|
sbiw xh:xl, (OBJECT_OFFS_TARGET_LO+1)
|
||||||
|
ret
|
||||||
|
; @end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
; ---------------------------------------------------------------------------
|
||||||
|
; @routine C03App_EnterMenuWin
|
||||||
|
;
|
||||||
|
; @param Y ptr to this guiapp
|
||||||
|
|
||||||
|
C03App_EnterMenuWin:
|
||||||
|
ldd xl, Y+C03APP_OFFS_WMENU_LO
|
||||||
|
ldd xh, Y+C03APP_OFFS_WMENU_HI
|
||||||
|
mov r16, xl ; was window created?
|
||||||
|
or r16, xh
|
||||||
|
breq C03App_EnterMenuWin_ret ; nope, jump
|
||||||
|
bigcall GuiApp_EnterWindow
|
||||||
|
C03App_EnterMenuWin_ret:
|
||||||
|
sec
|
||||||
|
ret
|
||||||
|
; @end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
; ---------------------------------------------------------------------------
|
||||||
|
; @routine C03App_OnCmdClimate
|
||||||
|
;
|
||||||
|
; @param Y ptr to this guiapp
|
||||||
|
|
||||||
|
C03App_OnCmdClimate:
|
||||||
|
ldd xl, Y+C03APP_OFFS_WCLIMATE_LO
|
||||||
|
ldd xh, Y+C03APP_OFFS_WCLIMATE_HI
|
||||||
|
mov r16, xl ; was window created?
|
||||||
|
or r16, xh
|
||||||
|
breq C03App_OnCmdClimate_ret ; nope, ignore this signal
|
||||||
|
bigcall GuiApp_EnterWindow
|
||||||
|
C03App_OnCmdClimate_ret:
|
||||||
|
sec
|
||||||
|
ret
|
||||||
|
; @end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
; ---------------------------------------------------------------------------
|
||||||
|
; @routine C03App_OnCmdLight
|
||||||
|
;
|
||||||
|
; @param Y ptr to this guiapp
|
||||||
|
|
||||||
|
C03App_OnCmdLight:
|
||||||
|
ldd xl, Y+C03APP_OFFS_WLIGHT_LO
|
||||||
|
ldd xh, Y+C03APP_OFFS_WLIGHT_HI
|
||||||
|
mov r16, xl ; was window created?
|
||||||
|
or r16, xh
|
||||||
|
breq C03App_OnCmdLight_ret ; nope, ignore this signal
|
||||||
|
bigcall GuiApp_EnterWindow
|
||||||
|
C03App_OnCmdLight_ret:
|
||||||
|
sec
|
||||||
|
ret
|
||||||
|
; @end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
; ---------------------------------------------------------------------------
|
||||||
|
; @routine C03App_OnCmdWindows
|
||||||
|
;
|
||||||
|
; @param Y ptr to this guiapp
|
||||||
|
|
||||||
|
C03App_OnCmdWindows:
|
||||||
|
ldd xl, Y+C03APP_OFFS_WWINDOWS_LO
|
||||||
|
ldd xh, Y+C03APP_OFFS_WWINDOWS_HI
|
||||||
|
mov r16, xl ; was window created?
|
||||||
|
or r16, xh
|
||||||
|
breq C03App_OnCmdWindows_ret ; nope, ignore this signal
|
||||||
|
bigcall GuiApp_EnterWindow
|
||||||
|
C03App_OnCmdWindows_ret:
|
||||||
|
sec
|
||||||
|
ret
|
||||||
|
; @end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
; ---------------------------------------------------------------------------
|
||||||
|
; @routine C03App_OnCmdDebug
|
||||||
|
;
|
||||||
|
; @param Y ptr to this guiapp
|
||||||
|
|
||||||
|
C03App_OnCmdDebug:
|
||||||
|
ldd xl, Y+C03APP_OFFS_WDEBUG_LO
|
||||||
|
ldd xh, Y+C03APP_OFFS_WDEBUG_HI
|
||||||
|
mov r16, xl ; was window created?
|
||||||
|
or r16, xh
|
||||||
|
breq C03App_OnCmdDebug_ret ; nope, ignore this signal
|
||||||
|
bigcall GuiApp_EnterWindow
|
||||||
|
C03App_OnCmdDebug_ret:
|
||||||
|
sec
|
||||||
|
ret
|
||||||
|
; @end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
; ---------------------------------------------------------------------------
|
||||||
|
; @routine C03App_OnCmdBack
|
||||||
|
;
|
||||||
|
; @param Y ptr to this guiapp
|
||||||
|
|
||||||
|
C03App_OnCmdBack:
|
||||||
|
bigcall GuiApp_LeaveWindow
|
||||||
|
sec
|
||||||
|
ret
|
||||||
|
; @end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
; ---------------------------------------------------------------------------
|
||||||
|
; @routine C03App_CreateButton
|
||||||
|
;
|
||||||
|
; @param X parent
|
||||||
|
; @param r16 value for OBJECT_OFFS_OPTS
|
||||||
|
; @param r17 value for WIDGET_OFFS_PACK
|
||||||
|
; @param r21:r20 img ressource
|
||||||
|
; @param r22 selector
|
||||||
|
; @return CFLAG set if new object created, cleared on error
|
||||||
|
; @return Y button created
|
||||||
|
; @clobbers any, !X
|
||||||
|
|
||||||
|
C03App_CreateButton:
|
||||||
|
push xl
|
||||||
|
push xh
|
||||||
|
push r20
|
||||||
|
push r21
|
||||||
|
push r22
|
||||||
|
ldi r20, BUTTON_MODE_NORMAL
|
||||||
|
rcall Button_new
|
||||||
|
pop r22
|
||||||
|
pop r21
|
||||||
|
pop r20
|
||||||
|
brcc C03App_CreateButton_done
|
||||||
|
mov xl, yl
|
||||||
|
mov xh, yh
|
||||||
|
push xl ; Button
|
||||||
|
push xh
|
||||||
|
push r22
|
||||||
|
ldi r16, 0
|
||||||
|
ldi r17, (WIDGET_PACK_BEGIN<<WIDGET_PACK_HSELF0_BIT) | (WIDGET_PACK_BEGIN<<WIDGET_PACK_VSELF0_BIT) ; PACK
|
||||||
|
bigcall ImageView_new
|
||||||
|
pop r22
|
||||||
|
pop yh ; pop button into Y
|
||||||
|
pop yl
|
||||||
|
brcc C03App_CreateButton_done
|
||||||
|
pop xh
|
||||||
|
pop xl
|
||||||
|
std Y+OBJECT_OFFS_TARGET_LO, xl
|
||||||
|
std Y+OBJECT_OFFS_TARGET_HI, xh
|
||||||
|
std Y+OBJECT_OFFS_SELECTOR, r22
|
||||||
|
rjmp C03App_CreateButton_ret
|
||||||
|
|
||||||
|
C03App_CreateButton_done:
|
||||||
|
pop xh
|
||||||
|
pop xl
|
||||||
|
C03App_CreateButton_ret:
|
||||||
|
ret
|
||||||
|
; @end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
; ---------------------------------------------------------------------------
|
||||||
|
; @routine C03App_CreateBackButton
|
||||||
|
;
|
||||||
|
; @param X parent
|
||||||
|
; @return CFLAG set of okay, cleared otherwise
|
||||||
|
; @return Y address of newly created object
|
||||||
|
; @clobbers any
|
||||||
|
|
||||||
|
C03App_CreateBackButton:
|
||||||
|
ldi r16, 0
|
||||||
|
ldi r17, (WIDGET_PACK_END<<WIDGET_PACK_HSELF0_BIT) | (WIDGET_PACK_END<<WIDGET_PACK_VSELF0_BIT) ; PACK
|
||||||
|
ldi r20, LOW(RESSSOURCE_IMG_ARROWLEFT)
|
||||||
|
ldi r21, HIGH(RESSSOURCE_IMG_ARROWLEFT)
|
||||||
|
ldi r22, C03APP_SEL_BACK
|
||||||
|
bigcall C03App_CreateButton
|
||||||
|
brcc C03App_CreateBackButton
|
||||||
|
|
||||||
|
bigcall Widget_GetApp
|
||||||
|
brcc C03App_CreateBackButton_ret
|
||||||
|
std Y+OBJECT_OFFS_TARGET_LO, r18
|
||||||
|
std Y+OBJECT_OFFS_TARGET_HI, r19
|
||||||
|
C03App_CreateBackButton_ret:
|
||||||
|
ret
|
||||||
|
; @end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
; ***************************************************************************
|
||||||
|
; data in FLASH
|
||||||
|
|
||||||
|
C03App_DefaultSignalmap:
|
||||||
|
; header
|
||||||
|
.dw GuiApp_DefaultSignalmap*2 ; next table to use
|
||||||
|
; entries
|
||||||
|
.db C03APP_SEL_BACK, WIDGET_SIGNAL_COMMAND, LOW(C03App_OnCmdBack), HIGH(C03App_OnCmdBack)
|
||||||
|
.db C03APP_SEL_MENU, MENUWIN_SIGNAL_CLIMATE, LOW(C03App_OnCmdClimate), HIGH(C03App_OnCmdClimate)
|
||||||
|
.db C03APP_SEL_MENU, MENUWIN_SIGNAL_LIGHT, LOW(C03App_OnCmdLight), HIGH(C03App_OnCmdLight)
|
||||||
|
.db C03APP_SEL_MENU, MENUWIN_SIGNAL_WINDOWS, LOW(C03App_OnCmdWindows), HIGH(C03App_OnCmdWindows)
|
||||||
|
.db C03APP_SEL_MENU, MENUWIN_SIGNAL_DEBUG, LOW(C03App_OnCmdDebug), HIGH(C03App_OnCmdDebug)
|
||||||
|
.db 0, 0, 0, 0 ; end of table
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
@@ -243,42 +243,10 @@ onEveryLoop:
|
|||||||
|
|
||||||
|
|
||||||
test:
|
test:
|
||||||
clr r16
|
bigcall C03App_new
|
||||||
sts guiApp, r16
|
|
||||||
sts guiApp+1, r16
|
|
||||||
|
|
||||||
ldi r16, 0
|
|
||||||
ldi r17, 0
|
|
||||||
bigcall GuiApp_new
|
|
||||||
sts guiApp, yl
|
sts guiApp, yl
|
||||||
sts guiApp+1, yh
|
sts guiApp+1, yh
|
||||||
|
|
||||||
push yl
|
|
||||||
push yh
|
|
||||||
bigcall ClimateWin_new
|
|
||||||
; rcall mkTestWindow
|
|
||||||
mov xl, yl
|
|
||||||
mov xh, yh
|
|
||||||
pop yh
|
|
||||||
pop yl
|
|
||||||
brcc DEBUG_STOP2
|
|
||||||
|
|
||||||
push xl
|
|
||||||
push xh
|
|
||||||
bigcall GuiApp_EnterWindow
|
|
||||||
pop xh
|
|
||||||
pop xl
|
|
||||||
brcc DEBUG_STOP3
|
|
||||||
|
|
||||||
push yl
|
|
||||||
push yh
|
|
||||||
mov yl, xl
|
|
||||||
mov yh, xh
|
|
||||||
ldi r16, (1<<WIDGET_FLAGS_VISIBLE_BIT) | (1<<WIDGET_FLAGS_DIRTY_BIT) | (1<<WIDGET_FLAGS_LAYOUT_BIT)
|
|
||||||
bigcall OBJ_AddFlagsUp
|
|
||||||
pop yh
|
|
||||||
pop yl
|
|
||||||
|
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
|
||||||
@@ -367,7 +335,7 @@ mkTestWindow_ret:
|
|||||||
mkTestWidgets:
|
mkTestWidgets:
|
||||||
ldi r16, (1<<WIDGET_OPTS_BORDER_BIT) ; OPT
|
ldi r16, (1<<WIDGET_OPTS_BORDER_BIT) ; OPT
|
||||||
ldi r17, (WIDGET_PACK_FILLED<<WIDGET_PACK_HSELF0_BIT) | (WIDGET_PACK_FILLED<<WIDGET_PACK_VSELF0_BIT) ; PACK
|
ldi r17, (WIDGET_PACK_FILLED<<WIDGET_PACK_HSELF0_BIT) | (WIDGET_PACK_FILLED<<WIDGET_PACK_VSELF0_BIT) ; PACK
|
||||||
ldi r20, HLAYOUT_MODE_COLUMNS
|
ldi r20, MLAYOUT_MODE_COLUMNS
|
||||||
ldi r21, 3
|
ldi r21, 3
|
||||||
bigcall MLayout_new
|
bigcall MLayout_new
|
||||||
sts mLayoutWidget, yl
|
sts mLayoutWidget, yl
|
||||||
@@ -596,6 +564,8 @@ GUI2_MODULE_BEGIN:
|
|||||||
GUI2_MODULE_END:
|
GUI2_MODULE_END:
|
||||||
.equ MODULE_SIZE_GUI2 = GUI2_MODULE_END-GUI2_MODULE_BEGIN
|
.equ MODULE_SIZE_GUI2 = GUI2_MODULE_END-GUI2_MODULE_BEGIN
|
||||||
|
|
||||||
|
.include "a_c03.asm"
|
||||||
|
.include "w_menu.asm"
|
||||||
.include "w_climate.asm"
|
.include "w_climate.asm"
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -42,28 +42,23 @@ ClimateWin_new:
|
|||||||
ldi r17, (WIDGET_PACK_FILLED<<WIDGET_PACK_HSELF0_BIT) | (WIDGET_PACK_FILLED<<WIDGET_PACK_VSELF0_BIT) ; PACK
|
ldi r17, (WIDGET_PACK_FILLED<<WIDGET_PACK_HSELF0_BIT) | (WIDGET_PACK_FILLED<<WIDGET_PACK_VSELF0_BIT) ; PACK
|
||||||
ldi r20, LOW(RESSSOURCE_TXT_ROOMCLIMATE)
|
ldi r20, LOW(RESSSOURCE_TXT_ROOMCLIMATE)
|
||||||
ldi r21, HIGH(RESSSOURCE_TXT_ROOMCLIMATE)
|
ldi r21, HIGH(RESSSOURCE_TXT_ROOMCLIMATE)
|
||||||
bigcall MainWindow_new
|
bigcall MainWindow_new ; Y=main window
|
||||||
brcc ClimateWin_new_ret
|
brcc ClimateWin_new_ret
|
||||||
|
|
||||||
; Y=MainWindow
|
bigcall MainWindow_GetContentWidget ; r19:r18=content window
|
||||||
push yl
|
brcc ClimateWin_new_ret
|
||||||
|
mov xl, r18 ; use content window as parent
|
||||||
|
mov xh, r19
|
||||||
|
|
||||||
|
push yl ; main window
|
||||||
push yh
|
push yh
|
||||||
bigcall MainWindow_GetContentWidget ; r19:r18=content window
|
push xl ; content window
|
||||||
brcc ClimateWin_new_popRet
|
|
||||||
mov xl, r18 ; use content window as parent
|
|
||||||
mov xh, r19
|
|
||||||
|
|
||||||
push xl ; content window
|
|
||||||
push xh
|
push xh
|
||||||
rcall climateWinCreateSensorWatches
|
rcall climateWinCreateSensorWatches
|
||||||
pop xh
|
pop xh ; content window
|
||||||
pop xl
|
pop xl
|
||||||
; brcc ClimateWin_new_popRet
|
bigcall C03App_CreateBackButton
|
||||||
|
pop yh ; main window
|
||||||
; TODO: create menu bar below
|
|
||||||
|
|
||||||
ClimateWin_new_popRet:
|
|
||||||
pop yh
|
|
||||||
pop yl
|
pop yl
|
||||||
ClimateWin_new_ret:
|
ClimateWin_new_ret:
|
||||||
ret
|
ret
|
||||||
|
|||||||
248
avr/devices/c03/test/w_menu.asm
Normal file
248
avr/devices/c03/test/w_menu.asm
Normal file
@@ -0,0 +1,248 @@
|
|||||||
|
; ***************************************************************************
|
||||||
|
; 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_W_MENU_ASM
|
||||||
|
#define AQH_AVR_W_MENU_ASM
|
||||||
|
|
||||||
|
|
||||||
|
; ***************************************************************************
|
||||||
|
; defines
|
||||||
|
|
||||||
|
.equ MENUWIN_OFFS_BEGIN = MAINWINDOW_SIZE
|
||||||
|
.equ MENUWIN_SIZE = MENUWIN_OFFS_BEGIN+0
|
||||||
|
|
||||||
|
|
||||||
|
.equ MENUWIN_SIGNAL_CLIMATE = WIDGET_SIGNAL_NEXTFREE+0
|
||||||
|
.equ MENUWIN_SIGNAL_LIGHT = WIDGET_SIGNAL_NEXTFREE+1
|
||||||
|
.equ MENUWIN_SIGNAL_WINDOWS = WIDGET_SIGNAL_NEXTFREE+2
|
||||||
|
.equ MENUWIN_SIGNAL_DEBUG = WIDGET_SIGNAL_NEXTFREE+3
|
||||||
|
.equ MENUWIN_SIGNAL_NEXTFREE = WIDGET_SIGNAL_NEXTFREE+4
|
||||||
|
|
||||||
|
|
||||||
|
.equ MENUWIN_SEL_CLIMATE = 1
|
||||||
|
.equ MENUWIN_SEL_LIGHT = 2
|
||||||
|
.equ MENUWIN_SEL_WINDOWS = 3
|
||||||
|
.equ MENUWIN_SEL_DEBUG = 4
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
; ***************************************************************************
|
||||||
|
; code
|
||||||
|
|
||||||
|
.cseg
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
; ---------------------------------------------------------------------------
|
||||||
|
; @routine MenuWin_new @global
|
||||||
|
;
|
||||||
|
; @param Y pointer to GUIAPP
|
||||||
|
; @return CFLAG set of okay, cleared otherwise
|
||||||
|
; @return Y address of newly created object
|
||||||
|
|
||||||
|
MenuWin_new:
|
||||||
|
bigcall GuiApp_GetRootWindow
|
||||||
|
brcc MenuWin_new_ret
|
||||||
|
mov xl, r18 ; use root window as parent for main window
|
||||||
|
mov xh, r19
|
||||||
|
|
||||||
|
ldi r16, 0 ; OPTS
|
||||||
|
ldi r17, (WIDGET_PACK_FILLED<<WIDGET_PACK_HSELF0_BIT) | (WIDGET_PACK_FILLED<<WIDGET_PACK_VSELF0_BIT) ; PACK
|
||||||
|
ldi r20, LOW(RESSSOURCE_TXT_UNKNOWN_S) ; TODO!
|
||||||
|
ldi r21, HIGH(RESSSOURCE_TXT_UNKNOWN_S)
|
||||||
|
bigcall MainWindow_new
|
||||||
|
brcc MenuWin_new_ret
|
||||||
|
|
||||||
|
; set default signal map
|
||||||
|
ldi r16, LOW(MenuWin_DefaultSignalmap*2)
|
||||||
|
std Y+OBJECT_OFFS_SIGNALMAP_LO, r16
|
||||||
|
ldi r16, HIGH(MenuWin_DefaultSignalmap*2)
|
||||||
|
std Y+OBJECT_OFFS_SIGNALMAP_HI, r16
|
||||||
|
|
||||||
|
|
||||||
|
; Y=MainWindow
|
||||||
|
push yl
|
||||||
|
push yh
|
||||||
|
bigcall MainWindow_GetContentWidget ; r19:r18=content window
|
||||||
|
brcc MenuWin_new_popRet
|
||||||
|
mov xl, r18 ; use content window as parent
|
||||||
|
mov xh, r19
|
||||||
|
|
||||||
|
push xl ; content window
|
||||||
|
push xh
|
||||||
|
rcall menuWinCreateContent
|
||||||
|
pop xh
|
||||||
|
pop xl
|
||||||
|
MenuWin_new_popRet:
|
||||||
|
pop yh
|
||||||
|
pop yl
|
||||||
|
MenuWin_new_ret:
|
||||||
|
ret
|
||||||
|
; @end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
; ---------------------------------------------------------------------------
|
||||||
|
; @routine menuWinCreateContent
|
||||||
|
;
|
||||||
|
; @param Y pointer to MainWindow
|
||||||
|
; @param X pointer to MainWindow content window (becomes parent)
|
||||||
|
; @return CFLAG set of okay, cleared otherwise
|
||||||
|
; @return Y address of newly created object
|
||||||
|
|
||||||
|
menuWinCreateContent:
|
||||||
|
; create MLayout
|
||||||
|
push yl
|
||||||
|
push yh
|
||||||
|
ldi r16, 0 ; OPTS
|
||||||
|
ldi r17, (WIDGET_PACK_FILLED<<WIDGET_PACK_HSELF0_BIT) | (WIDGET_PACK_FILLED<<WIDGET_PACK_VSELF0_BIT) ; PACK
|
||||||
|
ldi r20, MLAYOUT_MODE_COLUMNS
|
||||||
|
ldi r21, 5 ; columns per row
|
||||||
|
bigcall MLayout_new
|
||||||
|
mov xl, yl ; use MLayout as parent
|
||||||
|
mov xh, yh
|
||||||
|
pop yh
|
||||||
|
pop yl
|
||||||
|
brcc menuWinCreateContent_ret
|
||||||
|
|
||||||
|
ldi r20, LOW(RESSSOURCE_IMG_TEMP)
|
||||||
|
ldi r21, HIGH(RESSSOURCE_IMG_TEMP)
|
||||||
|
ldi r22, MENUWIN_SEL_CLIMATE
|
||||||
|
rcall menuWinCreateButton
|
||||||
|
brcc menuWinCreateContent_ret
|
||||||
|
|
||||||
|
ldi r20, LOW(RESSSOURCE_IMG_LIGHT)
|
||||||
|
ldi r21, HIGH(RESSSOURCE_IMG_LIGHT)
|
||||||
|
ldi r22, MENUWIN_SEL_LIGHT
|
||||||
|
rcall menuWinCreateButton
|
||||||
|
brcc menuWinCreateContent_ret
|
||||||
|
|
||||||
|
ldi r20, LOW(RESSSOURCE_IMG_WINCLOSED)
|
||||||
|
ldi r21, HIGH(RESSSOURCE_IMG_WINCLOSED)
|
||||||
|
ldi r22, MENUWIN_SEL_WINDOWS
|
||||||
|
rcall menuWinCreateButton
|
||||||
|
brcc menuWinCreateContent_ret
|
||||||
|
|
||||||
|
ldi r20, LOW(RESSSOURCE_IMG_DEBUGEEPROM)
|
||||||
|
ldi r21, HIGH(RESSSOURCE_IMG_DEBUGEEPROM)
|
||||||
|
ldi r22, MENUWIN_SEL_DEBUG
|
||||||
|
rcall menuWinCreateButton
|
||||||
|
brcc menuWinCreateContent_ret
|
||||||
|
|
||||||
|
mov yl, xl
|
||||||
|
mov yh, xh
|
||||||
|
sec
|
||||||
|
menuWinCreateContent_ret:
|
||||||
|
ret
|
||||||
|
; @end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
; ---------------------------------------------------------------------------
|
||||||
|
; @routine menuWinCreateButton
|
||||||
|
;
|
||||||
|
; @param Y pointer to MainWindow
|
||||||
|
; @param X parent
|
||||||
|
; @param r21:r20 img ressource
|
||||||
|
; @param r22 selector
|
||||||
|
; @return CFLAG set if new object created, cleared on error
|
||||||
|
; @clobbers any, !X, !Y
|
||||||
|
|
||||||
|
menuWinCreateButton:
|
||||||
|
push xl
|
||||||
|
push xh
|
||||||
|
push yl
|
||||||
|
push yh
|
||||||
|
ldi r16, 0
|
||||||
|
ldi r17, (WIDGET_PACK_BEGIN<<WIDGET_PACK_HSELF0_BIT) | (WIDGET_PACK_BEGIN<<WIDGET_PACK_VSELF0_BIT) ; PACK
|
||||||
|
bigcall C03App_CreateButton
|
||||||
|
mov xl, yl
|
||||||
|
mov xh, yh
|
||||||
|
pop yh
|
||||||
|
pop yl
|
||||||
|
brcc menuWinCreateButton_popRet
|
||||||
|
adiw xh:xl, OBJECT_OFFS_TARGET_LO
|
||||||
|
st X+, yl
|
||||||
|
st X, yh
|
||||||
|
sbiw xh:xl, (OBJECT_OFFS_TARGET_LO+1)
|
||||||
|
sec
|
||||||
|
menuWinCreateButton_popRet:
|
||||||
|
pop xh
|
||||||
|
pop xl
|
||||||
|
menuWinCreateButton_ret:
|
||||||
|
ret
|
||||||
|
; @end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
; ---------------------------------------------------------------------------
|
||||||
|
; @routine MenuWin_OnCmdClimate
|
||||||
|
|
||||||
|
MenuWin_OnCmdClimate:
|
||||||
|
ldi r16, MENUWIN_SIGNAL_CLIMATE
|
||||||
|
bigcall OBJ_EmitSignal
|
||||||
|
ret
|
||||||
|
; @end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
; ---------------------------------------------------------------------------
|
||||||
|
; @routine MenuWin_OnCmdLight
|
||||||
|
|
||||||
|
MenuWin_OnCmdLight:
|
||||||
|
ldi r16, MENUWIN_SIGNAL_LIGHT
|
||||||
|
bigcall OBJ_EmitSignal
|
||||||
|
ret
|
||||||
|
; @end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
; ---------------------------------------------------------------------------
|
||||||
|
; @routine MenuWin_OnCmdWindows
|
||||||
|
|
||||||
|
MenuWin_OnCmdWindows:
|
||||||
|
ldi r16, MENUWIN_SIGNAL_WINDOWS
|
||||||
|
bigcall OBJ_EmitSignal
|
||||||
|
ret
|
||||||
|
; @end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
; ---------------------------------------------------------------------------
|
||||||
|
; @routine MenuWin_OnCmdDebug
|
||||||
|
|
||||||
|
MenuWin_OnCmdDebug:
|
||||||
|
ldi r16, MENUWIN_SIGNAL_DEBUG
|
||||||
|
bigcall OBJ_EmitSignal
|
||||||
|
ret
|
||||||
|
; @end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
; ***************************************************************************
|
||||||
|
; data in FLASH
|
||||||
|
|
||||||
|
MenuWin_DefaultSignalmap:
|
||||||
|
; header
|
||||||
|
.dw MainWindow_DefaultSignalmap*2 ; next table to use
|
||||||
|
; entries
|
||||||
|
.db MENUWIN_SEL_CLIMATE, WIDGET_SIGNAL_COMMAND, LOW(MenuWin_OnCmdClimate), HIGH(MenuWin_OnCmdClimate)
|
||||||
|
.db MENUWIN_SEL_LIGHT, WIDGET_SIGNAL_COMMAND, LOW(MenuWin_OnCmdLight), HIGH(MenuWin_OnCmdLight)
|
||||||
|
.db MENUWIN_SEL_WINDOWS, WIDGET_SIGNAL_COMMAND, LOW(MenuWin_OnCmdWindows), HIGH(MenuWin_OnCmdWindows)
|
||||||
|
.db MENUWIN_SEL_DEBUG, WIDGET_SIGNAL_COMMAND, LOW(MenuWin_OnCmdDebug), HIGH(MenuWin_OnCmdDebug)
|
||||||
|
|
||||||
|
.db 0, 0, 0, 0 ; end of table
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
@@ -87,6 +87,11 @@ Button_Init:
|
|||||||
|
|
||||||
; setup button data
|
; setup button data
|
||||||
std Y+BUTTON_OFFS_MODE, r20
|
std Y+BUTTON_OFFS_MODE, r20
|
||||||
|
|
||||||
|
; set input opts
|
||||||
|
ldd r16, Y+OBJECT_OFFS_OPTS
|
||||||
|
sbr r16, (1<<WIDGET_OPTS_INPUT_BIT)
|
||||||
|
std Y+OBJECT_OFFS_OPTS, r16
|
||||||
|
|
||||||
; set default signal map
|
; set default signal map
|
||||||
ldi r16, LOW(Button_DefaultSignalmap*2)
|
ldi r16, LOW(Button_DefaultSignalmap*2)
|
||||||
|
|||||||
@@ -56,8 +56,8 @@
|
|||||||
|
|
||||||
|
|
||||||
; values for MLAYOUT_OFFS_MODE
|
; values for MLAYOUT_OFFS_MODE
|
||||||
.equ HLAYOUT_MODE_COLUMNS = 0
|
.equ MLAYOUT_MODE_COLUMNS = 0
|
||||||
.equ HLAYOUT_MODE_ROWS = 1
|
.equ MLAYOUT_MODE_ROWS = 1
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -145,7 +145,7 @@ MLayout_OnLayout:
|
|||||||
brcc MLayout_OnLayout_ret ; none, done here
|
brcc MLayout_OnLayout_ret ; none, done here
|
||||||
|
|
||||||
ldd r16, Y+MLAYOUT_OFFS_MODE
|
ldd r16, Y+MLAYOUT_OFFS_MODE
|
||||||
cpi r16, HLAYOUT_MODE_COLUMNS
|
cpi r16, MLAYOUT_MODE_COLUMNS
|
||||||
breq MLayout_OnLayout_columns
|
breq MLayout_OnLayout_columns
|
||||||
rjmp MLayout_OnLayout_ret
|
rjmp MLayout_OnLayout_ret
|
||||||
MLayout_OnLayout_columns:
|
MLayout_OnLayout_columns:
|
||||||
@@ -166,7 +166,7 @@ MLayout_OnGetDefaultWidth:
|
|||||||
brcc MLayout_OnGetDefaultWidth_ret ; none, done here
|
brcc MLayout_OnGetDefaultWidth_ret ; none, done here
|
||||||
|
|
||||||
ldd r16, Y+MLAYOUT_OFFS_MODE
|
ldd r16, Y+MLAYOUT_OFFS_MODE
|
||||||
cpi r16, HLAYOUT_MODE_COLUMNS
|
cpi r16, MLAYOUT_MODE_COLUMNS
|
||||||
breq MLayout_OnGetDefaultWidth_columns
|
breq MLayout_OnGetDefaultWidth_columns
|
||||||
rjmp MLayout_OnLayout_ret
|
rjmp MLayout_OnLayout_ret
|
||||||
MLayout_OnGetDefaultWidth_columns:
|
MLayout_OnGetDefaultWidth_columns:
|
||||||
@@ -188,7 +188,7 @@ MLayout_OnGetDefaultHeight:
|
|||||||
brcc MLayout_OnGetDefaultHeight_ret ; none, done here
|
brcc MLayout_OnGetDefaultHeight_ret ; none, done here
|
||||||
|
|
||||||
ldd r16, Y+MLAYOUT_OFFS_MODE
|
ldd r16, Y+MLAYOUT_OFFS_MODE
|
||||||
cpi r16, HLAYOUT_MODE_COLUMNS
|
cpi r16, MLAYOUT_MODE_COLUMNS
|
||||||
breq MLayout_OnGetDefaultHeight_columns
|
breq MLayout_OnGetDefaultHeight_columns
|
||||||
rjmp MLayout_OnLayout_ret
|
rjmp MLayout_OnLayout_ret
|
||||||
MLayout_OnGetDefaultHeight_columns:
|
MLayout_OnGetDefaultHeight_columns:
|
||||||
|
|||||||
@@ -88,6 +88,8 @@
|
|||||||
; ---------------------------------------------------------------------------
|
; ---------------------------------------------------------------------------
|
||||||
; @routine Object_Alloc @global
|
; @routine Object_Alloc @global
|
||||||
;
|
;
|
||||||
|
; Allocate memory and preset it with zeroes.
|
||||||
|
;
|
||||||
; @return CFLAG set if object created, cleared otherwise
|
; @return CFLAG set if object created, cleared otherwise
|
||||||
; @return Y address of created object in SDRAM (if CFLAG set)
|
; @return Y address of created object in SDRAM (if CFLAG set)
|
||||||
; @param r25:r24 size of object to allocate
|
; @param r25:r24 size of object to allocate
|
||||||
|
|||||||
Reference in New Issue
Block a user