1
0
mirror of https://github.com/DCC-EX/CommandStation-EX.git synced 2025-07-28 09:53:45 +02:00

Added code for FastClock

Added code for both I2C fastclock and serial clocks
This commit is contained in:
Colin Murdoch
2023-01-11 17:36:11 +00:00
parent de4954ca3e
commit ff7260b9bc
8 changed files with 209 additions and 3 deletions

View File

@@ -97,6 +97,8 @@ Print *DCCEXParser::stashStream = NULL;
RingStream *DCCEXParser::stashRingStream = NULL;
byte DCCEXParser::stashTarget=0;
int16_t lastclocktime = 0;
// This is a JMRI command parser.
// It doesnt know how the string got here, nor how it gets back.
// It knows nothing about hardware or tracks... it just parses strings and
@@ -570,9 +572,27 @@ void DCCEXParser::parseOne(Print *stream, byte *com, RingStream * ringStream)
case 'J' : // throttle info access
{
if ((params<1) | (params>2)) break; // <J>
if ((params<1) | (params>3)) break; // <J>
int16_t id=(params==2)?p[1]:0;
switch(p[0]) {
case HASH_KEYWORD_C: // <JC mmmm nn> sets time and speed
if (params==1) { // <JC> returns latest time
StringFormatter::send(stream, F("<jC %d>\n"), lastclocktime);
return;
}
if (p[1] != lastclocktime){
if (Diag::CMD) {
DIAG(F("Clock Command Received"));
DIAG(F("Received Clock Time is: %d at rate: %d"), p[1], p[2]);
}
LCD(6,F("Clk Time:%d Sp %d"), p[1], p[2]);
//LCD(7,F("Clock Speed: %d"), p[2]);
RMFT2::clockEvent(p[1],1);
// Now tell everyone else what the time is.
CommandDistributor::broadcastClockTime(p[1], p[2]);
lastclocktime = p[1];
}
return;
case HASH_KEYWORD_A: // <JA> returns automations/routes
StringFormatter::send(stream, F("<jA"));
if (params==1) {// <JA>