5.5 KiB
SquareLine Studio UI Integration Guide
✅ Current Status
Your SquareLine Studio UI is now fully integrated and displaying on the ESP32-S3-LCD-1.3!
What's Showing Now
The display shows your ui_Home_Screen with:
- ui_Home_LBL label showing "Home Screen" (default text from SquareLine)
- 240×240 pixel layout
- Centered flex container
UI Structure
From your SquareLine Studio export (include/ui/screens/ui_Home_Screen.c):
ui_Home_Screen (screen)
└── ui_Main_Container (240×240 container, centered)
└── ui_Home_LBL (label, centered)
Available UI Objects
You can access these objects in your code:
extern lv_obj_t * ui_Home_Screen; // Main screen
extern lv_obj_t * ui_Main_Container; // 240×240 container
extern lv_obj_t * ui_Home_LBL; // Label widget
// Alternative pointers (same objects)
extern lv_obj_t * uic_Home_Screen;
extern lv_obj_t * uic_Main_Container;
extern lv_obj_t * uic_Home_LBL;
How to Update UI Dynamically
Update the Label Text
In src/main.cpp, add to the loop() function:
void loop() {
static uint32_t last_update = 0;
if (millis() - last_update > 1000) {
last_update = millis();
// Update label with dynamic content
if (uic_Home_LBL != NULL) {
char text[64];
snprintf(text, sizeof(text),
"Uptime: %lus\nHeap: %d",
millis() / 1000,
ESP.getFreeHeap());
lv_label_set_text(uic_Home_LBL, text);
}
}
delay(10);
}
Change Label Color
lv_obj_set_style_text_color(uic_Home_LBL, lv_color_hex(0x00FF00), 0); // Green
Change Label Font Size
lv_obj_set_style_text_font(uic_Home_LBL, &lv_font_montserrat_24, 0);
Adding More Widgets in SquareLine Studio
-
Edit in SquareLine Studio
- Open your ESP32-S3-LCD-1.3 project
- Add widgets (buttons, labels, arcs, meters, etc.)
- Configure properties and events
-
Export UI Files
- File → Export → Create Template Project
- Export to:
include/ui/
-
Rebuild
pio run --target upload
Example: Automotive Dashboard UI
For your Phase 3 automotive dashboard, you could add in SquareLine:
Widgets to Add
- Large Label for gear position (P/R/N/D)
- Arc Meters for temperatures (3 arcs)
- Small Label for battery voltage
- Panel/Label for fault codes
Update Strategy
void updateAutomotiveUI(const automotive_data_t* data) {
// Update gear position
lv_label_set_text(ui_GearLabel, gear_to_string(data->gear_position));
// Update gearbox temp arc
lv_arc_set_value(ui_GearboxTempArc, (int)data->gearbox_temp_c);
// Update battery voltage
char voltage[16];
snprintf(voltage, sizeof(voltage), "%.2fV", data->battery_voltage_v);
lv_label_set_text(ui_BatteryLabel, voltage);
}
Current UI File Locations
include/ui/
├── ui.h # Main UI header
├── ui.c # UI initialization
├── ui_helpers.h/.c # Helper functions
├── ui_events.h # Event handlers
├── screens/
│ ├── ui_Home_Screen.h # Home screen header
│ └── ui_Home_Screen.c # Home screen implementation
├── components/ # Custom components
└── fonts/ # Custom fonts (if any)
Modifying SquareLine UI
Option 1: Edit in SquareLine Studio (Recommended)
- Open SquareLine Studio
- Load your ESP32-S3-LCD-1.3 project
- Make changes visually
- Export and replace files in
include/ui/
Option 2: Edit Code Directly
You can manually edit include/ui/screens/ui_Home_Screen.c:
void ui_Home_Screen_screen_init(void)
{
ui_Home_Screen = lv_obj_create(NULL);
// Add more widgets here
lv_obj_t * my_new_label = lv_label_create(ui_Main_Container);
lv_label_set_text(my_new_label, "Custom Label");
lv_obj_align(my_new_label, LV_ALIGN_BOTTOM_MID, 0, -10);
}
Warning: Manual changes will be lost if you re-export from SquareLine Studio!
Screen Transitions (Multi-Screen Apps)
If you add multiple screens in SquareLine:
// Load different screen
lv_scr_load(ui_SettingsScreen);
// Load with animation
lv_scr_load_anim(ui_SettingsScreen, LV_SCR_LOAD_ANIM_FADE_IN, 300, 0, false);
Troubleshooting
UI Not Showing / Blank Screen
Check initialization order in main.cpp:
DisplayInit::init()← Must be firstui_init()← Loads SquareLine UI- Start LVGL task
- Don't overwrite label text in loop unless intended
Label Text Not Updating
Ensure you're using the correct pointer:
if (uic_Home_LBL != NULL) { // ✅ Good
lv_label_set_text(uic_Home_LBL, "New text");
}
Colors Look Wrong
Check color depth in lv_conf.h:
#define LV_COLOR_DEPTH 16 // RGB565
SquareLine Studio exports for 16-bit color.
Resources
- SquareLine Studio Docs: https://docs.squareline.io/
- LVGL Documentation: https://docs.lvgl.io/8.4/
- LVGL Widgets: https://docs.lvgl.io/8.4/widgets/index.html
Next Steps for Phase 2 & 3
- Phase 2: Add UART receiver module
- Phase 3: Design automotive dashboard in SquareLine:
- Add gear position label (large font)
- Add 3 arc meters for temperatures
- Add battery voltage label
- Add fault code panel
- Export and integrate
- Update UI in
loop()with UART data
Current UI: Showing "Home Screen" label Status: ✅ SquareLine Studio UI fully integrated Last Updated: 2025-11-08