@@ -110,8 +110,9 @@ void drawConfigurableIndicators() {
110110
111111// New function to replace itemDraw with configurable panels
112112void drawConfigurableData (bool setup) {
113- // Draw RPM (always shown)
114- if (lastRpm != rpm || setup) {
113+ // Draw RPM with reduced frequency update (only when changed or setup)
114+ static uint32_t lastRpmUpdate = 0 ;
115+ if (lastRpm != rpm || setup || (millis () - lastRpmUpdate > 100 )) {
115116 drawRPMBarBlocks (rpm);
116117 spr.loadFont (AA_FONT_LARGE );
117118 spr.createSprite (100 , 50 );
@@ -122,13 +123,22 @@ void drawConfigurableData(bool setup) {
122123 spr.pushSprite (190 , 140 );
123124 spr.deleteSprite ();
124125 lastRpm = rpm;
126+ lastRpmUpdate = millis ();
125127 }
126128
127- // Draw configurable panels
128- drawConfigurablePanels (setup);
129+ // Draw configurable panels with reduced frequency
130+ static uint32_t lastPanelUpdate = 0 ;
131+ if (setup || (millis () - lastPanelUpdate > 50 )) { // Update panels every 50ms max
132+ drawConfigurablePanels (setup);
133+ lastPanelUpdate = millis ();
134+ }
129135
130- // Draw configurable indicators
131- drawConfigurableIndicators ();
136+ // Draw configurable indicators with reduced frequency
137+ static uint32_t lastIndicatorUpdate = 0 ;
138+ if (setup || (millis () - lastIndicatorUpdate > 100 )) { // Update indicators every 100ms max
139+ drawConfigurableIndicators ();
140+ lastIndicatorUpdate = millis ();
141+ }
132142}
133143
134144void startUpDisplay () {
@@ -195,16 +205,17 @@ void drawDataBox(int x, int y, const char *label, const float value, uint16_t la
195205}
196206
197207void drawData () {
198- // Use configurable display system
208+ // Use configurable display system with performance optimizations
199209 drawConfigurableData (false );
200210
201211#if ENABLE_SIMULATOR
202- // Draw simulator indicator if simulator is active
212+ // Draw simulator indicator if simulator is active (with reduced update frequency)
203213 static uint8_t lastSimMode = SIMULATOR_MODE_OFF ;
214+ static uint32_t lastSimUpdate = 0 ;
204215 uint8_t currentSimMode = getSimulatorMode ();
205216
206- // Only redraw if simulator mode has changed
207- if (currentSimMode != lastSimMode) {
217+ // Only redraw if simulator mode has changed or every 500ms
218+ if (currentSimMode != lastSimMode || ( millis () - lastSimUpdate > 500 ) ) {
208219 if (currentSimMode != SIMULATOR_MODE_OFF ) {
209220 // Clear the SIM area first
210221 display.fillRect (display.width () - 30 , 5 , 25 , 15 , TFT_BLACK );
@@ -220,17 +231,19 @@ void drawData() {
220231 }
221232
222233 lastSimMode = currentSimMode;
234+ lastSimUpdate = millis ();
223235 }
224236#endif
225237
226- // Draw communication mode indicator (top left)
238+ // Draw communication mode indicator (top left) with reduced update frequency
227239 static bool lastCommMode = true ; // Track changes
228240 static String lastCommText = " " ;
241+ static uint32_t lastCommUpdate = 0 ;
229242
230243 String currentCommText = isCANMode ? " CAN" : " SER" ;
231244
232- // Only redraw if communication mode has changed
233- if (isCANMode != lastCommMode || currentCommText != lastCommText) {
245+ // Only redraw if communication mode has changed or every 1000ms
246+ if (isCANMode != lastCommMode || currentCommText != lastCommText || ( millis () - lastCommUpdate > 1000 ) ) {
234247 // Clear the comm mode area first
235248 display.fillRect (5 , 5 , 40 , 15 , TFT_BLACK );
236249
@@ -242,18 +255,17 @@ void drawData() {
242255
243256 lastCommMode = isCANMode;
244257 lastCommText = currentCommText;
258+ lastCommUpdate = millis ();
245259 }
246260
247261#if ENABLE_DEBUG_MODE
248- // Draw debug information at center top if debug mode is active
249262 static bool lastDebugMode = false ;
250263 static String lastDebugInfo = " " ;
251264
252265 if (debugMode) {
253266 // Create debug info string - show only essential info in one line
254267 String debugInfo = " CPU:" + String (cpuUsage, 1 ) + " % FPS:" + String (fps, 1 ) + " Heap:" + String (ESP .getFreeHeap ()/1024 ) + " K" ;
255268
256- // Only redraw if debug info has changed or we just entered debug mode
257269 if (debugInfo != lastDebugInfo || !lastDebugMode) {
258270 int centerX = display.width () / 2 ;
259271
0 commit comments