1
0
mirror of https://github.com/DCC-EX/CommandStation-EX.git synced 2024-12-23 21:01:25 +01:00

eliminate resetsCounterP/setResetCounterPointer and replace with isProgTrack/makeProgTrack method

This commit is contained in:
Harald Barth 2022-08-02 15:36:51 +02:00
parent 6b2cd226e2
commit 863f2f4a85
4 changed files with 15 additions and 13 deletions

View File

@ -76,7 +76,6 @@ void DCCACK::Setup(int cv, byte byteValueOrBitnum, ackOp const program[], ACK_C
callback(-2); // our prog track cant measure current callback(-2); // our prog track cant measure current
return; return;
} }
progDriver->setResetCounterPointer(&(DCCWaveform::progTrack.sentResetsSincePacket));
ackManagerRejoin=TrackManager::isJoined(); ackManagerRejoin=TrackManager::isJoined();
if (ackManagerRejoin ) { if (ackManagerRejoin ) {

View File

@ -23,6 +23,7 @@
*/ */
#include <Arduino.h> #include <Arduino.h>
#include "MotorDriver.h" #include "MotorDriver.h"
#include "DCCWaveform.h"
#include "DCCTimer.h" #include "DCCTimer.h"
#include "DIAG.h" #include "DIAG.h"
@ -122,8 +123,8 @@ void MotorDriver::setPower(POWERMODE mode) {
bool on=mode==POWERMODE::ON; bool on=mode==POWERMODE::ON;
if (on) { if (on) {
IODevice::write(powerPin,HIGH); IODevice::write(powerPin,HIGH);
if (resetsCounterP != NULL) if (isProgTrack)
*resetsCounterP = 0; DCCWaveform::progTrack.clearResets();
} }
else IODevice::write(powerPin,LOW); else IODevice::write(powerPin,LOW);
powerMode=mode; powerMode=mode;

View File

@ -136,12 +136,12 @@ class MotorDriver {
inline byte getFaultPin() { inline byte getFaultPin() {
return faultPin; return faultPin;
} }
inline void setResetCounterPointer(volatile byte *bp) { // load resetPacketCounter pointer inline void makeProgTrack(bool on) { // let this output know it's a prog track.
resetsCounterP = bp; isProgTrack = on;
} }
void checkPowerOverload(bool useProgLimit, byte trackno); void checkPowerOverload(bool useProgLimit, byte trackno);
private: private:
volatile byte *resetsCounterP = NULL; // points to the resetPacketCounter if this is a prog track bool isProgTrack = false; // tells us 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);

View File

@ -140,14 +140,16 @@ bool TrackManager::setTrackMode(byte trackToSet, TRACK_MODE mode, int16_t dcAddr
} }
if (mode==TRACK_MODE_PROG) { if (mode==TRACK_MODE_PROG) {
// only allow 1 track to be prog // only allow 1 track to be prog
FOR_EACH_TRACK(t) FOR_EACH_TRACK(t)
if (trackMode[t]==TRACK_MODE_PROG && t != trackToSet) { if (trackMode[t]==TRACK_MODE_PROG && t != trackToSet) {
track[t]->setPower(POWERMODE::OFF); track[t]->setPower(POWERMODE::OFF);
trackMode[t]=TRACK_MODE_OFF; trackMode[t]=TRACK_MODE_OFF;
} track[t]->makeProgTrack(false); // revoke prog track special handling
}
track[trackToSet]->makeProgTrack(true); // set for prog track special handling
} else { } else {
track[trackToSet]->setResetCounterPointer(NULL); // only the prog track has this pointer set track[trackToSet]->makeProgTrack(false); // only the prog track knows it's type
} }
trackMode[trackToSet]=mode; trackMode[trackToSet]=mode;
trackDCAddr[trackToSet]=dcAddr; trackDCAddr[trackToSet]=dcAddr;