From a1f7d06508bbc1337356e6c79314dbd2650bb618 Mon Sep 17 00:00:00 2001 From: Harald Barth Date: Sun, 6 Dec 2020 21:43:37 +0100 Subject: [PATCH] Report current as 1/1024 as expected by JMRI --- DCCEXParser.cpp | 2 +- DCCWaveform.h | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/DCCEXParser.cpp b/DCCEXParser.cpp index 3d3bed6..f073f70 100644 --- a/DCCEXParser.cpp +++ b/DCCEXParser.cpp @@ -434,7 +434,7 @@ void DCCEXParser::parse(Print *stream, byte *com, bool blocking) return; case 'c': // READ CURRENT - StringFormatter::send(stream, F(""), DCCWaveform::mainTrack.getLastCurrent()); + StringFormatter::send(stream, F(""), DCCWaveform::mainTrack.get1024Current()); return; case 'Q': // SENSORS diff --git a/DCCWaveform.h b/DCCWaveform.h index c658577..b51e79f 100644 --- a/DCCWaveform.h +++ b/DCCWaveform.h @@ -57,6 +57,11 @@ class DCCWaveform { POWERMODE getPowerMode(); void checkPowerOverload(); int getLastCurrent(); + inline int get1024Current() { + if (powerMode == POWERMODE::ON) + return (int)(lastCurrent*(long int)1024/motorDriver->getRawCurrentTripValue()); + return 0; + } void schedulePacket(const byte buffer[], byte byteCount, byte repeats); volatile bool packetPending; volatile byte sentResetsSincePacket;