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

add warn/trip level to meter response

provides support for separate max vs trip levels
This commit is contained in:
SteveT 2021-01-18 09:14:41 -05:00
parent bf97adfe2d
commit de4bf42923
2 changed files with 12 additions and 5 deletions

View File

@ -441,10 +441,10 @@ void DCCEXParser::parse(Print *stream, byte *com, bool blocking)
} }
return; return;
case 'c': // READ CURRENT <c> case 'c': // SEND METER RESPONSES <c>
// <c MeterName val C/V unit min max res> // <c MeterName value C/V unit min max res warn>
StringFormatter::send(stream, F("<c CurrentMAIN %d C Milli 0 %d 1>"), DCCWaveform::mainTrack.getCurrentmA(), DCCWaveform::mainTrack.getMaxmA()); StringFormatter::send(stream, F("<c CurrentMAIN %d C Milli 0 %d 1 %d>"), DCCWaveform::mainTrack.getCurrentmA(),
// StringFormatter::send(stream, F("<c CurrentPROG %d C Milli 0 %d 1>"), DCCWaveform::progTrack.getCurrentmA(), DCCWaveform::progTrack.getMaxmA()); DCCWaveform::mainTrack.getMaxmA(), DCCWaveform::mainTrack.getTripmA());
StringFormatter::send(stream, F("<a %d>"), DCCWaveform::mainTrack.get1024Current()); //'a' message deprecated, remove once JMRI 4.22 is available StringFormatter::send(stream, F("<a %d>"), DCCWaveform::mainTrack.get1024Current()); //'a' message deprecated, remove once JMRI 4.22 is available
return; return;

View File

@ -69,10 +69,16 @@ class DCCWaveform {
} }
inline int getMaxmA() { inline int getMaxmA() {
if (maxmA == 0) { //only calculate this for first request, it doesn't change if (maxmA == 0) { //only calculate this for first request, it doesn't change
maxmA = motorDriver->raw2mA(motorDriver->getRawCurrentTripValue()); maxmA = motorDriver->raw2mA(motorDriver->getRawCurrentTripValue()); //TODO: replace with actual max value or calc
} }
return maxmA; return maxmA;
} }
inline int getTripmA() {
if (tripmA == 0) { //only calculate this for first request, it doesn't change
tripmA = motorDriver->raw2mA(motorDriver->getRawCurrentTripValue());
}
return tripmA;
}
void schedulePacket(const byte buffer[], byte byteCount, byte repeats); void schedulePacket(const byte buffer[], byte byteCount, byte repeats);
volatile bool packetPending; volatile bool packetPending;
volatile byte sentResetsSincePacket; volatile byte sentResetsSincePacket;
@ -124,6 +130,7 @@ class DCCWaveform {
byte pendingRepeats; byte pendingRepeats;
int lastCurrent; int lastCurrent;
int maxmA; int maxmA;
int tripmA;
// current sampling // current sampling
POWERMODE powerMode; POWERMODE powerMode;