started working on new n23 code.
This commit is contained in:
108
avr/devices/n23/main/motion.asm
Normal file
108
avr/devices/n23/main/motion.asm
Normal file
@@ -0,0 +1,108 @@
|
||||
; ***************************************************************************
|
||||
; copyright : (C) 2024 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. *
|
||||
; ***************************************************************************
|
||||
|
||||
|
||||
|
||||
; ***************************************************************************
|
||||
; defines
|
||||
|
||||
.equ APP_MOTION_KEEPUPTIME = 100 ; 10s
|
||||
|
||||
|
||||
|
||||
; ***************************************************************************
|
||||
; data
|
||||
|
||||
.dseg
|
||||
|
||||
appMotionKeepupData: .byte FILTER_KEEPUP_DATA_SIZE
|
||||
appMotionValSchedData: .byte VALSCHED_DATA_SIZE
|
||||
|
||||
|
||||
|
||||
; ***************************************************************************
|
||||
; code
|
||||
|
||||
.cseg
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine AppMotion_Init @global
|
||||
;
|
||||
|
||||
AppMotion_Init:
|
||||
rcall Motion_Init
|
||||
|
||||
ldi yl, LOW(appMotionKeepupData)
|
||||
ldi yh, HIGH(appMotionKeepupData)
|
||||
rcall FilterKeepUp_Init
|
||||
ldi r16, APP_MOTION_KEEPUPTIME
|
||||
std Y+FILTER_KEEPUP_OFFS_RESTARTVALUE, r16
|
||||
|
||||
ldi yl, LOW(appMotionValSchedData)
|
||||
ldi yh, HIGH(appMotionValSchedData)
|
||||
rcall ValueScheduler_Init
|
||||
ldi r16, (1<<VALSCHED_FLAGS_REPEAT1_BIT) ; only repeat report interval for active motion
|
||||
std Y+VALSCHED_OFFS_FLAGS, r16
|
||||
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine AppMotion_Every100ms @global
|
||||
;
|
||||
|
||||
AppMotion_Every100ms:
|
||||
rcall Motion_GetValue ; get value into R16
|
||||
|
||||
ldi yl, LOW(appMotionKeepupData)
|
||||
ldi yh, HIGH(appMotionKeepupData)
|
||||
rcall FilterKeepUp_SetValue ; (R17)
|
||||
rcall FilterKeepUp_Every100ms
|
||||
rcall FilterKeepUp_GetValue ; get value into R16
|
||||
|
||||
ldi yl, LOW(appMotionValSchedData)
|
||||
ldi yh, HIGH(appMotionValSchedData)
|
||||
rcall FilterKeepUp_SetValue ; (R17)
|
||||
rcall ValueScheduler_Every100ms ; (R16, R17)
|
||||
rcall ValueScheduler_CheckSend ; (R16)
|
||||
brcc AppMotion_Every100ms_end
|
||||
rcall NET_Buffer_Alloc
|
||||
brcc AppMotion_Every100ms_end ; jmp on error
|
||||
push r16 ; buffer num
|
||||
rcall ValueScheduler_GetValue ; get value to r16
|
||||
mov r18, r16 ; R19:R18 = value
|
||||
clr r19
|
||||
ldi r16, 0xff ; DEST addr
|
||||
ldi r17, VALUE_ID_MOTION ; VALUE ID
|
||||
ldi r20, 1 ; R21:R20 = denom
|
||||
clr r21
|
||||
ldi r22, AQHOME_VALUETYPE_MOTION ; VALUE TYPE
|
||||
adiw xh:xl, 1
|
||||
rcall NETMSG_ValueWriteReport ; (R16, R17, R18, R19, R20, R21, R23, R24, R25)
|
||||
sbiw xh:xl, 1
|
||||
pop r16 ; buffer num
|
||||
ldi yl, LOW(netInterfaceData)
|
||||
ldi yh, HIGH(netInterfaceData)
|
||||
rcall NET_Interface_AddOutgoingMsgNum ; (R17, R18, X)
|
||||
brcs AppMotion_Every100ms_markSent
|
||||
rcall NET_Buffer_ReleaseByNum
|
||||
rjmp AppMotion_Every100ms_end
|
||||
AppMotion_Every100ms_markSent:
|
||||
ldi yl, LOW(appMotionValSchedData)
|
||||
ldi yh, HIGH(appMotionValSchedData)
|
||||
rcall ValueScheduler_MarkSent ; (R16)
|
||||
AppMotion_Every100ms_end:
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user