avr: added netstats window
There seems to be a problem with MLayout (writes imaginary row at screen Y position 0 for unknown reasons).
This commit is contained in:
352
avr/devices/c03/test/w_netstats.asm
Normal file
352
avr/devices/c03/test/w_netstats.asm
Normal file
@@ -0,0 +1,352 @@
|
||||
; ***************************************************************************
|
||||
; 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_NETSTATS_ASM
|
||||
#define AQH_AVR_GUI2_NETSTATS_ASM
|
||||
|
||||
; ***************************************************************************
|
||||
; defines
|
||||
|
||||
|
||||
.equ NETSTATWIN_OFFS_BEGIN = MAINWINDOW_SIZE
|
||||
.equ NETSTATWIN_OFFS_TIMER = NETSTATWIN_OFFS_BEGIN+0
|
||||
.equ NETSTATWIN_SIZE = NETSTATWIN_OFFS_BEGIN+1
|
||||
|
||||
|
||||
.equ NETSTATWIN_TIMERVAL = 50 ; update every 5 secs
|
||||
|
||||
|
||||
|
||||
; ***************************************************************************
|
||||
; code
|
||||
|
||||
.cseg
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine NetStatWin_new @global
|
||||
;
|
||||
; @param Y pointer to GUIAPP
|
||||
; @return CFLAG set of okay, cleared otherwise
|
||||
; @return Y address of newly created object
|
||||
|
||||
NetStatWin_new:
|
||||
bigcall GuiApp_GetRootWindow
|
||||
brcc NetStatWin_new_ret
|
||||
mov xl, r18 ; use root window as parent for main window
|
||||
mov xh, r19
|
||||
ldi r24, LOW(NETSTATWIN_SIZE)
|
||||
ldi r25, HIGH(NETSTATWIN_SIZE)
|
||||
bigcall Object_Alloc ; Y=space (!r16, !r17, !X)
|
||||
brcc NetStatWin_new_ret
|
||||
rcall NetStatWin_Init
|
||||
NetStatWin_new_ret:
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine NetStatWin_new @global
|
||||
;
|
||||
; @param Y pointer to newly allocated widget data
|
||||
; @param X pointer to root window
|
||||
; @return CFLAG set of okay, cleared otherwise
|
||||
; @clobbers any, !Y
|
||||
|
||||
NetStatWin_Init:
|
||||
ldi r16, (1<<OBJECT_OPTS_TIMER_BIT) ; OPTS
|
||||
ldi r17, (WIDGET_PACK_FILLED<<WIDGET_PACK_HSELF0_BIT) | (WIDGET_PACK_FILLED<<WIDGET_PACK_VSELF0_BIT) ; PACK
|
||||
ldi r20, LOW(RESSSOURCE_TXT_NETSTATS)
|
||||
ldi r21, HIGH(RESSSOURCE_TXT_NETSTATS)
|
||||
rcall MainWindow_Init ; (any, !Y)
|
||||
brcc NetStatWin_Init_ret
|
||||
|
||||
; set default signal map
|
||||
ldi r16, LOW(NetStatWin_DefaultSignalmap*2)
|
||||
std Y+OBJECT_OFFS_SIGNALMAP_LO, r16
|
||||
ldi r16, HIGH(NetStatWin_DefaultSignalmap*2)
|
||||
std Y+OBJECT_OFFS_SIGNALMAP_HI, r16
|
||||
|
||||
; set timer
|
||||
ldi r16, NETSTATWIN_TIMERVAL
|
||||
std Y+NETSTATWIN_OFFS_TIMER, r16
|
||||
|
||||
; Y=MainWindow
|
||||
push yl
|
||||
push yh
|
||||
bigcall MainWindow_GetContentWidget ; r19:r18=content window
|
||||
brcc NetStatWin_Init_popRet
|
||||
mov xl, r18 ; use content window as parent
|
||||
mov xh, r19
|
||||
|
||||
push xl ; content window
|
||||
push xh
|
||||
rcall netStatWinCreateContent
|
||||
pop xh
|
||||
pop xl
|
||||
brcc NetStatWin_Init_popRet
|
||||
bigcall C03App_CreateBackButton
|
||||
NetStatWin_Init_popRet:
|
||||
pop yh
|
||||
pop yl
|
||||
NetStatWin_Init_ret:
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
NetStatWin_OnTimer:
|
||||
ldd r16, Y+OBJECT_OFFS_FLAGS
|
||||
andi r16, (1<<WIDGET_FLAGS_VISIBLE_BIT)
|
||||
breq NetStatWin_OnTimer_ret
|
||||
|
||||
ldd r16, Y+NETSTATWIN_OFFS_TIMER
|
||||
tst r16
|
||||
breq NetStatWin_OnTimer_ret
|
||||
dec r16
|
||||
std Y+NETSTATWIN_OFFS_TIMER, r16
|
||||
brne NetStatWin_OnTimer_ret
|
||||
push yl
|
||||
push yh
|
||||
rcall netStatWinUpdate
|
||||
pop yh
|
||||
pop yl
|
||||
ldi r16, NETSTATWIN_TIMERVAL
|
||||
std Y+NETSTATWIN_OFFS_TIMER, r16
|
||||
NetStatWin_OnTimer_ret:
|
||||
sec
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine netStatWinCreateContent
|
||||
;
|
||||
; @param Y pointer to MainWindow
|
||||
; @param X pointer to MainWindow content window (becomes parent)
|
||||
; @return CFLAG set of okay, cleared otherwise
|
||||
|
||||
netStatWinCreateContent:
|
||||
; 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, 2 ; columns per row
|
||||
bigcall MLayout_new
|
||||
mov xl, yl ; use MLayout as parent
|
||||
mov xh, yh
|
||||
pop yh
|
||||
pop yl
|
||||
brcc netStatWinCreateContent_ret
|
||||
|
||||
ldi r20, LOW(RESSSOURCE_TXT_PACKETSIN)
|
||||
ldi r21, HIGH(RESSSOURCE_TXT_PACKETSIN)
|
||||
rcall netStatWinCreateWidgetPair ; (any, !X, !Y)
|
||||
brcc netStatWinCreateContent_ret
|
||||
|
||||
ldi r20, LOW(RESSSOURCE_TXT_PACKETSOUT)
|
||||
ldi r21, HIGH(RESSSOURCE_TXT_PACKETSOUT)
|
||||
rcall netStatWinCreateWidgetPair ; (any, !X, !Y)
|
||||
brcc netStatWinCreateContent_ret
|
||||
|
||||
ldi r20, LOW(RESSSOURCE_TXT_ECONTENT)
|
||||
ldi r21, HIGH(RESSSOURCE_TXT_ECONTENT)
|
||||
rcall netStatWinCreateWidgetPair ; (any, !X, !Y)
|
||||
brcc netStatWinCreateContent_ret
|
||||
|
||||
ldi r20, LOW(RESSSOURCE_TXT_EIO)
|
||||
ldi r21, HIGH(RESSSOURCE_TXT_EIO)
|
||||
rcall netStatWinCreateWidgetPair ; (any, !X, !Y)
|
||||
brcc netStatWinCreateContent_ret
|
||||
|
||||
ldi r20, LOW(RESSSOURCE_TXT_EMSGSIZE)
|
||||
ldi r21, HIGH(RESSSOURCE_TXT_EMSGSIZE)
|
||||
rcall netStatWinCreateWidgetPair ; (any, !X, !Y)
|
||||
|
||||
netStatWinCreateContent_ret:
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine netStatWinCreateWidgetPair
|
||||
;
|
||||
; @param X parent
|
||||
; @param r21:r20 id of text ressource
|
||||
; @return CFLAG set if created, cleared otherwise
|
||||
; @clobbers !X, !Y
|
||||
|
||||
netStatWinCreateWidgetPair:
|
||||
push yl
|
||||
push yh
|
||||
rcall netStatWinCreateLabel ; (any, !X)
|
||||
brcc netStatWinCreateWidgetPair_popRet
|
||||
rcall netStatWinCreateValueLabel ; (any, !X)
|
||||
netStatWinCreateWidgetPair_popRet:
|
||||
pop yh
|
||||
pop yl
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine netStatWinCreateLabel
|
||||
;
|
||||
; @param X parent
|
||||
; @param r21:r20 id of text ressource
|
||||
; @return CFLAG set if created, cleared otherwise
|
||||
; @return Y new object created
|
||||
; @clobbers !X
|
||||
|
||||
netStatWinCreateLabel:
|
||||
push xl
|
||||
push xh
|
||||
ldi r16, 0
|
||||
ldi r17, (WIDGET_PACK_BEGIN<<WIDGET_PACK_HSELF0_BIT) | (WIDGET_PACK_CENTER<<WIDGET_PACK_VSELF0_BIT) | \
|
||||
(WIDGET_PACK_BEGIN<<WIDGET_PACK_HCONTENT0_BIT) | (WIDGET_PACK_CENTER<<WIDGET_PACK_VCONTENT0_BIT)
|
||||
bigcall Label_new
|
||||
pop xh
|
||||
pop xl
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine netStatWinCreateValueLabel
|
||||
;
|
||||
; @param X parent (content sub-window of main window)
|
||||
; @param r21:r20 id of text ressource
|
||||
; @return CFLAG set if created, cleared otherwise
|
||||
; @return Y new object created
|
||||
; @clobbers !X
|
||||
|
||||
netStatWinCreateValueLabel:
|
||||
push xl
|
||||
push xh
|
||||
ldi r16, 0
|
||||
ldi r17, (WIDGET_PACK_FILLED<<WIDGET_PACK_HSELF0_BIT) | (WIDGET_PACK_CENTER<<WIDGET_PACK_VSELF0_BIT) | \
|
||||
(WIDGET_PACK_END<<WIDGET_PACK_HCONTENT0_BIT) | (WIDGET_PACK_CENTER<<WIDGET_PACK_VCONTENT0_BIT)
|
||||
clr r20
|
||||
bigcall ValueLabel_new
|
||||
pop xh
|
||||
pop xl
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine netStatWinUpdate
|
||||
;
|
||||
; @param Y pointer to window
|
||||
; @clobbers any
|
||||
|
||||
netStatWinUpdate:
|
||||
bigcall MainWindow_GetFirstChildOfContentWidget ; get MLayout
|
||||
brcc netStatWinUpdate_ret
|
||||
mov yl, r18
|
||||
mov yh, r19
|
||||
bigcall OBJ_GetFirstChild ; get first child widget (label)
|
||||
brcc netStatWinUpdate_ret
|
||||
mov yl, r18
|
||||
mov yh, r19
|
||||
bigcall OBJ_GetNext ; get first value label widget
|
||||
brcc netStatWinUpdate_ret
|
||||
mov yl, r18
|
||||
mov yh, r19
|
||||
|
||||
rcall netWinStatsUpdatePacketsIn
|
||||
brcc netStatWinUpdate_ret
|
||||
rcall netWinStatsUpdatePacketsOut
|
||||
brcc netStatWinUpdate_ret
|
||||
rcall netWinStatsUpdateContentErrors
|
||||
brcc netStatWinUpdate_ret
|
||||
rcall netWinStatsUpdateIoErrors
|
||||
brcc netStatWinUpdate_ret
|
||||
rcall netWinStatsUpdateMsgSizeErrors
|
||||
netStatWinUpdate_ret:
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
netWinStatsUpdatePacketsIn:
|
||||
lds xl, netInterfaceData+NET_IFACE_OFFS_PACKETSIN_LOW
|
||||
lds xh, netInterfaceData+NET_IFACE_OFFS_PACKETSIN_HIGH
|
||||
bigcall ValueLabel_SetValue
|
||||
rjmp netWinStatsSkip2
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
netWinStatsUpdatePacketsOut:
|
||||
lds xl, netInterfaceData+NET_IFACE_OFFS_PACKETSOUT_LOW
|
||||
lds xh, netInterfaceData+NET_IFACE_OFFS_PACKETSOUT_HIGH
|
||||
bigcall ValueLabel_SetValue
|
||||
rjmp netWinStatsSkip2
|
||||
; @end
|
||||
|
||||
|
||||
netWinStatsUpdateContentErrors:
|
||||
lds xl, netInterfaceData+NET_IFACE_OFFS_ERR_CONTENT_LOW
|
||||
lds xh, netInterfaceData+NET_IFACE_OFFS_ERR_CONTENT_HIGH
|
||||
bigcall ValueLabel_SetValue
|
||||
rjmp netWinStatsSkip2
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
netWinStatsUpdateIoErrors:
|
||||
lds xl, netInterfaceData+NET_IFACE_OFFS_ERR_IO_LOW
|
||||
lds xh, netInterfaceData+NET_IFACE_OFFS_ERR_IO_HIGH
|
||||
bigcall ValueLabel_SetValue
|
||||
rjmp netWinStatsSkip2
|
||||
; @end
|
||||
|
||||
|
||||
netWinStatsUpdateMsgSizeErrors:
|
||||
lds xl, netInterfaceData+NET_IFACE_OFFS_ERR_MSGSIZE_LOW
|
||||
lds xh, netInterfaceData+NET_IFACE_OFFS_ERR_MSGSIZE_HIGH
|
||||
bigcall ValueLabel_SetValue
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
netWinStatsSkip2:
|
||||
ldi r16, 2
|
||||
bigcall OBJ_SkipObjects
|
||||
mov yl, r18
|
||||
mov yh, r19
|
||||
ret
|
||||
|
||||
|
||||
|
||||
|
||||
; ***************************************************************************
|
||||
; data in FLASH
|
||||
|
||||
NetStatWin_DefaultSignalmap:
|
||||
; header
|
||||
.dw MainWindow_DefaultSignalmap*2 ; next table to use
|
||||
; entries
|
||||
.db 0, OBJECT_SIGNAL_TIMER, LOW(NetStatWin_OnTimer), HIGH(NetStatWin_OnTimer)
|
||||
|
||||
.db 0, 0, 0, 0 ; end of table
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user