1
0
mirror of https://github.com/DCC-EX/CommandStation-EX.git synced 2024-11-22 23:56:13 +01:00
This commit is contained in:
Matthew Byng-Maddick 2024-10-10 19:58:42 +01:00 committed by GitHub
commit e114e8bbc0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 58 additions and 34 deletions

View File

@ -1074,37 +1074,41 @@ int16_t RMFT2::getSignalSlot(int16_t id) {
return; return;
} }
if (sigtype== DCC_SIGNAL_FLAG) { if (sigtype== DCC_SIGNAL_FLAG) {
// redpin,amberpin are the DCC addr,subaddr // redpin,amberpin are the DCC addr,subaddr
DCC::setAccessory(redpin,amberpin, rag!=SIGNAL_RED); DCC::setAccessory(redpin,amberpin, rag!=SIGNAL_RED);
return; return;
} }
// LED or similar 3 pin signal, (all pins zero would be a virtual signal) // we duck out early for a virtual signal
// If amberpin is zero, synthesise amber from red+green if (!(redpin | amberpin | greenpin)) return;
const byte SIMAMBER=0x00;
if (rag==SIGNAL_AMBER && (amberpin==0)) rag=SIMAMBER; // special case this func only // at this point we have some kind of LED signal, so we're going to do everything by manipulation of the aspect map
int16_t aspect_map = (sigid & SIGNAL_USE_ALT_MAP_FLAG) ? SIGNAL_ALT_ASPECT : SIGNAL_MAIN_ASPECT;
// Manage invert (HIGH on) pins
bool aHigh=sigid & ACTIVE_HIGH_SIGNAL_FLAG; // in the case of red and green available and amber not, synthesise SIGNAL_AMBER from red
// and green aspects, leaving the other bits of the aspect untouched
// set the three pins if (redpin && greenpin && !amberpin)
if (redpin) { aspect_map = (aspect_map & 0707) | ((aspect_map & 0700) >> 3) | ((aspect_map & 07) << 3);
bool redval=(rag==SIGNAL_RED || rag==SIMAMBER);
if (!aHigh) redval=!redval; // invert the aspect map if HIGH is "off"
IODevice::write(redpin,redval); if (sigid & ACTIVE_HIGH_SIGNAL_FLAG)
} aspect_map = 0777 - (aspect_map & 0777)
if (amberpin) {
bool amberval=(rag==SIGNAL_AMBER); int8_t pin_map = 0;
if (!aHigh) amberval=!amberval;
IODevice::write(amberpin,amberval); switch (rag) {
} case SIGNAL_RED:
if (greenpin) { pin_map = (aspect_map & 0700) >> 6; break;
bool greenval=(rag==SIGNAL_GREEN || rag==SIMAMBER); case SIGNAL_AMBER:
if (!aHigh) greenval=!greenval; pin_map = (aspect_map & 070) >> 3; break;
IODevice::write(greenpin,greenval); case SIGNAL_GREEN:
pin_map = aspect_map & 07; break;
} }
if (redpin) IODevice::write(redpin, !!(pin_map & 04));
if (amberpin) IODevice::write(amberpin, !!(pin_map & 02));
if (greenpin) IODevice::write(greenpin, !!(pin_map & 01));
} }
/* static */ bool RMFT2::isSignal(int16_t id,char rag) { /* static */ bool RMFT2::isSignal(int16_t id,char rag) {

View File

@ -130,6 +130,7 @@ class LookList {
static void activateEvent(int16_t addr, bool active); static void activateEvent(int16_t addr, bool active);
static void changeEvent(int16_t id, bool change); static void changeEvent(int16_t id, bool change);
static void clockEvent(int16_t clocktime, bool change); static void clockEvent(int16_t clocktime, bool change);
static const int16_t SIGNAL_USE_ALT_MAP_FLAG=0x8000;
static const int16_t SERVO_SIGNAL_FLAG=0x4000; static const int16_t SERVO_SIGNAL_FLAG=0x4000;
static const int16_t ACTIVE_HIGH_SIGNAL_FLAG=0x2000; static const int16_t ACTIVE_HIGH_SIGNAL_FLAG=0x2000;
static const int16_t DCC_SIGNAL_FLAG=0x1000; static const int16_t DCC_SIGNAL_FLAG=0x1000;

View File

@ -130,17 +130,19 @@
#undef SERVO_SIGNAL #undef SERVO_SIGNAL
#undef SET #undef SET
#undef SET_TRACK #undef SET_TRACK
#undef SETLOCO #undef SETLOCO
#undef SIGNAL #undef SIGNAL
#undef SIGNALH #undef SIGNALH
#undef SPEED #undef SIGNALA
#undef START #undef SIGNALAH
#undef STOP #undef SPEED
#undef THROW #undef START
#undef TURNOUT #undef STOP
#undef THROW
#undef TURNOUT
#undef TURNOUTL #undef TURNOUTL
#undef UNJOIN #undef UNJOIN
#undef UNLATCH #undef UNLATCH
#undef VIRTUAL_SIGNAL #undef VIRTUAL_SIGNAL
#undef VIRTUAL_TURNOUT #undef VIRTUAL_TURNOUT
#undef WAITFOR #undef WAITFOR

View File

@ -234,6 +234,11 @@ const FSH * RMFT2::getRosterFunctions(int16_t id) {
#define SIGNAL(redpin,amberpin,greenpin) redpin,redpin,amberpin,greenpin, #define SIGNAL(redpin,amberpin,greenpin) redpin,redpin,amberpin,greenpin,
#undef SIGNALH #undef SIGNALH
#define SIGNALH(redpin,amberpin,greenpin) redpin | RMFT2::ACTIVE_HIGH_SIGNAL_FLAG,redpin,amberpin,greenpin, #define SIGNALH(redpin,amberpin,greenpin) redpin | RMFT2::ACTIVE_HIGH_SIGNAL_FLAG,redpin,amberpin,greenpin,
#undef SIGNALA
#define SIGNALA(redpin,amberpin,greenpin) redpin | RMFT2::SIGNAL_USE_ALT_MAP_FLAG,redpin,amberpin,greenpin,
#undef SIGNALAH
#define SIGNALAH(redpin,amberpin,greenpin) redpin | RMFT2::ACTIVE_HIGH_SIGNAL_FLAG | RMFT2::SIGNAL_USE_ALT_MAP_FLAG, \
redpin,amberpin,greenpin,
#undef SERVO_SIGNAL #undef SERVO_SIGNAL
#define SERVO_SIGNAL(vpin,redval,amberval,greenval) vpin | RMFT2::SERVO_SIGNAL_FLAG,redval,amberval,greenval, #define SERVO_SIGNAL(vpin,redval,amberval,greenval) vpin | RMFT2::SERVO_SIGNAL_FLAG,redval,amberval,greenval,
#undef DCC_SIGNAL #undef DCC_SIGNAL

View File

@ -261,7 +261,7 @@ The configuration file for DCC-EX Command Station
// 2. The app will be bigger that 1.2MB, so the default partition scheme will not // 2. The app will be bigger that 1.2MB, so the default partition scheme will not
// work any more. You need to choose a partition scheme with 2MB (or bigger). // work any more. You need to choose a partition scheme with 2MB (or bigger).
// For example "NO OTA (2MB APP, 2MB SPIFFS)" in the Arduino IDE. // For example "NO OTA (2MB APP, 2MB SPIFFS)" in the Arduino IDE.
// 3. There is no securuity (PIN) implemented. Everyone in radio range can pair // 3. There is no security (PIN) implemented. Everyone in radio range can pair
// with your CS. // with your CS.
// //
//#define SERIAL_BT_COMMANDS //#define SERIAL_BT_COMMANDS
@ -278,3 +278,15 @@ The configuration file for DCC-EX Command Station
//#define SABERTOOTH 1 //#define SABERTOOTH 1
///////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////
// don't change this, this defines the main aspect as RED -> red pin, AMBER -> amber
// pin, and GREEN -> green pin
// these are octal int16_t types defining aspect and pin map:
// -----------N/A----------- ---RED--- --AMBER-- --GREEN--
// r a g r a g r a g
// | f | e | d | c | b | a | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
//
#define SIGNAL_MAIN_ASPECT 0421
// this defines an alternate aspect (eg. here, the Deutsche Bahn RED -> red pin,
// AMBER -> amber pin and green pin, GREEN -> green pin)
// These can be selected with the SIGNALA and SIGNALAH automations in myAutomation.h
#define SIGNAL_ALT_ASPECT 0431