From fa4f5f08efb890c14cadd4a4fb3a8066b5c99c5d Mon Sep 17 00:00:00 2001 From: Chris Mayo Date: Sun, 6 Mar 2022 15:05:35 +0000 Subject: [PATCH 1/4] Comment Typos (#214) * Example config comment typos * Code comment typos --- EXRAIL2.cpp | 10 +++++----- config.example.h | 8 ++++---- myAutomation.example.h | 6 +++--- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/EXRAIL2.cpp b/EXRAIL2.cpp index af6f0a1..737cef6 100644 --- a/EXRAIL2.cpp +++ b/EXRAIL2.cpp @@ -67,11 +67,11 @@ const int16_t HASH_KEYWORD_ROUTES=-3702; // One instance of RMFT clas is used for each "thread" in the automation. // Each thread manages a loco on a journey through the layout, and/or may manage a scenery automation. -// The thrrads exist in a ring, each time through loop() the next thread in the ring is serviced. +// The threads exist in a ring, each time through loop() the next thread in the ring is serviced. // Statics const int16_t LOCO_ID_WAITING=-99; // waiting for loco id from prog track -int16_t RMFT2::progtrackLocoId; // used for callback when detecting a loco on prograck +int16_t RMFT2::progtrackLocoId; // used for callback when detecting a loco on prog track bool RMFT2::diag=false; // RMFT2 * RMFT2::loopTask=NULL; // loopTask contains the address of ONE of the tasks in a ring. RMFT2 * RMFT2::pausingTask=NULL; // Task causing a PAUSE. @@ -870,13 +870,13 @@ void RMFT2::loop2() { break; case OPCODE_AUTOSTART: // Handled only during begin process - case OPCODE_PAD: // Just a padding for previous opcode needing >1 operad byte. + case OPCODE_PAD: // Just a padding for previous opcode needing >1 operand byte. case OPCODE_TURNOUT: // Turnout definition ignored at runtime case OPCODE_SERVOTURNOUT: // Turnout definition ignored at runtime case OPCODE_PINTURNOUT: // Turnout definition ignored at runtime - case OPCODE_ONCLOSE: // Turnout event catcers ignored here + case OPCODE_ONCLOSE: // Turnout event catchers ignored here case OPCODE_ONTHROW: - case OPCODE_ONACTIVATE: // Activate event catcers ignored here + case OPCODE_ONACTIVATE: // Activate event catchers ignored here case OPCODE_ONDEACTIVATE: break; diff --git a/config.example.h b/config.example.h index 731c56c..53d0d55 100644 --- a/config.example.h +++ b/config.example.h @@ -29,7 +29,7 @@ The configuration file for DCC-EX Command Station ///////////////////////////////////////////////////////////////////////////////////// // NOTE: Before connecting these boards and selecting one in this software // check the quick install guides!!! Some of these boards require a voltage -// generating resitor on the current sense pin of the device. Failure to select +// generating resistor on the current sense pin of the device. Failure to select // the correct resistor could damage the sense pin on your Arduino or destroy // the device. // @@ -85,7 +85,7 @@ The configuration file for DCC-EX Command Station // WIFI_PASSWORD is the network password for your home network or if // you want to change the password from default AP mode password // to the AP password you want. -// Your password may not conain ``"'' (double quote, ASCII 0x22). +// Your password may not contain ``"'' (double quote, ASCII 0x22). #define WIFI_PASSWORD "Your network passwd" // // WIFI_HOSTNAME: You probably don't need to change this @@ -137,7 +137,7 @@ The configuration file for DCC-EX Command Station // If you do not need the EEPROM at all, you can disable all the code that saves // data in the EEPROM. You might want to do that if you are in a Arduino UNO // and want to use the EX-RAIL automation. Otherwise you do not have enough RAM -// to do that. Of course, then none of the EEPROM related commands works. +// to do that. Of course, then none of the EEPROM related commands work. // // #define DISABLE_EEPROM @@ -174,7 +174,7 @@ The configuration file for DCC-EX Command Station // If you have issues with that the direction of the accessory commands is // reversed (for example when converting from another CS to DCC-EX) then -// you can use this to revese the sense of all accessory commmands sent +// you can use this to reverse the sense of all accessory commmands sent // over DCC++. This #define likewise inverts the behaviour of the command // for triggering DCC Accessory Decoders, so that generates a // DCC packet with D=1 (close turnout) and generates D=0 diff --git a/myAutomation.example.h b/myAutomation.example.h index f1bad26..4bb6301 100644 --- a/myAutomation.example.h +++ b/myAutomation.example.h @@ -1,7 +1,7 @@ /* This is an automation example file. * The presence of a file called "myAutomation.h" brings EX-RAIL code into * the command station. - * The auotomation may have multiple concurrent tasks. + * The automation may have multiple concurrent tasks. * A task may * - Act as a ROUTE setup macro for a user to drive over * - drive a loco through an AUTOMATION @@ -10,10 +10,10 @@ * At startup, a single task is created to execute the first * instruction after E$XRAIL. * This task may simply follow a route, or may START - * further tasks (thats is.. send a loco out along a route). + * further tasks (that is.. send a loco out along a route). * * Where the loco id is not known at compile time, a new task - * can be creatd with the command: + * can be created with the command: * * * A ROUTE, AUTOMATION or SEQUENCE are internally identical in ExRail terms From 90092b4ad55a9d7d8404a55aeb887e05874fdfb5 Mon Sep 17 00:00:00 2001 From: Chris Mayo Date: Sun, 6 Mar 2022 15:07:44 +0000 Subject: [PATCH 2/4] Remove EXRAIL/ENDEXRAIL from myAutomation.example.h (#215) Use "startup sequence" to describe the initial instructions. --- myAutomation.example.h | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/myAutomation.example.h b/myAutomation.example.h index 4bb6301..1382a52 100644 --- a/myAutomation.example.h +++ b/myAutomation.example.h @@ -7,8 +7,7 @@ * - drive a loco through an AUTOMATION * - automate some cosmetic part of the layout without any loco. * - * At startup, a single task is created to execute the first - * instruction after E$XRAIL. + * At startup, a single task is created to execute the startup sequence. * This task may simply follow a route, or may START * further tasks (that is.. send a loco out along a route). * @@ -24,11 +23,10 @@ * */ -EXRAIL // myAutomation must start with the EXRAIL instruction - // This is the default starting route, AKA SEQUENCE(0) - SENDLOCO(3,1) // send loco 3 off along route 1 - SENDLOCO(10,2) // send loco 10 off along route 2 - DONE // This just ends the startup thread, leaving 2 others running. +// This is the startup sequence, AKA SEQUENCE(0) +SENDLOCO(3,1) // send loco 3 off along route 1 +SENDLOCO(10,2) // send loco 10 off along route 2 +DONE // This just ends the startup thread, leaving 2 others running. /* SEQUENCE(1) is a simple shuttle between 2 sensors * S20 and S21 are sensors on arduino pins 20 and 21 @@ -78,7 +76,3 @@ EXRAIL // myAutomation must start with the EXRAIL instruction AT(33) STOP DELAY(20000) // wait 20 seconds FOLLOW(2) // follow sequence 2... ie repeat the process - - ENDEXRAIL // marks the end of the EXRAIL program. - - From c15ea6e08348465df67b480acb53aec65004c50b Mon Sep 17 00:00:00 2001 From: Fred Date: Mon, 7 Mar 2022 08:05:02 -0500 Subject: [PATCH 3/4] Update config.example.h Add description of display scroll modes --- config.example.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/config.example.h b/config.example.h index 53d0d55..3dac207 100644 --- a/config.example.h +++ b/config.example.h @@ -129,6 +129,9 @@ The configuration file for DCC-EX Command Station // #define OLED_DRIVER 128,32 // Define scroll mode as 0, 1 or 2 +// * #define SCROLLMODE 0 is scroll continuous (fill screen if poss), +// * #define SCROLLMODE 1 is by page (alternate between pages), +// * #define SCROLLMODE 2 is by row (move up 1 row at a time). #define SCROLLMODE 1 ///////////////////////////////////////////////////////////////////////////////////// From ac3ffd2a36274198061b6ed11f1f72a9eba3669d Mon Sep 17 00:00:00 2001 From: Asbelos Date: Mon, 7 Mar 2022 16:30:47 +0000 Subject: [PATCH 4/4] Exrail BROADCAST and POWERON version 4.0.1 (#216) * EXRAIL BROADCAST("msg") UNTESTED * Add POWERON to EXRAIL * POWERON only powers main, join will do both * Update Version 4.0.1 * Broadcast jopin after driveaway * rollback of previous edit line 535 WiThrottle.cpp * restructure GetLocoCallback() for better readability and put broadcastPower() at right place Co-authored-by: Ash-4 <81280775+Ash-4@users.noreply.github.com> Co-authored-by: Harald Barth --- CommandDistributor.cpp | 5 +++++ CommandDistributor.h | 1 + DCCEX.h | 2 +- EXRAIL2.cpp | 6 ++++++ EXRAIL2.h | 2 +- EXRAIL2MacroReset.h | 4 ++++ EXRAILMacros.h | 4 ++++ WiThrottle.cpp | 43 ++++++++++++++++++++++++------------------ version.h | 4 +++- 9 files changed, 50 insertions(+), 21 deletions(-) diff --git a/CommandDistributor.cpp b/CommandDistributor.cpp index 4e5ecb9..9bde259 100644 --- a/CommandDistributor.cpp +++ b/CommandDistributor.cpp @@ -135,3 +135,8 @@ void CommandDistributor::broadcastPower() { LCD(2,F("Power %S%S"),state=='1'?F("On"):F("Off"),reason); broadcast(true); } + +void CommandDistributor::broadcastText(const FSH * msg) { + StringFormatter::send(broadcastBufferWriter,F("%S"),msg); + broadcast(false); +} diff --git a/CommandDistributor.h b/CommandDistributor.h index 51458fa..a9af3bb 100644 --- a/CommandDistributor.h +++ b/CommandDistributor.h @@ -32,6 +32,7 @@ public : static void broadcastSensor(int16_t id, bool value); static void broadcastTurnout(int16_t id, bool isClosed); static void broadcastPower(); + static void broadcastText(const FSH * msg); static void forget(byte clientId); private: static void broadcast(bool includeWithrottleClients); diff --git a/DCCEX.h b/DCCEX.h index 00d89de..d60edfa 100644 --- a/DCCEX.h +++ b/DCCEX.h @@ -43,7 +43,7 @@ #include "Turnouts.h" #include "Sensors.h" #include "Outputs.h" -#include "EXRAIL.h" #include "CommandDistributor.h" +#include "EXRAIL.h" #endif diff --git a/EXRAIL2.cpp b/EXRAIL2.cpp index 737cef6..127a1ab 100644 --- a/EXRAIL2.cpp +++ b/EXRAIL2.cpp @@ -794,6 +794,12 @@ void RMFT2::loop2() { DCC::setProgTrackSyncMain(true); CommandDistributor::broadcastPower(); break; + + case OPCODE_POWERON: + DCCWaveform::mainTrack.setPowerMode(POWERMODE::ON); + DCC::setProgTrackSyncMain(false); + CommandDistributor::broadcastPower(); + break; case OPCODE_UNJOIN: DCC::setProgTrackSyncMain(false); diff --git a/EXRAIL2.h b/EXRAIL2.h index b44ada6..3114511 100644 --- a/EXRAIL2.h +++ b/EXRAIL2.h @@ -44,7 +44,7 @@ enum OPCODE : byte {OPCODE_THROW,OPCODE_CLOSE, OPCODE_PAD,OPCODE_FOLLOW,OPCODE_CALL,OPCODE_RETURN, OPCODE_JOIN,OPCODE_UNJOIN,OPCODE_READ_LOCO1,OPCODE_READ_LOCO2,OPCODE_POM, OPCODE_START,OPCODE_SETLOCO,OPCODE_SENDLOCO, - OPCODE_PAUSE, OPCODE_RESUME,OPCODE_POWEROFF, + OPCODE_PAUSE, OPCODE_RESUME,OPCODE_POWEROFF,OPCODE_POWERON, OPCODE_ONCLOSE, OPCODE_ONTHROW, OPCODE_SERVOTURNOUT, OPCODE_PINTURNOUT, OPCODE_PRINT,OPCODE_DCCACTIVATE, OPCODE_ONACTIVATE,OPCODE_ONDEACTIVATE,OPCODE_IFGTE,OPCODE_IFLT, diff --git a/EXRAIL2MacroReset.h b/EXRAIL2MacroReset.h index 852eb70..6a28b7f 100644 --- a/EXRAIL2MacroReset.h +++ b/EXRAIL2MacroReset.h @@ -32,6 +32,7 @@ #undef ATTIMEOUT #undef AUTOMATION #undef AUTOSTART +#undef BROADCAST #undef CALL #undef CLOSE #undef DEACTIVATE @@ -79,6 +80,7 @@ #undef PRINT #undef POM #undef POWEROFF +#undef POWERON #undef READ_LOCO #undef RED #undef RESERVE @@ -121,6 +123,7 @@ #define ATTIMEOUT(sensor_id,timeout_ms) #define AUTOMATION(id, description) #define AUTOSTART +#define BROADCAST(msg) #define CALL(route) #define CLOSE(id) #define DEACTIVATE(addr,subaddr) @@ -168,6 +171,7 @@ #define PRINT(msg) #define POM(cv,value) #define POWEROFF +#define POWERON #define READ_LOCO #define RED(signal_id) #define RESERVE(blockid) diff --git a/EXRAILMacros.h b/EXRAILMacros.h index 7efb445..aa8c971 100644 --- a/EXRAILMacros.h +++ b/EXRAILMacros.h @@ -69,6 +69,8 @@ void RMFT2::emitWithrottleDescriptions(Print * stream) { // Pass 3... Create Text sending functions #include "EXRAIL2MacroReset.h" const int StringMacroTracker1=__COUNTER__; +#undef BROADCAST +#define BROADCAST(msg) case (__COUNTER__ - StringMacroTracker1) : CommandDistributor::broadcastText(F(msg));break; #undef PRINT #define PRINT(msg) case (__COUNTER__ - StringMacroTracker1) : printMessage2(F(msg));break; #undef LCN @@ -170,6 +172,7 @@ const FLASH int16_t RMFT2::SignalDefinitions[] = { #define ATTIMEOUT(sensor_id,timeout) OPCODE_ATTIMEOUT1,0,0,OPCODE_ATTIMEOUT2,V(sensor_id),OPCODE_PAD,V(timeout/100L), #define AUTOMATION(id, description) OPCODE_AUTOMATION, V(id), #define AUTOSTART OPCODE_AUTOSTART,0,0, +#define BROADCAST(msg) PRINT(msg) #define CALL(route) OPCODE_CALL,V(route), #define CLOSE(id) OPCODE_CLOSE,V(id), #define DEACTIVATE(addr,subaddr) OPCODE_DCCACTIVATE,V(addr<<3 | subaddr<<1), @@ -216,6 +219,7 @@ const FLASH int16_t RMFT2::SignalDefinitions[] = { #define PIN_TURNOUT(id,pin,description...) OPCODE_PINTURNOUT,V(id),OPCODE_PAD,V(pin), #define POM(cv,value) OPCODE_POM,V(cv),OPCODE_PAD,V(value), #define POWEROFF OPCODE_POWEROFF,0,0, +#define POWERON OPCODE_POWERON,0,0, #define PRINT(msg) OPCODE_PRINT,V(__COUNTER__ - StringMacroTracker2), #define READ_LOCO OPCODE_READ_LOCO1,0,0,OPCODE_READ_LOCO2,0,0, #define RED(signal_id) OPCODE_RED,V(signal_id), diff --git a/WiThrottle.cpp b/WiThrottle.cpp index 312cf93..d91745c 100644 --- a/WiThrottle.cpp +++ b/WiThrottle.cpp @@ -514,25 +514,32 @@ char WiThrottle::stashThrottleChar; void WiThrottle::getLocoCallback(int16_t locoid) { stashStream->mark(stashClient); - if (locoid<=0) + if (locoid<=0) { StringFormatter::send(stashStream,F("HMNo loco found on prog track\n")); - else { - // short or long - char addrchar; - if (locoid & LONG_ADDR_MARKER) { // long addr - locoid = locoid ^ LONG_ADDR_MARKER; - addrchar = 'L'; - } else - addrchar = 'S'; - if (addrchar == 'L' && locoid <= HIGHEST_SHORT_ADDR ) - StringFormatter::send(stashStream,F("HMLong addr %d <= %d not supported\n"), locoid,HIGHEST_SHORT_ADDR); - else { - char addcmd[20]={'M',stashThrottleChar,'+', addrchar}; - itoa(locoid,addcmd+4,10); - stashInstance->multithrottle(stashStream, (byte *)addcmd); - DCCWaveform::progTrack.setPowerMode(POWERMODE::ON); - DCC::setProgTrackSyncMain(true); // <1 JOIN> so we can drive loco away - } + stashStream->commit(); // done here, commit and return + return; } + + // short or long + char addrchar; + if (locoid & LONG_ADDR_MARKER) { // maker bit indicates long addr + locoid = locoid ^ LONG_ADDR_MARKER; // remove marker bit to get real long addr + if (locoid <= HIGHEST_SHORT_ADDR ) { // out of range for long addr + StringFormatter::send(stashStream,F("HMLong addr %d <= %d unsupported\n"), locoid, HIGHEST_SHORT_ADDR); + stashStream->commit(); // done here, commit and return + return; + } + addrchar = 'L'; + } else { + addrchar = 'S'; + } + + char addcmd[20]={'M',stashThrottleChar,'+', addrchar}; + itoa(locoid,addcmd+4,10); + stashInstance->multithrottle(stashStream, (byte *)addcmd); + DCCWaveform::progTrack.setPowerMode(POWERMODE::ON); + DCC::setProgTrackSyncMain(true); // <1 JOIN> so we can drive loco away stashStream->commit(); + CommandDistributor::broadcastPower(); + } diff --git a/version.h b/version.h index 6a4c485..2889212 100644 --- a/version.h +++ b/version.h @@ -3,7 +3,9 @@ #include "StringFormatter.h" -#define VERSION "4.0.0" +#define VERSION "4.0.1" +// 4.0.1 EXRAIL BROADCAST("msg") +// EXRAIL POWERON // 4.0.0 Major functional and non-functional changes. // Engine Driver "DriveAway" feature enhancement //.......JMRI feature enhancement. Provides for multiple additional DCC++EX wifi