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

Merge branch 'ServoSignal' into TrackManager

This commit is contained in:
Asbelos 2022-04-29 13:58:26 +01:00
commit bcd1335b08
3 changed files with 11 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
// add sequences onRoutines to the lookups
for (int sigpos=0;;sigpos+=3) {
VPIN redpin=GETFLASHW(RMFT2::SignalDefinitions+sigpos);
if (redpin==0) break; // end of signal list
VPIN amberpin=GETFLASHW(RMFT2::SignalDefinitions+sigpos+1);
VPIN greenpin=GETFLASHW(RMFT2::SignalDefinitions+sigpos+2);
IODevice::write(redpin,true);
if (amberpin) IODevice::write(amberpin,false);
IODevice::write(greenpin,false);
for (int sigpos=0;;sigpos+=4) {
VPIN sigid=GETFLASHW(RMFT2::SignalDefinitions+sigpos);
if (sigid==0) break; // end of signal list
doSignal(sigid & (~ SERVO_SIGNAL_FLAG) & (~ACTIVE_HIGH_SIGNAL_FLAG), SIGNAL_RED);
}
for (progCounter=0;; SKIPOP){
@ -1005,7 +1001,7 @@ int16_t RMFT2::getSignalSlot(VPIN id) {
}
}
/* 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);
if (sigslot<0) return;
@ -1018,12 +1014,13 @@ int16_t RMFT2::getSignalSlot(VPIN id) {
VPIN redpin=GETFLASHW(RMFT2::SignalDefinitions+sigpos+1);
VPIN amberpin=GETFLASHW(RMFT2::SignalDefinitions+sigpos+2);
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) {
// A servo signal, the pin numbers are actually servo positions
// Note, setting a signal to a zero position has no effect.
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);
return;
}

View File

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

View File

@ -12,6 +12,7 @@
// Automatic ALIAS(name)
// Command Parser now accepts Underscore in Alias Names
// 4.0.2 EXRAIL additions:
// ACK defaults set to 50mA LIMIT, 2000uS MIN, 20000uS MAX
// myFilter automatic detection (no need to call setFilter)
// FIX negative route ids in WIthrottle problem.
// IFRED(signal_id), IFAMBER(signal_id), IFGREEN(signal_id)