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

G and I commands

This commit is contained in:
Asbelos 2023-02-25 17:38:39 +00:00
parent 95b640686a
commit c72bf51959
3 changed files with 31 additions and 2 deletions

View File

@ -501,8 +501,16 @@ void DCCEXParser::parseOne(Print *stream, byte *com, RingStream * ringStream)
return;
case 'c': // SEND METER RESPONSES <c>
// No longer supported because of multiple tracks <c MeterName value C/V unit min max res warn>
// No longer supported because of multiple tracks See <G> and <I>
break;
case 'G': // Track current gauge limits
TrackManager::reportGauges(stream); // <g limit...limit>
return;
case 'I': // Track current
TrackManager::reportCurrent(stream); // <i mA...mA>
return;
case 'Q': // SENSORS <Q>
Sensor::printAll(stream);

View File

@ -423,7 +423,26 @@ POWERMODE TrackManager::getProgPower() {
return track[t]->getPower();
return POWERMODE::OFF;
}
void TrackManager::reportCurrent(Print* stream) {
StringFormatter::send(stream,F("<i"));
FOR_EACH_TRACK(t) {
StringFormatter::send(stream, F(" %d"),
(track[t]->getPower()==POWERMODE::OVERLOAD) ? -1 :
track[t]->raw2mA(track[t]->getCurrentRaw(false)));
}
StringFormatter::send(stream,F(">\n"));
}
void TrackManager::reportGauges(Print* stream) {
StringFormatter::send(stream,F("<g"));
FOR_EACH_TRACK(t) {
StringFormatter::send(stream, F(" %d"),
track[t]->raw2mA(track[t]->getRawCurrentTripValue()));
}
StringFormatter::send(stream,F(">\n"));
}
void TrackManager::setJoinRelayPin(byte joinRelayPin) {
joinRelay=joinRelayPin;
if (joinRelay!=UNUSED_PIN) {

View File

@ -77,6 +77,8 @@ class TrackManager {
static bool isJoined() { return progTrackSyncMain;}
static void setJoinRelayPin(byte joinRelayPin);
static void sampleCurrent();
static void reportGauges(Print* stream);
static void reportCurrent(Print* stream);
static int16_t joinRelay;
static bool progTrackSyncMain; // true when prog track is a siding switched to main
static bool progTrackBoosted; // true when prog track is not current limited