freertos_f407/User/application/app.c

65 lines
2.0 KiB
C
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#include "app.h"
#include "board.h"
#include "os.h"
#include "shell_port.h"
#include "../system/sgl/sgl.h"
static TaskHandle_t business_task_handle = NULL;
extern Shell shell; /* defined in shell_port.c */
static void sgl_print_hello(void)
{
sgl_obj_delete(NULL);
sgl_task_handle(); /* 刷新:屏幕清空 */
sgl_page_set_color(sgl_screen_act(), sgl_rgb(0x00, 0x00, 0x00));
sgl_obj_t *label = sgl_label_create(NULL);
sgl_obj_set_pos(label, 0, 0);
sgl_obj_set_size(label, 240, 240);
sgl_label_set_font(label, &song23);
sgl_label_set_text_color(label, sgl_rgb(0xFF, 0xFF, 0xFF));
sgl_label_set_text_align(label, SGL_ALIGN_CENTER);
sgl_label_set_text(label, "Hello World");
sgl_task_handle(); /* 渲染Hello World 出现在屏幕 */
}
void business_task(void *pvParameters)
{
for (;;)
{
rtc_update();
sgl_print_hello();
vTaskDelay(1000); /* 显示 1 秒 */
lcd_rtc_test();
led_toggle(LED_USER);
vTaskDelay(1000);
}
}
static void cmd_mem_info(void)
{
sgl_mm_monitor_t m = sgl_mm_get_monitor();
shellPrint(&shell, "SGL mem: total=%u used=%u free=%u rate=%u.%02u%%\r\n",
m.total_size, m.used_size, m.free_size,
(m.used_rate >> 8) & 0xFF,
m.used_rate & 0xFF);
}
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0) | SHELL_CMD_TYPE(SHELL_TYPE_CMD_FUNC),
meminfo, cmd_mem_info, "show sgl memory usage");
void app_init(void)
{
userShellInit(); // 初始化shell
// 创建任务
xTaskCreate((TaskFunction_t)business_task, // 任务入口函数
(const char *)"business_task", // 任务名字
(uint16_t)1024, // 任务栈大小
(void *)NULL, // 任务入口函数参数
(UBaseType_t)1, // 任务优先级
(TaskHandle_t *)&business_task_handle); // 任务句柄
}