/*
    rc Task

*/

/* Includes ----------------------------------------------------------------- */
#include "cmsis_os2.h"
#include "task/user_task.h"
/* USER INCLUDE BEGIN */
#include "device/dr16.h"
#include "module/config.h"
// #include "module/shoot.h"
// #include "module/gimbal.h"
#include <stdbool.h>
// #include
/* USER INCLUDE END */

/* Private typedef ---------------------------------------------------------- */
/* Private define ----------------------------------------------------------- */
/* Private macro ------------------------------------------------------------ */
/* Private variables -------------------------------------------------------- */
/* USER STRUCT BEGIN */
DR16_t dr16;
// RC_CAN_t rc_can;
// Shoot_CMD_t for_shoot;
// Gimbal_CMD_t cmd_for_gimbal;
/* USER STRUCT END */

/* Private function --------------------------------------------------------- */
/* Exported functions ------------------------------------------------------- */
void Task_rc(void *argument) {
  (void)argument; /* 未使用argument，消除警告 */

  osDelay(RC_INIT_DELAY); /* 延时一段时间再开启任务 */

  /* USER CODE INIT BEGIN */
  DR16_Init(&dr16);
  /* USER CODE INIT END */

  while (1) {
    /* USER CODE BEGIN */
    DR16_StartDmaRecv(&dr16);
    if (DR16_WaitDmaCplt(20)) {
      DR16_ParseData(&dr16);

    } else {
      DR16_Offline(&dr16);
    }
    // for_shoot.online = dr16.header.online;
    // switch (dr16.data.sw_r) {
    // case DR16_SW_UP:
    //   for_shoot.ready = false;
    //   for_shoot.firecmd = false;
    //   break;
    // case DR16_SW_MID:
    //   for_shoot.ready = true;
    //   for_shoot.firecmd = false;
    //   break;
    // case DR16_SW_DOWN:
    //   for_shoot.ready = true;
    //   for_shoot.firecmd = true;
    //   break;
    // default:
    //   for_shoot.ready = false;
    //   for_shoot.firecmd = false;
    //   break;
    // }

    /* USER CODE END */
  }
}