mirror of
https://github.com/DCC-EX/CommandStation-EX.git
synced 2024-11-23 16:16:13 +01:00
Merge branch 'TrackManager' into TrackManager-PORTX
This commit is contained in:
commit
8f9da49cc8
|
@ -118,12 +118,12 @@ class MotorDriver {
|
||||||
inline byte getFaultPin() {
|
inline byte getFaultPin() {
|
||||||
return faultPin;
|
return faultPin;
|
||||||
}
|
}
|
||||||
inline void setResetCounterPointer(byte *bp) { // load resetPacketCounter pointer
|
inline void setResetCounterPointer(volatile byte *bp) { // load resetPacketCounter pointer
|
||||||
resetsCounterP = bp;
|
resetsCounterP = bp;
|
||||||
}
|
}
|
||||||
void checkPowerOverload(bool useProgLimit, byte trackno);
|
void checkPowerOverload(bool useProgLimit, byte trackno);
|
||||||
private:
|
private:
|
||||||
byte *resetsCounterP = NULL; // points to the resetPacketCounter if this is a prog track
|
volatile byte *resetsCounterP = NULL; // points to the resetPacketCounter if this is a prog track
|
||||||
void getFastPin(const FSH* type,int pin, bool input, FASTPIN & result);
|
void getFastPin(const FSH* type,int pin, bool input, FASTPIN & result);
|
||||||
void getFastPin(const FSH* type,int pin, FASTPIN & result) {
|
void getFastPin(const FSH* type,int pin, FASTPIN & result) {
|
||||||
getFastPin(type, pin, 0, result);
|
getFastPin(type, pin, 0, result);
|
||||||
|
|
|
@ -78,11 +78,11 @@ void TrackManager::Setup(const FSH * shieldname,
|
||||||
}
|
}
|
||||||
|
|
||||||
void TrackManager::addTrack(byte t, MotorDriver* driver) {
|
void TrackManager::addTrack(byte t, MotorDriver* driver) {
|
||||||
track[t]=driver;
|
|
||||||
trackMode[t]=TRACK_MODE_OFF;
|
trackMode[t]=TRACK_MODE_OFF;
|
||||||
|
track[t]=driver;
|
||||||
if (driver) {
|
if (driver) {
|
||||||
lastTrack=t;
|
|
||||||
track[t]->setPower(POWERMODE::OFF);
|
track[t]->setPower(POWERMODE::OFF);
|
||||||
|
lastTrack=t;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -167,9 +167,18 @@ bool TrackManager::setTrackMode(byte trackToSet, TRACK_MODE mode, int16_t dcAddr
|
||||||
// re-evaluate HighAccuracy mode
|
// re-evaluate HighAccuracy mode
|
||||||
// We can only do this is all main and prog tracks agree
|
// We can only do this is all main and prog tracks agree
|
||||||
bool canDo=true;
|
bool canDo=true;
|
||||||
FOR_EACH_TRACK(t)
|
FOR_EACH_TRACK(t) {
|
||||||
if (trackMode[t]==TRACK_MODE_MAIN ||trackMode[t]==TRACK_MODE_PROG)
|
// DC tracks must not have the DCC PWM switched on
|
||||||
|
// so we globally turn it off if one of the PWM
|
||||||
|
// capable tracks is now DC or DCX.
|
||||||
|
if (trackMode[t]==TRACK_MODE_DC || trackMode[t]==TRACK_MODE_DCX) {
|
||||||
|
if (track[t]->isPWMCapable()) {
|
||||||
|
canDo=false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} else if (trackMode[t]==TRACK_MODE_MAIN || trackMode[t]==TRACK_MODE_PROG)
|
||||||
canDo &= track[t]->isPWMCapable();
|
canDo &= track[t]->isPWMCapable();
|
||||||
|
}
|
||||||
//DIAG(F("HAMode=%d"),canDo);
|
//DIAG(F("HAMode=%d"),canDo);
|
||||||
if (!canDo) {
|
if (!canDo) {
|
||||||
DCCTimer::clearPWM();
|
DCCTimer::clearPWM();
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
#include "MotorDriver.h"
|
#include "MotorDriver.h"
|
||||||
// Virtualised Motor shield multi-track hardware Interface
|
// Virtualised Motor shield multi-track hardware Interface
|
||||||
|
|
||||||
enum TRACK_MODE : byte {TRACK_MODE_MAIN, TRACK_MODE_PROG, TRACK_MODE_OFF,
|
enum TRACK_MODE : byte {TRACK_MODE_OFF, TRACK_MODE_MAIN, TRACK_MODE_PROG,
|
||||||
TRACK_MODE_DC, TRACK_MODE_DCX};
|
TRACK_MODE_DC, TRACK_MODE_DCX};
|
||||||
|
|
||||||
// These constants help EXRAIL macros say SET_TRACK(2,mode) OR SET_TRACK(C,mode) etc.
|
// These constants help EXRAIL macros say SET_TRACK(2,mode) OR SET_TRACK(C,mode) etc.
|
||||||
|
|
Loading…
Reference in New Issue
Block a user