/** * @file display_service.c * @author Alvin Young (impressionyang@outlook.com) * @brief * @version 0.1 * @date 2025-03-20 * * _ _ * (_)_ _ ___ _______ ___ ___ (_)__ ___ __ _____ ____ ___ _ * / / ' \/ _ \/ __/ -_|_-<(_- * Date Version Author Description * 2025-03-20 v1.0 Alvin Young 首次创建 * * */ /* Define to prevent recursive inclusion -------------------------------------*/ /* Includes ------------------------------------------------------------------*/ #include "display_service.h" #include "freertos/FreeRTOS.h" #include "freertos/task.h" #include "imp_msg_queue.h" #include "main_common.h" #include #include #include "u8g2.h" #include "u8x8.h" /* define --------------------------------------------------------------------*/ /* typedef -------------------------------------------------------------------*/ /* variables -----------------------------------------------------------------*/ static imp_msg_queue_t* msg_q_handle = NULL; static u8g2_t u8g2; /* Private function(only *.c) -----------------------------------------------*/ /* Exported functions --------------------------------------------------------*/ void imp_display_service_task(void*) { uint8_t msg_recv_ret = 0; imp_msg_item_t msg_item = { 0 }; msg_q_handle = imp_msg_queue_create_handle(IMP_TASK_ID_DISP_SERVICE_TASK); extern void u8g2Init(u8g2_t * u8g2); u8g2Init(&u8g2); char build_time[100] = {0}; snprintf(build_time, 100, "%s %s", __DATE__, __TIME__); u8g2_SetFont(&u8g2, u8g2_font_helvB08_tr); // 设置英文字体 u8g2_DrawStr(&u8g2, 0, 13, "welcom to use u8g2"); u8g2_DrawStr(&u8g2, 0, 32, build_time); u8g2_SendBuffer(&u8g2); // 一定要发送buffer while (1) { msg_recv_ret = imp_msg_queue_recv_msg(msg_q_handle, &msg_item, 10); if (!msg_recv_ret) { cdc_printf("%s get msg from %s OK\r\n", imp_main_task_table[msg_item.recv_id], imp_main_task_table[msg_item.send_id]); switch (msg_item.msg_data) { case 0: // clear u8g2_ClearBuffer(&u8g2); u8g2_SendBuffer(&u8g2); break; case 1: u8g2_DrawStr(&u8g2, 0, 13, "impressionyang"); u8g2_SendBuffer(&u8g2); // 一定要发送buffer break; } } vTaskDelay(1 / portTICK_PERIOD_MS); } } /* * EOF */