mirror of
https://github.com/DCC-EX/CommandStation-EX.git
synced 2024-11-23 16:16:13 +01:00
Compare commits
3 Commits
6b713bf57c
...
182479c07b
Author | SHA1 | Date | |
---|---|---|---|
|
182479c07b | ||
|
3317b4666e | ||
|
f41f61dd5f |
33
DCC.cpp
33
DCC.cpp
|
@ -615,6 +615,19 @@ const ackOp FLASH SHORT_LOCO_ID_PROG[] = {
|
|||
CALLFAIL
|
||||
};
|
||||
|
||||
// for CONSIST_ID_PROG the 20,19 values are already calculated
|
||||
const ackOp FLASH CONSIST_ID_PROG[] = {
|
||||
BASELINE,
|
||||
SETCV,(ackOp)20,
|
||||
SETBYTEH, // high byte to CV 20
|
||||
WB,WACK, // ignore dedcoder without cv20 support
|
||||
SETCV,(ackOp)19,
|
||||
SETBYTEL, // low byte of word
|
||||
WB,WACK,ITC1, // If ACK, we are done - callback(1) means Ok
|
||||
VB,WACK,ITC1, // Some decoders do not ack and need verify
|
||||
CALLFAIL
|
||||
};
|
||||
|
||||
const ackOp FLASH LONG_LOCO_ID_PROG[] = {
|
||||
BASELINE,
|
||||
// Clear consist CV 19,20
|
||||
|
@ -689,6 +702,26 @@ void DCC::setLocoId(int id,ACK_CALLBACK callback) {
|
|||
DCCACK::Setup(id | 0xc000,LONG_LOCO_ID_PROG, callback);
|
||||
}
|
||||
|
||||
void DCC::setConsistId(int id,bool reverse,ACK_CALLBACK callback) {
|
||||
if (id<0 || id>10239) { //0x27FF according to standard
|
||||
callback(-1);
|
||||
return;
|
||||
}
|
||||
byte cv20;
|
||||
byte cv19;
|
||||
|
||||
if (id<=HIGHEST_SHORT_ADDR) {
|
||||
cv19=id;
|
||||
cv20=0;
|
||||
}
|
||||
else {
|
||||
cv20=id/100;
|
||||
cv19=id%100;
|
||||
}
|
||||
if (reverse) cv19|=0x80;
|
||||
DCCACK::Setup((cv20<<8)|cv19, CONSIST_ID_PROG, callback);
|
||||
}
|
||||
|
||||
void DCC::forgetLoco(int cab) { // removes any speed reminders for this loco
|
||||
setThrottle2(cab,1); // ESTOP this loco if still on track
|
||||
int reg=lookupSpeedTable(cab, false);
|
||||
|
|
2
DCC.h
2
DCC.h
|
@ -85,7 +85,7 @@ public:
|
|||
|
||||
static void getLocoId(ACK_CALLBACK callback);
|
||||
static void setLocoId(int id,ACK_CALLBACK callback);
|
||||
|
||||
static void setConsistId(int id,bool reverse,ACK_CALLBACK callback);
|
||||
// Enhanced API functions
|
||||
static void forgetLoco(int cab); // removes any speed reminders for this loco
|
||||
static void forgetAllLocos(); // removes all speed reminders
|
||||
|
|
|
@ -458,6 +458,9 @@ void DCCEXParser::parseOne(Print *stream, byte *com, RingStream * ringStream)
|
|||
DCC::setLocoId(p[0],callback_Wloco);
|
||||
else if (params == 4) // WRITE CV ON PROG <W CV VALUE [CALLBACKNUM] [CALLBACKSUB]>
|
||||
DCC::writeCVByte(p[0], p[1], callback_W4);
|
||||
else if ((params==2 || params==3 ) && p[0]=="CONSIST"_hk ) {
|
||||
DCC::setConsistId(p[1],p[2]=="REVERSE"_hk,callback_Wconsist);
|
||||
}
|
||||
else if (params == 2) // WRITE CV ON PROG <W CV VALUE>
|
||||
DCC::writeCVByte(p[0], p[1], callback_W);
|
||||
else
|
||||
|
@ -1347,3 +1350,11 @@ void DCCEXParser::callback_Wloco(int16_t result)
|
|||
StringFormatter::send(getAsyncReplyStream(), F("<w %d>\n"), result);
|
||||
commitAsyncReplyStream();
|
||||
}
|
||||
|
||||
void DCCEXParser::callback_Wconsist(int16_t result)
|
||||
{
|
||||
if (result==1) result=stashP[1]; // pick up original requested id from command
|
||||
StringFormatter::send(getAsyncReplyStream(), F("<w CONSIST %d%S>\n"),
|
||||
result, stashP[2]=="REVERSE"_hk ? F(" REVERSE") : F(""));
|
||||
commitAsyncReplyStream();
|
||||
}
|
||||
|
|
|
@ -71,6 +71,7 @@ struct DCCEXParser
|
|||
static void callback_R(int16_t result);
|
||||
static void callback_Rloco(int16_t result);
|
||||
static void callback_Wloco(int16_t result);
|
||||
static void callback_Wconsist(int16_t result);
|
||||
static void callback_Vbit(int16_t result);
|
||||
static void callback_Vbyte(int16_t result);
|
||||
static FILTER_CALLBACK filterCallback;
|
||||
|
|
|
@ -3,7 +3,9 @@
|
|||
|
||||
#include "StringFormatter.h"
|
||||
|
||||
#define VERSION "5.2.45"
|
||||
#define VERSION "5.2.46"
|
||||
// 5.2.46 - Support for extended consist CV20 in <R> and <W id>
|
||||
// - New cmd <W CONSIST id [REVERSE]> to handle long/short consist ids
|
||||
// 5.2.45 - ESP32 Trackmanager reset cab number to 0 when track is not DC
|
||||
// ESP32 fix PWM LEDC inverted pin mode
|
||||
// ESP32 rewrite PWM LEDC to use pin mux
|
||||
|
|
Loading…
Reference in New Issue
Block a user