avr: added widget SensorWatch
shows a pictogram for a sensor and changes background color according to values received from a given sensor.
This commit is contained in:
@@ -230,6 +230,29 @@ test:
|
||||
ldi zh, HIGH(testApp_flashdata*2)
|
||||
bigcall GuiApp_Init
|
||||
|
||||
ldi zl, LOW(winSensorWatch1*2)
|
||||
ldi zh, HIGH(winSensorWatch1*2)
|
||||
; set source
|
||||
ldi r16, SENSORWATCH_SIGNAL_SETSOURCE
|
||||
clr r17
|
||||
ldi xl, 191 ; node address
|
||||
ldi xh, 10 ; value 0x0a (SGP30_CO2)
|
||||
bigcall OBJ_HandleSignal
|
||||
|
||||
; set warning limit
|
||||
ldi r16, SENSORWATCH_SIGNAL_SETLIMWARN
|
||||
clr r17
|
||||
ldi xl, LOW(800)
|
||||
ldi xh, HIGH(800)
|
||||
bigcall OBJ_HandleSignal
|
||||
|
||||
; set critical limit
|
||||
ldi r16, SENSORWATCH_SIGNAL_SETLIMCRIT
|
||||
clr r17
|
||||
ldi xl, LOW(2000)
|
||||
ldi xh, HIGH(2000)
|
||||
bigcall OBJ_HandleSignal
|
||||
|
||||
ret
|
||||
|
||||
|
||||
@@ -266,6 +289,7 @@ test:
|
||||
.include "modules/lcd2/gui2/widget.asm"
|
||||
.include "modules/lcd2/gui2/label.asm"
|
||||
.include "modules/lcd2/gui2/imageview.asm"
|
||||
.include "modules/lcd2/gui2/sensorwatch.asm"
|
||||
.include "modules/lcd2/gui2/guiapp.asm"
|
||||
|
||||
.include "testwin.asm"
|
||||
|
||||
@@ -37,14 +37,16 @@ testWinHeader_ramdata:
|
||||
testWinBody_ramdata:
|
||||
.byte WIDGET_SD_SIZE
|
||||
|
||||
testWinBodyImg1_ramdata:
|
||||
winSensorWatch1_ramdata:
|
||||
.byte SENSORWATCH_SD_SIZE
|
||||
|
||||
winSensorWatch1Title_ramdata:
|
||||
.byte WIDGET_SD_SIZE
|
||||
|
||||
winSensorWatch1Image_ramdata:
|
||||
.byte IMGVIEW_SD_SIZE
|
||||
|
||||
testWinBodyImg2_ramdata:
|
||||
.byte IMGVIEW_SD_SIZE
|
||||
|
||||
testWinBodyImg3_ramdata:
|
||||
.byte IMGVIEW_SD_SIZE
|
||||
|
||||
|
||||
|
||||
@@ -164,7 +166,7 @@ testWinBody_flashdata:
|
||||
.db 0x55, 0xaa ; magic
|
||||
.dw 0 ; next
|
||||
.dw testWin_flashdata*2 ; parent
|
||||
.dw testWinBodyImg1_flashdata*2 ; first child
|
||||
.dw winSensorWatch1*2 ; first child
|
||||
.dw 0 ; target
|
||||
.dw 0 ; selector (ony lower 8 bits used)
|
||||
.dw testWinBody_signalmap*2 ; signal map
|
||||
@@ -187,88 +189,94 @@ testWinBody_signalmap:
|
||||
|
||||
|
||||
|
||||
testWinBodyImg1_flashdata:
|
||||
; OBJECT
|
||||
.db 0x55, 0xaa ; magic
|
||||
.dw testWinBodyImg2_flashdata*2 ; next
|
||||
.dw testWinBody_flashdata*2 ; parent
|
||||
.dw 0 ; first child
|
||||
.dw 0 ; target
|
||||
.dw 0 ; selector (ony lower 8 bits used)
|
||||
.dw testWinBodyImg1_signalmap*2 ; signal map
|
||||
; WIDGET
|
||||
.db 0, 0 ; opts lo, hi
|
||||
.dw 4 ; X
|
||||
.dw 6 ; Y
|
||||
.dw 96 ; W
|
||||
.dw 96 ; H
|
||||
.dw STYLE_WIN_FOREGROUND ; front color
|
||||
.dw STYLE_WIN_BACKGROUND ; back color
|
||||
.dw STYLE_WIN_FONT*2 ; font
|
||||
.dw testWinBodyImg1_ramdata ; ptr to SDRAM
|
||||
; IMGVIEW
|
||||
.dw RESSSOURCE_IMG_CLOUD96 ; ressource id
|
||||
|
||||
testWinBodyImg1_signalmap:
|
||||
.db 0, WIDGET_SIGNAL_DRAW, LOW(ImageView_OnDraw), HIGH(ImageView_OnDraw)
|
||||
.db 0, OBJECT_SIGNAL_CREATE, LOW(ImageView_OnCreate), HIGH(ImageView_OnCreate)
|
||||
.db 0, 0, 0, 0 ; end of table
|
||||
|
||||
|
||||
|
||||
testWinBodyImg2_flashdata:
|
||||
; OBJECT
|
||||
.db 0x55, 0xaa ; magic
|
||||
.dw testWinBodyImg3_flashdata*2 ; next
|
||||
.dw testWinBody_flashdata*2 ; parent
|
||||
.dw 0 ; first child
|
||||
.dw 0 ; target
|
||||
.dw 0 ; selector (ony lower 8 bits used)
|
||||
.dw testWinBodyImg2_signalmap*2 ; signal map
|
||||
; WIDGET
|
||||
.db 0, 0 ; opts lo, hi
|
||||
.dw 104 ; X
|
||||
.dw 6 ; Y
|
||||
.dw 96 ; W
|
||||
.dw 96 ; H
|
||||
.dw STYLE_WIN_FOREGROUND ; front color
|
||||
.dw STYLE_WIN_BACKGROUND ; back color
|
||||
.dw STYLE_WIN_FONT*2 ; font
|
||||
.dw testWinBodyImg2_ramdata ; ptr to SDRAM
|
||||
; IMGVIEW
|
||||
.dw RESSSOURCE_IMG_TEMP96 ; ressource id
|
||||
|
||||
testWinBodyImg2_signalmap:
|
||||
.db 0, WIDGET_SIGNAL_DRAW, LOW(ImageView_OnDraw), HIGH(ImageView_OnDraw)
|
||||
.db 0, OBJECT_SIGNAL_CREATE, LOW(ImageView_OnCreate), HIGH(ImageView_OnCreate)
|
||||
.db 0, 0, 0, 0 ; end of table
|
||||
|
||||
|
||||
|
||||
testWinBodyImg3_flashdata:
|
||||
winSensorWatch1:
|
||||
; OBJECT
|
||||
.db 0x55, 0xaa ; magic
|
||||
.dw 0 ; next
|
||||
.dw testWinBody_flashdata*2 ; parent
|
||||
.dw winSensorWatch1Title*2 ; first child
|
||||
.dw 0 ; target
|
||||
.dw 0 ; selector (ony lower 8 bits used)
|
||||
.dw winSensorWatch1_signalmap*2 ; signal map
|
||||
; WIDGET
|
||||
.db (1<<WIDGETS_OPTSLO_MSGRECV_BIT), 0 ; opts lo, hi
|
||||
.dw 4 ; X
|
||||
.dw 4 ; Y
|
||||
.dw 100 ; W (image=96, 2 px borders)
|
||||
.dw 100 ; H
|
||||
.dw STYLE_WIN_FOREGROUND ; front color
|
||||
.dw STYLE_WIN_BACKGROUND ; back color
|
||||
.dw STYLE_WIN_FONT*2 ; font
|
||||
.dw winSensorWatch1_ramdata ; ptr to SDRAM
|
||||
|
||||
winSensorWatch1_signalmap:
|
||||
.db 0, OBJECT_SIGNAL_CREATE, LOW(SensorWatch_OnCreate), HIGH(SensorWatch_OnCreate)
|
||||
.db 0, WIDGET_SIGNAL_DRAW, LOW(Widget_OnDraw), HIGH(Widget_OnDraw)
|
||||
.db 0, OBJECT_SIGNAL_RECVMSG, LOW(SensorWatch_OnMsgReceived), HIGH(SensorWatch_OnMsgReceived)
|
||||
.db 0, SENSORWATCH_SIGNAL_SETSOURCE, LOW(SensorWatch_OnSetSource), HIGH(SensorWatch_OnSetSource)
|
||||
.db 0, SENSORWATCH_SIGNAL_SETLIMWARN, LOW(SensorWatch_OnSetLimitWarn), HIGH(SensorWatch_OnSetLimitWarn)
|
||||
.db 0, SENSORWATCH_SIGNAL_SETLIMCRIT, LOW(SensorWatch_OnSetLimitCrit), HIGH(SensorWatch_OnSetLimitCrit)
|
||||
.db 0, 0, 0, 0 ; end of table
|
||||
|
||||
|
||||
|
||||
winSensorWatch1Title:
|
||||
; OBJECT
|
||||
.db 0x55, 0xaa ; magic
|
||||
.dw winSensorWatch1Image*2 ; next
|
||||
.dw winSensorWatch1*2 ; parent
|
||||
.dw 0 ; first child
|
||||
.dw 0 ; target
|
||||
.dw 0 ; selector (ony lower 8 bits used)
|
||||
.dw testWinBodyImg3_signalmap*2 ; signal map
|
||||
.dw winSensorWatch1Title_signalmap*2 ; signal map
|
||||
; WIDGET
|
||||
.db 0, 0 ; opts lo, hi
|
||||
.dw 212 ; X
|
||||
.dw 6 ; Y
|
||||
.dw 2 ; X
|
||||
.dw 1 ; Y
|
||||
.dw 96 ; W
|
||||
.dw STYLE_WIN_FONT_HEIGHT+2 ; H
|
||||
.dw STYLE_WIN_FOREGROUND ; front color
|
||||
.dw STYLE_WIN_BACKGROUND ; back color
|
||||
.dw STYLE_WIN_FONT*2 ; font
|
||||
.dw winSensorWatch1Title_ramdata ; ptr to SDRAM
|
||||
; LABEL
|
||||
.dw winSensorWatch1Title_text*2 ; text
|
||||
|
||||
winSensorWatch1Title_text:
|
||||
.db "CO2", 0
|
||||
|
||||
winSensorWatch1Title_signalmap:
|
||||
.db 0, OBJECT_SIGNAL_CREATE, LOW(Widget_OnCreate), HIGH(Widget_OnCreate)
|
||||
.db 0, WIDGET_SIGNAL_DRAW, LOW(Label_OnDraw), HIGH(Label_OnDraw)
|
||||
.db 0, 0, 0, 0 ; end of table
|
||||
|
||||
|
||||
|
||||
winSensorWatch1Image:
|
||||
; OBJECT
|
||||
.db 0x55, 0xaa ; magic
|
||||
.dw 0 ; next
|
||||
.dw winSensorWatch1*2 ; parent
|
||||
.dw 0 ; first child
|
||||
.dw 0 ; target
|
||||
.dw 0 ; selector (ony lower 8 bits used)
|
||||
.dw winSensorWatch1Image_signalmap*2 ; signal map
|
||||
; WIDGET
|
||||
.db 0, 0 ; opts lo, hi
|
||||
.dw 2 ; X
|
||||
.dw STYLE_WIN_FONT_HEIGHT+2 ; Y
|
||||
.dw 96 ; W
|
||||
.dw 96 ; H
|
||||
.dw STYLE_WIN_FOREGROUND ; front color
|
||||
.dw STYLE_WIN_BACKGROUND ; back color
|
||||
.dw STYLE_WIN_FONT*2 ; font
|
||||
.dw testWinBodyImg3_ramdata ; ptr to SDRAM
|
||||
.dw winSensorWatch1Image_ramdata ; ptr to SDRAM
|
||||
; IMGVIEW
|
||||
.dw RESSSOURCE_IMG_HUMIDITY96 ; ressource id
|
||||
.dw RESSSOURCE_IMG_CLOUD96 ; ressource id
|
||||
|
||||
testWinBodyImg3_signalmap:
|
||||
winSensorWatch1Image_signalmap:
|
||||
.db 0, WIDGET_SIGNAL_DRAW, LOW(ImageView_OnDraw), HIGH(ImageView_OnDraw)
|
||||
.db 0, IMGVIEW_SIGNAL_SETBGCOL, LOW(ImageView_OnSetBgCol), HIGH(ImageView_OnSetBgCol)
|
||||
.db 0, OBJECT_SIGNAL_CREATE, LOW(ImageView_OnCreate), HIGH(ImageView_OnCreate)
|
||||
.db 0, 0, 0, 0 ; end of table
|
||||
|
||||
@@ -278,5 +286,8 @@ testWinBodyImg3_signalmap:
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -120,7 +120,7 @@ GuiApp_OnTimer:
|
||||
mov zl, r16
|
||||
or r17, zh
|
||||
breq GuiApp_OnTimer_l1
|
||||
; bigcall Widget_Tree_SendTimerSignal
|
||||
bigcall Widget_Tree_SendTimerSignal
|
||||
GuiApp_OnTimer_l1:
|
||||
pop zh
|
||||
pop zl
|
||||
@@ -182,12 +182,8 @@ GuiApp_OnTouch_done:
|
||||
GuiApp_OnMsgReceived:
|
||||
push zl
|
||||
push zh
|
||||
adiw zh:zl, GUIAPP_OFFS_ROOTWIDGET_LO
|
||||
lpm r18, Z+
|
||||
lpm zh, Z
|
||||
mov zl, r18
|
||||
or r18, zh
|
||||
breq GuiApp_OnMsgReceived_done
|
||||
rcall GuiApp_GetRootWidgetToZ
|
||||
brcc GuiApp_OnMsgReceived_done
|
||||
bigcall Widget_Tree_SendMsgRecvSignal
|
||||
GuiApp_OnMsgReceived_done:
|
||||
pop zh
|
||||
@@ -418,12 +414,8 @@ guiAppInitWidgets_done:
|
||||
guiAppDrawWidgets:
|
||||
push zl
|
||||
push zh
|
||||
adiw zh:zl, GUIAPP_OFFS_ROOTWIDGET_LO
|
||||
lpm r16, Z+
|
||||
lpm zh, Z
|
||||
mov zl, r16
|
||||
or r16, zh
|
||||
breq guiAppDrawWidgets_done
|
||||
rcall GuiApp_GetRootWidgetToZ
|
||||
brcc guiAppDrawWidgets_done
|
||||
bigcall Widget_Tree_SendDrawSignal
|
||||
guiAppDrawWidgets_done:
|
||||
pop zh
|
||||
|
||||
@@ -28,6 +28,11 @@
|
||||
.equ IMGVIEW_SD_SIZE = IMGVIEW_SD_OFFS_IMGVIEW+2
|
||||
|
||||
|
||||
; signals
|
||||
.equ IMGVIEW_SIGNAL_SETBGCOL = WIDGET_SIGNAL_NEXTFREE+0
|
||||
.equ IMGVIEW_SIGNAL_NEXTFREE = WIDGET_SIGNAL_NEXTFREE+1
|
||||
|
||||
|
||||
|
||||
; ***************************************************************************
|
||||
; code
|
||||
@@ -56,6 +61,34 @@ ImageView_OnCreate:
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine ImageView_OnSetBgCol @global
|
||||
;
|
||||
; @param Z byte address of widget object (for LPM!)
|
||||
; @param X new value for background color
|
||||
; @return CFLAG set if signal handled
|
||||
; @clobbers r17
|
||||
|
||||
ImageView_OnSetBgCol:
|
||||
bigcall OBJ_IsObject ; (none)
|
||||
brcc ImageView_OnSetBgCol_ret
|
||||
push zl
|
||||
push zh
|
||||
rcall Widget_GetSdramPtr ; (none)
|
||||
std Y+IMGVIEW_SD_OFFS_BGCOL_LO, xl
|
||||
std Y+IMGVIEW_SD_OFFS_BGCOL_HI, xh
|
||||
ldd r17, Y+WIDGET_SD_OFFS_FLAGS
|
||||
ori r17, (1<<WIDGET_FLAGS_DIRTY_BIT)
|
||||
std Y+WIDGET_SD_OFFS_FLAGS, r17
|
||||
pop zh
|
||||
pop zl
|
||||
ImageView_OnSetBgCol_ret:
|
||||
sec
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine Widget_OnDraw @global
|
||||
;
|
||||
|
||||
340
avr/modules/lcd2/gui2/sensorwatch.asm
Normal file
340
avr/modules/lcd2/gui2/sensorwatch.asm
Normal file
@@ -0,0 +1,340 @@
|
||||
; ***************************************************************************
|
||||
; 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_SENSORWATCH_ASM
|
||||
#define AQH_AVR_GUI2_SENSORWATCH_ASM
|
||||
|
||||
|
||||
; ***************************************************************************
|
||||
; SensorWatch
|
||||
;
|
||||
; This widget has three subwidgets:
|
||||
; - Title (Label)
|
||||
; - Image (ImageView)
|
||||
; - Value (Label)
|
||||
;
|
||||
; It watches received messages and reacts on those matching the stored
|
||||
; combination of NodeAddr and ValueId by colouring the image according to
|
||||
; the value received and also shows the value beloe the image.
|
||||
;
|
||||
; Please note that this widget needs to have the option bit
|
||||
; "WIDGETS_OPTSLO_MSGRECV_BIT" set in order to receive MsgReceived signals.
|
||||
;
|
||||
; ***************************************************************************
|
||||
|
||||
|
||||
|
||||
|
||||
; ***************************************************************************
|
||||
; defines
|
||||
|
||||
; SensorWatch in flash
|
||||
.equ SENSORWATCH_OFFS_SENSORWATCH = WIDGET_SIZE
|
||||
.equ SENSORWATCH_SIZE = SENSORWATCH_OFFS_SENSORWATCH+0
|
||||
|
||||
; SDRAM data for SensorWatch
|
||||
.equ SENSORWATCH_SD_OFFS_SENSORWATCH = WIDGET_SD_SIZE
|
||||
.equ SENSORWATCH_SD_OFFS_NODEADDR = SENSORWATCH_SD_OFFS_SENSORWATCH+0
|
||||
.equ SENSORWATCH_SD_OFFS_VALUEID = SENSORWATCH_SD_OFFS_SENSORWATCH+1
|
||||
.equ SENSORWATCH_SD_OFFS_LIMIT_WARN_LO = SENSORWATCH_SD_OFFS_SENSORWATCH+2
|
||||
.equ SENSORWATCH_SD_OFFS_LIMIT_WARN_HI = SENSORWATCH_SD_OFFS_SENSORWATCH+3
|
||||
.equ SENSORWATCH_SD_OFFS_LIMIT_CRIT_LO = SENSORWATCH_SD_OFFS_SENSORWATCH+4
|
||||
.equ SENSORWATCH_SD_OFFS_LIMIT_CRIT_HI = SENSORWATCH_SD_OFFS_SENSORWATCH+5
|
||||
.equ SENSORWATCH_SD_OFFS_VALUE_LO = SENSORWATCH_SD_OFFS_SENSORWATCH+6
|
||||
.equ SENSORWATCH_SD_OFFS_VALUE_HI = SENSORWATCH_SD_OFFS_SENSORWATCH+7
|
||||
.equ SENSORWATCH_SD_SIZE = SENSORWATCH_SD_OFFS_SENSORWATCH+8
|
||||
|
||||
|
||||
; signals
|
||||
.equ SENSORWATCH_SIGNAL_SETSOURCE = WIDGET_SIGNAL_NEXTFREE+0
|
||||
.equ SENSORWATCH_SIGNAL_SETLIMWARN = WIDGET_SIGNAL_NEXTFREE+1
|
||||
.equ SENSORWATCH_SIGNAL_SETLIMCRIT = WIDGET_SIGNAL_NEXTFREE+2
|
||||
.equ SENSORWATCH_SIGNAL_NEXTFREE = WIDGET_SIGNAL_NEXTFREE+3
|
||||
|
||||
|
||||
|
||||
; ***************************************************************************
|
||||
; code
|
||||
|
||||
.cseg
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine SensorWatch_OnCreate @global
|
||||
;
|
||||
; @param Z byte address of widget object (for LPM!)
|
||||
; @param XL node addr
|
||||
; @param XH value id
|
||||
; @return CFLAG set if signal handled
|
||||
; @clobbers any, !Z
|
||||
|
||||
SensorWatch_OnCreate:
|
||||
bigcall OBJ_IsObject ; (none)
|
||||
brcc SensorWatch_OnCreate_ret
|
||||
|
||||
; preset SDRAM
|
||||
bigcall Widget_GetSdramPtr ; (none)
|
||||
clr r16
|
||||
ldi r17, SENSORWATCH_SD_SIZE
|
||||
push yl
|
||||
push yh
|
||||
SensorWatch_OnCreate_loop:
|
||||
st Y+, r16
|
||||
dec r17
|
||||
brne SensorWatch_OnCreate_loop
|
||||
pop yh
|
||||
pop yl
|
||||
|
||||
bigcall Widget_OnCreate
|
||||
|
||||
SensorWatch_OnCreate_ret:
|
||||
sec
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine SensorWatch_OnSetSource @global
|
||||
;
|
||||
; @param Z byte address of widget object (for LPM!)
|
||||
; @param XL node addr
|
||||
; @param XH value id
|
||||
; @return CFLAG set if signal handled
|
||||
; @clobbers any, !Z
|
||||
|
||||
SensorWatch_OnSetSource:
|
||||
bigcall OBJ_IsObject ; (none)
|
||||
brcc SensorWatch_OnSetSource_ret
|
||||
push zl
|
||||
push zh
|
||||
bigcall Widget_GetSdramPtr ; (none)
|
||||
std Y+SENSORWATCH_SD_OFFS_NODEADDR, xl
|
||||
std Y+SENSORWATCH_SD_OFFS_VALUEID, xh
|
||||
pop zh
|
||||
pop zl
|
||||
SensorWatch_OnSetSource_ret:
|
||||
sec
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine SensorWatch_OnSetLimitWarn @global
|
||||
;
|
||||
; @param Z byte address of widget object (for LPM!)
|
||||
; @param X value
|
||||
; @return CFLAG set if signal handled
|
||||
; @clobbers any, !Z
|
||||
|
||||
SensorWatch_OnSetLimitWarn:
|
||||
bigcall OBJ_IsObject ; (none)
|
||||
brcc SensorWatch_OnSetLimitWarn_ret
|
||||
bigcall Widget_GetSdramPtr ; (none)
|
||||
std Y+SENSORWATCH_SD_OFFS_LIMIT_WARN_LO, xl
|
||||
std Y+SENSORWATCH_SD_OFFS_LIMIT_WARN_HI, xh
|
||||
rcall sensorWatchSetColor
|
||||
SensorWatch_OnSetLimitWarn_ret:
|
||||
sec
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine SensorWatch_OnSetLimitCrit @global
|
||||
;
|
||||
; @param Z byte address of widget object (for LPM!)
|
||||
; @param X value
|
||||
; @return CFLAG set if signal handled
|
||||
; @clobbers any, !Z
|
||||
|
||||
SensorWatch_OnSetLimitCrit:
|
||||
bigcall OBJ_IsObject ; (none)
|
||||
brcc SensorWatch_OnSetLimitCrit_ret
|
||||
rcall Widget_GetSdramPtr ; (none)
|
||||
std Y+SENSORWATCH_SD_OFFS_LIMIT_CRIT_LO, xl
|
||||
std Y+SENSORWATCH_SD_OFFS_LIMIT_CRIT_HI, xh
|
||||
rcall sensorWatchSetColor
|
||||
SensorWatch_OnSetLimitCrit_ret:
|
||||
sec
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine SensorWatch_OnMsgReceived @global
|
||||
;
|
||||
; @param Z byte address of widget object (for LPM!)
|
||||
; @param XL node addr
|
||||
; @param XH value id
|
||||
; @return CFLAG set if signal handled
|
||||
; @clobbers any, !Z
|
||||
|
||||
SensorWatch_OnMsgReceived:
|
||||
adiw xh:xl, 2 ; command
|
||||
ld r16, X
|
||||
sbiw xh:xl, 2
|
||||
cpi r16, NETMSG_CMD_VALUE_REPORT
|
||||
breq SensorWatch_OnMsgReceived_report
|
||||
rjmp SensorWatch_OnMsgReceived_ret
|
||||
SensorWatch_OnMsgReceived_report:
|
||||
bigcall Widget_GetSdramPtr ; (none)
|
||||
bigcall NETMSG_ValueRead ; R17=valueId, R22=nodeAddr R19:R18=value (none)
|
||||
; check node addr
|
||||
ldd r16, Y+SENSORWATCH_SD_OFFS_NODEADDR
|
||||
cp r16, r22
|
||||
brne SensorWatch_OnMsgReceived_ret
|
||||
; check value id
|
||||
ldd r16, Y+SENSORWATCH_SD_OFFS_VALUEID
|
||||
cp r16, r17
|
||||
brne SensorWatch_OnMsgReceived_ret
|
||||
; store value
|
||||
std Y+SENSORWATCH_SD_OFFS_VALUE_LO, r18
|
||||
std Y+SENSORWATCH_SD_OFFS_VALUE_HI, r19
|
||||
; setup background color
|
||||
rcall sensorWatchSetColor ; (any, !Y, !Z)
|
||||
SensorWatch_OnMsgReceived_ret:
|
||||
sec
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine SensorWatch_GetImageView @global
|
||||
;
|
||||
; @param Z byte address of widget object (for LPM!)
|
||||
; @return CFLAG set if widget found, cleared otherwise
|
||||
; @return R19:R18 byte address pointer to image view (for LPM!)
|
||||
; @clobbers none
|
||||
|
||||
SensorWatch_GetImageView:
|
||||
bigcall OBJ_IsObject ; (none)
|
||||
brcc SensorWatch_GetImageView_ret
|
||||
push zl
|
||||
push zh
|
||||
bigcall OBJ_GetFirstChild ; (none)
|
||||
brcc SensorWatch_GetImageView_done
|
||||
mov zl, r18
|
||||
mov zh, r19
|
||||
bigcall OBJ_GetNext ; 2nd child
|
||||
SensorWatch_GetImageView_done:
|
||||
pop zh
|
||||
pop zl
|
||||
SensorWatch_GetImageView_ret:
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine SensorWatch_GetDataLabel @global
|
||||
;
|
||||
; @param Z byte address of widget object (for LPM!)
|
||||
; @return CFLAG set if widget found, cleared otherwise
|
||||
; @return R19:R18 byte address pointer to image view (for LPM!)
|
||||
; @clobbers none
|
||||
|
||||
SensorWatch_GetDataLabel:
|
||||
bigcall OBJ_IsObject ; (none)
|
||||
brcc SensorWatch_GetDataLabel_ret
|
||||
push zl
|
||||
push zh
|
||||
bigcall OBJ_GetFirstChild ; (none)
|
||||
brcc SensorWatch_GetDataLabel_done
|
||||
mov zl, r18
|
||||
mov zh, r19
|
||||
bigcall OBJ_GetNext ; 2nd child
|
||||
brcc SensorWatch_GetDataLabel_done
|
||||
mov zl, r18
|
||||
mov zh, r19
|
||||
bigcall OBJ_GetNext ; 3nd child
|
||||
SensorWatch_GetDataLabel_done:
|
||||
pop zh
|
||||
pop zl
|
||||
SensorWatch_GetDataLabel_ret:
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine sensorWatchSetColor
|
||||
;
|
||||
; @param Z byte address of widget object (for LPM!)
|
||||
; @param Y pointer to SDRAM data
|
||||
; @clobbers any, !Y, !Z
|
||||
|
||||
sensorWatchSetColor:
|
||||
; default color is green
|
||||
ldi xl, LOW(DISPLAY_COLOR_DARKGREEN)
|
||||
ldi xh, HIGH(DISPLAY_COLOR_DARKGREEN)
|
||||
ldd r20, Y+SENSORWATCH_SD_OFFS_VALUE_LO
|
||||
ldd r21, Y+SENSORWATCH_SD_OFFS_VALUE_HI
|
||||
mov r16, r20
|
||||
or r16, r21
|
||||
breq sensorWatchSetColor_ret ; do nothing
|
||||
|
||||
; check against critical limit
|
||||
ldd r22, Y+SENSORWATCH_SD_OFFS_LIMIT_CRIT_LO
|
||||
ldd r23, Y+SENSORWATCH_SD_OFFS_LIMIT_CRIT_HI
|
||||
mov r16, r22
|
||||
or r16, r23
|
||||
breq sensorWatchSetColor_checkWarn
|
||||
cp r20, r22
|
||||
cpc r21, r23
|
||||
brcc sensorWatchSetColor_setRed
|
||||
sensorWatchSetColor_checkWarn:
|
||||
; check against warning limit
|
||||
ldd r22, Y+SENSORWATCH_SD_OFFS_LIMIT_WARN_LO
|
||||
ldd r23, Y+SENSORWATCH_SD_OFFS_LIMIT_WARN_HI
|
||||
mov r16, r22
|
||||
or r16, r23
|
||||
breq sensorWatchSetColor_ret ; do nothing
|
||||
cp r20, r22
|
||||
cpc r21, r23
|
||||
brcc sensorWatchSetColor_setYellow
|
||||
; set green background
|
||||
rjmp sensorWatchSetColor_setColor
|
||||
sensorWatchSetColor_setRed:
|
||||
ldi xl, LOW(DISPLAY_COLOR_RED)
|
||||
ldi xh, HIGH(DISPLAY_COLOR_RED)
|
||||
rjmp sensorWatchSetColor_setColor
|
||||
sensorWatchSetColor_setYellow:
|
||||
ldi xl, LOW(DISPLAY_COLOR_YELLOW)
|
||||
ldi xh, HIGH(DISPLAY_COLOR_YELLOW)
|
||||
sensorWatchSetColor_setColor:
|
||||
rcall SensorWatch_GetImageView ; (none)
|
||||
brcc sensorWatchSetColor_ret
|
||||
push zl
|
||||
push zh
|
||||
mov zl, r18
|
||||
mov zh, r19
|
||||
ldi r16, IMGVIEW_SIGNAL_SETBGCOL
|
||||
clr r17
|
||||
bigcall OBJ_HandleSignal ; (any, !X, !Y, !Z)
|
||||
pop zh
|
||||
pop zl
|
||||
sensorWatchSetColor_ret:
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -145,6 +145,7 @@ Widget_OnTouch:
|
||||
|
||||
; check for position inside this widget
|
||||
rcall Widget_LoadDisplayRegs ; (R0-R11)
|
||||
rcall Widget_MakeAbsPos ; (R16, R17)
|
||||
rcall Widget_IsPointInRect ; (R16, R17)
|
||||
sbci r16, 0 ; r16=ff if touched inside, 0 otherwise
|
||||
|
||||
@@ -460,6 +461,7 @@ Widget_SubFlags_ret:
|
||||
|
||||
Widget_Clear:
|
||||
rcall Widget_LoadDisplayRegs
|
||||
rcall Widget_MakeAbsPos ; (R16, R17)
|
||||
rcall Widget_GetSdramPtr ; (none)
|
||||
adiw zh:zl, WIDGET_OFFS_OPTS_LO ; get OPTS low
|
||||
lpm r14, Z
|
||||
|
||||
Reference in New Issue
Block a user