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:
commit
bcd1335b08
17
EXRAIL2.cpp
17
EXRAIL2.cpp
@ -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){
|
||||||
@ -1005,7 +1001,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;
|
||||||
|
|
||||||
@ -1018,12 +1014,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;
|
||||||
}
|
}
|
||||||
|
@ -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;
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
// Automatic ALIAS(name)
|
// Automatic ALIAS(name)
|
||||||
// Command Parser now accepts Underscore in Alias Names
|
// Command Parser now accepts Underscore in Alias Names
|
||||||
// 4.0.2 EXRAIL additions:
|
// 4.0.2 EXRAIL additions:
|
||||||
|
// ACK defaults set to 50mA LIMIT, 2000uS MIN, 20000uS MAX
|
||||||
// myFilter automatic detection (no need to call setFilter)
|
// myFilter automatic detection (no need to call setFilter)
|
||||||
// FIX negative route ids in WIthrottle problem.
|
// FIX negative route ids in WIthrottle problem.
|
||||||
// IFRED(signal_id), IFAMBER(signal_id), IFGREEN(signal_id)
|
// IFRED(signal_id), IFAMBER(signal_id), IFGREEN(signal_id)
|
||||||
|
Loading…
Reference in New Issue
Block a user