From 697f228a05d990e028d4085ab1c6d36553d46519 Mon Sep 17 00:00:00 2001 From: Harald Barth Date: Thu, 23 Nov 2023 22:14:24 +0100 Subject: [PATCH] Save progmem with DISABLE_VDPY on Uno --- DCCEXParser.cpp | 4 +++- StringFormatter.cpp | 11 ++++++++--- config.example.h | 12 ++++++++++++ defines.h | 9 ++++----- 4 files changed, 27 insertions(+), 9 deletions(-) diff --git a/DCCEXParser.cpp b/DCCEXParser.cpp index abbf54a..f3cdfb2 100644 --- a/DCCEXParser.cpp +++ b/DCCEXParser.cpp @@ -847,13 +847,14 @@ void DCCEXParser::parseOne(Print *stream, byte *com, RingStream * ringStream) case 'L': // LCC interface implemented in EXRAIL parser break; // Will if not intercepted by EXRAIL +#ifndef DISABLE_VDPY case '@': // JMRI saying "give me virtual LCD msgs" CommandDistributor::setVirtualLCDSerial(stream); StringFormatter::send(stream, F("<@ 0 0 \"DCC-EX v" VERSION "\">\n" "<@ 0 1 \"Lic GPLv3\">\n")); return; - +#endif default: //anything else will diagnose and drop out to if (opcode >= ' ' && opcode <= '~') { DIAG(F("Opcode=%c params=%d"), opcode, params); @@ -1064,6 +1065,7 @@ bool DCCEXParser::parseS(Print *stream, int16_t params, int16_t p[]) } bool DCCEXParser::parseC(Print *stream, int16_t params, int16_t p[]) { + (void)stream; // arg not used, maybe later? if (params == 0) return false; switch (p[0]) diff --git a/StringFormatter.cpp b/StringFormatter.cpp index 13b5825..9c69877 100644 --- a/StringFormatter.cpp +++ b/StringFormatter.cpp @@ -39,8 +39,11 @@ void StringFormatter::diag( const FSH* input...) { void StringFormatter::lcd(byte row, const FSH* input...) { va_list args; +#ifndef DISABLE_VDPY Print * virtualLCD=CommandDistributor::getVirtualLCDSerial(0,row); - +#else + Print * virtualLCD=NULL; +#endif // Issue the LCD as a diag first // Unless the same serial is asking for the virtual @ respomnse if (virtualLCD!=&USB_SERIAL) { @@ -50,13 +53,14 @@ void StringFormatter::lcd(byte row, const FSH* input...) { send(&USB_SERIAL,F(" *>\n")); } +#ifndef DISABLE_VDPY // send to virtual LCD collector (if any) if (virtualLCD) { va_start(args, input); send2(virtualLCD,input,args); CommandDistributor::commitVirtualLCDSerial(); } - +#endif DisplayInterface::setRow(row); va_start(args, input); send2(DisplayInterface::getDisplayHandler(),input,args); @@ -66,12 +70,14 @@ void StringFormatter::lcd2(uint8_t display, byte row, const FSH* input...) { va_list args; // send to virtual LCD collector (if any) +#ifndef DISABLE_VDPY Print * virtualLCD=CommandDistributor::getVirtualLCDSerial(display,row); if (virtualLCD) { va_start(args, input); send2(virtualLCD,input,args); CommandDistributor::commitVirtualLCDSerial(); } +#endif DisplayInterface::setRow(display, row); va_start(args, input); @@ -250,4 +256,3 @@ void StringFormatter::printHex(Print * stream,uint16_t value) { result[4]='\0'; stream->print(result); } - \ No newline at end of file diff --git a/config.example.h b/config.example.h index 9909371..89d6c1f 100644 --- a/config.example.h +++ b/config.example.h @@ -199,6 +199,18 @@ The configuration file for DCC-EX Command Station // // #define DISABLE_PROG +///////////////////////////////////////////////////////////////////////////////////// +// DISABLE / ENABLE VDPY +// +// The Virtual display "VDPY" feature is by default enabled everywhere +// but on Uno and Nano. If you think you can fit it (for example +// having disabled some of the features above) you can enable it with +// ENABLE_VDPY. You can even disable it on all other CPUs with +// DISABLE_VDPY +// +// #define DISABLE_VDPY +// #define ENABLE_VDPY + ///////////////////////////////////////////////////////////////////////////////////// // REDEFINE WHERE SHORT/LONG ADDR break is. According to NMRA the last short address // is 127 and the first long address is 128. There are manufacturers which have diff --git a/defines.h b/defines.h index e90d7f4..14dd1c5 100644 --- a/defines.h +++ b/defines.h @@ -219,11 +219,10 @@ // The HAL is disabled by default on Nano and Uno platforms, because of limited flash space. // #if defined(ARDUINO_AVR_NANO) || defined(ARDUINO_AVR_UNO) - #if defined(DISABLE_DIAG) && defined(DISABLE_EEPROM) && defined(DISABLE_PROG) - #warning you have sacrificed DIAG for HAL - #else - #define IO_NO_HAL - #endif +#define IO_NO_HAL // HAL too big whatever you disable otherwise +#ifndef ENABLE_VDPY +#define DISABLE_VDPY +#endif #endif #if __has_include ( "myAutomation.h")