From 53769205e404f18d84d2cf69dad4f866a66ff18c Mon Sep 17 00:00:00 2001 From: Asbelos Date: Thu, 2 Jul 2020 19:13:08 +0100 Subject: [PATCH] OOps current detect wrong --- DCCWaveform.cpp | 8 ++++---- Hardware.cpp | 2 +- Hardware.h | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/DCCWaveform.cpp b/DCCWaveform.cpp index 50aba8d..bdeacc4 100644 --- a/DCCWaveform.cpp +++ b/DCCWaveform.cpp @@ -3,8 +3,8 @@ #include "DCCWaveform.h" #include "DIAG.h" -DCCWaveform DCCWaveform::mainTrack(PREAMBLE_BITS_MAIN, true, MAIN_MAX_MILLIAMPS* MAIN_SENSE_FACTOR); -DCCWaveform DCCWaveform::progTrack(PREAMBLE_BITS_PROG, false, 250 * PROG_SENSE_FACTOR); +DCCWaveform DCCWaveform::mainTrack(PREAMBLE_BITS_MAIN, true, (int)(MAIN_MAX_MILLIAMPS / MAIN_SENSE_FACTOR)); +DCCWaveform DCCWaveform::progTrack(PREAMBLE_BITS_PROG, false, (int)(PROG_MAX_MILLIAMPS / PROG_SENSE_FACTOR)); const int ACK_MIN_PULSE_RAW=65 / PROG_SENSE_FACTOR; @@ -94,8 +94,8 @@ void DCCWaveform::checkPowerOverload() { if (lastCurrent <= rawCurrentTripValue) sampleDelay = POWER_SAMPLE_ON_WAIT; else { setPowerMode(POWERMODE::OVERLOAD); - int mA=Hardware::getCurrentMilliamps(isMainTrack,lastCurrent); - int maxmA=Hardware::getCurrentMilliamps(isMainTrack,rawCurrentTripValue); + unsigned int mA=Hardware::getCurrentMilliamps(isMainTrack,lastCurrent); + unsigned int maxmA=Hardware::getCurrentMilliamps(isMainTrack,rawCurrentTripValue); DIAG(F("\n*** %S TRACK POWER OVERLOAD current=%d max=%d ***\n"), isMainTrack ? F("MAIN") : F("PROG"), mA, maxmA); sampleDelay = POWER_SAMPLE_OVERLOAD_WAIT; } diff --git a/Hardware.cpp b/Hardware.cpp index f631846..532240e 100644 --- a/Hardware.cpp +++ b/Hardware.cpp @@ -47,7 +47,7 @@ int Hardware::getCurrentRaw(bool isMainTrack) { } -int Hardware::getCurrentMilliamps(bool isMainTrack, int raw) { +unsigned int Hardware::getCurrentMilliamps(bool isMainTrack, int raw) { return (int)(raw * (isMainTrack ? MAIN_SENSE_FACTOR : PROG_SENSE_FACTOR)); } diff --git a/Hardware.h b/Hardware.h index dfb4845..9f8bd0e 100644 --- a/Hardware.h +++ b/Hardware.h @@ -6,7 +6,7 @@ class Hardware { static void init(); static void setPower(bool isMainTrack, bool on); static void setSignal(bool isMainTrack, bool high); - static int getCurrentMilliamps(bool isMainTrack, int rawValue); + static unsigned int getCurrentMilliamps(bool isMainTrack, int rawValue); static int getCurrentRaw(bool isMainTrack); static void setBrake(bool isMainTrack, bool on); static void setCallback(int duration, void (*isr)());