1
0
mirror of https://github.com/DCC-EX/CommandStation-EX.git synced 2024-12-23 12:51:24 +01:00

<D DCC SLOW>

This commit is contained in:
Asbelos 2020-09-10 17:11:50 +01:00
parent 39d9defec6
commit 5239164200
3 changed files with 15 additions and 3 deletions

View File

@ -43,7 +43,8 @@ const int HASH_KEYWORD_WIT=31594;
const int HASH_KEYWORD_WIFI=-5583;
const int HASH_KEYWORD_ACK=3113;
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];
@ -455,7 +456,7 @@ bool DCCEXParser::parseS( Print * stream,int params, int p[]) {
bool DCCEXParser::parseD( Print * stream,int params, int p[]) {
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]){
case HASH_KEYWORD_CABS: // <D CABS>
DCC::displayCabList(stream);
@ -481,6 +482,9 @@ bool DCCEXParser::parseD( Print * stream,int params, int p[]) {
Diag::WITHROTTLE=onOff;
return true;
case HASH_KEYWORD_DCC:
DCCWaveform::setDiagnosticSlowWave(params>=1 && p[1]==HASH_KEYWORD_SLOW);
return true;
default: // invalid/unknown
break;
}

View File

@ -22,6 +22,8 @@
#include "DCCWaveform.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::progTrack(PREAMBLE_BITS_PROG, false);
@ -47,10 +49,15 @@ void DCCWaveform::begin(MotorDriver * mainDriver, MotorDriver * progDriver, byte
return;
}
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->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() {
mainTrack.checkPowerOverload();

View File

@ -49,6 +49,7 @@ class DCCWaveform {
public:
DCCWaveform( byte preambleBits, bool isMain);
static void begin(MotorDriver * mainDriver, MotorDriver * progDriver, byte timerNumber);
static void setDiagnosticSlowWave(bool slow);
static void loop();
static DCCWaveform mainTrack;
static DCCWaveform progTrack;