@@ -14,8 +14,6 @@
|
|||||||
; ***************************************************************************
|
; ***************************************************************************
|
||||||
; defines
|
; defines
|
||||||
|
|
||||||
.equ SENSORWATCH_AVG_VALUE_COUNT = 4 ; CAVEAT: change sensorWatchAvgValues if value changes!
|
|
||||||
|
|
||||||
.equ SENSORWATCH_OFFS_BEGIN = VLAYOUT_SIZE
|
.equ SENSORWATCH_OFFS_BEGIN = VLAYOUT_SIZE
|
||||||
.equ SENSORWATCH_OFFS_BASEVALUEID = SENSORWATCH_OFFS_BEGIN+0
|
.equ SENSORWATCH_OFFS_BASEVALUEID = SENSORWATCH_OFFS_BEGIN+0
|
||||||
.equ SENSORWATCH_OFFS_EEPROMID = SENSORWATCH_OFFS_BEGIN+1
|
.equ SENSORWATCH_OFFS_EEPROMID = SENSORWATCH_OFFS_BEGIN+1
|
||||||
@@ -32,10 +30,7 @@
|
|||||||
.equ SENSORWATCH_OFFS_VALUE_LO = SENSORWATCH_OFFS_BEGIN+12
|
.equ SENSORWATCH_OFFS_VALUE_LO = SENSORWATCH_OFFS_BEGIN+12
|
||||||
.equ SENSORWATCH_OFFS_VALUE_HI = SENSORWATCH_OFFS_BEGIN+13
|
.equ SENSORWATCH_OFFS_VALUE_HI = SENSORWATCH_OFFS_BEGIN+13
|
||||||
.equ SENSORWATCH_OFFS_TYPE = SENSORWATCH_OFFS_BEGIN+14
|
.equ SENSORWATCH_OFFS_TYPE = SENSORWATCH_OFFS_BEGIN+14
|
||||||
.equ SENSORWATCH_OFFS_VALUES_CNT = SENSORWATCH_OFFS_BEGIN+15
|
.equ SENSORWATCH_SIZE = SENSORWATCH_OFFS_BEGIN+15
|
||||||
.equ SENSORWATCH_OFFS_VALUES_IDX = SENSORWATCH_OFFS_BEGIN+16
|
|
||||||
.equ SENSORWATCH_OFFS_VALUES_ARRAY = SENSORWATCH_OFFS_BEGIN+17
|
|
||||||
.equ SENSORWATCH_SIZE = SENSORWATCH_OFFS_VALUES_ARRAY+(SENSORWATCH_AVG_VALUE_COUNT*2)
|
|
||||||
|
|
||||||
; values (not used for now)
|
; values (not used for now)
|
||||||
.equ SENSORWATCH_VALUE = WIDGET_VALUE_NEXTFREE+0
|
.equ SENSORWATCH_VALUE = WIDGET_VALUE_NEXTFREE+0
|
||||||
@@ -341,91 +336,6 @@ SensorWatch_GetValueLabel:
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
; ---------------------------------------------------------------------------
|
|
||||||
; @routine sensorWatchAddValue
|
|
||||||
;
|
|
||||||
; @param r19:r18 new value
|
|
||||||
; @clobbers r16-r19
|
|
||||||
|
|
||||||
sensorWatchAddValue:
|
|
||||||
push xl
|
|
||||||
push xh
|
|
||||||
mov xl, yl
|
|
||||||
mov xh, yh
|
|
||||||
adiw xh:xl, SENSORWATCH_OFFS_VALUES_ARRAY
|
|
||||||
ldd r16, Y+SENSORWATCH_OFFS_VALUES_IDX
|
|
||||||
clr r17
|
|
||||||
lsl r16
|
|
||||||
rol r17
|
|
||||||
add xl, r16
|
|
||||||
adc xh, r17
|
|
||||||
st X+, r18
|
|
||||||
st X, r19
|
|
||||||
ldd r16, Y+SENSORWATCH_OFFS_VALUES_IDX
|
|
||||||
inc r16
|
|
||||||
cpi r16, SENSORWATCH_AVG_VALUE_COUNT
|
|
||||||
brcs sensorWatchAddValue_storeIdx
|
|
||||||
clr r16
|
|
||||||
sensorWatchAddValue_storeIdx:
|
|
||||||
std Y+SENSORWATCH_OFFS_VALUES_IDX, r16
|
|
||||||
ldd r16, Y+SENSORWATCH_OFFS_VALUES_CNT
|
|
||||||
cpi r16, SENSORWATCH_AVG_VALUE_COUNT
|
|
||||||
brcc sensorWatchAddValue_done
|
|
||||||
inc r16
|
|
||||||
std Y+SENSORWATCH_OFFS_VALUES_CNT, r16
|
|
||||||
sensorWatchAddValue_done:
|
|
||||||
pop xh
|
|
||||||
pop xl
|
|
||||||
ret
|
|
||||||
; @end
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
; ---------------------------------------------------------------------------
|
|
||||||
; @routine sensorWatchAvgValues
|
|
||||||
;
|
|
||||||
; @clobbers r16-r22
|
|
||||||
|
|
||||||
sensorWatchAvgValues:
|
|
||||||
ldd r22, Y+SENSORWATCH_OFFS_VALUES_CNT
|
|
||||||
cpi r22, SENSORWATCH_AVG_VALUE_COUNT
|
|
||||||
brcs sensorWatchAvgValues_ret ; array not full, don't update
|
|
||||||
|
|
||||||
clr r16 ; r18:r17:r16=sum of values
|
|
||||||
clr r17
|
|
||||||
clr r18
|
|
||||||
clr r19 ; zero to be added below
|
|
||||||
push xl
|
|
||||||
push xh
|
|
||||||
mov xl, yl
|
|
||||||
mov xh, yh
|
|
||||||
adiw xh:xl, SENSORWATCH_OFFS_VALUES_ARRAY
|
|
||||||
sensorWatchAvgValues_loop:
|
|
||||||
ld r20, X+
|
|
||||||
ld r21, X+
|
|
||||||
add r16, r20
|
|
||||||
adc r17, r21
|
|
||||||
adc r18, r19
|
|
||||||
dec r22
|
|
||||||
brne sensorWatchAvgValues_loop
|
|
||||||
pop xh
|
|
||||||
pop xl
|
|
||||||
.if SENSORWATCH_AVG_VALUE_COUNT == 4
|
|
||||||
lsr r18 ; /2
|
|
||||||
ror r17
|
|
||||||
ror r16
|
|
||||||
lsr r18 ; /4
|
|
||||||
ror r17
|
|
||||||
ror r16
|
|
||||||
.endif
|
|
||||||
std Y+SENSORWATCH_OFFS_VALUE_LO, r16
|
|
||||||
std Y+SENSORWATCH_OFFS_VALUE_HI, r17
|
|
||||||
sensorWatchAvgValues_ret:
|
|
||||||
ret
|
|
||||||
; @end
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
; ---------------------------------------------------------------------------
|
; ---------------------------------------------------------------------------
|
||||||
; @routine SensorWatch_OnRecvReport @global
|
; @routine SensorWatch_OnRecvReport @global
|
||||||
;
|
;
|
||||||
@@ -443,11 +353,16 @@ SensorWatch_OnRecvReport:
|
|||||||
cp r16, r17
|
cp r16, r17
|
||||||
brne SensorWatch_OnRecvReport_ret
|
brne SensorWatch_OnRecvReport_ret
|
||||||
; store value
|
; store value
|
||||||
rcall sensorWatchAddValue ; (r16-r19)
|
std Y+SENSORWATCH_OFFS_VALUE_LO, r18
|
||||||
rcall sensorWatchAvgValues ; (r16-r22)
|
std Y+SENSORWATCH_OFFS_VALUE_HI, r19
|
||||||
|
|
||||||
; setup background color
|
; setup background color
|
||||||
|
push xl
|
||||||
|
push xh
|
||||||
rcall sensorWatchSetColor ; (any, !Y)
|
rcall sensorWatchSetColor ; (any, !Y)
|
||||||
rcall sensorWatchSetValueLabel ; (any, !Y)
|
rcall sensorWatchSetValueLabel ; (any, !Y)
|
||||||
|
pop xh
|
||||||
|
pop xl
|
||||||
SensorWatch_OnRecvReport_ret:
|
SensorWatch_OnRecvReport_ret:
|
||||||
clc
|
clc
|
||||||
ret
|
ret
|
||||||
|
|||||||
Reference in New Issue
Block a user