From 6cad794411f60f2022548cb9fb9c6272a0daafd2 Mon Sep 17 00:00:00 2001 From: peteGSX Date: Tue, 29 Aug 2023 19:04:45 +1000 Subject: [PATCH] Working with 15 positions --- DCCEXParser.cpp | 10 +++++++++- DCCEXParser.h | 5 ++++- IODevice.h | 6 ------ Turntables.cpp | 4 ++++ Turntables.h | 5 +++++ defines.h | 20 ++++++++++++++++++++ 6 files changed, 42 insertions(+), 8 deletions(-) diff --git a/DCCEXParser.cpp b/DCCEXParser.cpp index 9047cad..a37e5d0 100644 --- a/DCCEXParser.cpp +++ b/DCCEXParser.cpp @@ -692,6 +692,8 @@ void DCCEXParser::parseOne(Print *stream, byte *com, RingStream * ringStream) } StringFormatter::send(stream, F(">\n")); return; +// No turntables without HAL support +#ifndef IO_NO_HAL case HASH_KEYWORD_O: // @@ -721,15 +723,19 @@ void DCCEXParser::parseOne(Print *stream, byte *com, RingStream * ringStream) } StringFormatter::send(stream, F(">\n")); return; +#endif default: break; } // switch(p[1]) break; // case J } +// No turntables without HAL support +#ifndef IO_NO_HAL case 'I': // TURNTABLE if (parseI(stream, params, p)) return; break; +#endif default: //anything else will diagnose and drop out to DIAG(F("Opcode=%c params=%d"), opcode, params); @@ -1051,12 +1057,13 @@ bool DCCEXParser::parseD(Print *stream, int16_t params, int16_t p[]) } // ========================== -// Turntable +// Turntable - no support if no HAL // - list all // - operate (DCC) // - operate (EXTT) // - create EXTT // - create DCC? - This TBA +#ifndef IO_NO_HAL bool DCCEXParser::parseI(Print *stream, int16_t params, int16_t p[]) { switch (params) @@ -1114,6 +1121,7 @@ bool DCCEXParser::parseI(Print *stream, int16_t params, int16_t p[]) return true; } } +#endif // CALLBACKS must be static bool DCCEXParser::stashCallback(Print *stream, int16_t p[MAX_COMMAND_PARAMS], RingStream * ringStream) diff --git a/DCCEXParser.h b/DCCEXParser.h index bf067a7..a3d5e10 100644 --- a/DCCEXParser.h +++ b/DCCEXParser.h @@ -24,6 +24,7 @@ #include #include "FSH.h" #include "RingStream.h" +#include "defines.h" typedef void (*FILTER_CALLBACK)(Print * stream, byte & opcode, byte & paramCount, int16_t p[]); typedef void (*AT_COMMAND_CALLBACK)(HardwareSerial * stream,const byte * command); @@ -37,7 +38,7 @@ struct DCCEXParser static void setFilter(FILTER_CALLBACK filter); static void setRMFTFilter(FILTER_CALLBACK filter); static void setAtCommandCallback(AT_COMMAND_CALLBACK filter); - static const int MAX_COMMAND_PARAMS=10; // Must not exceed this + static const int MAX_COMMAND_PARAMS=MAX_PARSER_PARAMS; // Must not exceed this private: @@ -49,7 +50,9 @@ struct DCCEXParser static bool parseS(Print * stream, int16_t params, int16_t p[]); static bool parsef(Print * stream, int16_t params, int16_t p[]); static bool parseD(Print * stream, int16_t params, int16_t p[]); +#ifndef IO_NO_HAL static bool parseI(Print * stream, int16_t params, int16_t p[]); +#endif static Print * getAsyncReplyStream(); static void commitAsyncReplyStream(); diff --git a/IODevice.h b/IODevice.h index 769e111..d2c80a4 100644 --- a/IODevice.h +++ b/IODevice.h @@ -27,12 +27,6 @@ // Define symbol DIAG_LOOPTIMES to enable CS loop execution time to be reported //#define DIAG_LOOPTIMES -// Define symbol IO_NO_HAL to reduce FLASH footprint when HAL features not required -// 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) -#define IO_NO_HAL -#endif - // Define symbol IO_SWITCH_OFF_SERVO to set the PCA9685 output to 0 when an // animation has completed. This switches off the servo motor, preventing // the continuous buzz sometimes found on servos, and reducing the diff --git a/Turntables.cpp b/Turntables.cpp index bcc0a94..6b4260f 100644 --- a/Turntables.cpp +++ b/Turntables.cpp @@ -26,6 +26,8 @@ #include "EXRAIL2.h" #include "DCC.h" +// No turntable support without HAL +#ifndef IO_NO_HAL /* * Protected static data @@ -180,3 +182,5 @@ EXTTTurntable::EXTTTurntable(uint16_t id, VPIN vpin, uint8_t i2caddress) : #endif return true; } + +#endif diff --git a/Turntables.h b/Turntables.h index 1016140..67017df 100644 --- a/Turntables.h +++ b/Turntables.h @@ -25,6 +25,9 @@ #include "IODevice.h" #include "StringFormatter.h" +// No turntable support without HAL +#ifndef IO_NO_HAL + // Turntable type definitions // EXTT = EX-Turntable // DCC = DCC accessory turntables - to be added later @@ -203,3 +206,5 @@ protected: }; #endif + +#endif diff --git a/defines.h b/defines.h index f3822ca..342d1b6 100644 --- a/defines.h +++ b/defines.h @@ -213,6 +213,26 @@ // #define WIFI_SERIAL_LINK_SPEED 115200 +//////////////////////////////////////////////////////////////////////////////// +// +// Define symbol IO_NO_HAL to reduce FLASH footprint when HAL features not required +// 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) +#define IO_NO_HAL +#endif + +//////////////////////////////////////////////////////////////////////////////// +// +// This defines the maximum number of parameters DCCEXParser will accept. +// The increase is required to allow for a sufficient number of turntable positions. +// +#ifdef IO_NO_HAL + #define MAX_PARSER_PARAMS 10 +#else + #define MAX_PARSER_PARAMS 20 +#endif + #if __has_include ( "myAutomation.h") #if defined(HAS_ENOUGH_MEMORY) || defined(DISABLE_EEPROM) || defined(DISABLE_PROG) #define EXRAIL_ACTIVE