void events_init_zhu_mian_screen(lv_ui *ui)
->static void zhu_mian_screen_imgbtn_1_event_handler(lv_event_t *e)
-> void setup_scr_tong_hua_screen(lv_ui *ui)
-> events_init_tong_hua_screen(ui);
->void call_screen_enter_cb(void)
->static void call_screen_update_timer_callback(lv_timer_t *timer)
->static void on_tong_hua_screen_imgbtn_4_click(lv_event_t *e)
void create_tong_hua_screen_cont_2(lv_obj_t *parent, int x, int y, int id)
#include <lvgl/lvgl.h>
#include <lvgl.h>
#include <stdio.h>
#define TIMER_INTERVAL_MS 30
void create_tong_hua_screen_cont_2(lv_obj_t *parent, int x, int y, int id);
void create_tong_hua_screen_cont_6(lv_obj_t *parent, int x, int y, int id);
lv_timer_t *call_screen_enter_timer;
static int container_counter = 0;
static int container_counter2 = 0;
static int container_counter3 = 0;
const char *button_str = "Hello, World!";
static void on_tong_hua_screen_imgbtn_4_click(lv_event_t *e)
{
lv_obj_t *obj = lv_event_get_target(e);
char *str_ptr = (char *)lv_event_get_user_data(e);
lv_obj_t *container = lv_obj_get_parent(obj);
bool checked = lv_obj_has_state(obj, LV_STATE_CHECKED);
if (checked)
{
printf("Button clicked! User data: %s\n", str_ptr);
}
else
{
printf("Button clicked! User data: %s\n", str_ptr);
}
}
static void on_tong_hua_screen_imgbtn_8_click(lv_event_t *e)
{
lv_obj_t *obj = lv_event_get_target(e);
char *str_ptr = (char *)lv_event_get_user_data(e);
lv_obj_t *container = lv_obj_get_parent(obj);
bool checked = lv_obj_has_state(obj, LV_STATE_CHECKED);
if (checked)
{
printf("Button clicked! User data: %s\n", str_ptr);
}
else
{
printf("Button clicked! User data: %s\n", str_ptr);
}
}
void create_tong_hua_screen_cont_2(lv_obj_t *parent, int x, int y, int id)
{
lv_obj_t *tong_hua_screen_cont_2 = lv_obj_create(parent);
lv_obj_set_pos(tong_hua_screen_cont_2, x, y);
lv_obj_set_size(tong_hua_screen_cont_2, 80, 120);
lv_obj_set_scrollbar_mode(tong_hua_screen_cont_2, LV_SCROLLBAR_MODE_OFF);
lv_obj_set_style_border_width(tong_hua_screen_cont_2, 2, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_border_opa(tong_hua_screen_cont_2, 255, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_border_color(tong_hua_screen_cont_2, lv_color_hex(0x2195f6), LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_border_side(tong_hua_screen_cont_2, LV_BORDER_SIDE_NONE, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_radius(tong_hua_screen_cont_2, 0, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_bg_opa(tong_hua_screen_cont_2, 0, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_pad_top(tong_hua_screen_cont_2, 0, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_pad_bottom(tong_hua_screen_cont_2, 0, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_pad_left(tong_hua_screen_cont_2, 0, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_pad_right(tong_hua_screen_cont_2, 0, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_shadow_width(tong_hua_screen_cont_2, 0, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_t *tong_hua_screen_imgbtn_4 = lv_imgbtn_create(tong_hua_screen_cont_2);
lv_obj_add_flag(tong_hua_screen_imgbtn_4, LV_OBJ_FLAG_CHECKABLE);
lv_imgbtn_set_src(tong_hua_screen_imgbtn_4, LV_IMGBTN_STATE_RELEASED, NULL, &_AQ_alpha_75x75, NULL);
lv_obj_set_pos(tong_hua_screen_imgbtn_4, 2, 8);
lv_obj_set_size(tong_hua_screen_imgbtn_4, 75, 75);
lv_obj_t *tong_hua_screen_imgbtn_4_label = lv_label_create(tong_hua_screen_imgbtn_4);
lv_label_set_text(tong_hua_screen_imgbtn_4_label, "");
lv_label_set_long_mode(tong_hua_screen_imgbtn_4_label, LV_LABEL_LONG_WRAP);
lv_obj_align(tong_hua_screen_imgbtn_4_label, LV_ALIGN_CENTER, 0, 0);
lv_obj_set_style_pad_all(tong_hua_screen_imgbtn_4, 0, LV_STATE_DEFAULT);
lv_obj_set_style_text_color(tong_hua_screen_imgbtn_4, lv_color_hex(0x000000), LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_text_font(tong_hua_screen_imgbtn_4, &lv_font_SourceHanSerifSC_Regular_12, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_text_opa(tong_hua_screen_imgbtn_4, 255, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_text_align(tong_hua_screen_imgbtn_4, LV_TEXT_ALIGN_CENTER, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_shadow_width(tong_hua_screen_imgbtn_4, 0, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_img_opa(tong_hua_screen_imgbtn_4, 255, LV_PART_MAIN | LV_STATE_PRESSED);
lv_obj_set_style_text_color(tong_hua_screen_imgbtn_4, lv_color_hex(0xFF33FF), LV_PART_MAIN | LV_STATE_PRESSED);
lv_obj_set_style_text_font(tong_hua_screen_imgbtn_4, &lv_font_SourceHanSerifSC_Regular_12, LV_PART_MAIN | LV_STATE_PRESSED);
lv_obj_set_style_text_opa(tong_hua_screen_imgbtn_4, 255, LV_PART_MAIN | LV_STATE_PRESSED);
lv_obj_set_style_shadow_width(tong_hua_screen_imgbtn_4, 0, LV_PART_MAIN | LV_STATE_PRESSED);
lv_obj_set_style_img_opa(tong_hua_screen_imgbtn_4, 255, LV_PART_MAIN | LV_STATE_CHECKED);
lv_obj_set_style_text_color(tong_hua_screen_imgbtn_4, lv_color_hex(0xFF33FF), LV_PART_MAIN | LV_STATE_CHECKED);
lv_obj_set_style_text_font(tong_hua_screen_imgbtn_4, &lv_font_SourceHanSerifSC_Regular_12, LV_PART_MAIN | LV_STATE_CHECKED);
lv_obj_set_style_text_opa(tong_hua_screen_imgbtn_4, 255, LV_PART_MAIN | LV_STATE_CHECKED);
lv_obj_set_style_shadow_width(tong_hua_screen_imgbtn_4, 0, LV_PART_MAIN | LV_STATE_CHECKED);
lv_obj_t *tong_hua_screen_label_4 = lv_label_create(tong_hua_screen_cont_2);
lv_label_set_text(tong_hua_screen_label_4, "yong1");
lv_label_set_long_mode(tong_hua_screen_label_4, LV_LABEL_LONG_WRAP);
lv_obj_set_pos(tong_hua_screen_label_4, 5, 91);
lv_obj_set_size(tong_hua_screen_label_4, 69, 32);
lv_obj_set_style_border_width(tong_hua_screen_label_4, 0, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_radius(tong_hua_screen_label_4, 0, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_text_color(tong_hua_screen_label_4, lv_color_hex(0x000000), LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_text_font(tong_hua_screen_label_4, &lv_font_SourceHanSerifSC_Regular_24, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_text_opa(tong_hua_screen_label_4, 255, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_text_letter_space(tong_hua_screen_label_4, 2, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_text_line_space(tong_hua_screen_label_4, 0, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_text_align(tong_hua_screen_label_4, LV_TEXT_ALIGN_CENTER, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_bg_opa(tong_hua_screen_label_4, 0, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_pad_top(tong_hua_screen_label_4, 0, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_pad_right(tong_hua_screen_label_4, 0, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_pad_bottom(tong_hua_screen_label_4, 0, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_pad_left(tong_hua_screen_label_4, 0, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_shadow_width(tong_hua_screen_label_4, 0, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_t *tong_hua_screen_led_1 = lv_led_create(tong_hua_screen_cont_2);
lv_led_set_brightness(tong_hua_screen_led_1, 255);
lv_led_set_color(tong_hua_screen_led_1, lv_color_hex(0xff5700));
lv_obj_set_pos(tong_hua_screen_led_1, 19, 15);
lv_obj_set_size(tong_hua_screen_led_1, 12, 12);
lv_obj_add_event_cb(tong_hua_screen_imgbtn_4, on_tong_hua_screen_imgbtn_4_click, LV_EVENT_CLICKED, (void *)button_str);
}
void create_tong_hua_screen_cont_6(lv_obj_t *parent, int x, int y, int id)
{
lv_obj_t *tong_hua_screen_cont_6 = lv_obj_create(parent);
lv_obj_set_pos(tong_hua_screen_cont_6, x, y);
lv_obj_set_size(tong_hua_screen_cont_6, 80, 120);
lv_obj_set_scrollbar_mode(tong_hua_screen_cont_6, LV_SCROLLBAR_MODE_OFF);
lv_obj_set_style_border_width(tong_hua_screen_cont_6, 2, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_border_opa(tong_hua_screen_cont_6, 255, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_border_color(tong_hua_screen_cont_6, lv_color_hex(0x2195f6), LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_border_side(tong_hua_screen_cont_6, LV_BORDER_SIDE_NONE, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_radius(tong_hua_screen_cont_6, 0, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_bg_opa(tong_hua_screen_cont_6, 0, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_pad_top(tong_hua_screen_cont_6, 0, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_pad_bottom(tong_hua_screen_cont_6, 0, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_pad_left(tong_hua_screen_cont_6, 0, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_pad_right(tong_hua_screen_cont_6, 0, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_shadow_width(tong_hua_screen_cont_6, 0, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_t *tong_hua_screen_imgbtn_8 = lv_imgbtn_create(tong_hua_screen_cont_6);
lv_obj_add_flag(tong_hua_screen_imgbtn_8, LV_OBJ_FLAG_CHECKABLE);
lv_imgbtn_set_src(tong_hua_screen_imgbtn_8, LV_IMGBTN_STATE_RELEASED, NULL, &_A6_alpha_80x90, NULL);
lv_obj_set_pos(tong_hua_screen_imgbtn_8, 5, 0);
lv_obj_set_size(tong_hua_screen_imgbtn_8, 80, 90);
lv_obj_t *tong_hua_screen_label_8 = lv_label_create(tong_hua_screen_cont_6);
lv_label_set_text(tong_hua_screen_label_8, "sss");
lv_label_set_long_mode(tong_hua_screen_label_8, LV_LABEL_LONG_WRAP);
lv_obj_set_pos(tong_hua_screen_label_8, 5, 91);
lv_obj_set_size(tong_hua_screen_label_8, 69, 32);
lv_obj_set_style_border_width(tong_hua_screen_label_8, 0, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_radius(tong_hua_screen_label_8, 0, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_text_color(tong_hua_screen_label_8, lv_color_hex(0x000000), LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_text_font(tong_hua_screen_label_8, &lv_font_SourceHanSerifSC_Regular_24, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_text_opa(tong_hua_screen_label_8, 255, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_text_letter_space(tong_hua_screen_label_8, 2, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_text_line_space(tong_hua_screen_label_8, 0, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_text_align(tong_hua_screen_label_8, LV_TEXT_ALIGN_CENTER, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_bg_opa(tong_hua_screen_label_8, 0, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_pad_top(tong_hua_screen_label_8, 0, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_pad_right(tong_hua_screen_label_8, 0, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_pad_bottom(tong_hua_screen_label_8, 0, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_pad_left(tong_hua_screen_label_8, 0, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_shadow_width(tong_hua_screen_label_8, 0, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_text_color(tong_hua_screen_imgbtn_8, lv_color_hex(0x000000), LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_text_font(tong_hua_screen_imgbtn_8, &lv_font_SourceHanSerifSC_Regular_12, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_text_opa(tong_hua_screen_imgbtn_8, 255, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_text_align(tong_hua_screen_imgbtn_8, LV_TEXT_ALIGN_CENTER, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_shadow_width(tong_hua_screen_imgbtn_8, 0, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_img_opa(tong_hua_screen_imgbtn_8, 255, LV_PART_MAIN | LV_STATE_PRESSED);
lv_obj_set_style_text_color(tong_hua_screen_imgbtn_8, lv_color_hex(0xFF33FF), LV_PART_MAIN | LV_STATE_PRESSED);
lv_obj_set_style_text_font(tong_hua_screen_imgbtn_8, &lv_font_SourceHanSerifSC_Regular_12, LV_PART_MAIN | LV_STATE_PRESSED);
lv_obj_set_style_text_opa(tong_hua_screen_imgbtn_8, 255, LV_PART_MAIN | LV_STATE_PRESSED);
lv_obj_set_style_shadow_width(tong_hua_screen_imgbtn_8, 0, LV_PART_MAIN | LV_STATE_PRESSED);
lv_obj_t *tong_hua_screen_led_2 = lv_led_create(tong_hua_screen_cont_6);
lv_led_set_brightness(tong_hua_screen_led_2, 255);
lv_led_set_color(tong_hua_screen_led_2, lv_color_hex(0xff5700));
lv_obj_set_pos(tong_hua_screen_led_2, 19, 15);
lv_obj_set_size(tong_hua_screen_led_2, 12, 12);
lv_obj_add_event_cb(tong_hua_screen_imgbtn_8, on_tong_hua_screen_imgbtn_8_click, LV_EVENT_CLICKED, (void *)button_str);
}
static void call_screen_update_timer_callback(lv_timer_t *timer)
{
int i = 0;
int n = 0;
int row = 0;
int col = 0;
int x = 0;
int y = 0;
int cont2_num = 0;
int cont6_num = 0;
static int last_index;
printf("call_screen_update_cb\n");
#if defined(_WIN32) || defined(_WIN64)
DWORD result = WaitForSingleObject(tab_content_mutex, INFINITE);
if (result != WAIT_OBJECT_0)
{
printf("Failed to wait on the event.\n");
return;
}
#elif defined(__FreeRTOS__)
if (xSemaphoreTake(tab_content_mutex, portMAX_DELAY) != pdTRUE)
{
printf("Failed to take the mutex.\n");
return;
}
#endif
int index = lv_tabview_get_tab_act(guider_ui.tong_hua_screen_tabview_1);
if (last_index != index)
{
last_index = index;
cont2_num = 0;
cont6_num = 0;
}
switch (index)
{
case 0:
for (int i = 0; i < NUM_SLAVE_DEV; i++)
{
if (host_dev.slave_dev_params_t[i].ext.is_registered)
{
if (host_dev.slave_dev_params_t[i].ext.type == USER_DEV)
{
cont2_num++;
}
else if (host_dev.slave_dev_params_t[i].ext.type == STAFF_DEV)
{
cont6_num++;
}
}
}
if (container_counter < cont2_num)
{
int n = container_counter;
int row = n / 10;
int col = n % 10;
int x = 10 + col * (80 + 10);
int y = 10 + row * (120 + 10);
create_tong_hua_screen_cont_2(guider_ui.tong_hua_screen_tabview_1_tab_1, x, y, container_counter + 1);
container_counter++;
}
else if (container_counter < cont2_num + cont6_num)
{
int n = container_counter;
int row = n / 10;
int col = n % 10;
int x = 10 + col * (80 + 10);
int y = 10 + row * (120 + 10);
create_tong_hua_screen_cont_6(guider_ui.tong_hua_screen_tabview_1_tab_1, x, y, container_counter + 1);
container_counter++;
}
if (container_counter >= cont2_num + cont6_num)
{
container_counter = 0;
if (call_screen_enter_timer != NULL)
{
lv_timer_del(call_screen_enter_timer);
call_screen_enter_timer = NULL;
}
}
break;
case 1:
{
for (int i = 0; i < NUM_SLAVE_DEV; i++)
{
if (host_dev.slave_dev_params_t[i].ext.type == USER_DEV && host_dev.slave_dev_params_t[i].ext.is_registered)
{
cont2_num++;
}
}
if (container_counter2 < cont2_num)
{
int n = container_counter2;
int row = n / 10;
int col = n % 10;
int x = 10 + col * (80 + 10);
int y = 10 + row * (120 + 10);
create_tong_hua_screen_cont_2(guider_ui.tong_hua_screen_tabview_1_tab_2, x, y, container_counter2 + 1);
container_counter2++;
}
else
{
container_counter2 = 0;
if (call_screen_enter_timer != NULL)
{
lv_timer_del(call_screen_enter_timer);
call_screen_enter_timer = NULL;
}
}
break;
}
case 2:
{
for (int i = 0; i < NUM_SLAVE_DEV; i++)
{
if (host_dev.slave_dev_params_t[i].ext.type == STAFF_DEV && host_dev.slave_dev_params_t[i].ext.is_registered)
{
cont6_num++;
}
}
if (container_counter3 < cont6_num)
{
int n = container_counter3;
int row = n / 10;
int col = n % 10;
int x = 10 + col * (80 + 10);
int y = 10 + row * (120 + 10);
create_tong_hua_screen_cont_6(guider_ui.tong_hua_screen_tabview_1_tab_3, x, y, container_counter3 + 1);
container_counter3++;
}
else
{
container_counter3 = 0;
if (call_screen_enter_timer != NULL)
{
lv_timer_del(call_screen_enter_timer);
call_screen_enter_timer = NULL;
}
}
break;
}
}
#if defined(_WIN32) || defined(_WIN64)
SetEvent(tab_content_mutex);
#elif defined(__FreeRTOS__)
xSemaphoreGive(tab_content_mutex);
#endif
}
void call_screen_enter_cb(void)
{
printf("Screen entered\n");
if (!call_screen_enter_timer)
{
for (int i = 0; i < NUM_SLAVE_DEV; i++)
{
host_dev.slave_dev_params_t[i].ext.is_registered = true;
host_dev.slave_dev_params_t[i].ext.type = (i % 2 == 0) ? USER_DEV : STAFF_DEV;
}
call_screen_enter_timer = lv_timer_create(call_screen_update_timer_callback, TIMER_INTERVAL_MS, NULL);
lv_timer_set_repeat_count(call_screen_enter_timer, -1);
}
}
extern void call_screen_enter_cb(void);
extern void call_screenexit_cb(void);
static void tong_hua_screen_event_handler(lv_event_t *e)
{
lv_event_code_t code = lv_event_get_code(e);
switch (code)
{
case LV_EVENT_CLICKED:
{
ui_load_scr_animation(&guider_ui, &guider_ui.zhu_mian_screen, guider_ui.zhu_mian_screen_del, &guider_ui.tong_hua_screen_del, setup_scr_zhu_mian_screen, LV_SCR_LOAD_ANIM_NONE, 200, 200, false, true);
break;
}
case LV_EVENT_SCREEN_LOAD_START:
{
call_screen_enter_cb();
break;
}
case LV_EVENT_SCREEN_UNLOAD_START:
{
break;
}
default:
break;
}
}
static void tong_hua_screen_tabview_1_event_handler(lv_event_t *e)
{
lv_event_code_t code = lv_event_get_code(e);
switch (code)
{
case LV_EVENT_VALUE_CHANGED:
{
call_screen_enter_cb();
break;
}
default:
break;
}
}
void events_init_tong_hua_screen(lv_ui *ui)
{
lv_obj_add_event_cb(ui->tong_hua_screen, tong_hua_screen_event_handler, LV_EVENT_ALL, ui);
lv_obj_add_event_cb(ui->tong_hua_screen_imgbtn_1, tong_hua_screen_imgbtn_1_event_handler, LV_EVENT_ALL, ui);
lv_obj_add_event_cb(ui->tong_hua_screen_tabview_1, tong_hua_screen_tabview_1_event_handler, LV_EVENT_ALL, ui);
lv_obj_add_event_cb(ui->tong_hua_screen_imgbtn_4, tong_hua_screen_imgbtn_4_event_handler, LV_EVENT_ALL, ui);
lv_obj_add_event_cb(ui->tong_hua_screen_imgbtn_8, tong_hua_screen_imgbtn_8_event_handler, LV_EVENT_ALL, ui);
}
void events_init_tong_hua_screen(lv_ui *ui)
{
lv_obj_add_event_cb(ui->tong_hua_screen, tong_hua_screen_event_handler, LV_EVENT_ALL, ui);
lv_obj_add_event_cb(ui->tong_hua_screen_imgbtn_1, tong_hua_screen_imgbtn_1_event_handler, LV_EVENT_ALL, ui);
lv_obj_add_event_cb(ui->tong_hua_screen_tabview_1, tong_hua_screen_tabview_1_event_handler, LV_EVENT_ALL, ui);
lv_obj_add_event_cb(ui->tong_hua_screen_imgbtn_4, tong_hua_screen_imgbtn_4_event_handler, LV_EVENT_ALL, ui);
lv_obj_add_event_cb(ui->tong_hua_screen_imgbtn_8, tong_hua_screen_imgbtn_8_event_handler, LV_EVENT_ALL, ui);
}
#include <lvgl.h>
#include <stdbool.h>
#include <stdlib.h>
#include <string.h>
typedef struct
{
int x;
int y;
lv_obj_t *container;
lv_obj_t *label;
lv_obj_t *led;
lv_obj_t *imgbtn;
} TabContent;
TabContent tab_content_1;
TabContent tab_content_2;
#if defined(_WIN32) || defined(_WIN64)
#include <windows.h>
HANDLE tab_content_mutex = NULL;
#elif defined(__FreeRTOS__)
SemaphoreHandle_t tab_content_mutex = NULL;
#else
#error "Unsupported platform"
#endif
void init_tab_content_mutex(void)
{
#if defined(_WIN32) || defined(_WIN64)
SECURITY_ATTRIBUTES sa;
sa.nLength = sizeof(SECURITY_ATTRIBUTES);
sa.bInheritHandle = FALSE;
sa.lpSecurityDescriptor = NULL;
tab_content_mutex = CreateEvent(&sa, TRUE, TRUE, NULL);
if (tab_content_mutex == NULL)
{
printf("Failed to create event.\n");
}
#elif defined(__FreeRTOS__)
tab_content_mutex = xSemaphoreCreateMutex();
if (tab_content_mutex == NULL)
{
printf("Failed to create mutex.\n");
}
#endif
}
void destroy_tab_content_mutex(void)
{
#if defined(_WIN32) || defined(_WIN64)
CloseHandle(tab_content_mutex);
#elif defined(__FreeRTOS__)
vSemaphoreDelete(tab_content_mutex);
#endif
}
void set_tab_content(TabContent *content, int x, int y, const char *label_text, bool tab_cont_checked, bool led_checked, bool imgbtn_src)
{
set_widget_pos(content->container, x, y);
if (tab_cont_checked)
{
lv_obj_clear_flag(content->container, LV_OBJ_FLAG_HIDDEN);
}
else
{
lv_obj_add_flag(content->container, LV_OBJ_FLAG_HIDDEN);
}
lv_label_set_text(content->label, label_text);
lv_obj_clear_flag(content->led, LV_OBJ_FLAG_HIDDEN);
if (led_checked)
{
lv_led_on(content->led);
}
else
{
lv_led_off(content->led);
}
if (imgbtn_src)
{
lv_obj_clear_flag(content->imgbtn, LV_OBJ_FLAG_HIDDEN);
}
else
{
lv_obj_add_flag(content->imgbtn, LV_OBJ_FLAG_HIDDEN);
}
}
#include <lvgl/lvgl.h>
static void on_tong_hua_screen_imgbtn_4_click(lv_event_t *e)
{
lv_obj_t *obj = lv_event_get_target(e);
int *id_ptr = (int *)lv_event_get_param(e);
int id = *id_ptr;
lv_obj_t *container = lv_obj_get_parent(obj);
bool checked = lv_obj_has_state(obj, LV_STATE_CHECKED);
if (checked)
{
printf("Button %d .", id);
}
else
{
printf("Button %d .", id);
}
}
static void on_tong_hua_screen_imgbtn_8_click(lv_event_t *e)
{
lv_obj_t *obj = lv_event_get_target(e);
int *id_ptr = (int *)lv_event_get_param(e);
int id = *id_ptr;
lv_obj_t *container = lv_obj_get_parent(obj);
bool checked = lv_obj_has_state(obj, LV_STATE_CHECKED);
if (checked)
{
printf("Button %d .", id);
}
else
{
printf("Button %d .", id);
}
}
void create_tong_hua_screen_cont_2(lv_obj_t *parent, int x, int y, int id)
{
lv_obj_t *tong_hua_screen_cont_2 = lv_obj_create(parent);
lv_obj_set_pos(tong_hua_screen_cont_2, x, y);
lv_obj_set_size(tong_hua_screen_cont_2, 80, 120);
lv_obj_set_scrollbar_mode(tong_hua_screen_cont_2, LV_SCROLLBAR_MODE_OFF);
lv_obj_set_style_border_width(tong_hua_screen_cont_2, 2, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_border_opa(tong_hua_screen_cont_2, 255, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_border_color(tong_hua_screen_cont_2, lv_color_hex(0x2195f6), LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_border_side(tong_hua_screen_cont_2, LV_BORDER_SIDE_NONE, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_radius(tong_hua_screen_cont_2, 0, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_bg_opa(tong_hua_screen_cont_2, 0, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_pad_top(tong_hua_screen_cont_2, 0, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_pad_bottom(tong_hua_screen_cont_2, 0, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_pad_left(tong_hua_screen_cont_2, 0, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_pad_right(tong_hua_screen_cont_2, 0, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_shadow_width(tong_hua_screen_cont_2, 0, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_t *tong_hua_screen_imgbtn_4 = lv_imgbtn_create(tong_hua_screen_cont_2);
lv_obj_add_flag(tong_hua_screen_imgbtn_4, LV_OBJ_FLAG_CHECKABLE);
lv_imgbtn_set_src(tong_hua_screen_imgbtn_4, LV_IMGBTN_STATE_RELEASED, NULL, &_AQ_alpha_75x75, NULL);
lv_obj_set_pos(tong_hua_screen_imgbtn_4, 2, 8);
lv_obj_set_size(tong_hua_screen_imgbtn_4, 75, 75);
lv_obj_t *tong_hua_screen_imgbtn_4_label = lv_label_create(tong_hua_screen_imgbtn_4);
lv_label_set_text(tong_hua_screen_imgbtn_4_label, "");
lv_label_set_long_mode(tong_hua_screen_imgbtn_4_label, LV_LABEL_LONG_WRAP);
lv_obj_align(tong_hua_screen_imgbtn_4_label, LV_ALIGN_CENTER, 0, 0);
lv_obj_set_style_pad_all(tong_hua_screen_imgbtn_4, 0, LV_STATE_DEFAULT);
lv_obj_set_style_text_color(tong_hua_screen_imgbtn_4, lv_color_hex(0x000000), LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_text_font(tong_hua_screen_imgbtn_4, &lv_font_SourceHanSerifSC_Regular_12, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_text_opa(tong_hua_screen_imgbtn_4, 255, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_text_align(tong_hua_screen_imgbtn_4, LV_TEXT_ALIGN_CENTER, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_shadow_width(tong_hua_screen_imgbtn_4, 0, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_img_opa(tong_hua_screen_imgbtn_4, 255, LV_PART_MAIN | LV_STATE_PRESSED);
lv_obj_set_style_text_color(tong_hua_screen_imgbtn_4, lv_color_hex(0xFF33FF), LV_PART_MAIN | LV_STATE_PRESSED);
lv_obj_set_style_text_font(tong_hua_screen_imgbtn_4, &lv_font_SourceHanSerifSC_Regular_12, LV_PART_MAIN | LV_STATE_PRESSED);
lv_obj_set_style_text_opa(tong_hua_screen_imgbtn_4, 255, LV_PART_MAIN | LV_STATE_PRESSED);
lv_obj_set_style_shadow_width(tong_hua_screen_imgbtn_4, 0, LV_PART_MAIN | LV_STATE_PRESSED);
lv_obj_set_style_img_opa(tong_hua_screen_imgbtn_4, 255, LV_PART_MAIN | LV_STATE_CHECKED);
lv_obj_set_style_text_color(tong_hua_screen_imgbtn_4, lv_color_hex(0xFF33FF), LV_PART_MAIN | LV_STATE_CHECKED);
lv_obj_set_style_text_font(tong_hua_screen_imgbtn_4, &lv_font_SourceHanSerifSC_Regular_12, LV_PART_MAIN | LV_STATE_CHECKED);
lv_obj_set_style_text_opa(tong_hua_screen_imgbtn_4, 255, LV_PART_MAIN | LV_STATE_CHECKED);
lv_obj_set_style_shadow_width(tong_hua_screen_imgbtn_4, 0, LV_PART_MAIN | LV_STATE_CHECKED);
lv_obj_t *tong_hua_screen_label_4 = lv_label_create(tong_hua_screen_cont_2);
lv_label_set_text(tong_hua_screen_label_4, "yong1");
lv_label_set_long_mode(tong_hua_screen_label_4, LV_LABEL_LONG_WRAP);
lv_obj_set_pos(tong_hua_screen_label_4, 5, 91);
lv_obj_set_size(tong_hua_screen_label_4, 69, 32);
lv_obj_set_style_border_width(tong_hua_screen_label_4, 0, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_radius(tong_hua_screen_label_4, 0, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_text_color(tong_hua_screen_label_4, lv_color_hex(0x000000), LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_text_font(tong_hua_screen_label_4, &lv_font_SourceHanSerifSC_Regular_24, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_text_opa(tong_hua_screen_label_4, 255, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_text_letter_space(tong_hua_screen_label_4, 2, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_text_line_space(tong_hua_screen_label_4, 0, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_text_align(tong_hua_screen_label_4, LV_TEXT_ALIGN_CENTER, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_bg_opa(tong_hua_screen_label_4, 0, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_pad_top(tong_hua_screen_label_4, 0, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_pad_right(tong_hua_screen_label_4, 0, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_pad_bottom(tong_hua_screen_label_4, 0, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_pad_left(tong_hua_screen_label_4, 0, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_shadow_width(tong_hua_screen_label_4, 0, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_t *tong_hua_screen_led_1 = lv_led_create(tong_hua_screen_cont_2);
lv_led_set_brightness(tong_hua_screen_led_1, 255);
lv_led_set_color(tong_hua_screen_led_1, lv_color_hex(0xff5700));
lv_obj_set_pos(tong_hua_screen_led_1, 19, 15);
lv_obj_set_size(tong_hua_screen_led_1, 12, 12);
lv_obj_add_event_cb(tong_hua_screen_imgbtn_4, on_tong_hua_screen_imgbtn_4_click, LV_EVENT_CLICKED, &id);
}
void create_tong_hua_screen_cont_6(lv_obj_t *parent, int x, int y, int id)
{
lv_obj_t *tong_hua_screen_cont_6 = lv_obj_create(parent);
lv_obj_set_pos(tong_hua_screen_cont_6, x, y);
lv_obj_set_size(tong_hua_screen_cont_6, 80, 120);
lv_obj_set_scrollbar_mode(tong_hua_screen_cont_6, LV_SCROLLBAR_MODE_OFF);
lv_obj_set_style_border_width(tong_hua_screen_cont_6, 2, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_border_opa(tong_hua_screen_cont_6, 255, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_border_color(tong_hua_screen_cont_6, lv_color_hex(0x2195f6), LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_border_side(tong_hua_screen_cont_6, LV_BORDER_SIDE_NONE, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_radius(tong_hua_screen_cont_6, 0, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_bg_opa(tong_hua_screen_cont_6, 0, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_pad_top(tong_hua_screen_cont_6, 0, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_pad_bottom(tong_hua_screen_cont_6, 0, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_pad_left(tong_hua_screen_cont_6, 0, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_pad_right(tong_hua_screen_cont_6, 0, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_shadow_width(tong_hua_screen_cont_6, 0, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_t *tong_hua_screen_imgbtn_8 = lv_imgbtn_create(tong_hua_screen_cont_6);
lv_obj_add_flag(tong_hua_screen_imgbtn_8, LV_OBJ_FLAG_CHECKABLE);
lv_imgbtn_set_src(tong_hua_screen_imgbtn_8, LV_IMGBTN_STATE_RELEASED, NULL, &_A6_alpha_80x90, NULL);
lv_obj_set_pos(tong_hua_screen_imgbtn_8, 5, 0);
lv_obj_set_size(tong_hua_screen_imgbtn_8, 80, 90);
lv_obj_t *tong_hua_screen_label_8 = lv_label_create(tong_hua_screen_cont_6);
lv_label_set_text(tong_hua_screen_label_8, "sss");
lv_label_set_long_mode(tong_hua_screen_label_8, LV_LABEL_LONG_WRAP);
lv_obj_set_pos(tong_hua_screen_label_8, 5, 91);
lv_obj_set_size(tong_hua_screen_label_8, 69, 32);
lv_obj_set_style_border_width(tong_hua_screen_label_8, 0, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_radius(tong_hua_screen_label_8, 0, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_text_color(tong_hua_screen_label_8, lv_color_hex(0x000000), LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_text_font(tong_hua_screen_label_8, &lv_font_SourceHanSerifSC_Regular_24, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_text_opa(tong_hua_screen_label_8, 255, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_text_letter_space(tong_hua_screen_label_8, 2, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_text_line_space(tong_hua_screen_label_8, 0, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_text_align(tong_hua_screen_label_8, LV_TEXT_ALIGN_CENTER, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_bg_opa(tong_hua_screen_label_8, 0, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_pad_top(tong_hua_screen_label_8, 0, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_pad_right(tong_hua_screen_label_8, 0, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_pad_bottom(tong_hua_screen_label_8, 0, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_pad_left(tong_hua_screen_label_8, 0, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_shadow_width(tong_hua_screen_label_8, 0, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_text_color(tong_hua_screen_imgbtn_8, lv_color_hex(0x000000), LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_text_font(tong_hua_screen_imgbtn_8, &lv_font_SourceHanSerifSC_Regular_12, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_text_opa(tong_hua_screen_imgbtn_8, 255, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_text_align(tong_hua_screen_imgbtn_8, LV_TEXT_ALIGN_CENTER, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_shadow_width(tong_hua_screen_imgbtn_8, 0, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_img_opa(tong_hua_screen_imgbtn_8, 255, LV_PART_MAIN | LV_STATE_PRESSED);
lv_obj_set_style_text_color(tong_hua_screen_imgbtn_8, lv_color_hex(0xFF33FF), LV_PART_MAIN | LV_STATE_PRESSED);
lv_obj_set_style_text_font(tong_hua_screen_imgbtn_8, &lv_font_SourceHanSerifSC_Regular_12, LV_PART_MAIN | LV_STATE_PRESSED);
lv_obj_set_style_text_opa(tong_hua_screen_imgbtn_8, 255, LV_PART_MAIN | LV_STATE_PRESSED);
lv_obj_set_style_shadow_width(tong_hua_screen_imgbtn_8, 0, LV_PART_MAIN | LV_STATE_PRESSED);
lv_obj_t *tong_hua_screen_led_2 = lv_led_create(tong_hua_screen_cont_6);
lv_led_set_brightness(tong_hua_screen_led_2, 255);
lv_led_set_color(tong_hua_screen_led_2, lv_color_hex(0xff5700));
lv_obj_set_pos(tong_hua_screen_led_2, 19, 15);
lv_obj_set_size(tong_hua_screen_led_2, 12, 12);
lv_obj_add_event_cb(tong_hua_screen_imgbtn_8, on_tong_hua_screen_imgbtn_8_click, LV_EVENT_CLICKED, &id);
}
void call_screen_enter_cb(void)
{
int i = 0;
int n = 0;
int row = 0;
int col = 0;
int x = 0;
int y = 0;
int cont2_num = 0;
int cont6_num = 0;
printf("Screen entered\n");
for (i = 0; i < NUM_SLAVE_DEV; i++)
{
host_dev.slave_dev_params_t[i].ext.is_registered = true;
if (i % 2 == 0)
{
host_dev.slave_dev_params_t[i].ext.type = USER_DEV;
}
else
{
host_dev.slave_dev_params_t[i].ext.type = STAFF_DEV;
}
}
for (i = 0; i < NUM_SLAVE_DEV; i++)
{
if (host_dev.slave_dev_params_t[i].ext.is_registered)
{
if (host_dev.slave_dev_params_t[i].ext.type == USER_DEV)
{
cont2_num++;
}
else if (host_dev.slave_dev_params_t[i].ext.type == STAFF_DEV)
{
cont6_num++;
}
}
}
for (n = 0; n < cont2_num; n++)
{
row = n / 10;
col = n % 10;
x = 10 + col * (80 + 10);
y = 0 + row * (120 + 10);
create_tong_hua_screen_cont_2(guider_ui.tong_hua_screen_tabview_1_tab_1, x, y, n + 1);
}
for (; n < (cont2_num + cont6_num); n++)
{
row = n / 10;
col = n % 10;
x = 10 + col * (80 + 10);
y = 0 + row * (120 + 10);
create_tong_hua_screen_cont_6(guider_ui.tong_hua_screen_tabview_1_tab_1, x, y, n + cont2_num + 1);
}
}
void call_screen_update_cb(unsigned char index)
{
int i = 0;
int n = 0;
int row = 0;
int col = 0;
int x = 0;
int y = 0;
int cont2_num = 0;
int cont6_num = 0;
printf("call_screen_update_cb\n");
#if defined(_WIN32) || defined(_WIN64)
DWORD result = WaitForSingleObject(tab_content_mutex, INFINITE);
if (result != WAIT_OBJECT_0)
{
printf("Failed to wait on the event.\n");
return;
}
#elif defined(__FreeRTOS__)
if (xSemaphoreTake(tab_content_mutex, portMAX_DELAY) != pdTRUE)
{
printf("Failed to take the mutex.\n");
return;
}
#endif
switch (index)
{
case 0:
call_screen_enter_cb();
break;
case 1:
for (i = 0; i < NUM_SLAVE_DEV; i++)
{
if (host_dev.slave_dev_params_t[i].ext.type == USER_DEV)
{
if (host_dev.slave_dev_params_t[i].ext.is_registered)
{
if (host_dev.slave_dev_params_t[i].ext.is_registered != host_dev.slave_dev_params_t[i].ext.last_is_registered)
{
host_dev.slave_dev_params_t[i].ext.last_is_registered = host_dev.slave_dev_params_t[i].ext.is_registered;
cont2_num++;
}
}
}
}
for (n = 0; n < cont2_num; n++)
{
row = n / 10;
col = n % 10;
x = 10 + col * (80 + 10);
y = 0 + row * (120 + 10);
create_tong_hua_screen_cont_2(guider_ui.tong_hua_screen_tabview_1_tab_2, x, y, n + 1);
}
break;
case 2:
for (i = 0; i < NUM_SLAVE_DEV; i++)
{
if (host_dev.slave_dev_params_t[i].ext.type == STAFF_DEV)
{
if (host_dev.slave_dev_params_t[i].ext.is_registered)
{
if (host_dev.slave_dev_params_t[i].ext.is_registered != host_dev.slave_dev_params_t[i].ext.last_is_registered)
{
host_dev.slave_dev_params_t[i].ext.last_is_registered = host_dev.slave_dev_params_t[i].ext.is_registered;
cont6_num++;
}
}
}
}
for (n = 0; n < (cont6_num); n++)
{
row = n / 10;
col = n % 10;
x = 10 + col * (80 + 10);
y = 0 + row * (120 + 10);
create_tong_hua_screen_cont_6(guider_ui.tong_hua_screen_tabview_1_tab_3, x, y, n + 1);
}
break;
}
#if defined(_WIN32) || defined(_WIN64)
SetEvent(tab_content_mutex);
#elif defined(__FreeRTOS__)
xSemaphoreGive(tab_content_mutex);
#endif
}
#include <lvgl.h>
#include <stdio.h>
#define TIMER_INTERVAL_MS 60
void create_tong_hua_screen_cont_2(lv_obj_t *parent, int x, int y, int id);
void create_tong_hua_screen_cont_6(lv_obj_t *parent, int x, int y, int id);
static int container_counter = 0;
static void timer_callback(lv_timer_t *timer)
{
int cont2_num = 0;
int cont6_num = 0;
for (int i = 0; i < NUM_SLAVE_DEV; i++)
{
if (host_dev.slave_dev_params_t[i].ext.is_registered)
{
if (host_dev.slave_dev_params_t[i].ext.type == USER_DEV)
{
cont2_num++;
}
else if (host_dev.slave_dev_params_t[i].ext.type == STAFF_DEV)
{
cont6_num++;
}
}
}
if (container_counter < cont2_num)
{
int n = container_counter;
int row = n / 10;
int col = n % 10;
int x = 10 + col * (80 + 10);
int y = 10 + row * (120 + 10);
create_tong_hua_screen_cont_2(guider_ui.tong_hua_screen_tabview_1_tab_1, x, y, container_counter + 1);
container_counter++;
}
else if (container_counter < cont2_num + cont6_num)
{
int n = container_counter;
int row = n / 10;
int col = n % 10;
int x = 10 + col * (80 + 10);
int y = 10 + row * (120 + 10);
create_tong_hua_screen_cont_6(guider_ui.tong_hua_screen_tabview_1_tab_1, x, y, container_counter + 1 - cont2_num);
container_counter++;
}
if (container_counter >= cont2_num + cont6_num)
{
container_counter = 0;
lv_timer_del(timer);
}
}
void call_screen_enter_cb(void)
{
printf("Screen entered\n");
for (int i = 0; i < NUM_SLAVE_DEV; i++)
{
host_dev.slave_dev_params_t[i].ext.is_registered = true;
host_dev.slave_dev_params_t[i].ext.type = (i % 2 == 0) ? USER_DEV : STAFF_DEV;
}
lv_timer_t *timer = lv_timer_create(timer_callback, TIMER_INTERVAL_MS, NULL);
lv_timer_set_repeat_count(timer, -1);
}
void call_screen_update_cb(unsigned char index)
{
int i = 0;
int n = 0;
int row = 0;
int col = 0;
int x = 0;
int y = 0;
int cont2_num = 0;
int cont6_num = 0;
printf("call_screen_update_cb\n");
#if defined(_WIN32) || defined(_WIN64)
DWORD result = WaitForSingleObject(tab_content_mutex, INFINITE);
if (result != WAIT_OBJECT_0)
{
printf("Failed to wait on the event.\n");
return;
}
#elif defined(__FreeRTOS__)
if (xSemaphoreTake(tab_content_mutex, portMAX_DELAY) != pdTRUE)
{
printf("Failed to take the mutex.\n");
return;
}
#endif
switch (index)
{
case 0:
call_screen_enter_cb();
break;
case 1:
for (i = 0; i < NUM_SLAVE_DEV; i++)
{
if (host_dev.slave_dev_params_t[i].ext.type == USER_DEV)
{
if (host_dev.slave_dev_params_t[i].ext.is_registered)
{
if (host_dev.slave_dev_params_t[i].ext.is_registered != host_dev.slave_dev_params_t[i].ext.last_is_registered)
{
host_dev.slave_dev_params_t[i].ext.last_is_registered = host_dev.slave_dev_params_t[i].ext.is_registered;
cont2_num++;
}
}
}
}
for (n = 0; n < cont2_num; n++)
{
row = n / 10;
col = n % 10;
x = 10 + col * (80 + 10);
y = 0 + row * (120 + 10);
create_tong_hua_screen_cont_2(guider_ui.tong_hua_screen_tabview_1_tab_2, x, y, n + 1);
}
break;
case 2:
for (i = 0; i < NUM_SLAVE_DEV; i++)
{
if (host_dev.slave_dev_params_t[i].ext.type == STAFF_DEV)
{
if (host_dev.slave_dev_params_t[i].ext.is_registered)
{
if (host_dev.slave_dev_params_t[i].ext.is_registered != host_dev.slave_dev_params_t[i].ext.last_is_registered)
{
host_dev.slave_dev_params_t[i].ext.last_is_registered = host_dev.slave_dev_params_t[i].ext.is_registered;
cont6_num++;
}
}
}
}
for (n = 0; n < (cont6_num); n++)
{
row = n / 10;
col = n % 10;
x = 10 + col * (80 + 10);
y = 0 + row * (120 + 10);
create_tong_hua_screen_cont_6(guider_ui.tong_hua_screen_tabview_1_tab_3, x, y, n + 1);
}
break;
}
#if defined(_WIN32) || defined(_WIN64)
SetEvent(tab_content_mutex);
#elif defined(__FreeRTOS__)
xSemaphoreGive(tab_content_mutex);
#endif
}