1
0
mirror of https://github.com/DCC-EX/CommandStation-EX.git synced 2024-11-22 23:56:13 +01:00

SIGNALH, ATGTE, ATLT

UNTESTED
This commit is contained in:
Asbelos 2022-03-18 13:46:07 +00:00
parent f5fb1540f0
commit 367e400d75
4 changed files with 33 additions and 5 deletions

View File

@ -594,6 +594,18 @@ void RMFT2::loop2() {
delayMe(50);
return;
case OPCODE_ATGTE: // wait for analog sensor>= value
timeoutFlag=false;
if (IODevice::readAnalogue(operand) >= (int)(GET_OPERAND(1))) break;
delayMe(50);
return;
case OPCODE_ATLT: // wait for analog sensor < value
timeoutFlag=false;
if (IODevice::readAnalogue(operand) < (int)(GET_OPERAND(1))) break;
delayMe(50);
return;
case OPCODE_ATTIMEOUT1: // ATTIMEOUT(vpin,timeout) part 1
timeoutStart=millis();
timeoutFlag=false;
@ -928,9 +940,9 @@ void RMFT2::kill(const FSH * reason, int operand) {
}
// sigid is the signal id used in RED/AMBER/GREEN macro
// for a LED signal it will be same as redpin
// but for a servo signal it will also have SERVER_SIGNAL_FLAG set.
// but for a servo signal it will also have SERVO_SIGNAL_FLAG set.
if ((sigid & ~SERVO_SIGNAL_FLAG)!= id) continue; // keep looking
if ((sigid & ~SERVO_SIGNAL_FLAG & ~ACTIVE_HIGH_SIGNAL_FLAG)!= id) continue; // keep looking
// Correct signal definition found, get the rag values
VPIN redpin=GETFLASHW(RMFT2::SignalDefinitions+sigpos+1);
@ -953,10 +965,13 @@ void RMFT2::kill(const FSH * reason, int operand) {
green=true;
}
// Manage invert (HIGH on) pins
bool aHigh=sigid & ACTIVE_HIGH_SIGNAL_FLAG;
// set the three pins
if (redpin) IODevice::write(redpin,red);
if (amberpin) IODevice::write(amberpin,amber);
if (greenpin) IODevice::write(greenpin,green);
if (redpin) IODevice::write(redpin,red^aHigh);
if (amberpin) IODevice::write(amberpin,amber^aHigh);
if (greenpin) IODevice::write(greenpin,green^aHigh);
return;
}
}

View File

@ -33,6 +33,7 @@ enum OPCODE : byte {OPCODE_THROW,OPCODE_CLOSE,
OPCODE_FWD,OPCODE_REV,OPCODE_SPEED,OPCODE_INVERT_DIRECTION,
OPCODE_RESERVE,OPCODE_FREE,
OPCODE_AT,OPCODE_AFTER,OPCODE_AUTOSTART,
OPCODE_ATGTE,OPCODE_ATLT,
OPCODE_ATTIMEOUT1,OPCODE_ATTIMEOUT2,OPCODE_IFTIMEOUT,
OPCODE_LATCH,OPCODE_UNLATCH,OPCODE_SET,OPCODE_RESET,
OPCODE_IF,OPCODE_IFNOT,OPCODE_ENDIF,OPCODE_IFRANDOM,OPCODE_IFRESERVE,
@ -95,6 +96,7 @@ class LookList {
static void emitWithrottleRoster(Print * stream);
static const FSH * getRosterFunctions(int16_t cabid);
static const int16_t SERVO_SIGNAL_FLAG=0x4000;
static const int16_t ACTIVE_HIGH_SIGNAL_FLAG=0x2000;
private:
static void ComandFilter(Print * stream, byte & opcode, byte & paramCount, int16_t p[]);

View File

@ -29,6 +29,8 @@
#undef ALIAS
#undef AMBER
#undef AT
#undef ATGTE
#undef ATLT
#undef ATTIMEOUT
#undef AUTOMATION
#undef AUTOSTART
@ -103,6 +105,7 @@
#undef SET
#undef SETLOCO
#undef SIGNAL
#undef SIGNALH
#undef SPEED
#undef START
#undef STOP
@ -121,6 +124,8 @@
#define ALIAS(name,value)
#define AMBER(signal_id)
#define AT(sensor_id)
#define ATGTE(sensor_id,value)
#define ATLT(sensor_id,value)
#define ATTIMEOUT(sensor_id,timeout_ms)
#define AUTOMATION(id, description)
#define AUTOSTART
@ -195,6 +200,7 @@
#define SET(pin)
#define SETLOCO(loco)
#define SIGNAL(redpin,amberpin,greenpin)
#define SIGNALH(redpin,amberpin,greenpin)
#define SPEED(speed)
#define START(route)
#define STOP

View File

@ -149,6 +149,8 @@ const FSH * RMFT2::getRosterFunctions(int16_t cabid) {
#include "EXRAIL2MacroReset.h"
#undef SIGNAL
#define SIGNAL(redpin,amberpin,greenpin) redpin,redpin,amberpin,greenpin,
#undef SIGNALH
#define SIGNALH(redpin,amberpin,greenpin) redpin | RMFT2::ACTIVE_HIGH_SIGNAL_FLAG,redpin,amberpin,greenpin,
#undef SERVO_SIGNAL
#define SERVO_SIGNAL(vpin,redval,amberval,greenval) vpin | RMFT2::SERVO_SIGNAL_FLAG,redval,amberval,greenval,
const FLASH int16_t RMFT2::SignalDefinitions[] = {
@ -171,6 +173,8 @@ const FLASH int16_t RMFT2::SignalDefinitions[] = {
#define ALIAS(name,value)
#define AMBER(signal_id) OPCODE_AMBER,V(signal_id),
#define AT(sensor_id) OPCODE_AT,V(sensor_id),
#define ATGTE(sensor_id,value) OPCODE_ATGTE,V(sensor_id),OPCODE_PAD,V(value),
#define ATLT(sensor_id,value) OPCODE_ATLT,V(sensor_id),OPCODE_PAD,V(value),
#define ATTIMEOUT(sensor_id,timeout) OPCODE_ATTIMEOUT1,0,0,OPCODE_ATTIMEOUT2,V(sensor_id),OPCODE_PAD,V(timeout/100L),
#define AUTOMATION(id, description) OPCODE_AUTOMATION, V(id),
#define AUTOSTART OPCODE_AUTOSTART,0,0,
@ -245,6 +249,7 @@ const FLASH int16_t RMFT2::SignalDefinitions[] = {
#define SET(pin) OPCODE_SET,V(pin),
#define SETLOCO(loco) OPCODE_SETLOCO,V(loco),
#define SIGNAL(redpin,amberpin,greenpin)
#define SIGNALH(redpin,amberpin,greenpin)
#define SPEED(speed) OPCODE_SPEED,V(speed),
#define START(route) OPCODE_START,V(route),
#define STOP OPCODE_SPEED,V(0),