界面实现,然后称重还有问题,灯改为手动控制
This commit is contained in:
@@ -13,7 +13,7 @@
|
||||
objects_t objects;
|
||||
|
||||
static const char *screen_names[] = { "Main" };
|
||||
static const char *object_names[] = { "main" };
|
||||
static const char *object_names[] = { "main", "obj0", "obj1", "obj2" };
|
||||
|
||||
//
|
||||
// Event handlers
|
||||
@@ -32,14 +32,36 @@ void create_screen_main() {
|
||||
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(0xff075d00), LV_PART_MAIN | LV_STATE_DEFAULT);
|
||||
lv_obj_set_style_bg_color(obj, lv_color_hex(0xff000000), LV_PART_MAIN | LV_STATE_DEFAULT);
|
||||
{
|
||||
lv_obj_t *parent_obj = obj;
|
||||
{
|
||||
lv_obj_t *obj = lv_label_create(parent_obj);
|
||||
lv_obj_set_pos(obj, 75, 103);
|
||||
objects.obj0 = obj;
|
||||
lv_obj_set_pos(obj, 217, 123);
|
||||
lv_obj_set_size(obj, LV_SIZE_CONTENT, LV_SIZE_CONTENT);
|
||||
lv_label_set_text(obj, "Hello, world!");
|
||||
lv_obj_set_style_text_font(obj, &ui_font_num, LV_PART_MAIN | LV_STATE_DEFAULT);
|
||||
lv_obj_set_style_text_color(obj, lv_color_hex(0xffffffff), LV_PART_MAIN | LV_STATE_DEFAULT);
|
||||
lv_label_set_text(obj, "g");
|
||||
}
|
||||
{
|
||||
lv_obj_t *obj = lv_label_create(parent_obj);
|
||||
objects.obj1 = obj;
|
||||
lv_obj_set_pos(obj, 5, 94);
|
||||
lv_obj_set_size(obj, LV_SIZE_CONTENT, LV_SIZE_CONTENT);
|
||||
lv_obj_set_style_text_font(obj, &ui_font_num2, LV_PART_MAIN | LV_STATE_DEFAULT);
|
||||
lv_obj_set_style_text_color(obj, lv_color_hex(0xffffe503), LV_PART_MAIN | LV_STATE_DEFAULT);
|
||||
lv_obj_set_style_text_align(obj, LV_TEXT_ALIGN_RIGHT, 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, 40, 7);
|
||||
lv_obj_set_size(obj, LV_SIZE_CONTENT, LV_SIZE_CONTENT);
|
||||
lv_obj_set_style_text_font(obj, &ui_font_chinese32, LV_PART_MAIN | LV_STATE_DEFAULT);
|
||||
lv_obj_set_style_text_color(obj, lv_color_hex(0xffffffff), LV_PART_MAIN | LV_STATE_DEFAULT);
|
||||
lv_label_set_text(obj, "智能电子称");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,6 +71,15 @@ void create_screen_main() {
|
||||
void tick_screen_main() {
|
||||
void *flowState = getFlowState(0, 0);
|
||||
(void)flowState;
|
||||
{
|
||||
const char *new_val = evalTextProperty(flowState, 2, 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
typedef void (*tick_screen_func_t)();
|
||||
@@ -67,6 +98,10 @@ void tick_screen_by_id(enum ScreensEnum screenId) {
|
||||
//
|
||||
|
||||
ext_font_desc_t fonts[] = {
|
||||
{ "Num", &ui_font_num },
|
||||
{ "Num2", &ui_font_num2 },
|
||||
{ "chinese64", &ui_font_chinese64 },
|
||||
{ "chinese32", &ui_font_chinese32 },
|
||||
#if LV_FONT_MONTSERRAT_8
|
||||
{ "MONTSERRAT_8", &lv_font_montserrat_8 },
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user