Please help me,
How do I include a Gauge from the LVGL Library in my code?
I made all the code in Squareline Studio, but since there is no Gauge widget there, I would like to create it manually.
How can I do that?
The examples I found in the Documentation are insufficient, and the code provided by chatgtp is not correct. Any suggestions?
// This file was generated by SquareLine Studio
// SquareLine Studio version: SquareLine Studio 1.3.3
// LVGL version: 8.3.6
// Project name: EnervisionDash
#include "ui.h"
void ui_scrMonitor2_screen_init(void)
{
ui_scrMonitor2 = lv_obj_create(NULL);
lv_obj_clear_flag( ui_scrMonitor2, LV_OBJ_FLAG_SCROLLABLE ); /// Flags
lv_obj_set_style_bg_color(ui_scrMonitor2, lv_color_hex(0x160DDD), LV_PART_MAIN | LV_STATE_DEFAULT );
lv_obj_set_style_bg_opa(ui_scrMonitor2, 255, LV_PART_MAIN| LV_STATE_DEFAULT);
lv_obj_set_style_bg_grad_dir(ui_scrMonitor2, LV_GRAD_DIR_VER, LV_PART_MAIN| LV_STATE_DEFAULT);
ui_Panel4 = lv_obj_create(ui_scrMonitor2);
lv_obj_set_width( ui_Panel4, 480);
lv_obj_set_height( ui_Panel4, 320);
lv_obj_set_align( ui_Panel4, LV_ALIGN_CENTER );
lv_obj_clear_flag( ui_Panel4, LV_OBJ_FLAG_SCROLLABLE ); /// Flags
lv_obj_set_style_bg_color(ui_Panel4, lv_color_hex(0xFFFFFF), LV_PART_MAIN | LV_STATE_DEFAULT );
lv_obj_set_style_bg_opa(ui_Panel4, 0, LV_PART_MAIN| LV_STATE_DEFAULT);
ui_Button1 = lv_btn_create(ui_Panel4);
lv_obj_set_width( ui_Button1, 61);
lv_obj_set_height( ui_Button1, 61);
lv_obj_set_x( ui_Button1, -184 );
lv_obj_set_y( ui_Button1, 107 );
lv_obj_set_align( ui_Button1, LV_ALIGN_CENTER );
lv_obj_add_flag( ui_Button1, LV_OBJ_FLAG_SCROLL_ON_FOCUS ); /// Flags
lv_obj_clear_flag( ui_Button1, LV_OBJ_FLAG_SCROLLABLE ); /// Flags
lv_obj_set_style_bg_color(ui_Button1, lv_color_hex(0x09EF2E), LV_PART_MAIN | LV_STATE_DEFAULT );
lv_obj_set_style_bg_opa(ui_Button1, 255, LV_PART_MAIN| LV_STATE_DEFAULT);
ui_Label13 = lv_label_create(ui_Panel4);
lv_obj_set_width( ui_Label13, LV_SIZE_CONTENT); /// 1
lv_obj_set_height( ui_Label13, LV_SIZE_CONTENT); /// 1
lv_obj_set_x( ui_Label13, -4 );
lv_obj_set_y( ui_Label13, -128 );
lv_obj_set_align( ui_Label13, LV_ALIGN_CENTER );
lv_label_set_text(ui_Label13,"Enervision Dash");
lv_obj_set_style_text_color(ui_Label13, lv_color_hex(0xFFFFFF), LV_PART_MAIN | LV_STATE_DEFAULT );
lv_obj_set_style_text_opa(ui_Label13, 255, LV_PART_MAIN| LV_STATE_DEFAULT);
**/*Describe the color for the needles*/**
** static lv_color_t needle_colors[3];**
** needle_colors[0] = LV_COLOR_BLUE;**
** needle_colors[1] = LV_COLOR_ORANGE;**
** needle_colors[2] = LV_COLOR_PURPLE;**
** /*Create a gauge*/**
** lv_obj_t * gauge1 = lv_gauge_create(lv_scr_act(), NULL);**
** lv_gauge_set_needle_count(gauge1, 3, needle_colors);**
** lv_obj_set_size(gauge1, 200, 200);**
** lv_obj_align(gauge1, NULL, LV_ALIGN_CENTER, 0, 0);**
** /*Set the values*/**
** lv_gauge_set_value(gauge1, 0, 10);**
** lv_gauge_set_value(gauge1, 1, 20);**
** lv_gauge_set_value(gauge1, 2, 30);**
lv_obj_add_event_cb(ui_Button1, ui_event_Button1, LV_EVENT_ALL, NULL);
}
The idea is to create the gauge inside the panel. ui_panel4