freertos_f407/User/application/app.c

66 lines
1.7 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 "shell_port.h"
#include "../system/lib/flow/flow.h"
#include "../system/sgl/sgl.h"
extern Shell shell; /* defined in shell_port.c */
static struct flow fl_business;
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 出现在屏幕 */
}
static char business_process(struct flow *fl)
{
FL_HEAD(fl);
for (;;)
{
rtc_update();
sgl_print_hello();
FL_LOCK_DELAY(fl, FL_CLOCK_SEC * 1U); /* 显示 1 秒 */
lcd_rtc_test();
led_toggle(LED_USER);
FL_LOCK_DELAY(fl, FL_CLOCK_SEC * 1U); /* 显示 1 秒 */
}
FL_TAIL(fl);
}
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)
{
FL_INIT(&fl_business);
userShellInit();
}
void app_run(void)
{
business_process(&fl_business);
shellTask(&shell);
}