1
0
mirror of https://github.com/DCC-EX/CommandStation-EX.git synced 2024-11-22 23:56:13 +01:00

Supply motor shield name for <s>

This commit is contained in:
Asbelos 2020-09-24 09:51:09 +01:00
parent 0b603d4dfd
commit caef013d35
4 changed files with 19 additions and 19 deletions

View File

@ -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,

18
DCC.h
View File

@ -60,7 +60,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
@ -91,6 +91,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;
@ -104,6 +107,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);
@ -153,17 +158,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 <Wire.h>

View File

@ -304,7 +304,7 @@ void DCCEXParser::parse(Print * stream, byte *com, bool blocking) {
case 's': // <s>
StringFormatter::send(stream,F("<p%d>"),DCCWaveform::mainTrack.getPowerMode()==POWERMODE::ON );
StringFormatter::send(stream,F("<iDCC-EX V-%S / %S / %S G-%S>"), VERSION, F(ARDUINO_TYPE), F(MOTOR_BOARD_TYPE), F(GITHUB_SHA));
StringFormatter::send(stream,F("<iDCC-EX V-%S / %S / %S G-%S>"), 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;

View File

@ -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)