Files
Smart-granary-code/components/ui/screens.c

504 lines
20 KiB
C

#include <string.h>
#include "screens.h"
#include "images.h"
#include "fonts.h"
#include "actions.h"
#include "vars.h"
#include "styles.h"
#include "ui.h"
#include <string.h>
objects_t objects;
static const char *screen_names[] = { "Main" };
static const char *object_names[] = { "main", "background_pic", "obj0", "obj1", "obj2", "obj3", "obj4", "obj5", "obj6", "obj7", "obj8", "obj9", "obj10", "obj11", "obj12", "obj13" };
//
// Event handlers
//
lv_obj_t *tick_value_change_obj;
//
// Screens
//
void create_screen_main() {
void *flowState = getFlowState(0, 0);
(void)flowState;
lv_obj_t *obj = lv_obj_create(0);
objects.main = obj;
lv_obj_set_pos(obj, 0, 0);
lv_obj_set_size(obj, 240, 240);
lv_obj_set_style_bg_color(obj, lv_color_hex(0xffc99494), LV_PART_MAIN | LV_STATE_DEFAULT);
{
lv_obj_t *parent_obj = obj;
{
// background_pic
lv_obj_t *obj = lv_image_create(parent_obj);
objects.background_pic = obj;
lv_obj_set_pos(obj, 0, 0);
lv_obj_set_size(obj, LV_SIZE_CONTENT, LV_SIZE_CONTENT);
lv_image_set_src(obj, &img_main_page);
}
{
lv_obj_t *obj = lv_label_create(parent_obj);
lv_obj_set_pos(obj, 15, 22);
lv_obj_set_size(obj, LV_SIZE_CONTENT, LV_SIZE_CONTENT);
lv_obj_set_style_text_font(obj, &ui_font_chinese_24, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_label_set_text(obj, "智能粮仓");
}
{
lv_obj_t *obj = lv_label_create(parent_obj);
lv_obj_set_pos(obj, 15, 55);
lv_obj_set_size(obj, LV_SIZE_CONTENT, LV_SIZE_CONTENT);
lv_obj_set_style_text_font(obj, &ui_font_chinese_16, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_label_set_text(obj, "温度");
}
{
lv_obj_t *obj = lv_label_create(parent_obj);
lv_obj_set_pos(obj, 15, 88);
lv_obj_set_size(obj, LV_SIZE_CONTENT, LV_SIZE_CONTENT);
lv_obj_set_style_text_font(obj, &ui_font_chinese_16, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_label_set_text(obj, "湿度");
}
{
lv_obj_t *obj = lv_label_create(parent_obj);
lv_obj_set_pos(obj, 159, 55);
lv_obj_set_size(obj, LV_SIZE_CONTENT, LV_SIZE_CONTENT);
lv_obj_set_style_text_font(obj, &ui_font_chinese_16, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_label_set_text(obj, "光照强度");
}
{
lv_obj_t *obj = lv_label_create(parent_obj);
objects.obj0 = obj;
lv_obj_set_pos(obj, 17, 72);
lv_obj_set_size(obj, LV_SIZE_CONTENT, LV_SIZE_CONTENT);
lv_obj_set_style_text_font(obj, &ui_font_number_16, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_text_color(obj, lv_color_hex(0xffff5e5e), LV_PART_MAIN | LV_STATE_DEFAULT);
lv_label_set_text(obj, "");
}
{
lv_obj_t *obj = lv_label_create(parent_obj);
objects.obj1 = obj;
lv_obj_set_pos(obj, 167, 73);
lv_obj_set_size(obj, LV_SIZE_CONTENT, LV_SIZE_CONTENT);
lv_obj_set_style_text_font(obj, &ui_font_number_16, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_text_color(obj, lv_color_hex(0xffff5e5e), LV_PART_MAIN | LV_STATE_DEFAULT);
lv_label_set_text(obj, "");
}
{
lv_obj_t *obj = lv_label_create(parent_obj);
objects.obj2 = obj;
lv_obj_set_pos(obj, 17, 107);
lv_obj_set_size(obj, LV_SIZE_CONTENT, LV_SIZE_CONTENT);
lv_obj_set_style_text_font(obj, &ui_font_number_16, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_text_color(obj, lv_color_hex(0xffff5e5e), LV_PART_MAIN | LV_STATE_DEFAULT);
lv_label_set_text(obj, "");
}
{
lv_obj_t *obj = lv_label_create(parent_obj);
lv_obj_set_pos(obj, 151, 122);
lv_obj_set_size(obj, LV_SIZE_CONTENT, LV_SIZE_CONTENT);
lv_obj_set_style_text_font(obj, &ui_font_chinese_16, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_label_set_text(obj, "门状态");
}
{
lv_obj_t *obj = lv_label_create(parent_obj);
objects.obj3 = obj;
lv_obj_set_pos(obj, 163, 140);
lv_obj_set_size(obj, LV_SIZE_CONTENT, LV_SIZE_CONTENT);
lv_obj_set_style_text_font(obj, &ui_font_chinese_16, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_text_color(obj, lv_color_hex(0xffff5e5e), LV_PART_MAIN | LV_STATE_DEFAULT);
lv_label_set_text(obj, "");
}
{
lv_obj_t *obj = lv_label_create(parent_obj);
lv_obj_set_pos(obj, 14, 124);
lv_obj_set_size(obj, LV_SIZE_CONTENT, LV_SIZE_CONTENT);
lv_obj_set_style_text_font(obj, &ui_font_chinese_16, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_label_set_text(obj, "粮食存量");
}
{
lv_obj_t *obj = lv_label_create(parent_obj);
objects.obj4 = obj;
lv_obj_set_pos(obj, 17, 142);
lv_obj_set_size(obj, LV_SIZE_CONTENT, LV_SIZE_CONTENT);
lv_obj_set_style_text_font(obj, &ui_font_number_16, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_text_color(obj, lv_color_hex(0xffff5e5e), LV_PART_MAIN | LV_STATE_DEFAULT);
lv_label_set_text(obj, "");
}
{
lv_obj_t *obj = lv_label_create(parent_obj);
lv_obj_set_pos(obj, 14, 158);
lv_obj_set_size(obj, LV_SIZE_CONTENT, LV_SIZE_CONTENT);
lv_obj_set_style_text_font(obj, &ui_font_chinese_16, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_label_set_text(obj, "粮食状态");
}
{
lv_obj_t *obj = lv_label_create(parent_obj);
objects.obj5 = obj;
lv_obj_set_pos(obj, 14, 176);
lv_obj_set_size(obj, LV_SIZE_CONTENT, LV_SIZE_CONTENT);
lv_obj_set_style_text_font(obj, &ui_font_chinese_16, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_text_color(obj, lv_color_hex(0xffff5e5e), LV_PART_MAIN | LV_STATE_DEFAULT);
lv_label_set_text(obj, "");
}
{
lv_obj_t *obj = lv_label_create(parent_obj);
lv_obj_set_pos(obj, 160, 88);
lv_obj_set_size(obj, LV_SIZE_CONTENT, LV_SIZE_CONTENT);
lv_obj_set_style_text_font(obj, &ui_font_chinese_16, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_label_set_text(obj, "空气质量");
}
{
lv_obj_t *obj = lv_label_create(parent_obj);
objects.obj6 = obj;
lv_obj_set_pos(obj, 167, 106);
lv_obj_set_size(obj, LV_SIZE_CONTENT, LV_SIZE_CONTENT);
lv_obj_set_style_text_font(obj, &ui_font_number_16, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_text_color(obj, lv_color_hex(0xffff5e5e), LV_PART_MAIN | LV_STATE_DEFAULT);
lv_label_set_text(obj, "");
}
{
lv_obj_t *obj = lv_label_create(parent_obj);
lv_obj_set_pos(obj, 135, 158);
lv_obj_set_size(obj, LV_SIZE_CONTENT, LV_SIZE_CONTENT);
lv_obj_set_style_text_font(obj, &ui_font_chinese_16, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_label_set_text(obj, "人存在状态");
}
{
lv_obj_t *obj = lv_label_create(parent_obj);
objects.obj7 = obj;
lv_obj_set_pos(obj, 139, 176);
lv_obj_set_size(obj, LV_SIZE_CONTENT, LV_SIZE_CONTENT);
lv_obj_set_style_text_font(obj, &ui_font_chinese_16, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_text_color(obj, lv_color_hex(0xffff5e5e), LV_PART_MAIN | LV_STATE_DEFAULT);
lv_label_set_text(obj, "");
}
{
lv_obj_t *obj = lv_label_create(parent_obj);
lv_obj_set_pos(obj, 17, 206);
lv_obj_set_size(obj, LV_SIZE_CONTENT, LV_SIZE_CONTENT);
lv_obj_set_style_text_font(obj, &ui_font_chinese_16, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_label_set_text(obj, "加热");
}
{
lv_obj_t *obj = lv_label_create(parent_obj);
lv_obj_set_pos(obj, 63, 206);
lv_obj_set_size(obj, LV_SIZE_CONTENT, LV_SIZE_CONTENT);
lv_obj_set_style_text_font(obj, &ui_font_chinese_16, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_label_set_text(obj, "制冷");
}
{
lv_obj_t *obj = lv_label_create(parent_obj);
lv_obj_set_pos(obj, 111, 206);
lv_obj_set_size(obj, LV_SIZE_CONTENT, LV_SIZE_CONTENT);
lv_obj_set_style_text_font(obj, &ui_font_chinese_16, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_label_set_text(obj, "通风");
}
{
lv_obj_t *obj = lv_label_create(parent_obj);
lv_obj_set_pos(obj, 159, 206);
lv_obj_set_size(obj, LV_SIZE_CONTENT, LV_SIZE_CONTENT);
lv_obj_set_style_text_font(obj, &ui_font_chinese_16, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_label_set_text(obj, "照明");
}
{
lv_obj_t *obj = lv_label_create(parent_obj);
objects.obj8 = obj;
lv_obj_set_pos(obj, 49, 206);
lv_obj_set_size(obj, LV_SIZE_CONTENT, LV_SIZE_CONTENT);
lv_obj_set_style_text_font(obj, &ui_font_chinese_16, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_text_color(obj, lv_color_hex(0xffff5e5e), LV_PART_MAIN | LV_STATE_DEFAULT);
lv_label_set_text(obj, "");
}
{
lv_obj_t *obj = lv_label_create(parent_obj);
objects.obj9 = obj;
lv_obj_set_pos(obj, 95, 206);
lv_obj_set_size(obj, LV_SIZE_CONTENT, LV_SIZE_CONTENT);
lv_obj_set_style_text_font(obj, &ui_font_chinese_16, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_text_color(obj, lv_color_hex(0xffff5e5e), LV_PART_MAIN | LV_STATE_DEFAULT);
lv_label_set_text(obj, "");
}
{
lv_obj_t *obj = lv_label_create(parent_obj);
objects.obj10 = obj;
lv_obj_set_pos(obj, 143, 206);
lv_obj_set_size(obj, LV_SIZE_CONTENT, LV_SIZE_CONTENT);
lv_obj_set_style_text_font(obj, &ui_font_chinese_16, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_text_color(obj, lv_color_hex(0xffff5e5e), LV_PART_MAIN | LV_STATE_DEFAULT);
lv_label_set_text(obj, "");
}
{
lv_obj_t *obj = lv_label_create(parent_obj);
objects.obj11 = obj;
lv_obj_set_pos(obj, 192, 206);
lv_obj_set_size(obj, LV_SIZE_CONTENT, LV_SIZE_CONTENT);
lv_obj_set_style_text_font(obj, &ui_font_chinese_16, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_text_color(obj, lv_color_hex(0xffff5e5e), LV_PART_MAIN | LV_STATE_DEFAULT);
lv_label_set_text(obj, "");
}
{
lv_obj_t *obj = lv_label_create(parent_obj);
objects.obj12 = obj;
lv_obj_set_pos(obj, 88, 8);
lv_obj_set_size(obj, LV_SIZE_CONTENT, LV_SIZE_CONTENT);
lv_obj_set_style_text_font(obj, &ui_font_number_14, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_text_color(obj, lv_color_hex(0xff000000), LV_PART_MAIN | LV_STATE_DEFAULT);
lv_label_set_text(obj, "");
}
{
lv_obj_t *obj = lv_label_create(parent_obj);
objects.obj13 = obj;
lv_obj_set_pos(obj, 124, 28);
lv_obj_set_size(obj, LV_SIZE_CONTENT, LV_SIZE_CONTENT);
lv_obj_set_style_text_font(obj, &ui_font_number_16, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_text_color(obj, lv_color_hex(0xff000000), LV_PART_MAIN | LV_STATE_DEFAULT);
lv_label_set_text(obj, "");
}
}
tick_screen_main();
}
void tick_screen_main() {
void *flowState = getFlowState(0, 0);
(void)flowState;
{
const char *new_val = evalTextProperty(flowState, 6, 3, "Failed to evaluate Text in Label widget");
const char *cur_val = lv_label_get_text(objects.obj0);
if (strcmp(new_val, cur_val) != 0) {
tick_value_change_obj = objects.obj0;
lv_label_set_text(objects.obj0, new_val);
tick_value_change_obj = NULL;
}
}
{
const char *new_val = evalTextProperty(flowState, 7, 3, "Failed to evaluate Text in Label widget");
const char *cur_val = lv_label_get_text(objects.obj1);
if (strcmp(new_val, cur_val) != 0) {
tick_value_change_obj = objects.obj1;
lv_label_set_text(objects.obj1, new_val);
tick_value_change_obj = NULL;
}
}
{
const char *new_val = evalTextProperty(flowState, 8, 3, "Failed to evaluate Text in Label widget");
const char *cur_val = lv_label_get_text(objects.obj2);
if (strcmp(new_val, cur_val) != 0) {
tick_value_change_obj = objects.obj2;
lv_label_set_text(objects.obj2, new_val);
tick_value_change_obj = NULL;
}
}
{
const char *new_val = evalTextProperty(flowState, 10, 3, "Failed to evaluate Text in Label widget");
const char *cur_val = lv_label_get_text(objects.obj3);
if (strcmp(new_val, cur_val) != 0) {
tick_value_change_obj = objects.obj3;
lv_label_set_text(objects.obj3, new_val);
tick_value_change_obj = NULL;
}
}
{
const char *new_val = evalTextProperty(flowState, 12, 3, "Failed to evaluate Text in Label widget");
const char *cur_val = lv_label_get_text(objects.obj4);
if (strcmp(new_val, cur_val) != 0) {
tick_value_change_obj = objects.obj4;
lv_label_set_text(objects.obj4, new_val);
tick_value_change_obj = NULL;
}
}
{
const char *new_val = evalTextProperty(flowState, 14, 3, "Failed to evaluate Text in Label widget");
const char *cur_val = lv_label_get_text(objects.obj5);
if (strcmp(new_val, cur_val) != 0) {
tick_value_change_obj = objects.obj5;
lv_label_set_text(objects.obj5, new_val);
tick_value_change_obj = NULL;
}
}
{
const char *new_val = evalTextProperty(flowState, 16, 3, "Failed to evaluate Text in Label widget");
const char *cur_val = lv_label_get_text(objects.obj6);
if (strcmp(new_val, cur_val) != 0) {
tick_value_change_obj = objects.obj6;
lv_label_set_text(objects.obj6, new_val);
tick_value_change_obj = NULL;
}
}
{
const char *new_val = evalTextProperty(flowState, 18, 3, "Failed to evaluate Text in Label widget");
const char *cur_val = lv_label_get_text(objects.obj7);
if (strcmp(new_val, cur_val) != 0) {
tick_value_change_obj = objects.obj7;
lv_label_set_text(objects.obj7, new_val);
tick_value_change_obj = NULL;
}
}
{
const char *new_val = evalTextProperty(flowState, 23, 3, "Failed to evaluate Text in Label widget");
const char *cur_val = lv_label_get_text(objects.obj8);
if (strcmp(new_val, cur_val) != 0) {
tick_value_change_obj = objects.obj8;
lv_label_set_text(objects.obj8, new_val);
tick_value_change_obj = NULL;
}
}
{
const char *new_val = evalTextProperty(flowState, 24, 3, "Failed to evaluate Text in Label widget");
const char *cur_val = lv_label_get_text(objects.obj9);
if (strcmp(new_val, cur_val) != 0) {
tick_value_change_obj = objects.obj9;
lv_label_set_text(objects.obj9, new_val);
tick_value_change_obj = NULL;
}
}
{
const char *new_val = evalTextProperty(flowState, 25, 3, "Failed to evaluate Text in Label widget");
const char *cur_val = lv_label_get_text(objects.obj10);
if (strcmp(new_val, cur_val) != 0) {
tick_value_change_obj = objects.obj10;
lv_label_set_text(objects.obj10, new_val);
tick_value_change_obj = NULL;
}
}
{
const char *new_val = evalTextProperty(flowState, 26, 3, "Failed to evaluate Text in Label widget");
const char *cur_val = lv_label_get_text(objects.obj11);
if (strcmp(new_val, cur_val) != 0) {
tick_value_change_obj = objects.obj11;
lv_label_set_text(objects.obj11, new_val);
tick_value_change_obj = NULL;
}
}
{
const char *new_val = evalTextProperty(flowState, 27, 3, "Failed to evaluate Text in Label widget");
const char *cur_val = lv_label_get_text(objects.obj12);
if (strcmp(new_val, cur_val) != 0) {
tick_value_change_obj = objects.obj12;
lv_label_set_text(objects.obj12, new_val);
tick_value_change_obj = NULL;
}
}
{
const char *new_val = evalTextProperty(flowState, 28, 3, "Failed to evaluate Text in Label widget");
const char *cur_val = lv_label_get_text(objects.obj13);
if (strcmp(new_val, cur_val) != 0) {
tick_value_change_obj = objects.obj13;
lv_label_set_text(objects.obj13, new_val);
tick_value_change_obj = NULL;
}
}
}
typedef void (*tick_screen_func_t)();
tick_screen_func_t tick_screen_funcs[] = {
tick_screen_main,
};
void tick_screen(int screen_index) {
tick_screen_funcs[screen_index]();
}
void tick_screen_by_id(enum ScreensEnum screenId) {
tick_screen_funcs[screenId - 1]();
}
//
// Fonts
//
ext_font_desc_t fonts[] = {
{ "chinese_36", &ui_font_chinese_36 },
{ "chinese_24", &ui_font_chinese_24 },
{ "chinese_16", &ui_font_chinese_16 },
{ "number_16", &ui_font_number_16 },
{ "number_14", &ui_font_number_14 },
#if LV_FONT_MONTSERRAT_8
{ "MONTSERRAT_8", &lv_font_montserrat_8 },
#endif
#if LV_FONT_MONTSERRAT_10
{ "MONTSERRAT_10", &lv_font_montserrat_10 },
#endif
#if LV_FONT_MONTSERRAT_12
{ "MONTSERRAT_12", &lv_font_montserrat_12 },
#endif
#if LV_FONT_MONTSERRAT_14
{ "MONTSERRAT_14", &lv_font_montserrat_14 },
#endif
#if LV_FONT_MONTSERRAT_16
{ "MONTSERRAT_16", &lv_font_montserrat_16 },
#endif
#if LV_FONT_MONTSERRAT_18
{ "MONTSERRAT_18", &lv_font_montserrat_18 },
#endif
#if LV_FONT_MONTSERRAT_20
{ "MONTSERRAT_20", &lv_font_montserrat_20 },
#endif
#if LV_FONT_MONTSERRAT_22
{ "MONTSERRAT_22", &lv_font_montserrat_22 },
#endif
#if LV_FONT_MONTSERRAT_24
{ "MONTSERRAT_24", &lv_font_montserrat_24 },
#endif
#if LV_FONT_MONTSERRAT_26
{ "MONTSERRAT_26", &lv_font_montserrat_26 },
#endif
#if LV_FONT_MONTSERRAT_28
{ "MONTSERRAT_28", &lv_font_montserrat_28 },
#endif
#if LV_FONT_MONTSERRAT_30
{ "MONTSERRAT_30", &lv_font_montserrat_30 },
#endif
#if LV_FONT_MONTSERRAT_32
{ "MONTSERRAT_32", &lv_font_montserrat_32 },
#endif
#if LV_FONT_MONTSERRAT_34
{ "MONTSERRAT_34", &lv_font_montserrat_34 },
#endif
#if LV_FONT_MONTSERRAT_36
{ "MONTSERRAT_36", &lv_font_montserrat_36 },
#endif
#if LV_FONT_MONTSERRAT_38
{ "MONTSERRAT_38", &lv_font_montserrat_38 },
#endif
#if LV_FONT_MONTSERRAT_40
{ "MONTSERRAT_40", &lv_font_montserrat_40 },
#endif
#if LV_FONT_MONTSERRAT_42
{ "MONTSERRAT_42", &lv_font_montserrat_42 },
#endif
#if LV_FONT_MONTSERRAT_44
{ "MONTSERRAT_44", &lv_font_montserrat_44 },
#endif
#if LV_FONT_MONTSERRAT_46
{ "MONTSERRAT_46", &lv_font_montserrat_46 },
#endif
#if LV_FONT_MONTSERRAT_48
{ "MONTSERRAT_48", &lv_font_montserrat_48 },
#endif
};
//
//
//
void create_screens() {
eez_flow_init_fonts(fonts, sizeof(fonts) / sizeof(ext_font_desc_t));
// Set default LVGL theme
lv_display_t *dispp = lv_display_get_default();
lv_theme_t *theme = lv_theme_default_init(dispp, lv_palette_main(LV_PALETTE_BLUE), lv_palette_main(LV_PALETTE_RED), false, LV_FONT_DEFAULT);
lv_display_set_theme(dispp, theme);
// Initialize screens
eez_flow_init_screen_names(screen_names, sizeof(screen_names) / sizeof(const char *));
eez_flow_init_object_names(object_names, sizeof(object_names) / sizeof(const char *));
// Create screens
create_screen_main();
}