Files
HSP_demo/has_project/has_app/gui/has_gui.c

45 lines
949 B
C
Raw Normal View History

2026-04-10 18:10:51 +08:00
#include "has_platform.h"
2026-04-14 18:25:35 +08:00
static void timer_cb(void *arg)
{
(void)arg;
printf("hello timer\n");
has_timer_set(timer_cb, NULL, 1000);
}
2026-04-10 18:10:51 +08:00
static OS_THREAD_ID gui_tid;
2026-04-23 14:48:24 +08:00
static void gui_task(void *param)
2026-04-10 18:10:51 +08:00
{
2026-04-14 18:25:35 +08:00
(void)param;
2026-04-10 18:10:51 +08:00
uint8_t data[2];
data[0] = 0x5a;
data[1] = 0x5b;
2026-04-14 18:25:35 +08:00
has_timer_set(timer_cb, NULL, 1000);
2026-04-10 18:10:51 +08:00
while (1)
{
has_msg_publish(GUI, data, sizeof(data));
2026-04-23 14:48:24 +08:00
has_sleep_ms(10000);
2026-04-10 18:10:51 +08:00
}
}
int example_gui_init(void)
{
2026-04-23 14:48:24 +08:00
has_task_attr_t task_attr = {
.name = "gui",
.entry = gui_task,
.arg = NULL,
.stack_size_bytes = 1024U,
.priority = HAS_TASK_PRIORITY_NORMAL,
.linux_attr = { .sched_policy = -1 },
};
2026-04-10 18:10:51 +08:00
printf("module:GUI\n");
/* 创建线程 */
2026-04-23 14:48:24 +08:00
if (has_task_create(&task_attr, &gui_tid) != 0) {
printf("module:GUI create task failed\n");
2026-04-10 18:10:51 +08:00
return -1;
}
return 0;
}
HAS_DECLARE_MODULE(GUI, example_gui_init)