1
0
mirror of https://github.com/DCC-EX/CommandStation-EX.git synced 2025-01-11 13:21:01 +01:00

DRIVE (part 1 experimental)

This commit is contained in:
Asbelos 2021-11-24 11:56:55 +00:00
parent 39c7bf3983
commit ef1719f6fc
3 changed files with 12 additions and 2 deletions

View File

@ -658,6 +658,14 @@ void RMFT2::loop2() {
if (loco) DCC::setFn(loco,operand,false);
break;
case OPCODE_DRIVE:
{
if (readSensor(operand)) break;
byte analogSpeed=IODevice::readAnalogue(GET_OPERAND(1)) *127 / 1024;
if (speedo!=analogSpeed) driveLoco(analogSpeed);
return;
}
case OPCODE_XFON:
DCC::setFn(operand,GET_OPERAND(1),true);
break;

View File

@ -35,7 +35,7 @@ enum OPCODE : byte {OPCODE_THROW,OPCODE_CLOSE,
OPCODE_IF,OPCODE_IFNOT,OPCODE_ENDIF,OPCODE_IFRANDOM,OPCODE_IFRESERVE,
OPCODE_DELAY,OPCODE_DELAYMINS,OPCODE_RANDWAIT,
OPCODE_FON,OPCODE_FOFF,OPCODE_XFON,OPCODE_XFOFF,
OPCODE_RED,OPCODE_GREEN,OPCODE_AMBER,
OPCODE_RED,OPCODE_GREEN,OPCODE_AMBER,OPCODE_DRIVE,
OPCODE_SERVO,OPCODE_SIGNAL,OPCODE_TURNOUT,OPCODE_WAITFOR,
OPCODE_PAD,OPCODE_FOLLOW,OPCODE_CALL,OPCODE_RETURN,
OPCODE_JOIN,OPCODE_UNJOIN,OPCODE_READ_LOCO1,OPCODE_READ_LOCO2,OPCODE_POM,

View File

@ -63,6 +63,7 @@
#define DEACTIVATE(addr,subaddr)
#define ACTIVATEL(addr)
#define DEACTIVATEL(addr)
#define DRIVE(analogpin,stopper)
#define AMBER(signal_id)
#define AT(sensor_id)
#define AUTOSTART
@ -164,6 +165,7 @@ const int StringMacroTracker1=__COUNTER__;
#undef AFTER
#undef ACTIVATE
#undef DEACTIVATE
#undef DRIVE
#undef ACTIVATEL
#undef DEACTIVATEL
#undef AMBER
@ -253,7 +255,7 @@ const int StringMacroTracker1=__COUNTER__;
#define DEACTIVATE(addr,subaddr) OPCODE_DCCACTIVATE,V(addr<<3 | subaddr<<1),
#define ACTIVATEL(addr) OPCODE_DCCACTIVATE,V((addr+3)<<3 | 1),
#define DEACTIVATEL(addr) OPCODE_DCCACTIVATE,V((addr+3)<<3),
#define DRIVE(analogpin,stopper) OPCODE_DRIVE,V(stopper),OPCODE_PAD,V(analogpin),
#define AFTER(sensor_id) OPCODE_AT,V(sensor_id),OPCODE_AFTER,V(sensor_id),
#define AMBER(signal_id) OPCODE_AMBER,V(signal_id),
#define AT(sensor_id) OPCODE_AT,V(sensor_id),