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

Better warnings for pin number errors

This commit is contained in:
Harald Barth 2023-05-29 09:48:22 +02:00
parent 82929245ed
commit e81d1cc93a
3 changed files with 11 additions and 13 deletions

View File

@ -1 +1 @@
#define GITHUB_SHA "devel-202305251144Z"
#define GITHUB_SHA "devel-202305290743Z"

View File

@ -35,7 +35,7 @@ volatile portreg_t shadowPORTC;
MotorDriver::MotorDriver(int16_t power_pin, byte signal_pin, byte signal_pin2, int16_t brake_pin,
byte current_pin, float sense_factor, unsigned int trip_milliamps, int16_t fault_pin) {
bool pinWarning = false;
const FSH * warnString = F("** WARNING **");
invertPower=power_pin < 0;
if (invertPower) {
@ -97,7 +97,7 @@ MotorDriver::MotorDriver(int16_t power_pin, byte signal_pin, byte signal_pin2, i
if (invertBrake)
brake_pin = 0-brake_pin;
if (brake_pin > MAX_PIN)
pinWarning = true;
DIAG(F("%S Brake pin %d > %d"), warnString, brake_pin, MAX_PIN);
brakePin=(byte)brake_pin;
getFastPin(F("BRAKE"),brakePin,fastBrakePin);
// if brake is used for railcom cutout we need to do PORTX register trick here as well
@ -112,12 +112,12 @@ MotorDriver::MotorDriver(int16_t power_pin, byte signal_pin, byte signal_pin2, i
ADCee::init(currentPin);
senseOffset=0; // value can not be obtained until waveform is activated
if (faultPin != UNUSED_PIN) {
if (fault_pin != UNUSED_PIN) {
invertFault=fault_pin < 0;
if (invertFault)
fault_pin = 0-fault_pin;
if (fault_pin > MAX_PIN)
pinWarning = true;
DIAG(F("%S Fault pin %d > %d"), warnString, fault_pin, MAX_PIN);
faultPin=(byte)fault_pin;
DIAG(F("Fault pin = %d invert %d"), faultPin, invertFault);
getFastPin(F("FAULT"),faultPin, 1 /*input*/, fastFaultPin);
@ -145,19 +145,15 @@ MotorDriver::MotorDriver(int16_t power_pin, byte signal_pin, byte signal_pin2, i
}
if (currentPin==UNUSED_PIN)
DIAG(F("** WARNING ** No current or short detection"));
DIAG(F("%S No current or short detection"), warnString);
else {
DIAG(F("Track %c, TripValue=%d"), trackLetter, rawCurrentTripValue);
DIAG(F("Pin %d Max %dmA (%d)"), currentPin, raw2mA(rawCurrentTripValue), rawCurrentTripValue);
// self testing diagnostic for the non-float converters... may be removed when happy
// DIAG(F("senseFactorInternal=%d raw2mA(1000)=%d mA2Raw(1000)=%d"),
// senseFactorInternal, raw2mA(1000),mA2raw(1000));
}
// give general warning if pin values out of range were encountered
if (pinWarning)
DIAG(F("** WARNING ** Pin values > 255"));
// prepare values for current detection
sampleDelay = 0;
lastSampleTaken = millis();

View File

@ -4,8 +4,10 @@
#include "StringFormatter.h"
#define VERSION "4.2.54pre4"
// 4.2.54 - Fix: Pin handling supports pins up to 254
#define VERSION "4.2.54pre5"
// 4.2.54 - Fix: Better warnings for pin number errors
// - Fix: Default roster list possible in Withrottle and <jR>
// - Fix: Pin handling supports pins up to 254
// 4.2.53 - Fix: Fault pin handling made more straight forward
// 4.2.52 - Experimental support for sabertooth motor controller on ESP32
// 4.2.51 - Add DISABLE_PROG to disable programming to save RAM/Flash