mirror of
https://github.com/DCC-EX/CommandStation-EX.git
synced 2024-12-24 21:21:24 +01:00
send milliAmps and meter setup for new JMRI Meter function (#113)
* send milliAmps and meter setup for new JMRI Meter function
This commit is contained in:
parent
0618a0bd72
commit
418d8eb1b2
@ -442,7 +442,10 @@ void DCCEXParser::parse(Print *stream, byte *com, bool blocking)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
case 'c': // READ CURRENT <c>
|
case 'c': // READ CURRENT <c>
|
||||||
StringFormatter::send(stream, F("<a %d>"), DCCWaveform::mainTrack.get1024Current());
|
// <c MeterName val C/V unit min max res>
|
||||||
|
StringFormatter::send(stream, F("<c CurrentMAIN %d C Milli 0 %d 1>"), DCCWaveform::mainTrack.getCurrentmA(), DCCWaveform::mainTrack.getMaxmA());
|
||||||
|
// StringFormatter::send(stream, F("<c CurrentPROG %d C Milli 0 %d 1>"), DCCWaveform::progTrack.getCurrentmA(), DCCWaveform::progTrack.getMaxmA());
|
||||||
|
StringFormatter::send(stream, F("<a %d>"), DCCWaveform::mainTrack.get1024Current()); //'a' message deprecated, remove once JMRI 4.22 is available
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case 'Q': // SENSORS <Q>
|
case 'Q': // SENSORS <Q>
|
||||||
|
@ -58,9 +58,20 @@ class DCCWaveform {
|
|||||||
void checkPowerOverload();
|
void checkPowerOverload();
|
||||||
int getLastCurrent();
|
int getLastCurrent();
|
||||||
inline int get1024Current() {
|
inline int get1024Current() {
|
||||||
if (powerMode == POWERMODE::ON)
|
if (powerMode == POWERMODE::ON)
|
||||||
return (int)(lastCurrent*(long int)1024/motorDriver->getRawCurrentTripValue());
|
return (int)(lastCurrent*(long int)1024/motorDriver->getRawCurrentTripValue());
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
|
inline int getCurrentmA() {
|
||||||
|
if (powerMode == POWERMODE::ON)
|
||||||
|
return motorDriver->raw2mA(lastCurrent);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
inline int getMaxmA() {
|
||||||
|
if (maxmA == 0) { //only calculate this for first request, it doesn't change
|
||||||
|
maxmA = motorDriver->raw2mA(motorDriver->getRawCurrentTripValue());
|
||||||
|
}
|
||||||
|
return maxmA;
|
||||||
}
|
}
|
||||||
void schedulePacket(const byte buffer[], byte byteCount, byte repeats);
|
void schedulePacket(const byte buffer[], byte byteCount, byte repeats);
|
||||||
volatile bool packetPending;
|
volatile bool packetPending;
|
||||||
@ -112,7 +123,7 @@ class DCCWaveform {
|
|||||||
byte pendingLength;
|
byte pendingLength;
|
||||||
byte pendingRepeats;
|
byte pendingRepeats;
|
||||||
int lastCurrent;
|
int lastCurrent;
|
||||||
|
int maxmA;
|
||||||
|
|
||||||
// current sampling
|
// current sampling
|
||||||
POWERMODE powerMode;
|
POWERMODE powerMode;
|
||||||
|
Loading…
Reference in New Issue
Block a user