; ***************************************************************************
; 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_APPS_FAN_CONTROL_RECV_ASM
#define AQH_AVR_APPS_FAN_CONTROL_RECV_ASM


.cseg




; ---------------------------------------------------------------------------
; @routine AppMotionLight_OnPacketReceived @global
;
; @clobbers any, -X

AppFanControl_OnPacketReceived:
  ldi zl, LOW(appFanControlObjectFlash*2)
  ldi zh, HIGH(appFanControlObjectFlash*2)
  push zl
    push zh
      lpm yl, Z+
      lpm yh, Z
      ldi zl, LOW(appFanControlMsgTable*2)
      ldi zh, HIGH(appFanControlMsgTable*2)
      bigcall Main_HandleValueMsg
    pop zh
  pop zl
AppFanControl_OnPacketReceived_ret:
  ret
; @end



; ---------------------------------------------------------------------------
; @routine appFanControlSetValue
;
; @clobbers any, -X

appFanControlSetValue:
  std Y+APP_FANCONTROL_RAM_OFFS_VALUE_LO, r18
  std Y+APP_FANCONTROL_RAM_OFFS_VALUE_HI, r19
  bigjmp TCA_SetValueACK
; @end




appFanControlMsgTable:
  .db NETMSG_CMD_VALUE_REPORT, 0,                            LOW(TCA_HandleMsg),               HIGH(TCA_HandleMsg)
  .db NETMSG_CMD_VALUE_SET,    VALUE_ID_FANCTRL_GUARDSRC,    LOW(TCA_SetValue_GuardSrc),       HIGH(TCA_SetValue_GuardSrc)
  .db NETMSG_CMD_VALUE_SET,    VALUE_ID_FANCTRL_GUARDLIM,    LOW(TCA_SetValue_GuardLimits),    HIGH(TCA_SetValue_GuardLimits)
  .db NETMSG_CMD_VALUE_SET,    VALUE_ID_FANCTRL_TRIGGER1SRC, LOW(TCA_SetValue_Trigger1Src),    HIGH(TCA_SetValue_Trigger1Src)
  .db NETMSG_CMD_VALUE_SET,    VALUE_ID_FANCTRL_TRIGGER1LIM, LOW(TCA_SetValue_Trigger1Limits), HIGH(TCA_SetValue_Trigger1Limits)
  .db NETMSG_CMD_VALUE_SET,    VALUE_ID_FANCTRL_TRIGGER2SRC, LOW(TCA_SetValue_Trigger2Src),    HIGH(TCA_SetValue_Trigger2Src)
  .db NETMSG_CMD_VALUE_SET,    VALUE_ID_FANCTRL_TRIGGER2LIM, LOW(TCA_SetValue_Trigger2Limits), HIGH(TCA_SetValue_Trigger2Limits)
  .db NETMSG_CMD_VALUE_SET,    VALUE_ID_FANCTRL_HOLDTIME,    LOW(TCA_SetValue_HoldTime),       HIGH(TCA_SetValue_HoldTime)
  .db NETMSG_CMD_VALUE_SET,    VALUE_ID_FANCTRL_MODE,        LOW(TCA_SetValue_Mode),           HIGH(TCA_SetValue_Mode)
  .db NETMSG_CMD_VALUE_SET,    VALUE_ID_FANCTRL_VALUE,       LOW(appFanControlSetValue),       HIGH(appFanControlSetValue)
  .db 0, 0, 0, 0








#endif

