Skip to content

Latest commit

 

History

History
110 lines (88 loc) · 4.1 KB

File metadata and controls

110 lines (88 loc) · 4.1 KB

MAZDUINO Display Modularization Status

Overview

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.

File Structure

Main Application

  • main.cpp - Main application file (replaces ESP32_DevkitC_3.5_SPI.ino)
  • ESP32_DevkitC_3.5_SPI.ino.backup - Backup of original file

Modular Components

Configuration & Data

  • Config.h - System constants, pin definitions, and configuration
  • DataTypes.h - Global variable declarations
  • GlobalVariables.cpp - Global variable definitions

Hardware Modules

  • 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

Network & Communication

  • WebServerHandler.h/cpp - OTA updates and web server functionality
  • Comms.h/cpp - Serial communication with ECU (formerly Comms.ino)

Legacy/Utility Files

  • 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

Key Features Implemented

1. CAN ID 0x369 (Trigger System Error Count)

  • ✅ 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

2. PWM Backlight Control

  • ✅ 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

3. Floating Point Display

  • ✅ 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

4. Modularization

  • ✅ 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

Function Distribution

main.cpp

  • setup() - Main initialization
  • loop() - Main application loop
  • handleSerialCommunication() - Serial ECU communication

CANHandler.cpp

  • setupCAN() - CAN initialization
  • handleCANCommunication() - CAN message processing
  • canTask() - FreeRTOS task for CAN

DisplayManager.cpp

  • setupDisplay() - Display initialization
  • drawSplashScreenWithImage() - Startup splash screen
  • itemDraw() - UI element rendering
  • startUpDisplay() - Initial display setup
  • drawDataBox() - Individual data box rendering
  • drawData() - Main display update

BacklightControl.cpp

  • initializeBacklight() - PWM setup
  • setBacklightBrightness() - Brightness control
  • adjustBacklightAutomatically() - Automatic brightness based on RPM

WebServerHandler.cpp

  • setupWebServer() - Web server initialization
  • handleRoot() - Root page handler
  • handleUpdate() - OTA update handler
  • handleToggle() - Display toggle handler
  • handleWebServerClients() - Client management

Build Configuration

  • platformio.ini - Updated with proper build flags
  • src/main.cpp - New main application file
  • All modules properly linked and included

Usage

  1. The project should now build with PlatformIO
  2. CAN ID 0x369 (Trigger System Error Count) is automatically parsed and displayed
  3. PWM backlight control automatically adjusts based on RPM
  4. AFR and Voltage display as floating point values
  5. Modular structure allows easy maintenance and updates

Notes

  • 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