|
|
|
@ -4,6 +4,8 @@
|
|
|
|
|
#include "actions.h" |
|
|
|
|
#include "../flow.h" |
|
|
|
|
|
|
|
|
|
objects_t objects; |
|
|
|
|
|
|
|
|
|
static void event_handler_cb_main_button_1(lv_event_t *e) { |
|
|
|
|
lv_event_code_t event = lv_event_get_code(e); |
|
|
|
|
if (event == LV_EVENT_PRESSED) { |
|
|
|
@ -18,18 +20,15 @@ static void event_handler_cb_main_button_2(lv_event_t *e) {
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
main_t *create_screen_main() { |
|
|
|
|
main_t *screen = (main_t *)lv_mem_alloc(sizeof(main_t)); |
|
|
|
|
void create_screen_main() { |
|
|
|
|
lv_obj_t *obj = lv_obj_create(0); |
|
|
|
|
screen->screen_obj = obj; |
|
|
|
|
objects.main = obj; |
|
|
|
|
lv_obj_set_pos(obj, 0, 0); |
|
|
|
|
lv_obj_set_size(obj, 800, 480); |
|
|
|
|
{ |
|
|
|
|
lv_obj_t *parent_obj = obj; |
|
|
|
|
{ |
|
|
|
|
// image_1
|
|
|
|
|
lv_obj_t *obj = lv_img_create(parent_obj); |
|
|
|
|
screen->obj_image_1 = obj; |
|
|
|
|
lv_obj_set_pos(obj, 130, 79); |
|
|
|
|
lv_obj_set_size(obj, LV_SIZE_CONTENT, LV_SIZE_CONTENT); |
|
|
|
|
lv_img_set_src(obj, &img_log_eez); |
|
|
|
@ -37,9 +36,7 @@ main_t *create_screen_main() {
|
|
|
|
|
lv_obj_clear_flag(obj, LV_OBJ_FLAG_SCROLLABLE); |
|
|
|
|
} |
|
|
|
|
{ |
|
|
|
|
// image_2
|
|
|
|
|
lv_obj_t *obj = lv_img_create(parent_obj); |
|
|
|
|
screen->obj_image_2 = obj; |
|
|
|
|
lv_obj_set_pos(obj, 457, 79); |
|
|
|
|
lv_obj_set_size(obj, LV_SIZE_CONTENT, LV_SIZE_CONTENT); |
|
|
|
|
lv_img_set_src(obj, &img_logo_lvgl); |
|
|
|
@ -47,29 +44,24 @@ main_t *create_screen_main() {
|
|
|
|
|
lv_obj_clear_flag(obj, LV_OBJ_FLAG_SCROLLABLE); |
|
|
|
|
} |
|
|
|
|
{ |
|
|
|
|
// label_1
|
|
|
|
|
lv_obj_t *obj = lv_label_create(parent_obj); |
|
|
|
|
screen->obj_label_1 = obj; |
|
|
|
|
objects.label_1 = obj; |
|
|
|
|
lv_obj_set_pos(obj, 0, 0); |
|
|
|
|
lv_obj_set_size(obj, LV_SIZE_CONTENT, LV_SIZE_CONTENT); |
|
|
|
|
lv_obj_set_style_align(obj, LV_ALIGN_CENTER, LV_PART_MAIN | LV_STATE_DEFAULT); |
|
|
|
|
lv_obj_set_style_text_font(obj, &lv_font_montserrat_32, LV_PART_MAIN | LV_STATE_DEFAULT); |
|
|
|
|
} |
|
|
|
|
{ |
|
|
|
|
// button_1
|
|
|
|
|
lv_obj_t *obj = lv_btn_create(parent_obj); |
|
|
|
|
screen->obj_button_1 = obj; |
|
|
|
|
lv_obj_set_pos(obj, 268, 348); |
|
|
|
|
lv_obj_set_size(obj, 100, 40); |
|
|
|
|
lv_obj_add_event_cb(obj, event_handler_cb_main_button_1, LV_EVENT_ALL, screen); |
|
|
|
|
lv_obj_add_event_cb(obj, event_handler_cb_main_button_1, LV_EVENT_ALL, 0); |
|
|
|
|
lv_obj_add_flag(obj, LV_OBJ_FLAG_SCROLL_ON_FOCUS); |
|
|
|
|
lv_obj_clear_flag(obj, LV_OBJ_FLAG_SCROLLABLE); |
|
|
|
|
{ |
|
|
|
|
lv_obj_t *parent_obj = obj; |
|
|
|
|
{ |
|
|
|
|
// label_2
|
|
|
|
|
lv_obj_t *obj = lv_label_create(parent_obj); |
|
|
|
|
screen->obj_label_2 = obj; |
|
|
|
|
lv_obj_set_pos(obj, 0, 0); |
|
|
|
|
lv_obj_set_size(obj, LV_SIZE_CONTENT, LV_SIZE_CONTENT); |
|
|
|
|
lv_label_set_text(obj, "+"); |
|
|
|
@ -79,20 +71,16 @@ main_t *create_screen_main() {
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
{ |
|
|
|
|
// button_2
|
|
|
|
|
lv_obj_t *obj = lv_btn_create(parent_obj); |
|
|
|
|
screen->obj_button_2 = obj; |
|
|
|
|
lv_obj_set_pos(obj, 408, 348); |
|
|
|
|
lv_obj_set_size(obj, 100, 40); |
|
|
|
|
lv_obj_add_event_cb(obj, event_handler_cb_main_button_2, LV_EVENT_ALL, screen); |
|
|
|
|
lv_obj_add_event_cb(obj, event_handler_cb_main_button_2, LV_EVENT_ALL, 0); |
|
|
|
|
lv_obj_add_flag(obj, LV_OBJ_FLAG_SCROLL_ON_FOCUS); |
|
|
|
|
lv_obj_clear_flag(obj, LV_OBJ_FLAG_SCROLLABLE); |
|
|
|
|
{ |
|
|
|
|
lv_obj_t *parent_obj = obj; |
|
|
|
|
{ |
|
|
|
|
// label_3
|
|
|
|
|
lv_obj_t *obj = lv_label_create(parent_obj); |
|
|
|
|
screen->obj_label_3 = obj; |
|
|
|
|
lv_obj_set_pos(obj, 0, 0); |
|
|
|
|
lv_obj_set_size(obj, LV_SIZE_CONTENT, LV_SIZE_CONTENT); |
|
|
|
|
lv_label_set_text(obj, "-"); |
|
|
|
@ -102,43 +90,27 @@ main_t *create_screen_main() {
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
return screen; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void tick_screen_main(main_t *screen) { |
|
|
|
|
void tick_screen_main() { |
|
|
|
|
{ |
|
|
|
|
const char *new_val = evalTextProperty(0, 2, 2, "Failed to evaluate Text in Label widget"); |
|
|
|
|
const char *cur_val = lv_label_get_text(screen->obj_label_1); |
|
|
|
|
if (strcmp(new_val, cur_val) != 0) lv_label_set_text(screen->obj_label_1, new_val); |
|
|
|
|
const char *cur_val = lv_label_get_text(objects.label_1); |
|
|
|
|
if (strcmp(new_val, cur_val) != 0) lv_label_set_text(objects.label_1, new_val); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include <assert.h> |
|
|
|
|
|
|
|
|
|
typedef screen_t (*create_screen_func_t)(); |
|
|
|
|
|
|
|
|
|
create_screen_func_t create_screen_funcs[] = { |
|
|
|
|
(create_screen_func_t)create_screen_main, |
|
|
|
|
}; |
|
|
|
|
void create_screens() { |
|
|
|
|
create_screen_main(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
typedef void (*tick_screen_func_t)(screen_t); |
|
|
|
|
typedef void (*tick_screen_func_t)(); |
|
|
|
|
|
|
|
|
|
tick_screen_func_t tick_screen_funcs[] = { |
|
|
|
|
(tick_screen_func_t)tick_screen_main, |
|
|
|
|
tick_screen_main, |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
screen_t screens[NUM_SCREENS]; |
|
|
|
|
|
|
|
|
|
screen_t get_screen(int screen_index) { |
|
|
|
|
assert(screen_index >= 0 && screen_index < NUM_SCREENS); |
|
|
|
|
if (!screens[screen_index]) { |
|
|
|
|
screens[screen_index] = create_screen_funcs[screen_index](); |
|
|
|
|
} |
|
|
|
|
return screens[screen_index]; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void tick_screen(int screen_index) { |
|
|
|
|
assert(screen_index >= 0 && screen_index < NUM_SCREENS); |
|
|
|
|
tick_screen_funcs[screen_index](get_screen(screen_index)); |
|
|
|
|
tick_screen_funcs[screen_index](); |
|
|
|
|
} |
|
|
|
|