mirror of
https://github.com/DCC-EX/CommandStation-EX.git
synced 2024-11-22 23:56:13 +01:00
prevent driver pins to be used by sensors or outputs
This commit is contained in:
parent
f8fb08e331
commit
06f8c567bc
|
@ -107,6 +107,9 @@ class DCCWaveform {
|
|||
inline void setMaxAckPulseDuration(unsigned int i) {
|
||||
maxAckPulseDuration = i;
|
||||
}
|
||||
inline bool pinUsed(byte pin) {
|
||||
return motorDriver->pinUsed(pin);
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
|
|
|
@ -84,6 +84,17 @@ bool MotorDriver::isPWMCapable() {
|
|||
return (!dualSignal) && DCCTimer::isPWMPin(signalPin);
|
||||
}
|
||||
|
||||
bool MotorDriver::pinUsed(byte pin) {
|
||||
// order by how likely to hit
|
||||
if (pin == powerPin) return true;
|
||||
if (pin == signalPin) return true;
|
||||
if (pin == currentPin) return true;
|
||||
if (pin == faultPin) return true;
|
||||
if (pin == brakePin) return true;
|
||||
if (pin == signalPin2) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
void MotorDriver::setPower(bool on) {
|
||||
if (on) {
|
||||
|
|
|
@ -53,6 +53,7 @@ class MotorDriver {
|
|||
inline int getRawCurrentTripValue() {
|
||||
return rawCurrentTripValue;
|
||||
}
|
||||
bool pinUsed(byte pin);
|
||||
bool isPWMCapable();
|
||||
bool canMeasureCurrent();
|
||||
static bool usePWM;
|
||||
|
|
|
@ -84,6 +84,7 @@ the state of any outputs being monitored or controlled by a separate interface o
|
|||
#include "Outputs.h"
|
||||
#include "EEStore.h"
|
||||
#include "StringFormatter.h"
|
||||
#include "DCCWaveform.h"
|
||||
|
||||
// print all output states to stream
|
||||
void Output::printAll(Print *stream){
|
||||
|
@ -192,6 +193,11 @@ void Output::store(){
|
|||
Output *Output::create(uint16_t id, uint8_t pin, uint8_t iFlag, uint8_t v){
|
||||
Output *tt;
|
||||
|
||||
if (DCCWaveform::mainTrack.pinUsed(pin) ||
|
||||
DCCWaveform::progTrack.pinUsed(pin)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(firstOutput==NULL){
|
||||
firstOutput=(Output *)calloc(1,sizeof(Output));
|
||||
tt=firstOutput;
|
||||
|
|
|
@ -68,6 +68,7 @@ decide to ignore the <q ID> return and only react to <Q ID> triggers.
|
|||
#include "StringFormatter.h"
|
||||
#include "Sensors.h"
|
||||
#include "EEStore.h"
|
||||
#include "DCCWaveform.h"
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -126,6 +127,11 @@ void Sensor::printAll(Print *stream){
|
|||
Sensor *Sensor::create(int snum, int pin, int pullUp){
|
||||
Sensor *tt;
|
||||
|
||||
if (DCCWaveform::mainTrack.pinUsed(pin) ||
|
||||
DCCWaveform::progTrack.pinUsed(pin)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(firstSensor==NULL){
|
||||
firstSensor=(Sensor *)calloc(1,sizeof(Sensor));
|
||||
tt=firstSensor;
|
||||
|
|
Loading…
Reference in New Issue
Block a user