/* Includes ----------------------------------------------------------------- */
#include "task\user_task.h"
#include "bsp\led.h"
#include "bsp\buzzer.h"
#include "device\lcd.h"

/* Private typedef ---------------------------------------------------------- */
/* Private define ----------------------------------------------------------- */
/* Private macro ------------------------------------------------------------ */
/* Private variables -------------------------------------------------------- */
/* Private function --------------------------------------------------------- */
/* Exported functions ------------------------------------------------------- */
void Task_Monitor(void *argument) {
    (void)argument; // 消除未使用参数的警告
    const uint32_t delay_tick = osKernelGetTickFreq() / TASK_FREQ_MONITOR; // 100Hz
    uint32_t tick = osKernelGetTickCount(); /* 控制任务运行频率的计时 */
    char tick_str[16];
    LCD_Init();
    LCD_Clear(BLACK);
    // HAL_Delay(5000); // 延时 1 秒
    LCD_Clear(RED);
    // LCD_DrawChar(0, 0, '0', WHITE, BLACK); // 在屏幕上显示字符
    LCD_DrawString(0, 0, "Hello", WHITE, BLACK); // 在屏幕上显示字符串
    LCD_DrawString(50, 0,"this is sick (DT35-driver)",BLACK,WHITE);
    BSP_LED_Set(BSP_LED_RED, BSP_LED_ON, 0);
    BSP_LED_Set(BSP_LED_BLUE, BSP_LED_ON, 0);
    while (1) {
        tick += delay_tick; /* 计算下一个唤醒时刻 */
        sprintf(tick_str, "Tick: %lu", tick);
        //展示tick
        LCD_DrawString(0, 20, tick_str, WHITE, BLACK); // 在屏幕上显示 tick 值
        // 切换 LED 状态
        BSP_LED_Set(BSP_LED_GREEN, BSP_LED_TAGGLE, 0); // 50% 占空比
        osDelayUntil(tick); /* 运行结束，等待下一次唤醒 */
    }
}
