The ESP32 dashboard project has been successfully modularized from a single .ino file into multiple .h and .cpp files. The main file has been converted from .ino to .cpp format.
- main.cpp - Main application file (replaces ESP32_DevkitC_3.5_SPI.ino)
- ESP32_DevkitC_3.5_SPI.ino.backup - Backup of original file
- Config.h - System constants, pin definitions, and configuration
- DataTypes.h - Global variable declarations
- GlobalVariables.cpp - Global variable definitions
- BacklightControl.h/cpp - PWM backlight control on pin 32
- CANHandler.h/cpp - CAN communication and message parsing
- DisplayManager.h/cpp - Display/UI management and rendering
- WebServerHandler.h/cpp - OTA updates and web server functionality
- Comms.h/cpp - Serial communication with ECU (formerly Comms.ino)
- drawing_utils.h - Drawing utility functions
- text_utils.h - Text utility functions
- NotoSansBold15.h - Font definition
- NotoSansBold36.h - Font definition
- splash.bmp - Splash screen image
- ✅ Added CAN0.watchFor(0x369) in setupCAN()
- ✅ Implemented parsing in handleCANCommunication()
- ✅ Added triggerError variable to DataTypes.h
- ✅ Updated display to show "Trigger" instead of "FPS" when EEPROM.read(0) == 1
- ✅ Updated Serial output to include "Trigger Error: " + triggerError
- ✅ Added PWM setup for pin 32 in BacklightControl.cpp
- ✅ Implemented automatic brightness adjustment based on RPM
- ✅ Added initializeBacklight() and adjustBacklightAutomatically() functions
- ✅ Removed old backlight defines from platformio.ini
- ✅ Fixed AFR display to show floating point values (afrConv with 1 decimal)
- ✅ Fixed Voltage display to show floating point values (bat with 1 decimal)
- ✅ Used drawFloat() function in drawDataBox() for proper decimal display
- ✅ Separated concerns into logical modules
- ✅ Clean include structure with proper header guards
- ✅ Maintained backward compatibility with legacy utility files
- ✅ Converted main file from .ino to .cpp format
- setup() - Main initialization
- loop() - Main application loop
- handleSerialCommunication() - Serial ECU communication
- setupCAN() - CAN initialization
- handleCANCommunication() - CAN message processing
- canTask() - FreeRTOS task for CAN
- setupDisplay() - Display initialization
- drawSplashScreenWithImage() - Startup splash screen
- itemDraw() - UI element rendering
- startUpDisplay() - Initial display setup
- drawDataBox() - Individual data box rendering
- drawData() - Main display update
- initializeBacklight() - PWM setup
- setBacklightBrightness() - Brightness control
- adjustBacklightAutomatically() - Automatic brightness based on RPM
- setupWebServer() - Web server initialization
- handleRoot() - Root page handler
- handleUpdate() - OTA update handler
- handleToggle() - Display toggle handler
- handleWebServerClients() - Client management
- platformio.ini - Updated with proper build flags
- src/main.cpp - New main application file
- All modules properly linked and included
- The project should now build with PlatformIO
- CAN ID 0x369 (Trigger System Error Count) is automatically parsed and displayed
- PWM backlight control automatically adjusts based on RPM
- AFR and Voltage display as floating point values
- Modular structure allows easy maintenance and updates
- Original .ino file backed up as .ino.backup
- All legacy functionality preserved
- Web server features available but commented out in main.cpp
- Serial communication mode still supported
- All previous CAN IDs still supported with new 0x369 addition