mirror of
https://github.com/DCC-EX/CommandStation-EX.git
synced 2025-01-11 21:31:02 +01:00
IFANALOG(pin, value)
This commit is contained in:
parent
4a8065d33b
commit
259696a117
15
RMFT2.cpp
15
RMFT2.cpp
@ -20,13 +20,17 @@
|
|||||||
/* EXRAILPlus planned FEATURE additions
|
/* EXRAILPlus planned FEATURE additions
|
||||||
F1. [DONE] DCC accessory packet opcodes (short and long form)
|
F1. [DONE] DCC accessory packet opcodes (short and long form)
|
||||||
F2. [DONE] ONAccessory catchers
|
F2. [DONE] ONAccessory catchers
|
||||||
F3. Turnout descriptions for Withrottle
|
F3. [DONE] Turnout descriptions for Withrottle
|
||||||
F4. Oled announcements (depends on HAL)
|
F4. Oled announcements (depends on HAL)
|
||||||
F5. Withrottle roster info
|
F5. Withrottle roster info
|
||||||
F6. Multi-occupancy semaphore
|
F6. Multi-occupancy semaphore
|
||||||
F7. [DONE see AUTOSTART] Self starting sequences
|
F7. [DONE see AUTOSTART] Self starting sequences
|
||||||
F8. Park/unpark
|
F8. Park/unpark
|
||||||
F9. Analog drive
|
F9. [DONE] Analog drive
|
||||||
|
F10. [DONE] Alias anywhere
|
||||||
|
F11. [DONE]EXRAIL/ENDEXRAIL unnecessary
|
||||||
|
F12. [DONE] Allow guarded code (as effect of ALIAS anywhere)
|
||||||
|
F13. [DONE] IFANALOG function
|
||||||
*/
|
*/
|
||||||
/* EXRAILPlus planned TRANSPARENT additions
|
/* EXRAILPlus planned TRANSPARENT additions
|
||||||
T1. [DONE] RAM based fast lookup for sequences ON* event catchers and signals.
|
T1. [DONE] RAM based fast lookup for sequences ON* event catchers and signals.
|
||||||
@ -495,6 +499,7 @@ bool RMFT2::skipIfBlock() {
|
|||||||
kill(F("missing ENDIF"), nest);
|
kill(F("missing ENDIF"), nest);
|
||||||
return false;
|
return false;
|
||||||
case OPCODE_IF:
|
case OPCODE_IF:
|
||||||
|
case OPCODE_IFANALOG:
|
||||||
case OPCODE_IFNOT:
|
case OPCODE_IFNOT:
|
||||||
case OPCODE_IFRANDOM:
|
case OPCODE_IFRANDOM:
|
||||||
case OPCODE_IFRESERVE:
|
case OPCODE_IFRESERVE:
|
||||||
@ -633,6 +638,10 @@ void RMFT2::loop2() {
|
|||||||
if (!readSensor(operand)) if (!skipIfBlock()) return;
|
if (!readSensor(operand)) if (!skipIfBlock()) return;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case OPCODE_IFANALOG: // do next operand if sensor>= value
|
||||||
|
if (IODevice::readAnalogue(operand)<(int)(GET_OPERAND(1))) if (!skipIfBlock()) return;
|
||||||
|
break;
|
||||||
|
|
||||||
case OPCODE_IFNOT: // do next operand if sensor not set
|
case OPCODE_IFNOT: // do next operand if sensor not set
|
||||||
if (readSensor(operand)) if (!skipIfBlock()) return;
|
if (readSensor(operand)) if (!skipIfBlock()) return;
|
||||||
break;
|
break;
|
||||||
@ -683,7 +692,7 @@ void RMFT2::loop2() {
|
|||||||
|
|
||||||
case OPCODE_DRIVE:
|
case OPCODE_DRIVE:
|
||||||
{
|
{
|
||||||
byte analogSpeed=IODevice::readAnalogue(GET_OPERAND(1)) *127 / 1024;
|
byte analogSpeed=IODevice::readAnalogue(operand) *127 / 1024;
|
||||||
if (speedo!=analogSpeed) driveLoco(analogSpeed);
|
if (speedo!=analogSpeed) driveLoco(analogSpeed);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
2
RMFT2.h
2
RMFT2.h
@ -43,7 +43,7 @@ enum OPCODE : byte {OPCODE_THROW,OPCODE_CLOSE,
|
|||||||
OPCODE_PAUSE, OPCODE_RESUME,OPCODE_POWEROFF,
|
OPCODE_PAUSE, OPCODE_RESUME,OPCODE_POWEROFF,
|
||||||
OPCODE_ONCLOSE, OPCODE_ONTHROW, OPCODE_SERVOTURNOUT, OPCODE_PINTURNOUT,
|
OPCODE_ONCLOSE, OPCODE_ONTHROW, OPCODE_SERVOTURNOUT, OPCODE_PINTURNOUT,
|
||||||
OPCODE_PRINT,OPCODE_DCCACTIVATE,
|
OPCODE_PRINT,OPCODE_DCCACTIVATE,
|
||||||
OPCODE_ONACTIVATE,OPCODE_ONDEACTIVATE,
|
OPCODE_ONACTIVATE,OPCODE_ONDEACTIVATE,OPCODE_IFANALOG,
|
||||||
OPCODE_ROUTE,OPCODE_AUTOMATION,OPCODE_SEQUENCE,OPCODE_ENDTASK,OPCODE_ENDEXRAIL
|
OPCODE_ROUTE,OPCODE_AUTOMATION,OPCODE_SEQUENCE,OPCODE_ENDTASK,OPCODE_ENDEXRAIL
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -52,6 +52,7 @@
|
|||||||
#undef FWD
|
#undef FWD
|
||||||
#undef GREEN
|
#undef GREEN
|
||||||
#undef IF
|
#undef IF
|
||||||
|
#undef IFANALOG
|
||||||
#undef IFNOT
|
#undef IFNOT
|
||||||
#undef IFRANDOM
|
#undef IFRANDOM
|
||||||
#undef IFRESERVE
|
#undef IFRESERVE
|
||||||
@ -133,6 +134,7 @@
|
|||||||
#define FWD(speed)
|
#define FWD(speed)
|
||||||
#define GREEN(signal_id)
|
#define GREEN(signal_id)
|
||||||
#define IF(sensor_id)
|
#define IF(sensor_id)
|
||||||
|
#define IFANALOG(sensor_id,value)
|
||||||
#define IFNOT(sensor_id)
|
#define IFNOT(sensor_id)
|
||||||
#define IFRANDOM(percent)
|
#define IFRANDOM(percent)
|
||||||
#define IFRESERVE(block)
|
#define IFRESERVE(block)
|
||||||
|
@ -152,6 +152,7 @@ void RMFT2::emitTurnoutDescription(Print* stream,int16_t turnoutid) {
|
|||||||
#define FWD(speed) OPCODE_FWD,V(speed),
|
#define FWD(speed) OPCODE_FWD,V(speed),
|
||||||
#define GREEN(signal_id) OPCODE_GREEN,V(signal_id),
|
#define GREEN(signal_id) OPCODE_GREEN,V(signal_id),
|
||||||
#define IF(sensor_id) OPCODE_IF,V(sensor_id),
|
#define IF(sensor_id) OPCODE_IF,V(sensor_id),
|
||||||
|
#define IFANALOG(sensor_id,value) OPCODE_IFANALOG,V(sensor_id),OPCODE_PAD,V(value),
|
||||||
#define IFNOT(sensor_id) OPCODE_IFNOT,V(sensor_id),
|
#define IFNOT(sensor_id) OPCODE_IFNOT,V(sensor_id),
|
||||||
#define IFRANDOM(percent) OPCODE_IFRANDOM,V(percent),
|
#define IFRANDOM(percent) OPCODE_IFRANDOM,V(percent),
|
||||||
#define IFRESERVE(block) OPCODE_IFRESERVE,V(block),
|
#define IFRESERVE(block) OPCODE_IFRESERVE,V(block),
|
||||||
|
Loading…
Reference in New Issue
Block a user