generated from Embedded_Projects/Landzo_K60Z_LwIP
67 lines
2.1 KiB
C
67 lines
2.1 KiB
C
/* FreeRTOS */
|
|
#include "FreeRTOS.h"
|
|
#include "task.h"
|
|
|
|
/* LVGL */
|
|
#include "lvgl.h"
|
|
|
|
/* UI */
|
|
#include "ui_helpers.h"
|
|
|
|
void ui_standby_task(void *pvParameters) {
|
|
lv_style_t style_label_time;
|
|
lv_style_t style_image_background;
|
|
lv_obj_t *label_time = NULL;
|
|
lv_obj_t *image_background = NULL;
|
|
|
|
if (xSemaphoreTake(g_lvgl_semphr, portMAX_DELAY) == pdTRUE) {
|
|
|
|
/* Background style */
|
|
lv_style_init(&style_image_background);
|
|
lv_style_set_opa(&style_image_background, LV_OPA_30);
|
|
|
|
/* Label style */
|
|
lv_style_init(&style_label_time);
|
|
lv_style_set_text_font(&style_label_time, g_font_noto_sans_bold_72);
|
|
lv_style_set_text_color(&style_label_time, lv_palette_main(LV_PALETTE_PINK));
|
|
|
|
/* Background image */
|
|
image_background = lv_img_create(g_screen_standby);
|
|
lv_img_set_src(image_background, "A:/resources/images/bg_image_1.bin");
|
|
lv_obj_add_style(image_background, &style_image_background, LV_STATE_DEFAULT);
|
|
lv_obj_move_background(image_background);
|
|
|
|
/* Time label */
|
|
label_time = lv_label_create(g_screen_standby);
|
|
lv_obj_add_style(label_time, &style_label_time, 0);
|
|
lv_obj_set_width(label_time, 240);
|
|
lv_obj_set_height(label_time, 80);
|
|
lv_obj_align(label_time, LV_ALIGN_CENTER, 0, -40);
|
|
lv_obj_set_style_text_align(label_time, LV_TEXT_ALIGN_CENTER, 0);
|
|
lv_label_set_text(label_time, "--:--");
|
|
|
|
xSemaphoreGive(g_lvgl_semphr);
|
|
}
|
|
|
|
ui_standby_queue_t cmd;
|
|
|
|
for (;;) {
|
|
if (xQueueReceive(g_ui_standby_queue, &cmd, portMAX_DELAY) == pdPASS) {
|
|
switch (cmd.cmd) {
|
|
case UI_STANDBY_CMD_UPDATE_TIME: {
|
|
if (xSemaphoreTake(g_lvgl_semphr, portMAX_DELAY) == pdTRUE) {
|
|
lv_label_set_text(label_time, (char *)cmd.payload);
|
|
|
|
xSemaphoreGive(g_lvgl_semphr);
|
|
}
|
|
|
|
vPortFree(cmd.payload);
|
|
|
|
break;
|
|
}
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
} |