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

Improved SIGNALs startup and diagnostics

This commit is contained in:
Asbelos 2022-04-29 11:56:17 +01:00
parent ad97592788
commit afd94f0645
2 changed files with 10 additions and 13 deletions

View File

@ -169,14 +169,10 @@ int16_t LookList::find(int16_t value) {
// Second pass startup, define any turnouts or servos, set signals red // Second pass startup, define any turnouts or servos, set signals red
// add sequences onRoutines to the lookups // add sequences onRoutines to the lookups
for (int sigpos=0;;sigpos+=3) { for (int sigpos=0;;sigpos+=4) {
VPIN redpin=GETFLASHW(RMFT2::SignalDefinitions+sigpos); VPIN sigid=GETFLASHW(RMFT2::SignalDefinitions+sigpos);
if (redpin==0) break; // end of signal list if (sigid==0) break; // end of signal list
VPIN amberpin=GETFLASHW(RMFT2::SignalDefinitions+sigpos+1); doSignal(sigid & (~ SERVO_SIGNAL_FLAG) & (~ACTIVE_HIGH_SIGNAL_FLAG), SIGNAL_RED);
VPIN greenpin=GETFLASHW(RMFT2::SignalDefinitions+sigpos+2);
IODevice::write(redpin,true);
if (amberpin) IODevice::write(amberpin,false);
IODevice::write(greenpin,false);
} }
for (progCounter=0;; SKIPOP){ for (progCounter=0;; SKIPOP){
@ -993,7 +989,7 @@ int16_t RMFT2::getSignalSlot(VPIN id) {
} }
} }
/* static */ void RMFT2::doSignal(VPIN id,char rag) { /* static */ void RMFT2::doSignal(VPIN id,char rag) {
//if (diag) DIAG(F(" dosignal %d %x"),id,rag); if (diag) DIAG(F(" doSignal %d %x"),id,rag);
int16_t sigslot=getSignalSlot(id); int16_t sigslot=getSignalSlot(id);
if (sigslot<0) return; if (sigslot<0) return;
@ -1006,12 +1002,13 @@ int16_t RMFT2::getSignalSlot(VPIN id) {
VPIN redpin=GETFLASHW(RMFT2::SignalDefinitions+sigpos+1); VPIN redpin=GETFLASHW(RMFT2::SignalDefinitions+sigpos+1);
VPIN amberpin=GETFLASHW(RMFT2::SignalDefinitions+sigpos+2); VPIN amberpin=GETFLASHW(RMFT2::SignalDefinitions+sigpos+2);
VPIN greenpin=GETFLASHW(RMFT2::SignalDefinitions+sigpos+3); VPIN greenpin=GETFLASHW(RMFT2::SignalDefinitions+sigpos+3);
//if (diag) DIAG(F("signal %d %d %d"),redpin,amberpin,greenpin); if (diag) DIAG(F("signal %d %d %d %d"),sigid,redpin,amberpin,greenpin);
if (sigid & SERVO_SIGNAL_FLAG) { if (sigid & SERVO_SIGNAL_FLAG) {
// A servo signal, the pin numbers are actually servo positions // A servo signal, the pin numbers are actually servo positions
// Note, setting a signal to a zero position has no effect. // Note, setting a signal to a zero position has no effect.
int16_t servopos= rag==SIGNAL_RED? redpin: (rag==SIGNAL_GREEN? greenpin : amberpin); int16_t servopos= rag==SIGNAL_RED? redpin: (rag==SIGNAL_GREEN? greenpin : amberpin);
if (diag) DIAG(F("sigA %d %d"),id,servopos);
if (servopos!=0) IODevice::writeAnalogue(id,servopos,PCA9685::Bounce); if (servopos!=0) IODevice::writeAnalogue(id,servopos,PCA9685::Bounce);
return; return;
} }

View File

@ -139,11 +139,11 @@ void PCA9685::_write(VPIN vpin, int value) {
// 4 (Bounce) Servo 'bounces' at extremes. // 4 (Bounce) Servo 'bounces' at extremes.
// //
void PCA9685::_writeAnalogue(VPIN vpin, int value, uint8_t profile, uint16_t duration) { void PCA9685::_writeAnalogue(VPIN vpin, int value, uint8_t profile, uint16_t duration) {
if (_deviceState == DEVSTATE_FAILED) return;
#ifdef DIAG_IO #ifdef DIAG_IO
DIAG(F("PCA9685 WriteAnalogue Vpin:%d Value:%d Profile:%d Duration:%d"), DIAG(F("PCA9685 WriteAnalogue Vpin:%d Value:%d Profile:%d Duration:%d %S"),
vpin, value, profile, duration); vpin, value, profile, duration, _deviceState == DEVSTATE_FAILED?F("DEVSTATE_FAILED"):F(""));
#endif #endif
if (_deviceState == DEVSTATE_FAILED) return;
int pin = vpin - _firstVpin; int pin = vpin - _firstVpin;
if (value > 4095) value = 4095; if (value > 4095) value = 4095;
else if (value < 0) value = 0; else if (value < 0) value = 0;