diff --git a/EXRAIL2MacroReset.h b/EXRAIL2MacroReset.h index 3554f6c..f52b636 100644 --- a/EXRAIL2MacroReset.h +++ b/EXRAIL2MacroReset.h @@ -84,6 +84,7 @@ #undef IFTTPOSITION #undef IFRE #undef INVERT_DIRECTION +#undef JMRI_SENSOR #undef JOIN #undef KILLALL #undef LATCH @@ -236,6 +237,7 @@ #define IFTTPOSITION(turntable_id,position) #define IFRE(sensor_id,value) #define INVERT_DIRECTION +#define JMRI_SENSOR(vpin,count...) #define JOIN #define KILLALL #define LATCH(sensor_id) diff --git a/EXRAILMacros.h b/EXRAILMacros.h index 98af846..5873e38 100644 --- a/EXRAILMacros.h +++ b/EXRAILMacros.h @@ -149,6 +149,8 @@ static_assert(!hasdup(compileTimeSequenceList[0],1),"Duplicate SEQUENCE/ROUTE/AU #define HAL(haltype,params...) haltype::create(params); #undef HAL_IGNORE_DEFAULTS #define HAL_IGNORE_DEFAULTS ignore_defaults=true; +#undef JMRI_SENSOR +#define JMRI_SENSOR(vpin,count...) Sensor::createMultiple(vpin,##count); bool exrailHalSetup() { bool ignore_defaults=false; #include "myAutomation.h" @@ -487,6 +489,7 @@ int RMFT2::onLCCLookup[RMFT2::countLCCLookup]; #endif #define IFRE(sensor_id,value) OPCODE_IFRE,V(sensor_id),OPCODE_PAD,V(value), #define INVERT_DIRECTION OPCODE_INVERT_DIRECTION,0,0, +#define JMRI_SENSOR(vpin,count...) #define JOIN OPCODE_JOIN,0,0, #define KILLALL OPCODE_KILLALL,0,0, #define LATCH(sensor_id) OPCODE_LATCH,V(sensor_id), diff --git a/Sensors.cpp b/Sensors.cpp index d1c0fe5..efd969d 100644 --- a/Sensors.cpp +++ b/Sensors.cpp @@ -230,6 +230,13 @@ Sensor *Sensor::create(int snum, VPIN pin, int pullUp){ return tt; } +// Creet multiple eponymous sensors based on vpin alone. +void Sensor::createMultiple(VPIN firstPin, byte count) { + for (byte i=0;i types. // 5.2.40 - Bugfix: WiThrottle sendIntro after initial N message as well // 5.2.29 - Added IO_I2CDFPlayer.h to support DFPLayer over I2C connected to NXP SC16IS750/SC16IS752 (currently only single UART for SC16IS752) // - Added enhanced IO_I2CDFPLayer enum commands to EXRAIL2.h