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

TackManager: Make OFF=zero and when DCC then HA must be off

This commit is contained in:
Harald Barth 2022-05-12 20:56:23 +02:00
parent 4a56998553
commit 6d382fa0f4
2 changed files with 13 additions and 4 deletions

View File

@ -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)
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();

View File

@ -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.