mirror of
https://github.com/DCC-EX/CommandStation-EX.git
synced 2024-12-23 12:51:24 +01:00
TackManager: Make OFF=zero and when DCC then HA must be off
This commit is contained in:
parent
4a56998553
commit
6d382fa0f4
@ -149,9 +149,18 @@ bool TrackManager::setTrackMode(byte trackToSet, TRACK_MODE mode, int16_t dcAddr
|
||||
// re-evaluate HighAccuracy mode
|
||||
// We can only do this is all main and prog tracks agree
|
||||
bool canDo=true;
|
||||
FOR_EACH_TRACK(t)
|
||||
if (trackMode[t]==TRACK_MODE_MAIN ||trackMode[t]==TRACK_MODE_PROG)
|
||||
canDo &= track[t]->isPWMCapable();
|
||||
FOR_EACH_TRACK(t) {
|
||||
// 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();
|
||||
}
|
||||
//DIAG(F("HAMode=%d"),canDo);
|
||||
if (!canDo) {
|
||||
DCCTimer::clearPWM();
|
||||
|
@ -23,7 +23,7 @@
|
||||
#include "MotorDriver.h"
|
||||
// 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};
|
||||
|
||||
// These constants help EXRAIL macros say SET_TRACK(2,mode) OR SET_TRACK(C,mode) etc.
|
||||
|
Loading…
Reference in New Issue
Block a user