Skip to content

feat: Implement on-device LVGL UI for ESP32-CYD#4

Open
leontappe wants to merge 9 commits into
mainfrom
feat/cyd-ondevice-ui
Open

feat: Implement on-device LVGL UI for ESP32-CYD#4
leontappe wants to merge 9 commits into
mainfrom
feat/cyd-ondevice-ui

Conversation

@leontappe

Copy link
Copy Markdown
Owner

Adds an LVGL-based user interface for the ESP32-2432S028R (CYD) board, allowing direct display of OBD-II statistics on the device's built-in screen.

Features:

  • Initializes TFT display and touch input using TFT_eSPI.
  • Uses LVGL to render a scrollable list of OBD states.
  • Displays state description, value, and unit.
  • Values update dynamically (currently polling every 1 second).
  • UI code is conditionally compiled for the 'cyd' PlatformIO environment using the BOARD_HAS_DISPLAY flag.
  • Includes updates to README.md to document the new feature.

Adds an LVGL-based user interface for the ESP32-2432S028R (CYD)
board, allowing direct display of OBD-II statistics on the device's
built-in screen.

Features:
- Initializes TFT display and touch input using TFT_eSPI.
- Uses LVGL to render a scrollable list of OBD states.
- Displays state description, value, and unit.
- Values update dynamically (currently polling every 1 second).
- UI code is conditionally compiled for the 'cyd' PlatformIO environment
  using the BOARD_HAS_DISPLAY flag.
- Includes updates to README.md to document the new feature.
- Set C++ standard to gnu++17 for cyd environment to support structured bindings.
- Corrected LV_FONT_CUSTOM_DECLARE definition in lv_conf.h.
- Fixed missing selector argument in lv_obj_set_style_min_width.
- Explicitly scoped obd::READ enum to resolve comparison warning.

These changes address build issues encountered after the initial
implementation of the on-device LVGL UI for the ESP32-CYD.
Restructures src/main.cpp to group all display-related includes,
static variables (e.g., obd_value_labels), and functions within a
single, continuous #ifdef BOARD_HAS_DISPLAY ... #endif block.

This is intended to resolve the persistent 'obd_value_labels' was
not declared in this scope' compilation error by ensuring clearer
scoping for the compiler.
Re-applies the LVGL on-device UI to a restored src/main.cpp.
Ensures all display-related code (includes, globals, functions) is within a single, continuous #ifdef BOARD_HAS_DISPLAY block to resolve previous scope and redefinition errors.

Includes fixes for lv_obj_set_style_min_width arguments and ensures correct task creation for LVGL within conditional blocks.
- Added -D ILI9341_DRIVER to platformio.ini for the cyd environment
  to ensure TFT_eSPI compiles with the correct driver when
  USER_SETUP_LOADED is defined.
- Corrected structure of main.cpp to ensure display-related code is
  properly scoped within a single #ifdef BOARD_HAS_DISPLAY block,
  resolving previous redefinition and scope errors.
- Ensured C++17 standard is used for cyd environment.
- Corrected LV_FONT_CUSTOM_DECLARE in lv_conf.h.
- Fixed lv_obj_set_style_min_width arguments in main.cpp.
- Scoped obd::READ in obd.cpp.

These changes address the compilation errors encountered during the
LVGL UI implementation for the ESP32-CYD.
- Set LV_LOG_PRINTF to 1 in lv_conf.h to use LVGL's internal printf for logging.
- Removed custom my_print function and the call to lv_log_register_print_cb
  from main.cpp as they are no longer needed.

This should resolve the undefined reference linker error and allow
the firmware to build successfully.
In lvgl_init() in main.cpp, added code to explicitly initialize
the TFT_BL pin (if defined) as an output and set it HIGH to turn on
the display backlight.

This is a common step needed to ensure the screen is visible and
may resolve the issue of a blank screen after flashing.
Modified `lvgl_update_obd_task` in `main.cpp` to:
- Store the last displayed string value for each OBD state label.
- Only call `lv_label_set_text` if the new formatted value string
  is different from the last displayed string.

This optimization aims to reduce unnecessary redraw operations and
minimize screen flickering on the on-device display.
- Added placeholder touch calibration logic in `my_touchpad_read`
  (requires user to find raw min/max values for their screen).
- Reduced vertical padding and inter-element gap for list items.
- Changed font for item labels (description, value, unit) to
  Montserrat 12 to make items more compact.
- Reduced min_width for the unit label.

These changes aim to enable touch scrolling (after calibration)
and allow more items to be visible on screen.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant