avr/gui2: added screen saver app

screen saver can be turned off by:
- touching and releasing the display
- specific messages (e.g. motion detection msg from other nodes)
This commit is contained in:
Martin Preuss
2026-02-07 16:09:31 +01:00
parent 39d1060334
commit 28deb9c591
10 changed files with 738 additions and 25 deletions

View File

@@ -0,0 +1,131 @@
; ***************************************************************************
; 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_DEVICES_ALL_HANDLEVALUEMSG_ASM
#define AQH_AVR_DEVICES_ALL_HANDLEVALUEMSG_ASM
; table:
; Byte 0 : command
; Byte 1 : value
; Byte 2, 3: handler fn
; CF set: send ACK
; ***************************************************************************
; defines
.equ HANDLEVALUEMSG_OFFS_COMMAND = 0
.equ HANDLEVALUEMSG_OFFS_VALUEID = 1
.equ HANDLEVALUEMSG_OFFS_HANDLER_LO = 2
.equ HANDLEVALUEMSG_OFFS_HANDLER_HI = 3
.equ HANDLEVALUEMSG_SIZE = 4
; ***************************************************************************
; code
.cseg
; ---------------------------------------------------------------------------
; @routine Main_HandleValueMsg
;
; Finds a handler for the given message using a table.
; Input for the hander routine is the result of @ref NETMSG_ValueRead
; Output from the handler is CFLAG set if ACK should be send, in this case r23
; should contain the command code to use for the ACK message.
;
; @param Z byte address pointer to handler table (for LPM!)
; @param X pointer to msg
; @param Y argument for handler routine
; @return CFLAG set if msg handled, cleared otherwise
; @clobbers any
Main_HandleValueMsg:
bigcall NETMSG_ValueRead
push r22
push r24
push r25
rcall mainFindEntryForValueMsg ; CF set: r25:r24=routine (r16, r22, r24, r25, Z)
pop r25
pop r24
pop r22
brcc Main_HandleValueMsg_ret ; not found, jmp
push xl
push xh
icall ; handler, in: y=arg out: CF=needAck, r23=command
pop xh
pop xl
brcs Main_HandleValueMsg_sendAck
sec
rjmp Main_HandleValueMsg_ret
Main_HandleValueMsg_sendAck:
push r23
bigcall NETMSG_ValueRead
pop r23
bigcall Main_SendValueResponse ; (R16, R17, R18, R19, R20, R21, R23, R24, R25, X, Y)
sec
Main_HandleValueMsg_ret:
ret
; @end
; ---------------------------------------------------------------------------
; @routine mainFindEntryForValueMsg
;
; @param Z byte address pointer to handler table (for LPM!)
; @param r17 value id
; @param r23 command
; @return CFLAG set if entry found
; @param r25:r24 word address pointer to handler routine
; @clobbers r16, r22, r24, r25, Z
mainFindEntryForValueMsg:
mainFindEntryForValueMsg_loop:
lpm r16, Z+ ; address
lpm r22, Z+ ; value id
lpm r24, Z+ ; routine lo
lpm r25, Z+ ; routine hi
tst r24
brne mainFindEntryForValueMsg_l0
tst r25
breq mainFindEntryForValueMsg_notFound
mainFindEntryForValueMsg_l0:
tst r16 ; node addr
breq mainFindEntryForValueMsg_l1
cp r16, r23
brne mainFindEntryForValueMsg_next
mainFindEntryForValueMsg_l1:
tst r22 ; value id
breq mainFindEntryForValueMsg_l2
cp r22, r17
brne mainFindEntryForValueMsg_next
mainFindEntryForValueMsg_l2:
mov zl, r24
mov zh, r25
sec
rjmp mainFindEntryForValueMsg_ret
mainFindEntryForValueMsg_next:
rjmp mainFindEntryForValueMsg_loop
mainFindEntryForValueMsg_notFound:
clc
mainFindEntryForValueMsg_ret:
ret
; @end
#endif

View File

@@ -58,6 +58,8 @@
.equ C03_EEID_SENSOR_TEMP = 0x11
.equ C03_EEID_SENSOR_HUM = 0x12
.equ EEID_SCREENSAVER = 0x20
; ---------------------------------------------------------------------------

View File

@@ -50,10 +50,11 @@ appC03:
.dw 0 ; first child
.dw 0 ; target
.dw 0 ; selector (ony lower 8 bits used)
.dw appC03_signalmap*2 ; signal map
.dw appC03_signalmap*2 ; signal map
; GUIAPP
.dw appC03_ramdata ; SDRAM data
.dw winRoot*2 ; root widget
.dw appC03_ramdata ; SDRAM data
.dw winRoot*2 ; root widget
.dw winScreenSaver*2 ; screen saver
appC03_signalmap:
.db 0, OBJECT_SIGNAL_TIMER, LOW(GuiApp_OnTimer), HIGH(GuiApp_OnTimer)

View File

@@ -70,7 +70,7 @@ buttonEepromDumpReset_ramdata:
winEepromDump:
; OBJECT
.db 0x55, 0xaa ; magic
.dw 0 ; next
.dw winScreenSaver*2 ; next
.dw winRoot*2 ; parent
.dw winEepromDumpHeader*2 ; first child
.dw 0 ; target

View File

@@ -0,0 +1,55 @@
; ***************************************************************************
; 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_DEVICE_C03_WIN_SCREENSAVER_ASM
#define AQH_AVR_DEVICE_C03_WIN_SCREENSAVER_ASM
; ***************************************************************************
; data
.dseg
winScreenSaver_ramdata:
.byte WIDGET_SD_SIZE
; ***************************************************************************
; code
.cseg
winScreenSaver:
; OBJECT
.db 0x55, 0xaa ; magic
.dw 0 ; next
.dw winRoot*2 ; parent
.dw 0 ; first child
.dw 0 ; target
.dw 0 ; selector (ony lower 8 bits used)
.dw ScreenSaver_DefaultSignalmap*2 ; signal map
; WIDGET
.db (1<<WIDGET_OPTSLO_INPUT_BIT) | (1<<WIDGET_OPTSLO_TIMER_BIT) | (1<<WIDGET_OPTSLO_MSGRECV_BIT), 0 ; opts lo, hi
.dw 0 ; X
.dw 0 ; Y
.dw DISPLAY_WIDTH ; W
.dw DISPLAY_HEIGHT ; H
.dw DISPLAY_COLOR_LIGHTGREY ; front color
.dw DISPLAY_COLOR_BLACK ; back color
.dw STYLE_WIN_FONT*2 ; font
.dw winScreenSaver_ramdata ; ptr to SDRAM
#endif

View File

@@ -98,23 +98,26 @@
.equ VALUE_ID_DEBUG = 0x7f
.equ VALUE_ID_LEDSIMPLE_TIMING = 0x88
.equ VALUE_ID_BEEPERSIMPLE_TIMING = 0x89
.equ VALUE_ID_LEDSIMPLE_TIMING = 0x88
.equ VALUE_ID_BEEPERSIMPLE_TIMING = 0x89
.equ VALUE_ID_SENSOR_CO2_BASE = 0x90
.equ VALUE_ID_SENSOR_CO2_SOURCE = 0x90
.equ VALUE_ID_SENSOR_CO2_LIMWARN = 0x91
.equ VALUE_ID_SENSOR_CO2_LIMCRIT = 0x92
.equ VALUE_ID_SENSOR_CO2_BASE = 0x90
.equ VALUE_ID_SENSOR_CO2_SOURCE = 0x90
.equ VALUE_ID_SENSOR_CO2_LIMWARN = 0x91
.equ VALUE_ID_SENSOR_CO2_LIMCRIT = 0x92
.equ VALUE_ID_SENSOR_TEMP_BASE = 0x93
.equ VALUE_ID_SENSOR_TEMP_SOURCE = 0x93
.equ VALUE_ID_SENSOR_TEMP_LIMWARN = 0x94
.equ VALUE_ID_SENSOR_TEMP_LIMCRIT = 0x95
.equ VALUE_ID_SENSOR_TEMP_BASE = 0x93
.equ VALUE_ID_SENSOR_TEMP_SOURCE = 0x93
.equ VALUE_ID_SENSOR_TEMP_LIMWARN = 0x94
.equ VALUE_ID_SENSOR_TEMP_LIMCRIT = 0x95
.equ VALUE_ID_SENSOR_HUM_BASE = 0x96
.equ VALUE_ID_SENSOR_HUM_SOURCE = 0x96
.equ VALUE_ID_SENSOR_HUM_LIMWARN = 0x97
.equ VALUE_ID_SENSOR_HUM_LIMCRIT = 0x98
.equ VALUE_ID_SENSOR_HUM_BASE = 0x96
.equ VALUE_ID_SENSOR_HUM_SOURCE = 0x96
.equ VALUE_ID_SENSOR_HUM_LIMWARN = 0x97
.equ VALUE_ID_SENSOR_HUM_LIMCRIT = 0x98
.equ VALUE_ID_SCREENSAVER_SETSOURCE1 = 0x9a
.equ VALUE_ID_SCREENSAVER_SETSOURCE2 = 0x9b
@@ -257,6 +260,8 @@ test:
.include "devices/all/hw_m644p.asm"
.include "devices/all/includes.asm"
.include "devices/all/handlevaluemsg.asm"
.include "common/debug.asm"
;.include "modules/lcd2/font/font2.asm"
@@ -293,6 +298,7 @@ test:
.include "modules/lcd2/gui2/generic/imageview.asm"
.include "modules/lcd2/gui2/generic/valuelabel.asm"
.include "modules/lcd2/gui2/generic/guiapp.asm"
.include "modules/lcd2/gui2/generic/screensaver.asm"
.include "modules/lcd2/gui2/sensorwatch.asm"
.include "modules/lcd2/gui2/eepromdump.asm"
@@ -300,6 +306,7 @@ test:
.include "g_win_climate.asm"
.include "g_win_network.asm"
.include "g_win_eepromdump.asm"
.include "g_win_screensaver.asm"
.include "ressources.inc"