From f99aab3254148f832532037add9099faf04493c2 Mon Sep 17 00:00:00 2001 From: Jeanette Schlosser Date: Mon, 14 Nov 2022 13:39:44 +0100 Subject: [PATCH] Reduce flash size usage when no LCD is used. -648 Bytes --- CommandStation-EX.ino | 6 ++++-- LCD_Implementation.h | 12 ++++++++---- StringFormatter.cpp | 4 +++- StringFormatter.h | 1 - 4 files changed, 15 insertions(+), 8 deletions(-) diff --git a/CommandStation-EX.ino b/CommandStation-EX.ino index 80d8b4e0..09489c94 100644 --- a/CommandStation-EX.ino +++ b/CommandStation-EX.ino @@ -136,9 +136,11 @@ void loop() #if defined(LCN_SERIAL) LCN::loop(); #endif - + + #ifndef NO_LCD_USED LCDDisplay::loop(); // ignored if LCD not in use - + #endif + // Handle/update IO devices. IODevice::loop(); diff --git a/LCD_Implementation.h b/LCD_Implementation.h index 95b0f817..cb01f941 100644 --- a/LCD_Implementation.h +++ b/LCD_Implementation.h @@ -27,10 +27,14 @@ #ifndef LCD_Implementation_h #define LCD_Implementation_h -#include "LCDDisplay.h" -#include "SSD1306Ascii.h" -#include "LiquidCrystal_I2C.h" - +#if !defined(OLED_DRIVER) && !defined(LCD_DRIVER) + #include "DisplayInterface.h" + #define NO_LCD_USED +#else + #include "LCDDisplay.h" + #include "SSD1306Ascii.h" + #include "LiquidCrystal_I2C.h" +#endif // Implement the LCDDisplay shim class as a singleton. // The DisplayInterface class implements a displayy handler with no code (null device); diff --git a/StringFormatter.cpp b/StringFormatter.cpp index 73a910ff..c7d17fdd 100644 --- a/StringFormatter.cpp +++ b/StringFormatter.cpp @@ -27,7 +27,7 @@ Print * StringFormatter::diagSerial=&Serial; #endif -#include "LCDDisplay.h" +#include "LCD_Implementation.h" bool Diag::ACK=false; bool Diag::CMD=false; @@ -47,6 +47,7 @@ void StringFormatter::diag( const FSH* input...) { } void StringFormatter::lcd(byte row, const FSH* input...) { +#ifndef NO_LCD_USED va_list args; // Issue the LCD as a diag first @@ -59,6 +60,7 @@ void StringFormatter::lcd(byte row, const FSH* input...) { LCDDisplay::lcdDisplay->setRow(row); va_start(args, input); send2(LCDDisplay::lcdDisplay,input,args); +#endif } void StringFormatter::send(Print * stream, const FSH* input...) { diff --git a/StringFormatter.h b/StringFormatter.h index 50ce0f73..b485b300 100644 --- a/StringFormatter.h +++ b/StringFormatter.h @@ -25,7 +25,6 @@ #include #endif -#include "LCDDisplay.h" class Diag { public: static bool ACK;