Skip to content

Commit

Permalink
ONBUTTON/ONSENSOR use latch
Browse files Browse the repository at this point in the history
  • Loading branch information
Asbelos committed Apr 13, 2024
1 parent 7dafe03 commit ebe8f62
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 7 deletions.
9 changes: 6 additions & 3 deletions EXRAIL2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -253,11 +253,13 @@ if (compileFeatures & FEATURE_SIGNAL) {
}

case OPCODE_ONSENSOR:
if (compileFeatures & FEATURE_SENSOR)
new EXRAILSensor(operand,progCounter+3,true );
break;
break;
case OPCODE_ONBUTTON:
if (compileFeatures & FEATURE_SENSOR)
new EXRAILSensor(operand,progCounter+3,false );
break;
break;
case OPCODE_TURNOUT: {
VPIN id=operand;
int addr=getOperand(progCounter,1);
Expand Down Expand Up @@ -487,7 +489,8 @@ bool RMFT2::skipIfBlock() {
}

void RMFT2::loop() {
EXRAILSensor::checkAll();
if (compileFeatures & FEATURE_SENSOR)
EXRAILSensor::checkAll();

// Round Robin call to a RMFT task each time
if (loopTask==NULL) return;
Expand Down
5 changes: 3 additions & 2 deletions EXRAIL2.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ enum BlinkState: byte {
static const byte FEATURE_ROUTESTATE= 0x10;
static const byte FEATURE_STASH = 0x08;
static const byte FEATURE_BLINK = 0x04;
static const byte FEATURE_SENSOR = 0x02;


// Flag bits for status of hardware and TPL
Expand Down Expand Up @@ -185,7 +186,8 @@ class LookList {
static const FSH * getTurntableDescription(int16_t id);
static const FSH * getTurntablePositionDescription(int16_t turntableId, uint8_t positionId);
static void startNonRecursiveTask(const FSH* reason, int16_t id,int pc);

static bool readSensor(uint16_t sensorId);

private:
static void ComandFilter(Print * stream, byte & opcode, byte & paramCount, int16_t p[]);
static bool parseSlash(Print * stream, byte & paramCount, int16_t p[]) ;
Expand All @@ -208,7 +210,6 @@ class LookList {
static RMFT2 * pausingTask;
void delayMe(long millisecs);
void driveLoco(byte speedo);
bool readSensor(uint16_t sensorId);
bool skipIfBlock();
bool readLoco();
void loop2();
Expand Down
4 changes: 4 additions & 0 deletions EXRAILMacros.h
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,10 @@ bool exrailHalSetup() {
#define STASH(id) | FEATURE_STASH
#undef BLINK
#define BLINK(vpin,onDuty,offDuty) | FEATURE_BLINK
#undef ONBUTTON
#define ONBUTTON(vpin) | FEATURE_SENSOR
#undef ONSENSOR
#define ONSENSOR(vpin) | FEATURE_SENSOR

const byte RMFT2::compileFeatures = 0
#include "myAutomation.h"
Expand Down
2 changes: 1 addition & 1 deletion EXRAILSensor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ void EXRAILSensor::checkAll() {

bool EXRAILSensor::check() {
// check for debounced change in this sensor
inputState = IODevice::read(pin);
inputState = RMFT2::readSensor(pin);

// Check if changed since last time, and process changes.
if (inputState == active) {// no change
Expand Down
3 changes: 2 additions & 1 deletion version.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@

#include "StringFormatter.h"

#define VERSION "5.2.49"
#define VERSION "5.2.50"
// 5.2.50 - EXRAIL ONBUTTON/ONSENSOR observe LATCH
// 5.2.49 - EXRAIL additions:
// ONBUTTON, ONSENSOR
// 5.2.48 - Bugfix: HALDisplay was generating I2C traffic prior to I2C being initialised
Expand Down

0 comments on commit ebe8f62

Please sign in to comment.