/* Includes ----------------------------------------------------------------- */
#include "task/user_task.h"
#include "usart.h" 
#include "bsp/led.h" 


/* Private variables -------------------------------------------------------- */
float distance = 0.0f; // 用于存储距离数据单位为米
/* Exported functions ------------------------------------------------------- */
void Task_PC(void *argument) {
    (void)argument; // 消除未使用参数的警告
    const uint32_t delay_tick = osKernelGetTickFreq() / 50; // 50Hz
    uint32_t tick = osKernelGetTickCount(); /* 控制任务运行频率的计时 */

    while (1) {
        tick += delay_tick; /* 计算下一个唤醒时刻 */
        if (osMessageQueueGet(task_runtime.msgq.pc, &distance, NULL, osWaitForever) == osOK) {
            HAL_UART_Transmit_DMA(&huart3, (uint8_t *)&distance, sizeof(distance)); // 发送数据
        }

        osDelayUntil(tick); /* 运行结束，等待下一次唤醒 */
    }
}