diff --git a/DCC.cpp b/DCC.cpp index e7ca624..5749afe 100644 --- a/DCC.cpp +++ b/DCC.cpp @@ -41,8 +41,10 @@ const byte FN_GROUP_3=0x04; const byte FN_GROUP_4=0x08; const byte FN_GROUP_5=0x10; +__FlashStringHelper* DCC::shieldName=NULL; -void DCC::begin(MotorDriver * mainDriver, MotorDriver* progDriver, byte timerNumber) { +void DCC::begin(const __FlashStringHelper* motorShieldName, MotorDriver * mainDriver, MotorDriver* progDriver, byte timerNumber) { + shieldName=motorShieldName; DCCWaveform::begin(mainDriver,progDriver, timerNumber); } @@ -206,6 +208,10 @@ void DCC::setProgTrackSyncMain(bool on) { DCCWaveform::progTrackSyncMain=on; } +__FlashStringHelper* DCC::getMotorShieldName() { + return shieldName; +} + const ackOp PROGMEM WRITE_BIT0_PROG[] = { BASELINE, W0,WACK, diff --git a/DCC.h b/DCC.h index 76aca0e..1254998 100644 --- a/DCC.h +++ b/DCC.h @@ -59,7 +59,7 @@ SKIPTARGET=0xFF // jump to target class DCC { public: - static void begin(MotorDriver * mainDriver, MotorDriver * progDriver, byte timerNumber=1); + static void begin(const __FlashStringHelper* motorShieldName, MotorDriver * mainDriver, MotorDriver * progDriver, byte timerNumber=1); static void loop(); // Public DCC API functions @@ -90,6 +90,9 @@ class DCC { static void forgetLoco(int cab); // removes any speed reminders for this loco static void forgetAllLocos(); // removes all speed reminders static void displayCabList(Print * stream); + + static __FlashStringHelper* getMotorShieldName(); + private: struct LOCO { int loco; @@ -103,6 +106,8 @@ private: static void setFunctionInternal( int cab, byte fByte, byte eByte); static bool issueReminder(int reg); static int nextLoco; + static __FlashStringHelper* shieldName; + static LOCO speedTable[MAX_LOCOS]; static byte cv1(byte opcode, int cv); static byte cv2(int cv); @@ -152,17 +157,6 @@ private: #error CANNOT COMPILE - DCC++ EX ONLY WORKS WITH AN ARDUINO UNO, NANO 328, OR ARDUINO MEGA 1280/2560 #endif -#if defined(STANDARD_MOTOR_SHIELD) - #define MOTOR_BOARD_TYPE "Ardu" -#elif defined(POLOLU_MOTOR_SHIELD) - #define MOTOR_BOARD_TYPE "Polo" -#elif defined(FUNDUMOTO_SHIELD) - #define MOTOR_BOARD_TYPE "Fundu" -#elif defined(FIREBOX_MK1) - #define MOTOR_BOARD_TYPE "FireBox1" -#elif if defined(FIREBOX_MK1S) - #define MOTOR_BOARD_TYPE "FireBox1S" -#endif #ifdef ENABLE_LCD #include diff --git a/DCCEXParser.cpp b/DCCEXParser.cpp index f7ba4ef..e10e028 100644 --- a/DCCEXParser.cpp +++ b/DCCEXParser.cpp @@ -304,7 +304,7 @@ void DCCEXParser::parse(Print * stream, byte *com, bool blocking) { case 's': // StringFormatter::send(stream,F(""),DCCWaveform::mainTrack.getPowerMode()==POWERMODE::ON ); - StringFormatter::send(stream,F(""), VERSION, F(ARDUINO_TYPE), F(MOTOR_BOARD_TYPE), F(GITHUB_SHA)); + StringFormatter::send(stream,F(""), F(VERSION), F(ARDUINO_TYPE), DCC::getMotorShieldName(), F(GITHUB_SHA)); // TODO Send stats of speed reminders table // TODO send status of turnouts etc etc return; diff --git a/MotorDrivers.h b/MotorDrivers.h index f31aeac..c81bc37 100644 --- a/MotorDrivers.h +++ b/MotorDrivers.h @@ -16,27 +16,27 @@ const byte UNUSED_PIN = 255; // float senseFactor, unsigned int tripMilliamps, byte faultPin); // Arduino standard Motor Shield -#define STANDARD_MOTOR_SHIELD \ +#define STANDARD_MOTOR_SHIELD F("STANDARD_MOTOR_SHIELD"), \ new MotorDriver(3 , 12, UNUSED_PIN, UNUSED_PIN, A0, 2.99, 2000, UNUSED_PIN), \ new MotorDriver(11, 13, UNUSED_PIN, UNUSED_PIN, A1, 2.99, 250 , UNUSED_PIN) // Pololu Motor Shield -#define POLOLU_MOTOR_SHIELD \ +#define POLOLU_MOTOR_SHIELD F("POLOLU_MOTOR_SHIELD"), \ new MotorDriver(4, 7, UNUSED_PIN, 9 , A0, 18, 2000, 12), \ new MotorDriver(2, 8, UNUSED_PIN, 10, A1, 18, 250 , UNUSED_PIN) // Firebox Mk1 -#define FIREBOX_MK1 \ +#define FIREBOX_MK1 F("FIREBOX_MK1"), \ new MotorDriver(3, 6, 7, UNUSED_PIN, A5, 9.766, 5500, UNUSED_PIN), \ new MotorDriver(4, 8, 9, UNUSED_PIN, A1, 5.00, 250 , UNUSED_PIN) // Firebox Mk1S -#define FIREBOX_MK1S \ +#define FIREBOX_MK1S F("FIREBOX_MK1A"), \ new MotorDriver(24, 21, 22, 25, 23, 9.766, 5500, UNUSED_PIN), \ new MotorDriver(30, 27, 28, 31, 29, 5.00, 250 , UNUSED_PIN) // FunduMoto Motor Shield -#define FUNDUMOTO_SHIELD \ +#define FUNDUMOTO_SHIELD F("FUNDUMOTO_SHIELD"), \ new MotorDriver(10 , 12, UNUSED_PIN, 9, A0, 2.99, 2000, UNUSED_PIN), \ new MotorDriver(11, 13, UNUSED_PIN, UNUSED_PIN, A1, 2.99, 250 , UNUSED_PIN)