mirror of
https://github.com/DCC-EX/CommandStation-EX.git
synced 2024-12-23 21:01:25 +01:00
<D DCC SLOW>
This commit is contained in:
parent
39d9defec6
commit
5239164200
@ -43,7 +43,8 @@ const int HASH_KEYWORD_WIT=31594;
|
|||||||
const int HASH_KEYWORD_WIFI=-5583;
|
const int HASH_KEYWORD_WIFI=-5583;
|
||||||
const int HASH_KEYWORD_ACK=3113;
|
const int HASH_KEYWORD_ACK=3113;
|
||||||
const int HASH_KEYWORD_ON=2657;
|
const int HASH_KEYWORD_ON=2657;
|
||||||
const int HASH_KEYWORD_OFF=22479;
|
const int HASH_KEYWORD_DCC=6436;
|
||||||
|
const int HASH_KEYWORD_SLOW=-17209;
|
||||||
|
|
||||||
|
|
||||||
int DCCEXParser::stashP[MAX_PARAMS];
|
int DCCEXParser::stashP[MAX_PARAMS];
|
||||||
@ -455,7 +456,7 @@ bool DCCEXParser::parseS( Print * stream,int params, int p[]) {
|
|||||||
|
|
||||||
bool DCCEXParser::parseD( Print * stream,int params, int p[]) {
|
bool DCCEXParser::parseD( Print * stream,int params, int p[]) {
|
||||||
if (params==0) return false;
|
if (params==0) return false;
|
||||||
bool onOff=p[1]==1 || p[1]==HASH_KEYWORD_ON; // dont care if other stuff or missing... just means off
|
bool onOff=(params>0) && (p[1]==1 || p[1]==HASH_KEYWORD_ON); // dont care if other stuff or missing... just means off
|
||||||
switch(p[0]){
|
switch(p[0]){
|
||||||
case HASH_KEYWORD_CABS: // <D CABS>
|
case HASH_KEYWORD_CABS: // <D CABS>
|
||||||
DCC::displayCabList(stream);
|
DCC::displayCabList(stream);
|
||||||
@ -481,6 +482,9 @@ bool DCCEXParser::parseD( Print * stream,int params, int p[]) {
|
|||||||
Diag::WITHROTTLE=onOff;
|
Diag::WITHROTTLE=onOff;
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
case HASH_KEYWORD_DCC:
|
||||||
|
DCCWaveform::setDiagnosticSlowWave(params>=1 && p[1]==HASH_KEYWORD_SLOW);
|
||||||
|
return true;
|
||||||
default: // invalid/unknown
|
default: // invalid/unknown
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -22,6 +22,8 @@
|
|||||||
#include "DCCWaveform.h"
|
#include "DCCWaveform.h"
|
||||||
#include "DIAG.h"
|
#include "DIAG.h"
|
||||||
|
|
||||||
|
const int NORMAL_SIGNAL_TIME=58; // this is the 58uS DCC 1-bit waveform half-cycle
|
||||||
|
const int SLOW_SIGNAL_TIME=NORMAL_SIGNAL_TIME*256;
|
||||||
|
|
||||||
DCCWaveform DCCWaveform::mainTrack(PREAMBLE_BITS_MAIN, true);
|
DCCWaveform DCCWaveform::mainTrack(PREAMBLE_BITS_MAIN, true);
|
||||||
DCCWaveform DCCWaveform::progTrack(PREAMBLE_BITS_PROG, false);
|
DCCWaveform DCCWaveform::progTrack(PREAMBLE_BITS_PROG, false);
|
||||||
@ -47,10 +49,15 @@ void DCCWaveform::begin(MotorDriver * mainDriver, MotorDriver * progDriver, byte
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
interruptTimer->initialize();
|
interruptTimer->initialize();
|
||||||
interruptTimer->setPeriod(58); // this is the 58uS DCC 1-bit waveform half-cycle
|
interruptTimer->setPeriod(NORMAL_SIGNAL_TIME); // this is the 58uS DCC 1-bit waveform half-cycle
|
||||||
interruptTimer->attachInterrupt(interruptHandler);
|
interruptTimer->attachInterrupt(interruptHandler);
|
||||||
interruptTimer->start();
|
interruptTimer->start();
|
||||||
}
|
}
|
||||||
|
void DCCWaveform::setDiagnosticSlowWave(bool slow) {
|
||||||
|
interruptTimer->setPeriod(slow? SLOW_SIGNAL_TIME : NORMAL_SIGNAL_TIME);
|
||||||
|
interruptTimer->start();
|
||||||
|
DIAG(F("\nDCC SLOW WAVE %S\n"),slow?F("SET. DO NOT ADD LOCOS TO TRACK"):F("RESET"));
|
||||||
|
}
|
||||||
|
|
||||||
void DCCWaveform::loop() {
|
void DCCWaveform::loop() {
|
||||||
mainTrack.checkPowerOverload();
|
mainTrack.checkPowerOverload();
|
||||||
|
@ -49,6 +49,7 @@ class DCCWaveform {
|
|||||||
public:
|
public:
|
||||||
DCCWaveform( byte preambleBits, bool isMain);
|
DCCWaveform( byte preambleBits, bool isMain);
|
||||||
static void begin(MotorDriver * mainDriver, MotorDriver * progDriver, byte timerNumber);
|
static void begin(MotorDriver * mainDriver, MotorDriver * progDriver, byte timerNumber);
|
||||||
|
static void setDiagnosticSlowWave(bool slow);
|
||||||
static void loop();
|
static void loop();
|
||||||
static DCCWaveform mainTrack;
|
static DCCWaveform mainTrack;
|
||||||
static DCCWaveform progTrack;
|
static DCCWaveform progTrack;
|
||||||
|
Loading…
Reference in New Issue
Block a user