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

Compare commits

..

3 Commits

Author SHA1 Message Date
Harald Barth
6b713bf57c version 5.2.45 2024-04-06 19:48:02 +02:00
Harald Barth
38a9585a41 ESP32 Trackmanager reset cab number to 0 when track is not DC 2024-04-06 19:46:23 +02:00
Asbelos
1a307eea3d Extended consist <R> and <W> 2024-04-06 13:19:56 +01:00
6 changed files with 74 additions and 11 deletions

43
DCC.cpp
View File

@ -325,8 +325,8 @@ preamble -0- 1 0 A7 A6 A5 A4 A3 A2 -0- 0 ^A10 ^A9 ^A8 0 A1 A0 1 -0- ....
Thus in byte packet form the format is 10AAAAAA, 0AAA0AA1, 000XXXXX
Die Adresse für den ersten erweiterten Zubehördecoder ist wie bei den einfachen
Zubehördecodern die Adresse 4 = 1000-0001 0111-0001 . Diese Adresse wird in
Die Adresse f<EFBFBD>r den ersten erweiterten Zubeh<EFBFBD>rdecoder ist wie bei den einfachen
Zubeh<EFBFBD>rdecodern die Adresse 4 = 1000-0001 0111-0001 . Diese Adresse wird in
Anwenderdialogen als Adresse 1 dargestellt.
This means that the first address shown to the user as "1" is mapped
@ -500,6 +500,36 @@ const ackOp FLASH READ_CV_PROG[] = {
const ackOp FLASH LOCO_ID_PROG[] = {
BASELINE,
// first check cv20 for extended addressing
SETCV, (ackOp)20, // CV 19 is extended
SETBYTE, (ackOp)0,
VB, WACK, ITSKIP, // skip past extended section if cv20 is zero
// read cv20 and 19 and merge
STARTMERGE, // Setup to read cv 20
V0, WACK, MERGE,
V0, WACK, MERGE,
V0, WACK, MERGE,
V0, WACK, MERGE,
V0, WACK, MERGE,
V0, WACK, MERGE,
V0, WACK, MERGE,
V0, WACK, MERGE,
VB, WACK, NAKSKIP, // bad read of cv20, assume its 0
STASHLOCOID, // keep cv 20 until we have cv19 as well.
SETCV, (ackOp)19,
STARTMERGE, // Setup to read cv 19
V0, WACK, MERGE,
V0, WACK, MERGE,
V0, WACK, MERGE,
V0, WACK, MERGE,
V0, WACK, MERGE,
V0, WACK, MERGE,
V0, WACK, MERGE,
V0, WACK, MERGE,
VB, WACK, NAKFAIL, // cant recover if cv 19 unreadable
COMBINE1920, // Combile byte with stash and callback
// end of advanced 20,19 check
SKIPTARGET,
SETCV, (ackOp)19, // CV 19 is consist setting
SETBYTE, (ackOp)0,
VB, WACK, ITSKIP, // ignore consist if cv19 is zero (no consist)
@ -566,6 +596,10 @@ const ackOp FLASH LOCO_ID_PROG[] = {
const ackOp FLASH SHORT_LOCO_ID_PROG[] = {
BASELINE,
// Clear consist CV 19,20
SETCV,(ackOp)20,
SETBYTE, (ackOp)0,
WB,WACK, // ignore dedcoder without cv20 support
SETCV,(ackOp)19,
SETBYTE, (ackOp)0,
WB,WACK, // ignore dedcoder without cv19 support
@ -583,7 +617,10 @@ const ackOp FLASH SHORT_LOCO_ID_PROG[] = {
const ackOp FLASH LONG_LOCO_ID_PROG[] = {
BASELINE,
// Clear consist CV 19
// Clear consist CV 19,20
SETCV,(ackOp)20,
SETBYTE, (ackOp)0,
WB,WACK, // ignore dedcoder without cv20 support
SETCV,(ackOp)19,
SETBYTE, (ackOp)0,
WB,WACK, // ignore decoder without cv19 support

View File

@ -314,6 +314,14 @@ void DCCACK::loop() {
callback( LONG_ADDR_MARKER | ( ackManagerByte + ((ackManagerStash - 192) << 8)));
return;
case COMBINE1920:
// ackManagerStash is cv20, ackManagerByte is CV 19
// This will not be called if cv20==0
ackManagerByte &= 0x7F; // ignore direction marker
ackManagerByte %=100; // take last 2 decimal digits
callback( ackManagerStash*100+ackManagerByte);
return;
case ITSKIP:
if (!ackReceived) break;
// SKIP opcodes until SKIPTARGET found
@ -322,6 +330,15 @@ void DCCACK::loop() {
opcode=GETFLASH(ackManagerProg);
}
break;
case NAKSKIP:
if (ackReceived) break;
// SKIP opcodes until SKIPTARGET found
while (opcode!=SKIPTARGET) {
ackManagerProg++;
opcode=GETFLASH(ackManagerProg);
}
break;
case SKIPTARGET:
break;
default:

View File

@ -56,6 +56,8 @@ enum ackOp : byte
STASHLOCOID, // keeps current byte value for later
COMBINELOCOID, // combines current value with stashed value and returns it
ITSKIP, // skip to SKIPTARGET if ack true
NAKSKIP, // skip to SKIPTARGET if ack false
COMBINE1920, // combine cvs 19 and 20 and callback
SKIPTARGET = 0xFF // jump to target
};

View File

@ -1 +1 @@
#define GITHUB_SHA "devel-202404051830Z"
#define GITHUB_SHA "devel-202404061747Z"

View File

@ -38,8 +38,8 @@
if (track[t]->getMode()==findmode) \
track[t]->function;
MotorDriver * TrackManager::track[MAX_TRACKS];
int16_t TrackManager::trackDCAddr[MAX_TRACKS];
MotorDriver * TrackManager::track[MAX_TRACKS] = { NULL };
int16_t TrackManager::trackDCAddr[MAX_TRACKS] = { 0 };
int8_t TrackManager::lastTrack=-1;
bool TrackManager::progTrackSyncMain=false;
@ -251,7 +251,6 @@ bool TrackManager::setTrackMode(byte trackToSet, TRACK_MODE mode, int16_t dcAddr
} else {
track[trackToSet]->makeProgTrack(false); // only the prog track knows it's type
}
track[trackToSet]->setMode(mode);
// When a track is switched, we must clear any side effects of its previous
// state, otherwise trains run away or just dont move.
@ -259,8 +258,13 @@ bool TrackManager::setTrackMode(byte trackToSet, TRACK_MODE mode, int16_t dcAddr
// This can be done BEFORE the PWM-Timer evaluation (methinks)
if (mode & TRACK_MODE_DC) {
if (trackDCAddr[trackToSet] != dcAddr) {
// if we change dcAddr, detach first old signal
// new or changed DC Addr, run the new setup
if (trackDCAddr[trackToSet] != 0) {
// if we change dcAddr and not only
// change from another mode,
// first detach old DC signal
track[trackToSet]->detachDCSignal();
}
#ifdef ARDUINO_ARCH_ESP32
int trackfound = -1;
FOR_EACH_TRACK(t) {
@ -285,7 +289,9 @@ bool TrackManager::setTrackMode(byte trackToSet, TRACK_MODE mode, int16_t dcAddr
// DCC tracks need to have set the PWM to zero or they will not work.
track[trackToSet]->detachDCSignal();
track[trackToSet]->setBrake(false);
trackDCAddr[trackToSet]=0; // clear that an addr is set for DC as this is not a DC track
}
track[trackToSet]->setMode(mode);
// BOOST:
// Leave it as is

View File

@ -3,8 +3,9 @@
#include "StringFormatter.h"
#define VERSION "5.2.44"
// 5.2.44 - ESP32 fix PWM LEDC inverted pin mode
#define VERSION "5.2.45"
// 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
// 5.2.42 - ESP32 Bugfix: Uninitialized stack variable
// 5.2.41 - Update rotary encoder default address to 0x67