From 9aac34b403b07f02ffdcad5747aa151f21bf7a86 Mon Sep 17 00:00:00 2001 From: Asbelos Date: Mon, 11 Mar 2024 12:26:28 +0000 Subject: [PATCH 1/8] comments --- DCCEXParser.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DCCEXParser.cpp b/DCCEXParser.cpp index 2eeedc9..6f4bf52 100644 --- a/DCCEXParser.cpp +++ b/DCCEXParser.cpp @@ -68,7 +68,7 @@ Once a new OPCODE is decided upon, update this list. K, Reserved for future use - Potentially Railcom l, Loco speedbyte/function map broadcast L, Reserved for LCC interface (implemented in EXRAIL) - m, + m, message to throttles broadcast M, Write DCC packet n, N, From d753eb43e3d53a0c9d17ba98742b49cb27f3485a Mon Sep 17 00:00:00 2001 From: Harald Barth Date: Mon, 11 Mar 2024 14:52:55 +0100 Subject: [PATCH 2/8] Functions for DC frequency: Use func up to F31 --- CommandDistributor.cpp | 4 +--- DCC.cpp | 2 +- DCCEXParser.cpp | 25 +++++++++++-------------- 3 files changed, 13 insertions(+), 18 deletions(-) diff --git a/CommandDistributor.cpp b/CommandDistributor.cpp index 67bcc54..e7087ad 100644 --- a/CommandDistributor.cpp +++ b/CommandDistributor.cpp @@ -209,9 +209,7 @@ int16_t CommandDistributor::retClockTime() { void CommandDistributor::broadcastLoco(byte slot) { DCC::LOCO * sp=&DCC::speedTable[slot]; - uint32_t func = sp->functions; - func = func & 0x1fffffff; // mask out bits 0-28 - broadcastReply(COMMAND_TYPE, F("\n"), sp->loco,slot,sp->speedCode,func); + broadcastReply(COMMAND_TYPE, F("\n"), sp->loco,slot,sp->speedCode,sp->functions); #ifdef SABERTOOTH if (Serial2 && sp->loco == SABERTOOTH) { static uint8_t rampingmode = 0; diff --git a/DCC.cpp b/DCC.cpp index 5ab7eff..36d91fb 100644 --- a/DCC.cpp +++ b/DCC.cpp @@ -242,7 +242,7 @@ void DCC::changeFn( int cab, int16_t functionNumber) { // Report function state (used from withrottle protocol) // returns 0 false, 1 true or -1 for do not know int8_t DCC::getFn( int cab, int16_t functionNumber) { - if (cab<=0 || functionNumber>28) + if (cab<=0 || functionNumber>31) return -1; // unknown int reg = lookupSpeedTable(cab); if (reg<0) diff --git a/DCCEXParser.cpp b/DCCEXParser.cpp index 6f4bf52..fa4c9f8 100644 --- a/DCCEXParser.cpp +++ b/DCCEXParser.cpp @@ -283,25 +283,22 @@ void DCCEXParser::parseOne(Print *stream, byte *com, RingStream * ringStream) return; // filterCallback asked us to ignore case 't': // THROTTLE { - if (params==1) { // display state - - int16_t slot=DCC::lookupSpeedTable(p[0],false); - if (slot>=0) { - DCC::LOCO * sp=&DCC::speedTable[slot]; - StringFormatter::send(stream,F("\n"), - sp->loco,slot,sp->speedCode,sp->functions); - } - else // send dummy state speed 0 fwd no functions. - StringFormatter::send(stream,F("\n"),p[0]); - return; - } - int16_t cab; int16_t tspeed; int16_t direction; - + + if (params==1) { // display state + int16_t slot=DCC::lookupSpeedTable(p[0],false); + if (slot>=0) + CommandDistributor::broadcastLoco(slot); + else // send dummy state speed 0 fwd no functions. + StringFormatter::send(stream,F("\n"),p[0]); + return; + } + if (params == 4) { // + // ignore register p[0] cab = p[1]; tspeed = p[2]; direction = p[3]; From 8eec85edcf742b42bdd53517baa9b271463151ca Mon Sep 17 00:00:00 2001 From: Harald Barth Date: Mon, 11 Mar 2024 14:54:18 +0100 Subject: [PATCH 3/8] version 5.2.39 --- GITHUB_SHA.h | 2 +- version.h | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/GITHUB_SHA.h b/GITHUB_SHA.h index 699ead5..29d9a87 100644 --- a/GITHUB_SHA.h +++ b/GITHUB_SHA.h @@ -1 +1 @@ -#define GITHUB_SHA "devel-202402241957Z" +#define GITHUB_SHA "devel-202403111353Z" diff --git a/version.h b/version.h index 97b0a70..23e7e02 100644 --- a/version.h +++ b/version.h @@ -3,7 +3,8 @@ #include "StringFormatter.h" -#define VERSION "5.2.38" +#define VERSION "5.2.39" +// 5.2.39 - Functions for DC frequency: Use func up to F31 // 5.2.38 - Exrail MESSAGE("text") to send a user message to all // connected throttles (uses and withrottle Hmtext. // 5.2.37 - Bugfix ESP32: Use BOOSTER_INPUT define From e3081a7e56a58d2af0858a8ba80ba6f3e66dede2 Mon Sep 17 00:00:00 2001 From: Harald Barth Date: Tue, 12 Mar 2024 11:45:28 +0100 Subject: [PATCH 4/8] Functions for DC frequency: Use func up to F31 part 2 --- DCC.cpp | 7 ++++--- WiThrottle.cpp | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/DCC.cpp b/DCC.cpp index 36d91fb..a8bc953 100644 --- a/DCC.cpp +++ b/DCC.cpp @@ -219,8 +219,9 @@ bool DCC::setFn( int cab, int16_t functionNumber, bool on) { } else { speedTable[reg].functions &= ~funcmask; } - if (speedTable[reg].functions != previous && functionNumber <= 28) { - updateGroupflags(speedTable[reg].groupFlags, functionNumber); + if (speedTable[reg].functions != previous) { + if (functionNumber <= 28) + updateGroupflags(speedTable[reg].groupFlags, functionNumber); CommandDistributor::broadcastLoco(reg); } return true; @@ -235,8 +236,8 @@ void DCC::changeFn( int cab, int16_t functionNumber) { speedTable[reg].functions ^= funcmask; if (functionNumber <= 28) { updateGroupflags(speedTable[reg].groupFlags, functionNumber); - CommandDistributor::broadcastLoco(reg); } + CommandDistributor::broadcastLoco(reg); } // Report function state (used from withrottle protocol) diff --git a/WiThrottle.cpp b/WiThrottle.cpp index 3e712b3..f3d9253 100644 --- a/WiThrottle.cpp +++ b/WiThrottle.cpp @@ -571,7 +571,7 @@ void WiThrottle::sendRoutes(Print* stream) { void WiThrottle::sendFunctions(Print* stream, byte loco) { int16_t locoid=myLocos[loco].cab; - int fkeys=29; + int fkeys=32; // upper limit (send functions 0 to 31) myLocos[loco].functionToggles=1<<2; // F2 (HORN) is a non-toggle #ifdef EXRAIL_ACTIVE From 59d855549e087cababbb3cab368208fd6bdfb629 Mon Sep 17 00:00:00 2001 From: Harald Barth Date: Tue, 12 Mar 2024 11:47:25 +0100 Subject: [PATCH 5/8] version tag --- GITHUB_SHA.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/GITHUB_SHA.h b/GITHUB_SHA.h index 29d9a87..c5e1882 100644 --- a/GITHUB_SHA.h +++ b/GITHUB_SHA.h @@ -1 +1 @@ -#define GITHUB_SHA "devel-202403111353Z" +#define GITHUB_SHA "devel-202403121045Z" From 3cda869c6e15de7c00e7817172f248e2e2be01ea Mon Sep 17 00:00:00 2001 From: Harald Barth Date: Mon, 18 Mar 2024 21:17:51 +0100 Subject: [PATCH 6/8] Allow no shield --- MotorDrivers.h | 6 +++++- TrackManager.cpp | 10 +++++++--- TrackManager.h | 6 +++--- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/MotorDrivers.h b/MotorDrivers.h index 907c11b..9e5f85b 100644 --- a/MotorDrivers.h +++ b/MotorDrivers.h @@ -1,7 +1,7 @@ /* * © 2022-2023 Paul M. Antoine * © 2021 Fred Decker - * © 2020-2023 Harald Barth + * © 2020-2024 Harald Barth * (c) 2020 Chris Harlow. All rights reserved. * (c) 2021 Fred Decker. All rights reserved. * (c) 2020 Harald Barth. All rights reserved. @@ -57,6 +57,10 @@ // of the brake pin on the motor bridge is inverted // (HIGH == release brake) +// You can have a CS wihout any possibility to do any track signal. +// That's strange but possible. +#define NO_SHIELD F("No shield at all") + // Arduino STANDARD Motor Shield, used on different architectures: #if defined(ARDUINO_ARCH_SAMD) || defined(ARDUINO_ARCH_STM32) diff --git a/TrackManager.cpp b/TrackManager.cpp index e357e7f..338b11c 100644 --- a/TrackManager.cpp +++ b/TrackManager.cpp @@ -1,6 +1,6 @@ /* * © 2022 Chris Harlow - * © 2022,2023 Harald Barth + * © 2022-2024 Harald Barth * © 2023 Colin Murdoch * All rights reserved. * @@ -41,7 +41,7 @@ MotorDriver * TrackManager::track[MAX_TRACKS]; int16_t TrackManager::trackDCAddr[MAX_TRACKS]; -byte TrackManager::lastTrack=0; +int8_t TrackManager::lastTrack=-1; bool TrackManager::progTrackSyncMain=false; bool TrackManager::progTrackBoosted=false; int16_t TrackManager::joinRelay=UNUSED_PIN; @@ -498,7 +498,11 @@ void TrackManager::setTrackPower(TRACK_MODE trackmodeToMatch, POWERMODE powermod // Set track power for this track, inependent of mode void TrackManager::setTrackPower(POWERMODE powermode, byte t) { - MotorDriver *driver=track[t]; + MotorDriver *driver=track[t]; + if (driver == NULL) { // track is not defined at all + DIAG(F("Error: Track %c does not exist"), t+'A'); + return; + } TRACK_MODE trackmode = driver->getMode(); POWERMODE oldpower = driver->getPower(); if (trackmode & TRACK_MODE_NONE) { diff --git a/TrackManager.h b/TrackManager.h index c1f314a..7dce0ee 100644 --- a/TrackManager.h +++ b/TrackManager.h @@ -1,6 +1,6 @@ /* * © 2022 Chris Harlow - * © 2022 Harald Barth + * © 2022-2024 Harald Barth * © 2023 Colin Murdoch * * All rights reserved. @@ -46,7 +46,7 @@ const byte TRACK_POWER_1=1, TRACK_POWER_ON=1; class TrackManager { public: static void Setup(const FSH * shieldName, - MotorDriver * track0, + MotorDriver * track0=NULL, MotorDriver * track1=NULL, MotorDriver * track2=NULL, MotorDriver * track3=NULL, @@ -108,7 +108,7 @@ class TrackManager { private: static void addTrack(byte t, MotorDriver* driver); - static byte lastTrack; + static int8_t lastTrack; static byte nextCycleTrack; static void applyDCSpeed(byte t); From 0587e6fc097a708d76ce002d804df9c5d3865ff0 Mon Sep 17 00:00:00 2001 From: Harald Barth Date: Mon, 18 Mar 2024 21:18:57 +0100 Subject: [PATCH 7/8] version 5.2.40 --- GITHUB_SHA.h | 2 +- version.h | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/GITHUB_SHA.h b/GITHUB_SHA.h index c5e1882..e5f3571 100644 --- a/GITHUB_SHA.h +++ b/GITHUB_SHA.h @@ -1 +1 @@ -#define GITHUB_SHA "devel-202403121045Z" +#define GITHUB_SHA "devel-202403182018Z" diff --git a/version.h b/version.h index 23e7e02..27a10f0 100644 --- a/version.h +++ b/version.h @@ -3,7 +3,8 @@ #include "StringFormatter.h" -#define VERSION "5.2.39" +#define VERSION "5.2.40" +// 5.2.40 - Allow no shield // 5.2.39 - Functions for DC frequency: Use func up to F31 // 5.2.38 - Exrail MESSAGE("text") to send a user message to all // connected throttles (uses and withrottle Hmtext. From 87073b0d36ad6c2b39d3c9cc45b7692f5d45fbe1 Mon Sep 17 00:00:00 2001 From: peteGSX Date: Sat, 23 Mar 2024 13:31:34 +1000 Subject: [PATCH 8/8] Rotary Encoder address 0x67 --- IO_RotaryEncoder.h | 6 +++--- myHal.cpp_example.txt | 9 +++++---- version.h | 3 ++- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/IO_RotaryEncoder.h b/IO_RotaryEncoder.h index 9d40b34..2e6cfe7 100644 --- a/IO_RotaryEncoder.h +++ b/IO_RotaryEncoder.h @@ -42,9 +42,9 @@ * Defining in myAutomation.h requires the device driver to be included in addition to the HAL() statement. Examples: * * #include "IO_RotaryEncoder.h" -* HAL(RotaryEncoder, 700, 1, 0x70) // Define single Vpin, no feedback or position sent to rotary encoder software -* HAL(RotaryEncoder, 700, 2, 0x70) // Define two Vpins, feedback only sent to rotary encoder software -* HAL(RotaryEncoder, 700, 3, 0x70) // Define three Vpins, can send feedback and position update to rotary encoder software +* HAL(RotaryEncoder, 700, 1, 0x67) // Define single Vpin, no feedback or position sent to rotary encoder software +* HAL(RotaryEncoder, 700, 2, 0x67) // Define two Vpins, feedback only sent to rotary encoder software +* HAL(RotaryEncoder, 700, 3, 0x67) // Define three Vpins, can send feedback and position update to rotary encoder software * * Refer to the documentation for further information including the valid activities and examples. */ diff --git a/myHal.cpp_example.txt b/myHal.cpp_example.txt index 9073430..f715c63 100644 --- a/myHal.cpp_example.txt +++ b/myHal.cpp_example.txt @@ -311,12 +311,13 @@ void halSetup() { //======================================================================= // The parameters are: // firstVpin = First available Vpin to allocate - // numPins= Number of Vpins to allocate, can be either 1 or 2 - // i2cAddress = Available I2C address (default 0x70) + // numPins= Number of Vpins to allocate, can be either 1 to 3 + // i2cAddress = Available I2C address (default 0x67) //RotaryEncoder::create(firstVpin, numPins, i2cAddress); - //RotaryEncoder::create(700, 1, 0x70); - //RotaryEncoder::create(701, 2, 0x71); + //RotaryEncoder::create(700, 1, 0x67); + //RotaryEncoder::create(700, 2, 0x67); + //RotaryEncoder::create(700, 3, 0x67); //======================================================================= // The following directive defines an EX-FastClock instance. diff --git a/version.h b/version.h index 27a10f0..f292b43 100644 --- a/version.h +++ b/version.h @@ -3,7 +3,8 @@ #include "StringFormatter.h" -#define VERSION "5.2.40" +#define VERSION "5.2.41" +// 5.2.41 - Update rotary encoder default address to 0x67 // 5.2.40 - Allow no shield // 5.2.39 - Functions for DC frequency: Use func up to F31 // 5.2.38 - Exrail MESSAGE("text") to send a user message to all