2020-07-03 18:35:02 +02:00
|
|
|
/*
|
2022-05-17 12:06:08 +02:00
|
|
|
* © 2022 Paul M Antoine
|
2022-01-07 02:28:35 +01:00
|
|
|
* © 2021 Neil McKechnie
|
|
|
|
* © 2021 Mike S
|
|
|
|
* © 2021 Herb Morton
|
2023-04-23 22:45:47 +02:00
|
|
|
* © 2020-2023 Harald Barth
|
2022-01-07 02:28:35 +01:00
|
|
|
* © 2020-2021 M Steve Todd
|
|
|
|
* © 2020-2021 Fred Decker
|
|
|
|
* © 2020-2021 Chris Harlow
|
2023-04-19 20:45:40 +02:00
|
|
|
* © 2022 Colin Murdoch
|
2022-01-07 02:28:35 +01:00
|
|
|
* All rights reserved.
|
2020-07-03 18:35:02 +02:00
|
|
|
*
|
2020-09-25 22:14:20 +02:00
|
|
|
* This file is part of CommandStation-EX
|
2020-07-03 18:35:02 +02:00
|
|
|
*
|
|
|
|
* This is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* It is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with CommandStation. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
*/
|
2020-06-10 18:31:26 +02:00
|
|
|
#include "StringFormatter.h"
|
2020-06-04 21:55:18 +02:00
|
|
|
#include "DCCEXParser.h"
|
2020-05-25 14:38:18 +02:00
|
|
|
#include "DCC.h"
|
|
|
|
#include "DCCWaveform.h"
|
2020-06-03 15:26:49 +02:00
|
|
|
#include "Turnouts.h"
|
|
|
|
#include "Outputs.h"
|
|
|
|
#include "Sensors.h"
|
2020-09-20 01:59:07 +02:00
|
|
|
#include "GITHUB_SHA.h"
|
2020-09-24 03:54:01 +02:00
|
|
|
#include "version.h"
|
2021-08-27 22:43:24 +02:00
|
|
|
#include "defines.h"
|
2021-12-05 13:08:59 +01:00
|
|
|
#include "CommandDistributor.h"
|
2020-06-03 15:26:49 +02:00
|
|
|
#include "EEStore.h"
|
2020-06-11 14:35:16 +02:00
|
|
|
#include "DIAG.h"
|
2022-02-22 02:27:27 +01:00
|
|
|
#include "TrackManager.h"
|
2022-03-01 13:52:25 +01:00
|
|
|
#include "DCCTimer.h"
|
2022-04-08 12:41:50 +02:00
|
|
|
#include "EXRAIL2.h"
|
2023-08-22 11:30:22 +02:00
|
|
|
#include "Turntables.h"
|
2022-07-08 16:01:40 +02:00
|
|
|
|
2022-12-16 14:14:48 +01:00
|
|
|
// This macro can't be created easily as a portable function because the
|
|
|
|
// flashlist requires a far pointer for high flash access.
|
|
|
|
#define SENDFLASHLIST(stream,flashList) \
|
|
|
|
for (int16_t i=0;;i+=sizeof(flashList[0])) { \
|
|
|
|
int16_t value=GETHIGHFLASHW(flashList,i); \
|
2023-05-23 10:57:45 +02:00
|
|
|
if (value==INT16_MAX) break; \
|
2023-05-24 13:31:18 +02:00
|
|
|
if (value != 0) StringFormatter::send(stream,F(" %d"),value); \
|
2022-12-16 14:14:48 +01:00
|
|
|
}
|
2020-06-03 15:26:49 +02:00
|
|
|
|
2021-08-23 12:58:48 +02:00
|
|
|
|
2020-07-30 16:34:56 +02:00
|
|
|
// These keywords are used in the <1> command. The number is what you get if you use the keyword as a parameter.
|
|
|
|
// To discover new keyword numbers , use the <$ YOURKEYWORD> command
|
2021-03-25 18:16:12 +01:00
|
|
|
const int16_t HASH_KEYWORD_MAIN = 11339;
|
|
|
|
const int16_t HASH_KEYWORD_CABS = -11981;
|
|
|
|
const int16_t HASH_KEYWORD_RAM = 25982;
|
|
|
|
const int16_t HASH_KEYWORD_CMD = 9962;
|
|
|
|
const int16_t HASH_KEYWORD_ACK = 3113;
|
|
|
|
const int16_t HASH_KEYWORD_ON = 2657;
|
|
|
|
const int16_t HASH_KEYWORD_DCC = 6436;
|
|
|
|
const int16_t HASH_KEYWORD_SLOW = -17209;
|
2023-04-23 20:24:29 +02:00
|
|
|
#ifndef DISABLE_PROG
|
2023-04-23 22:45:47 +02:00
|
|
|
const int16_t HASH_KEYWORD_JOIN = -30750;
|
2023-04-23 20:24:29 +02:00
|
|
|
const int16_t HASH_KEYWORD_PROG = -29718;
|
2021-03-25 18:16:12 +01:00
|
|
|
const int16_t HASH_KEYWORD_PROGBOOST = -6353;
|
2023-04-23 20:24:29 +02:00
|
|
|
#endif
|
2021-11-08 02:07:21 +01:00
|
|
|
#ifndef DISABLE_EEPROM
|
2021-03-25 18:16:12 +01:00
|
|
|
const int16_t HASH_KEYWORD_EEPROM = -7168;
|
2021-11-08 02:07:21 +01:00
|
|
|
#endif
|
2021-03-25 18:16:12 +01:00
|
|
|
const int16_t HASH_KEYWORD_LIMIT = 27413;
|
|
|
|
const int16_t HASH_KEYWORD_MAX = 16244;
|
|
|
|
const int16_t HASH_KEYWORD_MIN = 15978;
|
2021-03-25 19:02:33 +01:00
|
|
|
const int16_t HASH_KEYWORD_RESET = 26133;
|
2021-08-23 12:58:48 +02:00
|
|
|
const int16_t HASH_KEYWORD_RETRY = 25704;
|
2021-04-06 22:00:33 +02:00
|
|
|
const int16_t HASH_KEYWORD_SPEED28 = -17064;
|
|
|
|
const int16_t HASH_KEYWORD_SPEED128 = 25816;
|
2021-08-19 22:22:59 +02:00
|
|
|
const int16_t HASH_KEYWORD_SERVO=27709;
|
2022-08-13 22:58:20 +02:00
|
|
|
const int16_t HASH_KEYWORD_TT=2688;
|
2021-08-19 22:22:59 +02:00
|
|
|
const int16_t HASH_KEYWORD_VPIN=-415;
|
2022-04-08 12:41:50 +02:00
|
|
|
const int16_t HASH_KEYWORD_A='A';
|
|
|
|
const int16_t HASH_KEYWORD_C='C';
|
2023-03-02 13:56:30 +01:00
|
|
|
const int16_t HASH_KEYWORD_G='G';
|
|
|
|
const int16_t HASH_KEYWORD_I='I';
|
2022-04-08 12:41:50 +02:00
|
|
|
const int16_t HASH_KEYWORD_R='R';
|
|
|
|
const int16_t HASH_KEYWORD_T='T';
|
2022-11-05 23:11:54 +01:00
|
|
|
const int16_t HASH_KEYWORD_X='X';
|
2021-08-23 12:58:48 +02:00
|
|
|
const int16_t HASH_KEYWORD_LCN = 15137;
|
2021-08-27 16:44:26 +02:00
|
|
|
const int16_t HASH_KEYWORD_HAL = 10853;
|
|
|
|
const int16_t HASH_KEYWORD_SHOW = -21309;
|
2021-10-08 14:30:23 +02:00
|
|
|
const int16_t HASH_KEYWORD_ANIN = -10424;
|
|
|
|
const int16_t HASH_KEYWORD_ANOUT = -26399;
|
2021-08-23 12:58:48 +02:00
|
|
|
const int16_t HASH_KEYWORD_WIFI = -5583;
|
|
|
|
const int16_t HASH_KEYWORD_ETHERNET = -30767;
|
|
|
|
const int16_t HASH_KEYWORD_WIT = 31594;
|
2023-08-20 22:43:06 +02:00
|
|
|
const int16_t HASH_KEYWORD_EXTT = 8573;
|
2021-03-25 18:16:12 +01:00
|
|
|
|
|
|
|
int16_t DCCEXParser::stashP[MAX_COMMAND_PARAMS];
|
2020-06-11 14:35:16 +02:00
|
|
|
bool DCCEXParser::stashBusy;
|
2020-09-25 19:51:08 +02:00
|
|
|
Print *DCCEXParser::stashStream = NULL;
|
2021-03-08 11:40:32 +01:00
|
|
|
RingStream *DCCEXParser::stashRingStream = NULL;
|
|
|
|
byte DCCEXParser::stashTarget=0;
|
2020-06-10 18:31:26 +02:00
|
|
|
|
2022-04-19 10:35:03 +02:00
|
|
|
// This is a JMRI command parser.
|
2020-05-25 14:38:18 +02:00
|
|
|
// It doesnt know how the string got here, nor how it gets back.
|
|
|
|
// It knows nothing about hardware or tracks... it just parses strings and
|
|
|
|
// calls the corresponding DCC api.
|
2020-09-25 19:51:08 +02:00
|
|
|
// Non-DCC things like turnouts, pins and sensors are handled in additional JMRI interface classes.
|
2020-06-03 15:26:49 +02:00
|
|
|
|
2020-09-25 19:51:08 +02:00
|
|
|
|
2021-12-16 12:23:20 +01:00
|
|
|
int16_t DCCEXParser::splitValues(int16_t result[MAX_COMMAND_PARAMS], const byte *cmd, bool usehex)
|
2020-09-25 19:51:08 +02:00
|
|
|
{
|
|
|
|
byte state = 1;
|
|
|
|
byte parameterCount = 0;
|
2021-03-25 18:16:12 +01:00
|
|
|
int16_t runningValue = 0;
|
2020-09-25 19:51:08 +02:00
|
|
|
const byte *remainingCmd = cmd + 1; // skips the opcode
|
|
|
|
bool signNegative = false;
|
|
|
|
|
|
|
|
// clear all parameters in case not enough found
|
2021-03-25 18:16:12 +01:00
|
|
|
for (int16_t i = 0; i < MAX_COMMAND_PARAMS; i++)
|
2020-09-25 19:51:08 +02:00
|
|
|
result[i] = 0;
|
|
|
|
|
Nano every2 (#129)
* Start adding back unowifi stuffz
* Uno Wifi compiling
* Fixes for compile arduino unowifi r2
* FlasString and Timers for Uno Wifi
ALL these changes should be portable back to master
* Remove extra timer that was already added
* Changed to EveryTimerB
* Add everytimerb.h
* Cleanup
* Linear address <a> cmd
* Allow lower case keywords
* Add the F define to be on safe side if it is not present in the library core code
* Clean simple Timer interface
Removes overkill files, puts all timer in a single small file. (DCCTimer)
* Timer port
* Timer working
And slow wave command removed
* Correcting non-portables merged from master
* Wave-state machine ( part 11)
* Microtuning waveform
Significant reduction in code paths and call overheads
* Current check cleanup
* Fix no-loco id
Has to handle -1 correctly
* fix wrong format letter
* redo flow through wifisetup again
* version++
* bugfixes wifi setup
* Retry harder for AP mode
* Remove unued if
* DIO2 replacement
Currently for writing signal pins during waveform.
* Drop analogReadFast (see DCCTimer)
AnalogRead speed set in DCCTimer for ease of porting.
Code tidy and diagnostics in MotorDriver
* UNTESTED fast power,brake,fault pins
* Distunguish between in/out of FASTPIN
* minor performance tweaks
* Config comments and example use
* Config/example loading
* IP/PORT on LCD
* Ethernet simulated mac
Plus fixed listening port
* Github SHA
* Committing a SHA
* Fix for nano compile
* Comments and a reliability fix.
* UnoRev2 protection
* PWM pin implementation
* fix wifi setup issue
* Reinstate IP_PORT
* Wifi channel and code cleaninga
* Reduce duplicated F() macros
Compiler isn't as clever as one might expect
* Committing a SHA
* Update config.example.h
Add comment to wifi channel section
* Committing a SHA
* Handle shields with common fault pins (Pololu)
* Committing a SHA
* remove warning
* Committing a SHA
* only do the sha generation on master
* yaml syntax
* Fast SSD1306 OLED driver
Incorporate code from SSD1306Ascii library to speed up OLED screen updates, reduce memory requirements and eliminate some library dependences.
* Fix auto-configure from cold boot.
Add call to Wire.begin().
* Update comment for OLED_DRIVER define.
* Update MotorDrivers.h
Add a motor board definition for using the IBT_2 board for a high current to the main track and keep the Arduino Motor Shield for operating the programming track.
* Committing a SHA
* Fix missing F in motor drivers
* JOIN relay pin
* Swap Join Relay high/low
* Hide WIFI_CONNECT_TIMEOUT
This is not what the config suggests it is... The timeout is in the ES and defaults to 15 seconds. Abandoning it early leads to confused setup.
* Enhance OLED/LCD speed
Write one character or position command per loop entry so as not to hold up the loop. Add support for SH1106 OLED as 132x64 size option.
* Enhance OLED/LCD speed
* Delete comment about OLED on UNO.
* Trim unwanted code
* Handle display types correctly
* Update comments
* Speed up OLED writes
Add new flushDisplay() to end any in-progress I2C transaction. Previously, an redundant command was sent that ended the in-progress transaction but also sent another complete, but unnecessary, transaction.
* Comments and copyright update
* Reduce RAM and flash requirement a few more bytes.
* Move statics into LCDDisplay class, and reduce RAM.
Some state variables were static in LCDDisplay.write(). Moved to class members. Also, types of data items like row, column & character position changed to int8_t to save a few bytes of RAM.
* Type lcdCols and lcdRows to unsigned.
Since lcdCols is normally 128, it needs to be uint8_t, not int8_t.
* remove timeout from user config
* faultpin is common only if it exists ; make code prettier
* Rationalisation of SSD1306 driver
Merge SSD1306AsciiWire.cpp into SSD1306Ascii.cpp and rename SSD1306AsciiWire.h as SSD1306Ascii.h.
Merge allFonts.h into System5x7.h and rename as SSD1306font.h.
Move all SSD1306 files into root folder to facilitate compilation in Arduino IDE.
* Fix some font attributes as const.
* Remove unused initialisation sequences for tiny oled screens
* Add m_ to variables
* Bump up I2C speed
Speed was 100kHz (default). Max for OLEDis 400kHz.
* Revert "Bump up I2C speed"
This reverts commit 1c1168f43314d3a6855738fbc406d5654e801831.
* Bump up I2C speed
Speed was 100kHz (default). Max for OLEDis 400kHz.
* Drop duplicate DIAG
* ignore mySetup.h files
* Restore uno to default_envs
Restore uno (previously commented out) to default_envs.
* Update objdump.bat
Allows other editors as Notepad is very slow on large files
* Prog Track overload during cv read
* Faster LCD Driver
Extract LCD driver from library;
Trim unused functionality;
Reduce I2C communications to minimum;
Speed up I2C clock to 400kHz.
* Update config.example.h
Add IBT_2_WITH_ARDUINO to example config
* Update config.example.h
* Screen enhancements (#126)
* Add I2CManager to coordinate I2C shared parameters.
* Add use of I2CManager, and experimental scrolling strategies.
New scrolling capability by defining SCROLLMODE in Config.h to 0 (original), 1 (by page) or 2 (by line). If not defined, defaults to 0.
* Scrolling updates
New scrolling capability by defining SCROLLMODE in Config.h to 0 (original), 1 (by page) or 2 (by line). If not defined, defaults to 0.
Reformat.
* Add I2CManager calls. Remove unnecessary delays.
* Add I2CManager calls, remove unnecessary I2C delays.
* SSD1306: Move methods from .h to .cpp and reformat.
* Fix compiler warning in LiquidCrystal_I2C
* Allow forcing of I2C clock speed.
New method forceClock allows the I2C speed to be overridden. For example, if the I2C bus is long then the speed can be forced lower. It can also be forced higher to gain performance if devices are capable.
* Make Config.h conditionally included.
Allow for non-existence of Config.h.
* Correct scrolling and allow longer messages
Correct the handling of scrolling in scrollmode 1 to avoid a blank page being displayed. Also, allow MAX_MSG_SIZE to be optionally configured to override maximum message length on screens.
* compiler warning on uno
Co-authored-by: dexslab <dex35803@gmail.com>
Co-authored-by: Asbelos <asbelos@btinternet.com>
Co-authored-by: Harald Barth <haba@kth.se>
Co-authored-by: Neil McKechnie <neilmck999@gmail.com>
Co-authored-by: Neil McKechnie <75813993+Neil-McK@users.noreply.github.com>
2021-03-07 21:58:35 +01:00
|
|
|
while (parameterCount < MAX_COMMAND_PARAMS)
|
2020-09-25 19:51:08 +02:00
|
|
|
{
|
|
|
|
byte hot = *remainingCmd;
|
|
|
|
|
|
|
|
switch (state)
|
|
|
|
{
|
|
|
|
|
|
|
|
case 1: // skipping spaces before a param
|
|
|
|
if (hot == ' ')
|
|
|
|
break;
|
|
|
|
if (hot == '\0' || hot == '>')
|
|
|
|
return parameterCount;
|
|
|
|
state = 2;
|
|
|
|
continue;
|
|
|
|
|
|
|
|
case 2: // checking sign
|
|
|
|
signNegative = false;
|
|
|
|
runningValue = 0;
|
|
|
|
state = 3;
|
|
|
|
if (hot != '-')
|
|
|
|
continue;
|
|
|
|
signNegative = true;
|
|
|
|
break;
|
|
|
|
case 3: // building a parameter
|
|
|
|
if (hot >= '0' && hot <= '9')
|
|
|
|
{
|
2021-12-16 12:23:20 +01:00
|
|
|
runningValue = (usehex?16:10) * runningValue + (hot - '0');
|
2020-09-25 19:51:08 +02:00
|
|
|
break;
|
|
|
|
}
|
Nano every2 (#129)
* Start adding back unowifi stuffz
* Uno Wifi compiling
* Fixes for compile arduino unowifi r2
* FlasString and Timers for Uno Wifi
ALL these changes should be portable back to master
* Remove extra timer that was already added
* Changed to EveryTimerB
* Add everytimerb.h
* Cleanup
* Linear address <a> cmd
* Allow lower case keywords
* Add the F define to be on safe side if it is not present in the library core code
* Clean simple Timer interface
Removes overkill files, puts all timer in a single small file. (DCCTimer)
* Timer port
* Timer working
And slow wave command removed
* Correcting non-portables merged from master
* Wave-state machine ( part 11)
* Microtuning waveform
Significant reduction in code paths and call overheads
* Current check cleanup
* Fix no-loco id
Has to handle -1 correctly
* fix wrong format letter
* redo flow through wifisetup again
* version++
* bugfixes wifi setup
* Retry harder for AP mode
* Remove unued if
* DIO2 replacement
Currently for writing signal pins during waveform.
* Drop analogReadFast (see DCCTimer)
AnalogRead speed set in DCCTimer for ease of porting.
Code tidy and diagnostics in MotorDriver
* UNTESTED fast power,brake,fault pins
* Distunguish between in/out of FASTPIN
* minor performance tweaks
* Config comments and example use
* Config/example loading
* IP/PORT on LCD
* Ethernet simulated mac
Plus fixed listening port
* Github SHA
* Committing a SHA
* Fix for nano compile
* Comments and a reliability fix.
* UnoRev2 protection
* PWM pin implementation
* fix wifi setup issue
* Reinstate IP_PORT
* Wifi channel and code cleaninga
* Reduce duplicated F() macros
Compiler isn't as clever as one might expect
* Committing a SHA
* Update config.example.h
Add comment to wifi channel section
* Committing a SHA
* Handle shields with common fault pins (Pololu)
* Committing a SHA
* remove warning
* Committing a SHA
* only do the sha generation on master
* yaml syntax
* Fast SSD1306 OLED driver
Incorporate code from SSD1306Ascii library to speed up OLED screen updates, reduce memory requirements and eliminate some library dependences.
* Fix auto-configure from cold boot.
Add call to Wire.begin().
* Update comment for OLED_DRIVER define.
* Update MotorDrivers.h
Add a motor board definition for using the IBT_2 board for a high current to the main track and keep the Arduino Motor Shield for operating the programming track.
* Committing a SHA
* Fix missing F in motor drivers
* JOIN relay pin
* Swap Join Relay high/low
* Hide WIFI_CONNECT_TIMEOUT
This is not what the config suggests it is... The timeout is in the ES and defaults to 15 seconds. Abandoning it early leads to confused setup.
* Enhance OLED/LCD speed
Write one character or position command per loop entry so as not to hold up the loop. Add support for SH1106 OLED as 132x64 size option.
* Enhance OLED/LCD speed
* Delete comment about OLED on UNO.
* Trim unwanted code
* Handle display types correctly
* Update comments
* Speed up OLED writes
Add new flushDisplay() to end any in-progress I2C transaction. Previously, an redundant command was sent that ended the in-progress transaction but also sent another complete, but unnecessary, transaction.
* Comments and copyright update
* Reduce RAM and flash requirement a few more bytes.
* Move statics into LCDDisplay class, and reduce RAM.
Some state variables were static in LCDDisplay.write(). Moved to class members. Also, types of data items like row, column & character position changed to int8_t to save a few bytes of RAM.
* Type lcdCols and lcdRows to unsigned.
Since lcdCols is normally 128, it needs to be uint8_t, not int8_t.
* remove timeout from user config
* faultpin is common only if it exists ; make code prettier
* Rationalisation of SSD1306 driver
Merge SSD1306AsciiWire.cpp into SSD1306Ascii.cpp and rename SSD1306AsciiWire.h as SSD1306Ascii.h.
Merge allFonts.h into System5x7.h and rename as SSD1306font.h.
Move all SSD1306 files into root folder to facilitate compilation in Arduino IDE.
* Fix some font attributes as const.
* Remove unused initialisation sequences for tiny oled screens
* Add m_ to variables
* Bump up I2C speed
Speed was 100kHz (default). Max for OLEDis 400kHz.
* Revert "Bump up I2C speed"
This reverts commit 1c1168f43314d3a6855738fbc406d5654e801831.
* Bump up I2C speed
Speed was 100kHz (default). Max for OLEDis 400kHz.
* Drop duplicate DIAG
* ignore mySetup.h files
* Restore uno to default_envs
Restore uno (previously commented out) to default_envs.
* Update objdump.bat
Allows other editors as Notepad is very slow on large files
* Prog Track overload during cv read
* Faster LCD Driver
Extract LCD driver from library;
Trim unused functionality;
Reduce I2C communications to minimum;
Speed up I2C clock to 400kHz.
* Update config.example.h
Add IBT_2_WITH_ARDUINO to example config
* Update config.example.h
* Screen enhancements (#126)
* Add I2CManager to coordinate I2C shared parameters.
* Add use of I2CManager, and experimental scrolling strategies.
New scrolling capability by defining SCROLLMODE in Config.h to 0 (original), 1 (by page) or 2 (by line). If not defined, defaults to 0.
* Scrolling updates
New scrolling capability by defining SCROLLMODE in Config.h to 0 (original), 1 (by page) or 2 (by line). If not defined, defaults to 0.
Reformat.
* Add I2CManager calls. Remove unnecessary delays.
* Add I2CManager calls, remove unnecessary I2C delays.
* SSD1306: Move methods from .h to .cpp and reformat.
* Fix compiler warning in LiquidCrystal_I2C
* Allow forcing of I2C clock speed.
New method forceClock allows the I2C speed to be overridden. For example, if the I2C bus is long then the speed can be forced lower. It can also be forced higher to gain performance if devices are capable.
* Make Config.h conditionally included.
Allow for non-existence of Config.h.
* Correct scrolling and allow longer messages
Correct the handling of scrolling in scrollmode 1 to avoid a blank page being displayed. Also, allow MAX_MSG_SIZE to be optionally configured to override maximum message length on screens.
* compiler warning on uno
Co-authored-by: dexslab <dex35803@gmail.com>
Co-authored-by: Asbelos <asbelos@btinternet.com>
Co-authored-by: Harald Barth <haba@kth.se>
Co-authored-by: Neil McKechnie <neilmck999@gmail.com>
Co-authored-by: Neil McKechnie <75813993+Neil-McK@users.noreply.github.com>
2021-03-07 21:58:35 +01:00
|
|
|
if (hot >= 'a' && hot <= 'z') hot=hot-'a'+'A'; // uppercase a..z
|
2021-12-16 12:23:20 +01:00
|
|
|
if (usehex && hot>='A' && hot<='F') {
|
|
|
|
// treat A..F as hex not keyword
|
|
|
|
runningValue = 16 * runningValue + (hot - 'A' + 10);
|
|
|
|
break;
|
|
|
|
}
|
2022-03-21 17:29:35 +01:00
|
|
|
if (hot=='_' || (hot >= 'A' && hot <= 'Z'))
|
2020-09-25 19:51:08 +02:00
|
|
|
{
|
|
|
|
// Since JMRI got modified to send keywords in some rare cases, we need this
|
|
|
|
// Super Kluge to turn keywords into a hash value that can be recognised later
|
|
|
|
runningValue = ((runningValue << 5) + runningValue) ^ hot;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
result[parameterCount] = runningValue * (signNegative ? -1 : 1);
|
|
|
|
parameterCount++;
|
|
|
|
state = 1;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
remainingCmd++;
|
2020-06-10 18:31:26 +02:00
|
|
|
}
|
2020-09-25 19:51:08 +02:00
|
|
|
return parameterCount;
|
2020-06-10 18:31:26 +02:00
|
|
|
}
|
2020-05-25 14:38:18 +02:00
|
|
|
|
2022-04-20 10:10:27 +02:00
|
|
|
extern __attribute__((weak)) void myFilter(Print * stream, byte & opcode, byte & paramCount, int16_t p[]);
|
2022-04-19 10:35:03 +02:00
|
|
|
FILTER_CALLBACK DCCEXParser::filterCallback = myFilter;
|
2021-01-05 19:05:17 +01:00
|
|
|
FILTER_CALLBACK DCCEXParser::filterRMFTCallback = 0;
|
2020-09-26 11:54:11 +02:00
|
|
|
AT_COMMAND_CALLBACK DCCEXParser::atCommandCallback = 0;
|
2022-04-19 10:35:03 +02:00
|
|
|
|
|
|
|
// deprecated
|
2020-09-25 19:51:08 +02:00
|
|
|
void DCCEXParser::setFilter(FILTER_CALLBACK filter)
|
|
|
|
{
|
|
|
|
filterCallback = filter;
|
2020-06-18 20:36:37 +02:00
|
|
|
}
|
2021-01-05 19:05:17 +01:00
|
|
|
void DCCEXParser::setRMFTFilter(FILTER_CALLBACK filter)
|
|
|
|
{
|
|
|
|
filterRMFTCallback = filter;
|
|
|
|
}
|
2020-09-26 11:54:11 +02:00
|
|
|
void DCCEXParser::setAtCommandCallback(AT_COMMAND_CALLBACK callback)
|
|
|
|
{
|
|
|
|
atCommandCallback = callback;
|
|
|
|
}
|
2020-09-25 19:51:08 +02:00
|
|
|
|
2021-01-07 21:58:23 +01:00
|
|
|
// Parse an F() string
|
Nano every2 (#129)
* Start adding back unowifi stuffz
* Uno Wifi compiling
* Fixes for compile arduino unowifi r2
* FlasString and Timers for Uno Wifi
ALL these changes should be portable back to master
* Remove extra timer that was already added
* Changed to EveryTimerB
* Add everytimerb.h
* Cleanup
* Linear address <a> cmd
* Allow lower case keywords
* Add the F define to be on safe side if it is not present in the library core code
* Clean simple Timer interface
Removes overkill files, puts all timer in a single small file. (DCCTimer)
* Timer port
* Timer working
And slow wave command removed
* Correcting non-portables merged from master
* Wave-state machine ( part 11)
* Microtuning waveform
Significant reduction in code paths and call overheads
* Current check cleanup
* Fix no-loco id
Has to handle -1 correctly
* fix wrong format letter
* redo flow through wifisetup again
* version++
* bugfixes wifi setup
* Retry harder for AP mode
* Remove unued if
* DIO2 replacement
Currently for writing signal pins during waveform.
* Drop analogReadFast (see DCCTimer)
AnalogRead speed set in DCCTimer for ease of porting.
Code tidy and diagnostics in MotorDriver
* UNTESTED fast power,brake,fault pins
* Distunguish between in/out of FASTPIN
* minor performance tweaks
* Config comments and example use
* Config/example loading
* IP/PORT on LCD
* Ethernet simulated mac
Plus fixed listening port
* Github SHA
* Committing a SHA
* Fix for nano compile
* Comments and a reliability fix.
* UnoRev2 protection
* PWM pin implementation
* fix wifi setup issue
* Reinstate IP_PORT
* Wifi channel and code cleaninga
* Reduce duplicated F() macros
Compiler isn't as clever as one might expect
* Committing a SHA
* Update config.example.h
Add comment to wifi channel section
* Committing a SHA
* Handle shields with common fault pins (Pololu)
* Committing a SHA
* remove warning
* Committing a SHA
* only do the sha generation on master
* yaml syntax
* Fast SSD1306 OLED driver
Incorporate code from SSD1306Ascii library to speed up OLED screen updates, reduce memory requirements and eliminate some library dependences.
* Fix auto-configure from cold boot.
Add call to Wire.begin().
* Update comment for OLED_DRIVER define.
* Update MotorDrivers.h
Add a motor board definition for using the IBT_2 board for a high current to the main track and keep the Arduino Motor Shield for operating the programming track.
* Committing a SHA
* Fix missing F in motor drivers
* JOIN relay pin
* Swap Join Relay high/low
* Hide WIFI_CONNECT_TIMEOUT
This is not what the config suggests it is... The timeout is in the ES and defaults to 15 seconds. Abandoning it early leads to confused setup.
* Enhance OLED/LCD speed
Write one character or position command per loop entry so as not to hold up the loop. Add support for SH1106 OLED as 132x64 size option.
* Enhance OLED/LCD speed
* Delete comment about OLED on UNO.
* Trim unwanted code
* Handle display types correctly
* Update comments
* Speed up OLED writes
Add new flushDisplay() to end any in-progress I2C transaction. Previously, an redundant command was sent that ended the in-progress transaction but also sent another complete, but unnecessary, transaction.
* Comments and copyright update
* Reduce RAM and flash requirement a few more bytes.
* Move statics into LCDDisplay class, and reduce RAM.
Some state variables were static in LCDDisplay.write(). Moved to class members. Also, types of data items like row, column & character position changed to int8_t to save a few bytes of RAM.
* Type lcdCols and lcdRows to unsigned.
Since lcdCols is normally 128, it needs to be uint8_t, not int8_t.
* remove timeout from user config
* faultpin is common only if it exists ; make code prettier
* Rationalisation of SSD1306 driver
Merge SSD1306AsciiWire.cpp into SSD1306Ascii.cpp and rename SSD1306AsciiWire.h as SSD1306Ascii.h.
Merge allFonts.h into System5x7.h and rename as SSD1306font.h.
Move all SSD1306 files into root folder to facilitate compilation in Arduino IDE.
* Fix some font attributes as const.
* Remove unused initialisation sequences for tiny oled screens
* Add m_ to variables
* Bump up I2C speed
Speed was 100kHz (default). Max for OLEDis 400kHz.
* Revert "Bump up I2C speed"
This reverts commit 1c1168f43314d3a6855738fbc406d5654e801831.
* Bump up I2C speed
Speed was 100kHz (default). Max for OLEDis 400kHz.
* Drop duplicate DIAG
* ignore mySetup.h files
* Restore uno to default_envs
Restore uno (previously commented out) to default_envs.
* Update objdump.bat
Allows other editors as Notepad is very slow on large files
* Prog Track overload during cv read
* Faster LCD Driver
Extract LCD driver from library;
Trim unused functionality;
Reduce I2C communications to minimum;
Speed up I2C clock to 400kHz.
* Update config.example.h
Add IBT_2_WITH_ARDUINO to example config
* Update config.example.h
* Screen enhancements (#126)
* Add I2CManager to coordinate I2C shared parameters.
* Add use of I2CManager, and experimental scrolling strategies.
New scrolling capability by defining SCROLLMODE in Config.h to 0 (original), 1 (by page) or 2 (by line). If not defined, defaults to 0.
* Scrolling updates
New scrolling capability by defining SCROLLMODE in Config.h to 0 (original), 1 (by page) or 2 (by line). If not defined, defaults to 0.
Reformat.
* Add I2CManager calls. Remove unnecessary delays.
* Add I2CManager calls, remove unnecessary I2C delays.
* SSD1306: Move methods from .h to .cpp and reformat.
* Fix compiler warning in LiquidCrystal_I2C
* Allow forcing of I2C clock speed.
New method forceClock allows the I2C speed to be overridden. For example, if the I2C bus is long then the speed can be forced lower. It can also be forced higher to gain performance if devices are capable.
* Make Config.h conditionally included.
Allow for non-existence of Config.h.
* Correct scrolling and allow longer messages
Correct the handling of scrolling in scrollmode 1 to avoid a blank page being displayed. Also, allow MAX_MSG_SIZE to be optionally configured to override maximum message length on screens.
* compiler warning on uno
Co-authored-by: dexslab <dex35803@gmail.com>
Co-authored-by: Asbelos <asbelos@btinternet.com>
Co-authored-by: Harald Barth <haba@kth.se>
Co-authored-by: Neil McKechnie <neilmck999@gmail.com>
Co-authored-by: Neil McKechnie <75813993+Neil-McK@users.noreply.github.com>
2021-03-07 21:58:35 +01:00
|
|
|
void DCCEXParser::parse(const FSH * cmd) {
|
2021-12-07 01:24:48 +01:00
|
|
|
DIAG(F("SETUP(\"%S\")"),cmd);
|
2023-01-23 23:28:43 +01:00
|
|
|
int size=STRLEN_P((char *)cmd)+1;
|
2021-01-07 21:58:23 +01:00
|
|
|
char buffer[size];
|
2023-01-23 23:28:43 +01:00
|
|
|
STRCPY_P(buffer,(char *)cmd);
|
2022-07-08 16:52:46 +02:00
|
|
|
parse(&USB_SERIAL,(byte *)buffer,NULL);
|
2021-01-07 21:58:23 +01:00
|
|
|
}
|
|
|
|
|
2020-05-25 14:38:18 +02:00
|
|
|
// See documentation on DCC class for info on this section
|
2021-08-23 12:58:48 +02:00
|
|
|
|
2022-05-13 16:18:47 +02:00
|
|
|
void DCCEXParser::parse(Print *stream, byte *com, RingStream *ringStream) {
|
|
|
|
// This function can get stings of the form "<C OMM AND>" or "C OMM AND"
|
|
|
|
// found is true first after the leading "<" has been passed
|
|
|
|
bool found = (com[0] != '<');
|
|
|
|
for (byte *c=com; c[0] != '\0'; c++) {
|
|
|
|
if (found) {
|
|
|
|
parseOne(stream, c, ringStream);
|
|
|
|
found=false;
|
|
|
|
}
|
|
|
|
if (c[0] == '<')
|
|
|
|
found = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void DCCEXParser::parseOne(Print *stream, byte *com, RingStream * ringStream)
|
2020-09-25 19:51:08 +02:00
|
|
|
{
|
2023-08-02 01:12:32 +02:00
|
|
|
#ifdef DISABLE_PROG
|
|
|
|
(void)ringStream;
|
|
|
|
#endif
|
2021-11-08 02:07:21 +01:00
|
|
|
#ifndef DISABLE_EEPROM
|
2020-10-03 14:07:25 +02:00
|
|
|
(void)EEPROM; // tell compiler not to warn this is unused
|
2021-11-08 02:07:21 +01:00
|
|
|
#endif
|
2020-09-25 19:51:08 +02:00
|
|
|
if (Diag::CMD)
|
2021-03-25 15:23:38 +01:00
|
|
|
DIAG(F("PARSING:%s"), com);
|
2021-03-25 18:16:12 +01:00
|
|
|
int16_t p[MAX_COMMAND_PARAMS];
|
2020-09-25 19:51:08 +02:00
|
|
|
while (com[0] == '<' || com[0] == ' ')
|
|
|
|
com++; // strip off any number of < or spaces
|
|
|
|
byte opcode = com[0];
|
2021-12-16 12:23:20 +01:00
|
|
|
byte params = splitValues(p, com, opcode=='M' || opcode=='P');
|
|
|
|
|
2020-09-25 19:51:08 +02:00
|
|
|
if (filterCallback)
|
|
|
|
filterCallback(stream, opcode, params, p);
|
2021-01-05 19:05:17 +01:00
|
|
|
if (filterRMFTCallback && opcode!='\0')
|
|
|
|
filterRMFTCallback(stream, opcode, params, p);
|
2020-09-25 19:51:08 +02:00
|
|
|
|
2020-06-03 15:26:49 +02:00
|
|
|
// Functions return from this switch if complete, break from switch implies error <X> to send
|
2020-09-25 19:51:08 +02:00
|
|
|
switch (opcode)
|
|
|
|
{
|
|
|
|
case '\0':
|
|
|
|
return; // filterCallback asked us to ignore
|
|
|
|
case 't': // THROTTLE <t [REGISTER] CAB SPEED DIRECTION>
|
|
|
|
{
|
2022-04-12 19:47:06 +02:00
|
|
|
if (params==1) { // <t cab> display state
|
|
|
|
|
|
|
|
int16_t slot=DCC::lookupSpeedTable(p[0],false);
|
|
|
|
if (slot>=0) {
|
|
|
|
DCC::LOCO * sp=&DCC::speedTable[slot];
|
|
|
|
StringFormatter::send(stream,F("<l %d %d %d %l>\n"),
|
|
|
|
sp->loco,slot,sp->speedCode,sp->functions);
|
|
|
|
}
|
|
|
|
else // send dummy state speed 0 fwd no functions.
|
|
|
|
StringFormatter::send(stream,F("<l %d -1 128 0>\n"),p[0]);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2021-03-25 18:16:12 +01:00
|
|
|
int16_t cab;
|
|
|
|
int16_t tspeed;
|
|
|
|
int16_t direction;
|
2022-04-12 19:47:06 +02:00
|
|
|
|
2020-09-25 19:51:08 +02:00
|
|
|
if (params == 4)
|
|
|
|
{ // <t REGISTER CAB SPEED DIRECTION>
|
|
|
|
cab = p[1];
|
|
|
|
tspeed = p[2];
|
|
|
|
direction = p[3];
|
|
|
|
}
|
|
|
|
else if (params == 3)
|
|
|
|
{ // <t CAB SPEED DIRECTION>
|
|
|
|
cab = p[0];
|
|
|
|
tspeed = p[1];
|
|
|
|
direction = p[2];
|
2020-07-23 16:41:43 +02:00
|
|
|
}
|
2020-09-25 19:51:08 +02:00
|
|
|
else
|
|
|
|
break;
|
|
|
|
|
2020-12-11 19:03:05 +01:00
|
|
|
// Convert DCC-EX protocol speed steps where
|
|
|
|
// -1=emergency stop, 0-126 as speeds
|
2020-09-25 19:51:08 +02:00
|
|
|
// to DCC 0=stop, 1= emergency stop, 2-127 speeds
|
|
|
|
if (tspeed > 126 || tspeed < -1)
|
|
|
|
break; // invalid JMRI speed code
|
|
|
|
if (tspeed < 0)
|
|
|
|
tspeed = 1; // emergency stop DCC speed
|
|
|
|
else if (tspeed > 0)
|
|
|
|
tspeed++; // map 1-126 -> 2-127
|
|
|
|
if (cab == 0 && tspeed > 1)
|
|
|
|
break; // ignore broadcasts of speed>1
|
|
|
|
|
|
|
|
if (direction < 0 || direction > 1)
|
|
|
|
break; // invalid direction code
|
2023-05-08 00:19:59 +02:00
|
|
|
if (cab > 10239 || cab < 0)
|
|
|
|
break; // beyond DCC range
|
2020-09-25 19:51:08 +02:00
|
|
|
|
|
|
|
DCC::setThrottle(cab, tspeed, direction);
|
2021-12-15 20:51:01 +01:00
|
|
|
if (params == 4) // send obsolete format T response
|
2021-03-30 23:01:37 +02:00
|
|
|
StringFormatter::send(stream, F("<T %d %d %d>\n"), p[0], p[2], p[3]);
|
2021-12-15 20:51:01 +01:00
|
|
|
// speed change will be broadcast anyway in new <l > format
|
2020-09-25 19:51:08 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
case 'f': // FUNCTION <f CAB BYTE1 [BYTE2]>
|
|
|
|
if (parsef(stream, params, p))
|
|
|
|
return;
|
2020-06-22 11:54:57 +02:00
|
|
|
break;
|
2020-09-25 19:51:08 +02:00
|
|
|
|
2022-05-22 23:39:46 +02:00
|
|
|
case 'a': // ACCESSORY <a ADDRESS SUBADDRESS ACTIVATE [ONOFF]> or <a LINEARADDRESS ACTIVATE>
|
Nano every2 (#129)
* Start adding back unowifi stuffz
* Uno Wifi compiling
* Fixes for compile arduino unowifi r2
* FlasString and Timers for Uno Wifi
ALL these changes should be portable back to master
* Remove extra timer that was already added
* Changed to EveryTimerB
* Add everytimerb.h
* Cleanup
* Linear address <a> cmd
* Allow lower case keywords
* Add the F define to be on safe side if it is not present in the library core code
* Clean simple Timer interface
Removes overkill files, puts all timer in a single small file. (DCCTimer)
* Timer port
* Timer working
And slow wave command removed
* Correcting non-portables merged from master
* Wave-state machine ( part 11)
* Microtuning waveform
Significant reduction in code paths and call overheads
* Current check cleanup
* Fix no-loco id
Has to handle -1 correctly
* fix wrong format letter
* redo flow through wifisetup again
* version++
* bugfixes wifi setup
* Retry harder for AP mode
* Remove unued if
* DIO2 replacement
Currently for writing signal pins during waveform.
* Drop analogReadFast (see DCCTimer)
AnalogRead speed set in DCCTimer for ease of porting.
Code tidy and diagnostics in MotorDriver
* UNTESTED fast power,brake,fault pins
* Distunguish between in/out of FASTPIN
* minor performance tweaks
* Config comments and example use
* Config/example loading
* IP/PORT on LCD
* Ethernet simulated mac
Plus fixed listening port
* Github SHA
* Committing a SHA
* Fix for nano compile
* Comments and a reliability fix.
* UnoRev2 protection
* PWM pin implementation
* fix wifi setup issue
* Reinstate IP_PORT
* Wifi channel and code cleaninga
* Reduce duplicated F() macros
Compiler isn't as clever as one might expect
* Committing a SHA
* Update config.example.h
Add comment to wifi channel section
* Committing a SHA
* Handle shields with common fault pins (Pololu)
* Committing a SHA
* remove warning
* Committing a SHA
* only do the sha generation on master
* yaml syntax
* Fast SSD1306 OLED driver
Incorporate code from SSD1306Ascii library to speed up OLED screen updates, reduce memory requirements and eliminate some library dependences.
* Fix auto-configure from cold boot.
Add call to Wire.begin().
* Update comment for OLED_DRIVER define.
* Update MotorDrivers.h
Add a motor board definition for using the IBT_2 board for a high current to the main track and keep the Arduino Motor Shield for operating the programming track.
* Committing a SHA
* Fix missing F in motor drivers
* JOIN relay pin
* Swap Join Relay high/low
* Hide WIFI_CONNECT_TIMEOUT
This is not what the config suggests it is... The timeout is in the ES and defaults to 15 seconds. Abandoning it early leads to confused setup.
* Enhance OLED/LCD speed
Write one character or position command per loop entry so as not to hold up the loop. Add support for SH1106 OLED as 132x64 size option.
* Enhance OLED/LCD speed
* Delete comment about OLED on UNO.
* Trim unwanted code
* Handle display types correctly
* Update comments
* Speed up OLED writes
Add new flushDisplay() to end any in-progress I2C transaction. Previously, an redundant command was sent that ended the in-progress transaction but also sent another complete, but unnecessary, transaction.
* Comments and copyright update
* Reduce RAM and flash requirement a few more bytes.
* Move statics into LCDDisplay class, and reduce RAM.
Some state variables were static in LCDDisplay.write(). Moved to class members. Also, types of data items like row, column & character position changed to int8_t to save a few bytes of RAM.
* Type lcdCols and lcdRows to unsigned.
Since lcdCols is normally 128, it needs to be uint8_t, not int8_t.
* remove timeout from user config
* faultpin is common only if it exists ; make code prettier
* Rationalisation of SSD1306 driver
Merge SSD1306AsciiWire.cpp into SSD1306Ascii.cpp and rename SSD1306AsciiWire.h as SSD1306Ascii.h.
Merge allFonts.h into System5x7.h and rename as SSD1306font.h.
Move all SSD1306 files into root folder to facilitate compilation in Arduino IDE.
* Fix some font attributes as const.
* Remove unused initialisation sequences for tiny oled screens
* Add m_ to variables
* Bump up I2C speed
Speed was 100kHz (default). Max for OLEDis 400kHz.
* Revert "Bump up I2C speed"
This reverts commit 1c1168f43314d3a6855738fbc406d5654e801831.
* Bump up I2C speed
Speed was 100kHz (default). Max for OLEDis 400kHz.
* Drop duplicate DIAG
* ignore mySetup.h files
* Restore uno to default_envs
Restore uno (previously commented out) to default_envs.
* Update objdump.bat
Allows other editors as Notepad is very slow on large files
* Prog Track overload during cv read
* Faster LCD Driver
Extract LCD driver from library;
Trim unused functionality;
Reduce I2C communications to minimum;
Speed up I2C clock to 400kHz.
* Update config.example.h
Add IBT_2_WITH_ARDUINO to example config
* Update config.example.h
* Screen enhancements (#126)
* Add I2CManager to coordinate I2C shared parameters.
* Add use of I2CManager, and experimental scrolling strategies.
New scrolling capability by defining SCROLLMODE in Config.h to 0 (original), 1 (by page) or 2 (by line). If not defined, defaults to 0.
* Scrolling updates
New scrolling capability by defining SCROLLMODE in Config.h to 0 (original), 1 (by page) or 2 (by line). If not defined, defaults to 0.
Reformat.
* Add I2CManager calls. Remove unnecessary delays.
* Add I2CManager calls, remove unnecessary I2C delays.
* SSD1306: Move methods from .h to .cpp and reformat.
* Fix compiler warning in LiquidCrystal_I2C
* Allow forcing of I2C clock speed.
New method forceClock allows the I2C speed to be overridden. For example, if the I2C bus is long then the speed can be forced lower. It can also be forced higher to gain performance if devices are capable.
* Make Config.h conditionally included.
Allow for non-existence of Config.h.
* Correct scrolling and allow longer messages
Correct the handling of scrolling in scrollmode 1 to avoid a blank page being displayed. Also, allow MAX_MSG_SIZE to be optionally configured to override maximum message length on screens.
* compiler warning on uno
Co-authored-by: dexslab <dex35803@gmail.com>
Co-authored-by: Asbelos <asbelos@btinternet.com>
Co-authored-by: Harald Barth <haba@kth.se>
Co-authored-by: Neil McKechnie <neilmck999@gmail.com>
Co-authored-by: Neil McKechnie <75813993+Neil-McK@users.noreply.github.com>
2021-03-07 21:58:35 +01:00
|
|
|
{
|
|
|
|
int address;
|
|
|
|
byte subaddress;
|
|
|
|
byte activep;
|
2022-05-22 23:39:46 +02:00
|
|
|
byte onoff;
|
Nano every2 (#129)
* Start adding back unowifi stuffz
* Uno Wifi compiling
* Fixes for compile arduino unowifi r2
* FlasString and Timers for Uno Wifi
ALL these changes should be portable back to master
* Remove extra timer that was already added
* Changed to EveryTimerB
* Add everytimerb.h
* Cleanup
* Linear address <a> cmd
* Allow lower case keywords
* Add the F define to be on safe side if it is not present in the library core code
* Clean simple Timer interface
Removes overkill files, puts all timer in a single small file. (DCCTimer)
* Timer port
* Timer working
And slow wave command removed
* Correcting non-portables merged from master
* Wave-state machine ( part 11)
* Microtuning waveform
Significant reduction in code paths and call overheads
* Current check cleanup
* Fix no-loco id
Has to handle -1 correctly
* fix wrong format letter
* redo flow through wifisetup again
* version++
* bugfixes wifi setup
* Retry harder for AP mode
* Remove unued if
* DIO2 replacement
Currently for writing signal pins during waveform.
* Drop analogReadFast (see DCCTimer)
AnalogRead speed set in DCCTimer for ease of porting.
Code tidy and diagnostics in MotorDriver
* UNTESTED fast power,brake,fault pins
* Distunguish between in/out of FASTPIN
* minor performance tweaks
* Config comments and example use
* Config/example loading
* IP/PORT on LCD
* Ethernet simulated mac
Plus fixed listening port
* Github SHA
* Committing a SHA
* Fix for nano compile
* Comments and a reliability fix.
* UnoRev2 protection
* PWM pin implementation
* fix wifi setup issue
* Reinstate IP_PORT
* Wifi channel and code cleaninga
* Reduce duplicated F() macros
Compiler isn't as clever as one might expect
* Committing a SHA
* Update config.example.h
Add comment to wifi channel section
* Committing a SHA
* Handle shields with common fault pins (Pololu)
* Committing a SHA
* remove warning
* Committing a SHA
* only do the sha generation on master
* yaml syntax
* Fast SSD1306 OLED driver
Incorporate code from SSD1306Ascii library to speed up OLED screen updates, reduce memory requirements and eliminate some library dependences.
* Fix auto-configure from cold boot.
Add call to Wire.begin().
* Update comment for OLED_DRIVER define.
* Update MotorDrivers.h
Add a motor board definition for using the IBT_2 board for a high current to the main track and keep the Arduino Motor Shield for operating the programming track.
* Committing a SHA
* Fix missing F in motor drivers
* JOIN relay pin
* Swap Join Relay high/low
* Hide WIFI_CONNECT_TIMEOUT
This is not what the config suggests it is... The timeout is in the ES and defaults to 15 seconds. Abandoning it early leads to confused setup.
* Enhance OLED/LCD speed
Write one character or position command per loop entry so as not to hold up the loop. Add support for SH1106 OLED as 132x64 size option.
* Enhance OLED/LCD speed
* Delete comment about OLED on UNO.
* Trim unwanted code
* Handle display types correctly
* Update comments
* Speed up OLED writes
Add new flushDisplay() to end any in-progress I2C transaction. Previously, an redundant command was sent that ended the in-progress transaction but also sent another complete, but unnecessary, transaction.
* Comments and copyright update
* Reduce RAM and flash requirement a few more bytes.
* Move statics into LCDDisplay class, and reduce RAM.
Some state variables were static in LCDDisplay.write(). Moved to class members. Also, types of data items like row, column & character position changed to int8_t to save a few bytes of RAM.
* Type lcdCols and lcdRows to unsigned.
Since lcdCols is normally 128, it needs to be uint8_t, not int8_t.
* remove timeout from user config
* faultpin is common only if it exists ; make code prettier
* Rationalisation of SSD1306 driver
Merge SSD1306AsciiWire.cpp into SSD1306Ascii.cpp and rename SSD1306AsciiWire.h as SSD1306Ascii.h.
Merge allFonts.h into System5x7.h and rename as SSD1306font.h.
Move all SSD1306 files into root folder to facilitate compilation in Arduino IDE.
* Fix some font attributes as const.
* Remove unused initialisation sequences for tiny oled screens
* Add m_ to variables
* Bump up I2C speed
Speed was 100kHz (default). Max for OLEDis 400kHz.
* Revert "Bump up I2C speed"
This reverts commit 1c1168f43314d3a6855738fbc406d5654e801831.
* Bump up I2C speed
Speed was 100kHz (default). Max for OLEDis 400kHz.
* Drop duplicate DIAG
* ignore mySetup.h files
* Restore uno to default_envs
Restore uno (previously commented out) to default_envs.
* Update objdump.bat
Allows other editors as Notepad is very slow on large files
* Prog Track overload during cv read
* Faster LCD Driver
Extract LCD driver from library;
Trim unused functionality;
Reduce I2C communications to minimum;
Speed up I2C clock to 400kHz.
* Update config.example.h
Add IBT_2_WITH_ARDUINO to example config
* Update config.example.h
* Screen enhancements (#126)
* Add I2CManager to coordinate I2C shared parameters.
* Add use of I2CManager, and experimental scrolling strategies.
New scrolling capability by defining SCROLLMODE in Config.h to 0 (original), 1 (by page) or 2 (by line). If not defined, defaults to 0.
* Scrolling updates
New scrolling capability by defining SCROLLMODE in Config.h to 0 (original), 1 (by page) or 2 (by line). If not defined, defaults to 0.
Reformat.
* Add I2CManager calls. Remove unnecessary delays.
* Add I2CManager calls, remove unnecessary I2C delays.
* SSD1306: Move methods from .h to .cpp and reformat.
* Fix compiler warning in LiquidCrystal_I2C
* Allow forcing of I2C clock speed.
New method forceClock allows the I2C speed to be overridden. For example, if the I2C bus is long then the speed can be forced lower. It can also be forced higher to gain performance if devices are capable.
* Make Config.h conditionally included.
Allow for non-existence of Config.h.
* Correct scrolling and allow longer messages
Correct the handling of scrolling in scrollmode 1 to avoid a blank page being displayed. Also, allow MAX_MSG_SIZE to be optionally configured to override maximum message length on screens.
* compiler warning on uno
Co-authored-by: dexslab <dex35803@gmail.com>
Co-authored-by: Asbelos <asbelos@btinternet.com>
Co-authored-by: Harald Barth <haba@kth.se>
Co-authored-by: Neil McKechnie <neilmck999@gmail.com>
Co-authored-by: Neil McKechnie <75813993+Neil-McK@users.noreply.github.com>
2021-03-07 21:58:35 +01:00
|
|
|
if (params==2) { // <a LINEARADDRESS ACTIVATE>
|
|
|
|
address=(p[0] - 1) / 4 + 1;
|
|
|
|
subaddress=(p[0] - 1) % 4;
|
2022-05-22 23:39:46 +02:00
|
|
|
activep=1;
|
|
|
|
onoff=2; // send both
|
Nano every2 (#129)
* Start adding back unowifi stuffz
* Uno Wifi compiling
* Fixes for compile arduino unowifi r2
* FlasString and Timers for Uno Wifi
ALL these changes should be portable back to master
* Remove extra timer that was already added
* Changed to EveryTimerB
* Add everytimerb.h
* Cleanup
* Linear address <a> cmd
* Allow lower case keywords
* Add the F define to be on safe side if it is not present in the library core code
* Clean simple Timer interface
Removes overkill files, puts all timer in a single small file. (DCCTimer)
* Timer port
* Timer working
And slow wave command removed
* Correcting non-portables merged from master
* Wave-state machine ( part 11)
* Microtuning waveform
Significant reduction in code paths and call overheads
* Current check cleanup
* Fix no-loco id
Has to handle -1 correctly
* fix wrong format letter
* redo flow through wifisetup again
* version++
* bugfixes wifi setup
* Retry harder for AP mode
* Remove unued if
* DIO2 replacement
Currently for writing signal pins during waveform.
* Drop analogReadFast (see DCCTimer)
AnalogRead speed set in DCCTimer for ease of porting.
Code tidy and diagnostics in MotorDriver
* UNTESTED fast power,brake,fault pins
* Distunguish between in/out of FASTPIN
* minor performance tweaks
* Config comments and example use
* Config/example loading
* IP/PORT on LCD
* Ethernet simulated mac
Plus fixed listening port
* Github SHA
* Committing a SHA
* Fix for nano compile
* Comments and a reliability fix.
* UnoRev2 protection
* PWM pin implementation
* fix wifi setup issue
* Reinstate IP_PORT
* Wifi channel and code cleaninga
* Reduce duplicated F() macros
Compiler isn't as clever as one might expect
* Committing a SHA
* Update config.example.h
Add comment to wifi channel section
* Committing a SHA
* Handle shields with common fault pins (Pololu)
* Committing a SHA
* remove warning
* Committing a SHA
* only do the sha generation on master
* yaml syntax
* Fast SSD1306 OLED driver
Incorporate code from SSD1306Ascii library to speed up OLED screen updates, reduce memory requirements and eliminate some library dependences.
* Fix auto-configure from cold boot.
Add call to Wire.begin().
* Update comment for OLED_DRIVER define.
* Update MotorDrivers.h
Add a motor board definition for using the IBT_2 board for a high current to the main track and keep the Arduino Motor Shield for operating the programming track.
* Committing a SHA
* Fix missing F in motor drivers
* JOIN relay pin
* Swap Join Relay high/low
* Hide WIFI_CONNECT_TIMEOUT
This is not what the config suggests it is... The timeout is in the ES and defaults to 15 seconds. Abandoning it early leads to confused setup.
* Enhance OLED/LCD speed
Write one character or position command per loop entry so as not to hold up the loop. Add support for SH1106 OLED as 132x64 size option.
* Enhance OLED/LCD speed
* Delete comment about OLED on UNO.
* Trim unwanted code
* Handle display types correctly
* Update comments
* Speed up OLED writes
Add new flushDisplay() to end any in-progress I2C transaction. Previously, an redundant command was sent that ended the in-progress transaction but also sent another complete, but unnecessary, transaction.
* Comments and copyright update
* Reduce RAM and flash requirement a few more bytes.
* Move statics into LCDDisplay class, and reduce RAM.
Some state variables were static in LCDDisplay.write(). Moved to class members. Also, types of data items like row, column & character position changed to int8_t to save a few bytes of RAM.
* Type lcdCols and lcdRows to unsigned.
Since lcdCols is normally 128, it needs to be uint8_t, not int8_t.
* remove timeout from user config
* faultpin is common only if it exists ; make code prettier
* Rationalisation of SSD1306 driver
Merge SSD1306AsciiWire.cpp into SSD1306Ascii.cpp and rename SSD1306AsciiWire.h as SSD1306Ascii.h.
Merge allFonts.h into System5x7.h and rename as SSD1306font.h.
Move all SSD1306 files into root folder to facilitate compilation in Arduino IDE.
* Fix some font attributes as const.
* Remove unused initialisation sequences for tiny oled screens
* Add m_ to variables
* Bump up I2C speed
Speed was 100kHz (default). Max for OLEDis 400kHz.
* Revert "Bump up I2C speed"
This reverts commit 1c1168f43314d3a6855738fbc406d5654e801831.
* Bump up I2C speed
Speed was 100kHz (default). Max for OLEDis 400kHz.
* Drop duplicate DIAG
* ignore mySetup.h files
* Restore uno to default_envs
Restore uno (previously commented out) to default_envs.
* Update objdump.bat
Allows other editors as Notepad is very slow on large files
* Prog Track overload during cv read
* Faster LCD Driver
Extract LCD driver from library;
Trim unused functionality;
Reduce I2C communications to minimum;
Speed up I2C clock to 400kHz.
* Update config.example.h
Add IBT_2_WITH_ARDUINO to example config
* Update config.example.h
* Screen enhancements (#126)
* Add I2CManager to coordinate I2C shared parameters.
* Add use of I2CManager, and experimental scrolling strategies.
New scrolling capability by defining SCROLLMODE in Config.h to 0 (original), 1 (by page) or 2 (by line). If not defined, defaults to 0.
* Scrolling updates
New scrolling capability by defining SCROLLMODE in Config.h to 0 (original), 1 (by page) or 2 (by line). If not defined, defaults to 0.
Reformat.
* Add I2CManager calls. Remove unnecessary delays.
* Add I2CManager calls, remove unnecessary I2C delays.
* SSD1306: Move methods from .h to .cpp and reformat.
* Fix compiler warning in LiquidCrystal_I2C
* Allow forcing of I2C clock speed.
New method forceClock allows the I2C speed to be overridden. For example, if the I2C bus is long then the speed can be forced lower. It can also be forced higher to gain performance if devices are capable.
* Make Config.h conditionally included.
Allow for non-existence of Config.h.
* Correct scrolling and allow longer messages
Correct the handling of scrolling in scrollmode 1 to avoid a blank page being displayed. Also, allow MAX_MSG_SIZE to be optionally configured to override maximum message length on screens.
* compiler warning on uno
Co-authored-by: dexslab <dex35803@gmail.com>
Co-authored-by: Asbelos <asbelos@btinternet.com>
Co-authored-by: Harald Barth <haba@kth.se>
Co-authored-by: Neil McKechnie <neilmck999@gmail.com>
Co-authored-by: Neil McKechnie <75813993+Neil-McK@users.noreply.github.com>
2021-03-07 21:58:35 +01:00
|
|
|
}
|
|
|
|
else if (params==3) { // <a ADDRESS SUBADDRESS ACTIVATE>
|
|
|
|
address=p[0];
|
|
|
|
subaddress=p[1];
|
2022-05-22 23:39:46 +02:00
|
|
|
activep=2;
|
|
|
|
onoff=2; // send both
|
|
|
|
}
|
|
|
|
else if (params==4) { // <a ADDRESS SUBADDRESS ACTIVATE ONOFF>
|
|
|
|
address=p[0];
|
|
|
|
subaddress=p[1];
|
|
|
|
activep=2;
|
2022-07-06 21:12:10 +02:00
|
|
|
if ((p[3] < 0) || (p[3] > 1)) // invalid onoff 0|1
|
|
|
|
break;
|
2022-05-22 23:39:46 +02:00
|
|
|
onoff=p[3];
|
Nano every2 (#129)
* Start adding back unowifi stuffz
* Uno Wifi compiling
* Fixes for compile arduino unowifi r2
* FlasString and Timers for Uno Wifi
ALL these changes should be portable back to master
* Remove extra timer that was already added
* Changed to EveryTimerB
* Add everytimerb.h
* Cleanup
* Linear address <a> cmd
* Allow lower case keywords
* Add the F define to be on safe side if it is not present in the library core code
* Clean simple Timer interface
Removes overkill files, puts all timer in a single small file. (DCCTimer)
* Timer port
* Timer working
And slow wave command removed
* Correcting non-portables merged from master
* Wave-state machine ( part 11)
* Microtuning waveform
Significant reduction in code paths and call overheads
* Current check cleanup
* Fix no-loco id
Has to handle -1 correctly
* fix wrong format letter
* redo flow through wifisetup again
* version++
* bugfixes wifi setup
* Retry harder for AP mode
* Remove unued if
* DIO2 replacement
Currently for writing signal pins during waveform.
* Drop analogReadFast (see DCCTimer)
AnalogRead speed set in DCCTimer for ease of porting.
Code tidy and diagnostics in MotorDriver
* UNTESTED fast power,brake,fault pins
* Distunguish between in/out of FASTPIN
* minor performance tweaks
* Config comments and example use
* Config/example loading
* IP/PORT on LCD
* Ethernet simulated mac
Plus fixed listening port
* Github SHA
* Committing a SHA
* Fix for nano compile
* Comments and a reliability fix.
* UnoRev2 protection
* PWM pin implementation
* fix wifi setup issue
* Reinstate IP_PORT
* Wifi channel and code cleaninga
* Reduce duplicated F() macros
Compiler isn't as clever as one might expect
* Committing a SHA
* Update config.example.h
Add comment to wifi channel section
* Committing a SHA
* Handle shields with common fault pins (Pololu)
* Committing a SHA
* remove warning
* Committing a SHA
* only do the sha generation on master
* yaml syntax
* Fast SSD1306 OLED driver
Incorporate code from SSD1306Ascii library to speed up OLED screen updates, reduce memory requirements and eliminate some library dependences.
* Fix auto-configure from cold boot.
Add call to Wire.begin().
* Update comment for OLED_DRIVER define.
* Update MotorDrivers.h
Add a motor board definition for using the IBT_2 board for a high current to the main track and keep the Arduino Motor Shield for operating the programming track.
* Committing a SHA
* Fix missing F in motor drivers
* JOIN relay pin
* Swap Join Relay high/low
* Hide WIFI_CONNECT_TIMEOUT
This is not what the config suggests it is... The timeout is in the ES and defaults to 15 seconds. Abandoning it early leads to confused setup.
* Enhance OLED/LCD speed
Write one character or position command per loop entry so as not to hold up the loop. Add support for SH1106 OLED as 132x64 size option.
* Enhance OLED/LCD speed
* Delete comment about OLED on UNO.
* Trim unwanted code
* Handle display types correctly
* Update comments
* Speed up OLED writes
Add new flushDisplay() to end any in-progress I2C transaction. Previously, an redundant command was sent that ended the in-progress transaction but also sent another complete, but unnecessary, transaction.
* Comments and copyright update
* Reduce RAM and flash requirement a few more bytes.
* Move statics into LCDDisplay class, and reduce RAM.
Some state variables were static in LCDDisplay.write(). Moved to class members. Also, types of data items like row, column & character position changed to int8_t to save a few bytes of RAM.
* Type lcdCols and lcdRows to unsigned.
Since lcdCols is normally 128, it needs to be uint8_t, not int8_t.
* remove timeout from user config
* faultpin is common only if it exists ; make code prettier
* Rationalisation of SSD1306 driver
Merge SSD1306AsciiWire.cpp into SSD1306Ascii.cpp and rename SSD1306AsciiWire.h as SSD1306Ascii.h.
Merge allFonts.h into System5x7.h and rename as SSD1306font.h.
Move all SSD1306 files into root folder to facilitate compilation in Arduino IDE.
* Fix some font attributes as const.
* Remove unused initialisation sequences for tiny oled screens
* Add m_ to variables
* Bump up I2C speed
Speed was 100kHz (default). Max for OLEDis 400kHz.
* Revert "Bump up I2C speed"
This reverts commit 1c1168f43314d3a6855738fbc406d5654e801831.
* Bump up I2C speed
Speed was 100kHz (default). Max for OLEDis 400kHz.
* Drop duplicate DIAG
* ignore mySetup.h files
* Restore uno to default_envs
Restore uno (previously commented out) to default_envs.
* Update objdump.bat
Allows other editors as Notepad is very slow on large files
* Prog Track overload during cv read
* Faster LCD Driver
Extract LCD driver from library;
Trim unused functionality;
Reduce I2C communications to minimum;
Speed up I2C clock to 400kHz.
* Update config.example.h
Add IBT_2_WITH_ARDUINO to example config
* Update config.example.h
* Screen enhancements (#126)
* Add I2CManager to coordinate I2C shared parameters.
* Add use of I2CManager, and experimental scrolling strategies.
New scrolling capability by defining SCROLLMODE in Config.h to 0 (original), 1 (by page) or 2 (by line). If not defined, defaults to 0.
* Scrolling updates
New scrolling capability by defining SCROLLMODE in Config.h to 0 (original), 1 (by page) or 2 (by line). If not defined, defaults to 0.
Reformat.
* Add I2CManager calls. Remove unnecessary delays.
* Add I2CManager calls, remove unnecessary I2C delays.
* SSD1306: Move methods from .h to .cpp and reformat.
* Fix compiler warning in LiquidCrystal_I2C
* Allow forcing of I2C clock speed.
New method forceClock allows the I2C speed to be overridden. For example, if the I2C bus is long then the speed can be forced lower. It can also be forced higher to gain performance if devices are capable.
* Make Config.h conditionally included.
Allow for non-existence of Config.h.
* Correct scrolling and allow longer messages
Correct the handling of scrolling in scrollmode 1 to avoid a blank page being displayed. Also, allow MAX_MSG_SIZE to be optionally configured to override maximum message length on screens.
* compiler warning on uno
Co-authored-by: dexslab <dex35803@gmail.com>
Co-authored-by: Asbelos <asbelos@btinternet.com>
Co-authored-by: Harald Barth <haba@kth.se>
Co-authored-by: Neil McKechnie <neilmck999@gmail.com>
Co-authored-by: Neil McKechnie <75813993+Neil-McK@users.noreply.github.com>
2021-03-07 21:58:35 +01:00
|
|
|
}
|
|
|
|
else break; // invalid no of parameters
|
|
|
|
|
|
|
|
if (
|
2022-07-06 21:12:10 +02:00
|
|
|
((address & 0x01FF) != address) // invalid address (limit 9 bits)
|
|
|
|
|| ((subaddress & 0x03) != subaddress) // invalid subaddress (limit 2 bits)
|
|
|
|
|| (p[activep] > 1) || (p[activep] < 0) // invalid activate 0|1
|
|
|
|
) break;
|
2021-08-27 22:43:24 +02:00
|
|
|
// Honour the configuration option (config.h) which allows the <a> command to be reversed
|
2021-11-25 23:10:03 +01:00
|
|
|
#ifdef DCC_ACCESSORY_COMMAND_REVERSE
|
2022-05-22 23:39:46 +02:00
|
|
|
DCC::setAccessory(address, subaddress,p[activep]==0,onoff);
|
2021-08-27 22:43:24 +02:00
|
|
|
#else
|
2022-05-22 23:39:46 +02:00
|
|
|
DCC::setAccessory(address, subaddress,p[activep]==1,onoff);
|
2021-08-27 22:43:24 +02:00
|
|
|
#endif
|
Nano every2 (#129)
* Start adding back unowifi stuffz
* Uno Wifi compiling
* Fixes for compile arduino unowifi r2
* FlasString and Timers for Uno Wifi
ALL these changes should be portable back to master
* Remove extra timer that was already added
* Changed to EveryTimerB
* Add everytimerb.h
* Cleanup
* Linear address <a> cmd
* Allow lower case keywords
* Add the F define to be on safe side if it is not present in the library core code
* Clean simple Timer interface
Removes overkill files, puts all timer in a single small file. (DCCTimer)
* Timer port
* Timer working
And slow wave command removed
* Correcting non-portables merged from master
* Wave-state machine ( part 11)
* Microtuning waveform
Significant reduction in code paths and call overheads
* Current check cleanup
* Fix no-loco id
Has to handle -1 correctly
* fix wrong format letter
* redo flow through wifisetup again
* version++
* bugfixes wifi setup
* Retry harder for AP mode
* Remove unued if
* DIO2 replacement
Currently for writing signal pins during waveform.
* Drop analogReadFast (see DCCTimer)
AnalogRead speed set in DCCTimer for ease of porting.
Code tidy and diagnostics in MotorDriver
* UNTESTED fast power,brake,fault pins
* Distunguish between in/out of FASTPIN
* minor performance tweaks
* Config comments and example use
* Config/example loading
* IP/PORT on LCD
* Ethernet simulated mac
Plus fixed listening port
* Github SHA
* Committing a SHA
* Fix for nano compile
* Comments and a reliability fix.
* UnoRev2 protection
* PWM pin implementation
* fix wifi setup issue
* Reinstate IP_PORT
* Wifi channel and code cleaninga
* Reduce duplicated F() macros
Compiler isn't as clever as one might expect
* Committing a SHA
* Update config.example.h
Add comment to wifi channel section
* Committing a SHA
* Handle shields with common fault pins (Pololu)
* Committing a SHA
* remove warning
* Committing a SHA
* only do the sha generation on master
* yaml syntax
* Fast SSD1306 OLED driver
Incorporate code from SSD1306Ascii library to speed up OLED screen updates, reduce memory requirements and eliminate some library dependences.
* Fix auto-configure from cold boot.
Add call to Wire.begin().
* Update comment for OLED_DRIVER define.
* Update MotorDrivers.h
Add a motor board definition for using the IBT_2 board for a high current to the main track and keep the Arduino Motor Shield for operating the programming track.
* Committing a SHA
* Fix missing F in motor drivers
* JOIN relay pin
* Swap Join Relay high/low
* Hide WIFI_CONNECT_TIMEOUT
This is not what the config suggests it is... The timeout is in the ES and defaults to 15 seconds. Abandoning it early leads to confused setup.
* Enhance OLED/LCD speed
Write one character or position command per loop entry so as not to hold up the loop. Add support for SH1106 OLED as 132x64 size option.
* Enhance OLED/LCD speed
* Delete comment about OLED on UNO.
* Trim unwanted code
* Handle display types correctly
* Update comments
* Speed up OLED writes
Add new flushDisplay() to end any in-progress I2C transaction. Previously, an redundant command was sent that ended the in-progress transaction but also sent another complete, but unnecessary, transaction.
* Comments and copyright update
* Reduce RAM and flash requirement a few more bytes.
* Move statics into LCDDisplay class, and reduce RAM.
Some state variables were static in LCDDisplay.write(). Moved to class members. Also, types of data items like row, column & character position changed to int8_t to save a few bytes of RAM.
* Type lcdCols and lcdRows to unsigned.
Since lcdCols is normally 128, it needs to be uint8_t, not int8_t.
* remove timeout from user config
* faultpin is common only if it exists ; make code prettier
* Rationalisation of SSD1306 driver
Merge SSD1306AsciiWire.cpp into SSD1306Ascii.cpp and rename SSD1306AsciiWire.h as SSD1306Ascii.h.
Merge allFonts.h into System5x7.h and rename as SSD1306font.h.
Move all SSD1306 files into root folder to facilitate compilation in Arduino IDE.
* Fix some font attributes as const.
* Remove unused initialisation sequences for tiny oled screens
* Add m_ to variables
* Bump up I2C speed
Speed was 100kHz (default). Max for OLEDis 400kHz.
* Revert "Bump up I2C speed"
This reverts commit 1c1168f43314d3a6855738fbc406d5654e801831.
* Bump up I2C speed
Speed was 100kHz (default). Max for OLEDis 400kHz.
* Drop duplicate DIAG
* ignore mySetup.h files
* Restore uno to default_envs
Restore uno (previously commented out) to default_envs.
* Update objdump.bat
Allows other editors as Notepad is very slow on large files
* Prog Track overload during cv read
* Faster LCD Driver
Extract LCD driver from library;
Trim unused functionality;
Reduce I2C communications to minimum;
Speed up I2C clock to 400kHz.
* Update config.example.h
Add IBT_2_WITH_ARDUINO to example config
* Update config.example.h
* Screen enhancements (#126)
* Add I2CManager to coordinate I2C shared parameters.
* Add use of I2CManager, and experimental scrolling strategies.
New scrolling capability by defining SCROLLMODE in Config.h to 0 (original), 1 (by page) or 2 (by line). If not defined, defaults to 0.
* Scrolling updates
New scrolling capability by defining SCROLLMODE in Config.h to 0 (original), 1 (by page) or 2 (by line). If not defined, defaults to 0.
Reformat.
* Add I2CManager calls. Remove unnecessary delays.
* Add I2CManager calls, remove unnecessary I2C delays.
* SSD1306: Move methods from .h to .cpp and reformat.
* Fix compiler warning in LiquidCrystal_I2C
* Allow forcing of I2C clock speed.
New method forceClock allows the I2C speed to be overridden. For example, if the I2C bus is long then the speed can be forced lower. It can also be forced higher to gain performance if devices are capable.
* Make Config.h conditionally included.
Allow for non-existence of Config.h.
* Correct scrolling and allow longer messages
Correct the handling of scrolling in scrollmode 1 to avoid a blank page being displayed. Also, allow MAX_MSG_SIZE to be optionally configured to override maximum message length on screens.
* compiler warning on uno
Co-authored-by: dexslab <dex35803@gmail.com>
Co-authored-by: Asbelos <asbelos@btinternet.com>
Co-authored-by: Harald Barth <haba@kth.se>
Co-authored-by: Neil McKechnie <neilmck999@gmail.com>
Co-authored-by: Neil McKechnie <75813993+Neil-McK@users.noreply.github.com>
2021-03-07 21:58:35 +01:00
|
|
|
}
|
2020-06-03 15:26:49 +02:00
|
|
|
return;
|
Nano every2 (#129)
* Start adding back unowifi stuffz
* Uno Wifi compiling
* Fixes for compile arduino unowifi r2
* FlasString and Timers for Uno Wifi
ALL these changes should be portable back to master
* Remove extra timer that was already added
* Changed to EveryTimerB
* Add everytimerb.h
* Cleanup
* Linear address <a> cmd
* Allow lower case keywords
* Add the F define to be on safe side if it is not present in the library core code
* Clean simple Timer interface
Removes overkill files, puts all timer in a single small file. (DCCTimer)
* Timer port
* Timer working
And slow wave command removed
* Correcting non-portables merged from master
* Wave-state machine ( part 11)
* Microtuning waveform
Significant reduction in code paths and call overheads
* Current check cleanup
* Fix no-loco id
Has to handle -1 correctly
* fix wrong format letter
* redo flow through wifisetup again
* version++
* bugfixes wifi setup
* Retry harder for AP mode
* Remove unued if
* DIO2 replacement
Currently for writing signal pins during waveform.
* Drop analogReadFast (see DCCTimer)
AnalogRead speed set in DCCTimer for ease of porting.
Code tidy and diagnostics in MotorDriver
* UNTESTED fast power,brake,fault pins
* Distunguish between in/out of FASTPIN
* minor performance tweaks
* Config comments and example use
* Config/example loading
* IP/PORT on LCD
* Ethernet simulated mac
Plus fixed listening port
* Github SHA
* Committing a SHA
* Fix for nano compile
* Comments and a reliability fix.
* UnoRev2 protection
* PWM pin implementation
* fix wifi setup issue
* Reinstate IP_PORT
* Wifi channel and code cleaninga
* Reduce duplicated F() macros
Compiler isn't as clever as one might expect
* Committing a SHA
* Update config.example.h
Add comment to wifi channel section
* Committing a SHA
* Handle shields with common fault pins (Pololu)
* Committing a SHA
* remove warning
* Committing a SHA
* only do the sha generation on master
* yaml syntax
* Fast SSD1306 OLED driver
Incorporate code from SSD1306Ascii library to speed up OLED screen updates, reduce memory requirements and eliminate some library dependences.
* Fix auto-configure from cold boot.
Add call to Wire.begin().
* Update comment for OLED_DRIVER define.
* Update MotorDrivers.h
Add a motor board definition for using the IBT_2 board for a high current to the main track and keep the Arduino Motor Shield for operating the programming track.
* Committing a SHA
* Fix missing F in motor drivers
* JOIN relay pin
* Swap Join Relay high/low
* Hide WIFI_CONNECT_TIMEOUT
This is not what the config suggests it is... The timeout is in the ES and defaults to 15 seconds. Abandoning it early leads to confused setup.
* Enhance OLED/LCD speed
Write one character or position command per loop entry so as not to hold up the loop. Add support for SH1106 OLED as 132x64 size option.
* Enhance OLED/LCD speed
* Delete comment about OLED on UNO.
* Trim unwanted code
* Handle display types correctly
* Update comments
* Speed up OLED writes
Add new flushDisplay() to end any in-progress I2C transaction. Previously, an redundant command was sent that ended the in-progress transaction but also sent another complete, but unnecessary, transaction.
* Comments and copyright update
* Reduce RAM and flash requirement a few more bytes.
* Move statics into LCDDisplay class, and reduce RAM.
Some state variables were static in LCDDisplay.write(). Moved to class members. Also, types of data items like row, column & character position changed to int8_t to save a few bytes of RAM.
* Type lcdCols and lcdRows to unsigned.
Since lcdCols is normally 128, it needs to be uint8_t, not int8_t.
* remove timeout from user config
* faultpin is common only if it exists ; make code prettier
* Rationalisation of SSD1306 driver
Merge SSD1306AsciiWire.cpp into SSD1306Ascii.cpp and rename SSD1306AsciiWire.h as SSD1306Ascii.h.
Merge allFonts.h into System5x7.h and rename as SSD1306font.h.
Move all SSD1306 files into root folder to facilitate compilation in Arduino IDE.
* Fix some font attributes as const.
* Remove unused initialisation sequences for tiny oled screens
* Add m_ to variables
* Bump up I2C speed
Speed was 100kHz (default). Max for OLEDis 400kHz.
* Revert "Bump up I2C speed"
This reverts commit 1c1168f43314d3a6855738fbc406d5654e801831.
* Bump up I2C speed
Speed was 100kHz (default). Max for OLEDis 400kHz.
* Drop duplicate DIAG
* ignore mySetup.h files
* Restore uno to default_envs
Restore uno (previously commented out) to default_envs.
* Update objdump.bat
Allows other editors as Notepad is very slow on large files
* Prog Track overload during cv read
* Faster LCD Driver
Extract LCD driver from library;
Trim unused functionality;
Reduce I2C communications to minimum;
Speed up I2C clock to 400kHz.
* Update config.example.h
Add IBT_2_WITH_ARDUINO to example config
* Update config.example.h
* Screen enhancements (#126)
* Add I2CManager to coordinate I2C shared parameters.
* Add use of I2CManager, and experimental scrolling strategies.
New scrolling capability by defining SCROLLMODE in Config.h to 0 (original), 1 (by page) or 2 (by line). If not defined, defaults to 0.
* Scrolling updates
New scrolling capability by defining SCROLLMODE in Config.h to 0 (original), 1 (by page) or 2 (by line). If not defined, defaults to 0.
Reformat.
* Add I2CManager calls. Remove unnecessary delays.
* Add I2CManager calls, remove unnecessary I2C delays.
* SSD1306: Move methods from .h to .cpp and reformat.
* Fix compiler warning in LiquidCrystal_I2C
* Allow forcing of I2C clock speed.
New method forceClock allows the I2C speed to be overridden. For example, if the I2C bus is long then the speed can be forced lower. It can also be forced higher to gain performance if devices are capable.
* Make Config.h conditionally included.
Allow for non-existence of Config.h.
* Correct scrolling and allow longer messages
Correct the handling of scrolling in scrollmode 1 to avoid a blank page being displayed. Also, allow MAX_MSG_SIZE to be optionally configured to override maximum message length on screens.
* compiler warning on uno
Co-authored-by: dexslab <dex35803@gmail.com>
Co-authored-by: Asbelos <asbelos@btinternet.com>
Co-authored-by: Harald Barth <haba@kth.se>
Co-authored-by: Neil McKechnie <neilmck999@gmail.com>
Co-authored-by: Neil McKechnie <75813993+Neil-McK@users.noreply.github.com>
2021-03-07 21:58:35 +01:00
|
|
|
|
2020-09-25 19:51:08 +02:00
|
|
|
case 'T': // TURNOUT <T ...>
|
|
|
|
if (parseT(stream, params, p))
|
|
|
|
return;
|
|
|
|
break;
|
|
|
|
|
2023-03-23 20:52:49 +01:00
|
|
|
case 'z': // direct pin manipulation
|
|
|
|
if (p[0]==0) break;
|
|
|
|
if (params==1) { // <z vpin | -vpin>
|
|
|
|
if (p[0]>0) IODevice::write(p[0],HIGH);
|
|
|
|
else IODevice::write(-p[0],LOW);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (params>=2 && params<=4) { // <z vpin ana;og profile duration>
|
|
|
|
// unused params default to 0
|
|
|
|
IODevice::writeAnalogue(p[0],p[1],p[2],p[3]);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2020-09-25 19:51:08 +02:00
|
|
|
case 'Z': // OUTPUT <Z ...>
|
|
|
|
if (parseZ(stream, params, p))
|
|
|
|
return;
|
2020-05-27 10:24:56 +02:00
|
|
|
break;
|
2020-05-25 14:38:18 +02:00
|
|
|
|
2020-09-25 19:51:08 +02:00
|
|
|
case 'S': // SENSOR <S ...>
|
|
|
|
if (parseS(stream, params, p))
|
|
|
|
return;
|
|
|
|
break;
|
2020-05-25 14:38:18 +02:00
|
|
|
|
2023-04-19 23:08:11 +02:00
|
|
|
#ifndef DISABLE_PROG
|
2020-09-25 19:51:08 +02:00
|
|
|
case 'w': // WRITE CV on MAIN <w CAB CV VALUE>
|
|
|
|
DCC::writeCVByteMain(p[0], p[1], p[2]);
|
2020-06-03 15:26:49 +02:00
|
|
|
return;
|
2020-05-25 14:38:18 +02:00
|
|
|
|
2020-09-25 19:51:08 +02:00
|
|
|
case 'b': // WRITE CV BIT ON MAIN <b CAB CV BIT VALUE>
|
|
|
|
DCC::writeCVBitMain(p[0], p[1], p[2], p[3]);
|
2020-06-03 15:26:49 +02:00
|
|
|
return;
|
2023-04-19 23:08:11 +02:00
|
|
|
#endif
|
2020-05-25 14:38:18 +02:00
|
|
|
|
2020-11-24 13:49:15 +01:00
|
|
|
case 'M': // WRITE TRANSPARENT DCC PACKET MAIN <M REG X1 ... X9>
|
2023-04-23 20:24:29 +02:00
|
|
|
#ifndef DISABLE_PROG
|
2020-11-24 13:49:15 +01:00
|
|
|
case 'P': // WRITE TRANSPARENT DCC PACKET PROG <P REG X1 ... X9>
|
2023-04-23 20:24:29 +02:00
|
|
|
#endif
|
2021-12-16 12:23:20 +01:00
|
|
|
// NOTE: this command was parsed in HEX instead of decimal
|
|
|
|
params--; // drop REG
|
2022-08-05 15:15:42 +02:00
|
|
|
if (params<1) break;
|
|
|
|
if (params > MAX_PACKET_SIZE) break;
|
2020-11-24 13:49:15 +01:00
|
|
|
{
|
|
|
|
byte packet[params];
|
|
|
|
for (int i=0;i<params;i++) {
|
|
|
|
packet[i]=(byte)p[i+1];
|
2021-03-25 15:23:38 +01:00
|
|
|
if (Diag::CMD) DIAG(F("packet[%d]=%d (0x%x)"), i, packet[i], packet[i]);
|
2020-11-24 13:49:15 +01:00
|
|
|
}
|
|
|
|
(opcode=='M'?DCCWaveform::mainTrack:DCCWaveform::progTrack).schedulePacket(packet,params,3);
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
|
2023-04-19 23:08:11 +02:00
|
|
|
#ifndef DISABLE_PROG
|
2020-09-25 19:51:08 +02:00
|
|
|
case 'W': // WRITE CV ON PROG <W CV VALUE CALLBACKNUM CALLBACKSUB>
|
2021-03-08 11:40:32 +01:00
|
|
|
if (!stashCallback(stream, p, ringStream))
|
2021-01-18 11:06:46 +01:00
|
|
|
break;
|
|
|
|
if (params == 1) // <W id> Write new loco id (clearing consist and managing short/long)
|
2021-03-08 11:40:32 +01:00
|
|
|
DCC::setLocoId(p[0],callback_Wloco);
|
2022-04-30 06:23:15 +02:00
|
|
|
else if (params == 4) // WRITE CV ON PROG <W CV VALUE [CALLBACKNUM] [CALLBACKSUB]>
|
|
|
|
DCC::writeCVByte(p[0], p[1], callback_W4);
|
|
|
|
else // WRITE CV ON PROG <W CV VALUE>
|
2021-03-08 11:40:32 +01:00
|
|
|
DCC::writeCVByte(p[0], p[1], callback_W);
|
2020-06-03 15:26:49 +02:00
|
|
|
return;
|
2020-06-07 21:11:44 +02:00
|
|
|
|
2020-09-25 19:51:08 +02:00
|
|
|
case 'V': // VERIFY CV ON PROG <V CV VALUE> <V CV BIT 0|1>
|
|
|
|
if (params == 2)
|
|
|
|
{ // <V CV VALUE>
|
2021-03-08 11:40:32 +01:00
|
|
|
if (!stashCallback(stream, p, ringStream))
|
2020-09-25 19:51:08 +02:00
|
|
|
break;
|
2021-03-08 11:40:32 +01:00
|
|
|
DCC::verifyCVByte(p[0], p[1], callback_Vbyte);
|
2020-09-25 19:51:08 +02:00
|
|
|
return;
|
2020-09-20 01:59:07 +02:00
|
|
|
}
|
2020-09-25 19:51:08 +02:00
|
|
|
if (params == 3)
|
|
|
|
{
|
2021-03-08 11:40:32 +01:00
|
|
|
if (!stashCallback(stream, p, ringStream))
|
2020-09-25 19:51:08 +02:00
|
|
|
break;
|
2021-03-08 11:40:32 +01:00
|
|
|
DCC::verifyCVBit(p[0], p[1], p[2], callback_Vbit);
|
2020-09-25 19:51:08 +02:00
|
|
|
return;
|
2020-09-20 01:59:07 +02:00
|
|
|
}
|
|
|
|
break;
|
2020-09-25 19:51:08 +02:00
|
|
|
|
|
|
|
case 'B': // WRITE CV BIT ON PROG <B CV BIT VALUE CALLBACKNUM CALLBACKSUB>
|
2021-03-08 11:40:32 +01:00
|
|
|
if (!stashCallback(stream, p, ringStream))
|
2020-09-25 19:51:08 +02:00
|
|
|
break;
|
2021-03-08 11:40:32 +01:00
|
|
|
DCC::writeCVBit(p[0], p[1], p[2], callback_B);
|
2020-06-03 15:26:49 +02:00
|
|
|
return;
|
2020-09-25 19:51:08 +02:00
|
|
|
|
|
|
|
case 'R': // READ CV ON PROG
|
2022-05-03 01:58:03 +02:00
|
|
|
if (params == 1)
|
|
|
|
{ // <R CV> -- uses verify callback
|
|
|
|
if (!stashCallback(stream, p, ringStream))
|
|
|
|
break;
|
2022-05-03 08:38:35 +02:00
|
|
|
DCC::verifyCVByte(p[0], 0, callback_Vbyte);
|
2022-05-03 01:58:03 +02:00
|
|
|
return;
|
|
|
|
}
|
2020-09-25 19:51:08 +02:00
|
|
|
if (params == 3)
|
|
|
|
{ // <R CV CALLBACKNUM CALLBACKSUB>
|
2021-03-08 11:40:32 +01:00
|
|
|
if (!stashCallback(stream, p, ringStream))
|
2020-09-25 19:51:08 +02:00
|
|
|
break;
|
2021-03-08 11:40:32 +01:00
|
|
|
DCC::readCV(p[0], callback_R);
|
2020-09-25 19:51:08 +02:00
|
|
|
return;
|
2020-09-20 01:59:07 +02:00
|
|
|
}
|
2020-09-25 19:51:08 +02:00
|
|
|
if (params == 0)
|
|
|
|
{ // <R> New read loco id
|
2021-03-08 11:40:32 +01:00
|
|
|
if (!stashCallback(stream, p, ringStream))
|
2020-09-25 19:51:08 +02:00
|
|
|
break;
|
2021-03-08 11:40:32 +01:00
|
|
|
DCC::getLocoId(callback_Rloco);
|
2020-09-25 19:51:08 +02:00
|
|
|
return;
|
2020-09-20 01:59:07 +02:00
|
|
|
}
|
|
|
|
break;
|
2023-04-19 23:21:32 +02:00
|
|
|
#endif
|
2020-09-25 19:51:08 +02:00
|
|
|
|
2021-12-05 13:08:59 +01:00
|
|
|
case '1': // POWERON <1 [MAIN|PROG|JOIN]>
|
2022-01-06 23:03:57 +01:00
|
|
|
{
|
2021-12-05 13:08:59 +01:00
|
|
|
bool main=false;
|
|
|
|
bool prog=false;
|
2022-01-06 23:03:57 +01:00
|
|
|
bool join=false;
|
2021-12-05 13:08:59 +01:00
|
|
|
if (params > 1) break;
|
2023-06-21 10:44:57 +02:00
|
|
|
if (params==0) { // All
|
2022-01-06 23:03:57 +01:00
|
|
|
main=true;
|
|
|
|
prog=true;
|
2021-12-05 13:08:59 +01:00
|
|
|
}
|
2022-01-08 21:44:32 +01:00
|
|
|
if (params==1) {
|
2023-04-23 22:45:47 +02:00
|
|
|
if (p[0]==HASH_KEYWORD_MAIN) { // <1 MAIN>
|
2022-01-06 23:03:57 +01:00
|
|
|
main=true;
|
2022-01-08 21:44:32 +01:00
|
|
|
}
|
2023-04-23 22:45:47 +02:00
|
|
|
#ifndef DISABLE_PROG
|
|
|
|
else if (p[0] == HASH_KEYWORD_JOIN) { // <1 JOIN>
|
2022-01-06 23:03:57 +01:00
|
|
|
main=true;
|
2023-04-23 22:45:47 +02:00
|
|
|
prog=true;
|
|
|
|
join=true;
|
2022-01-08 21:44:32 +01:00
|
|
|
}
|
|
|
|
else if (p[0]==HASH_KEYWORD_PROG) { // <1 PROG>
|
2022-01-06 23:03:57 +01:00
|
|
|
prog=true;
|
2022-01-08 21:44:32 +01:00
|
|
|
}
|
2023-04-23 20:24:29 +02:00
|
|
|
#endif
|
2022-01-08 21:44:32 +01:00
|
|
|
else break; // will reply <X>
|
|
|
|
}
|
2023-07-02 13:55:56 +02:00
|
|
|
TrackManager::setJoin(join);
|
2022-02-23 16:44:34 +01:00
|
|
|
if (main) TrackManager::setMainPower(POWERMODE::ON);
|
|
|
|
if (prog) TrackManager::setProgPower(POWERMODE::ON);
|
2022-01-06 23:03:57 +01:00
|
|
|
|
|
|
|
CommandDistributor::broadcastPower();
|
2020-06-03 15:26:49 +02:00
|
|
|
return;
|
2021-12-05 13:08:59 +01:00
|
|
|
}
|
2022-01-06 23:03:57 +01:00
|
|
|
|
2021-12-05 13:08:59 +01:00
|
|
|
case '0': // POWEROFF <0 [MAIN | PROG] >
|
2022-01-06 23:03:57 +01:00
|
|
|
{
|
2021-12-05 13:08:59 +01:00
|
|
|
bool main=false;
|
|
|
|
bool prog=false;
|
|
|
|
if (params > 1) break;
|
2023-06-21 10:44:57 +02:00
|
|
|
if (params==0) { // All
|
2022-01-08 21:44:32 +01:00
|
|
|
main=true;
|
|
|
|
prog=true;
|
2021-12-05 13:08:59 +01:00
|
|
|
}
|
2022-01-08 21:44:32 +01:00
|
|
|
if (params==1) {
|
|
|
|
if (p[0]==HASH_KEYWORD_MAIN) { // <0 MAIN>
|
|
|
|
main=true;
|
|
|
|
}
|
2023-04-23 20:24:29 +02:00
|
|
|
#ifndef DISABLE_PROG
|
2022-01-08 21:44:32 +01:00
|
|
|
else if (p[0]==HASH_KEYWORD_PROG) { // <0 PROG>
|
|
|
|
prog=true;
|
|
|
|
}
|
2023-04-23 20:24:29 +02:00
|
|
|
#endif
|
2022-01-08 21:44:32 +01:00
|
|
|
else break; // will reply <X>
|
|
|
|
}
|
2020-05-25 14:38:18 +02:00
|
|
|
|
2023-07-02 13:55:56 +02:00
|
|
|
TrackManager::setJoin(false);
|
2022-02-23 16:44:34 +01:00
|
|
|
if (main) TrackManager::setMainPower(POWERMODE::OFF);
|
2021-12-05 13:08:59 +01:00
|
|
|
if (prog) {
|
2022-03-19 12:22:31 +01:00
|
|
|
TrackManager::progTrackBoosted=false; // Prog track boost mode will not outlive prog track off
|
2022-02-23 16:44:34 +01:00
|
|
|
TrackManager::setProgPower(POWERMODE::OFF);
|
2021-12-05 13:08:59 +01:00
|
|
|
}
|
2022-01-06 23:03:57 +01:00
|
|
|
|
2021-12-05 13:08:59 +01:00
|
|
|
CommandDistributor::broadcastPower();
|
|
|
|
return;
|
|
|
|
}
|
2022-01-06 23:03:57 +01:00
|
|
|
|
2021-03-23 15:37:05 +01:00
|
|
|
case '!': // ESTOP ALL <!>
|
2022-01-06 23:03:57 +01:00
|
|
|
DCC::setThrottle(0,1,1); // this broadcasts speed 1(estop) and sets all reminders to speed 1.
|
2021-03-23 15:37:05 +01:00
|
|
|
return;
|
|
|
|
|
2021-01-18 23:46:41 +01:00
|
|
|
case 'c': // SEND METER RESPONSES <c>
|
2023-03-02 13:56:30 +01:00
|
|
|
// No longer useful because of multiple tracks See <JG> and <JI>
|
|
|
|
if (params>0) break;
|
|
|
|
TrackManager::reportObsoleteCurrent(stream);
|
|
|
|
return;
|
2020-09-25 19:51:08 +02:00
|
|
|
|
|
|
|
case 'Q': // SENSORS <Q>
|
2020-10-26 00:56:25 +01:00
|
|
|
Sensor::printAll(stream);
|
2020-09-06 13:44:19 +02:00
|
|
|
return;
|
2020-06-03 15:26:49 +02:00
|
|
|
|
2020-09-25 19:51:08 +02:00
|
|
|
case 's': // <s>
|
2021-03-30 23:01:37 +02:00
|
|
|
StringFormatter::send(stream, F("<iDCC-EX V-%S / %S / %S G-%S>\n"), F(VERSION), F(ARDUINO_TYPE), DCC::getMotorShieldName(), F(GITHUB_SHA));
|
2023-01-29 08:13:52 +01:00
|
|
|
CommandDistributor::broadcastPower(); // <s> is the only "get power status" command we have
|
2021-01-04 16:57:03 +01:00
|
|
|
Turnout::printAll(stream); //send all Turnout states
|
2020-12-27 16:20:11 +01:00
|
|
|
Sensor::printAll(stream); //send all Sensor states
|
|
|
|
return;
|
2020-05-25 14:38:18 +02:00
|
|
|
|
2021-11-08 02:07:21 +01:00
|
|
|
#ifndef DISABLE_EEPROM
|
2020-09-25 19:51:08 +02:00
|
|
|
case 'E': // STORE EPROM <E>
|
2020-05-25 14:38:18 +02:00
|
|
|
EEStore::store();
|
2021-03-30 23:01:37 +02:00
|
|
|
StringFormatter::send(stream, F("<e %d %d %d>\n"), EEStore::eeStore->data.nTurnouts, EEStore::eeStore->data.nSensors, EEStore::eeStore->data.nOutputs);
|
2020-06-03 15:26:49 +02:00
|
|
|
return;
|
2020-05-25 14:38:18 +02:00
|
|
|
|
2020-09-25 19:51:08 +02:00
|
|
|
case 'e': // CLEAR EPROM <e>
|
2020-05-25 14:38:18 +02:00
|
|
|
EEStore::clear();
|
2021-03-30 23:01:37 +02:00
|
|
|
StringFormatter::send(stream, F("<O>\n"));
|
2020-06-03 15:26:49 +02:00
|
|
|
return;
|
2021-11-08 02:07:21 +01:00
|
|
|
#endif
|
2020-09-25 19:51:08 +02:00
|
|
|
case ' ': // < >
|
|
|
|
StringFormatter::send(stream, F("\n"));
|
2020-06-03 15:26:49 +02:00
|
|
|
return;
|
2020-09-25 19:51:08 +02:00
|
|
|
|
|
|
|
case 'D': // < >
|
|
|
|
if (parseD(stream, params, p))
|
|
|
|
return;
|
2020-07-01 11:27:53 +02:00
|
|
|
return;
|
2020-07-04 21:53:44 +02:00
|
|
|
|
2022-03-18 17:41:52 +01:00
|
|
|
case '=': // <= Track manager control >
|
2022-02-22 02:27:27 +01:00
|
|
|
if (TrackManager::parseJ(stream, params, p))
|
|
|
|
return;
|
|
|
|
break;
|
|
|
|
|
2020-09-25 19:51:08 +02:00
|
|
|
case '#': // NUMBER OF LOCOSLOTS <#>
|
2021-03-30 23:01:37 +02:00
|
|
|
StringFormatter::send(stream, F("<# %d>\n"), MAX_LOCOS);
|
2020-09-25 19:51:08 +02:00
|
|
|
return;
|
2020-07-30 16:34:56 +02:00
|
|
|
|
2021-03-23 15:37:05 +01:00
|
|
|
case '-': // Forget Loco <- [cab]>
|
|
|
|
if (params > 1 || p[0]<0) break;
|
|
|
|
if (p[0]==0) DCC::forgetAllLocos();
|
|
|
|
else DCC::forgetLoco(p[0]);
|
|
|
|
return;
|
|
|
|
|
2020-07-30 16:34:56 +02:00
|
|
|
case 'F': // New command to call the new Loco Function API <F cab func 1|0>
|
2021-12-17 22:19:55 +01:00
|
|
|
if(params!=3) break;
|
2020-09-25 19:51:08 +02:00
|
|
|
if (Diag::CMD)
|
|
|
|
DIAG(F("Setting loco %d F%d %S"), p[0], p[1], p[2] ? F("ON") : F("OFF"));
|
2022-08-20 18:15:18 +02:00
|
|
|
if (DCC::setFn(p[0], p[1], p[2] == 1)) return;
|
|
|
|
break;
|
2020-09-26 11:54:11 +02:00
|
|
|
|
2022-04-12 18:05:55 +02:00
|
|
|
#if WIFI_ON
|
2020-09-25 19:51:08 +02:00
|
|
|
case '+': // Complex Wifi interface command (not usual parse)
|
2021-06-30 23:01:18 +02:00
|
|
|
if (atCommandCallback && !ringStream) {
|
2022-02-23 16:44:34 +01:00
|
|
|
TrackManager::setPower(POWERMODE::OFF);
|
2021-12-20 11:33:48 +01:00
|
|
|
atCommandCallback((HardwareSerial *)stream,com);
|
2020-09-26 11:54:11 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
break;
|
2022-04-12 18:05:55 +02:00
|
|
|
#endif
|
2020-09-26 11:54:11 +02:00
|
|
|
|
2022-04-08 12:41:50 +02:00
|
|
|
case 'J' : // throttle info access
|
|
|
|
{
|
2023-01-11 18:36:11 +01:00
|
|
|
if ((params<1) | (params>3)) break; // <J>
|
2023-01-21 11:18:54 +01:00
|
|
|
//if ((params<1) | (params>2)) break; // <J>
|
2022-04-08 12:41:50 +02:00
|
|
|
int16_t id=(params==2)?p[1]:0;
|
|
|
|
switch(p[0]) {
|
2023-01-11 18:36:11 +01:00
|
|
|
case HASH_KEYWORD_C: // <JC mmmm nn> sets time and speed
|
|
|
|
if (params==1) { // <JC> returns latest time
|
2023-01-21 11:18:54 +01:00
|
|
|
int16_t x = CommandDistributor::retClockTime();
|
|
|
|
StringFormatter::send(stream, F("<jC %d>\n"), x);
|
2023-01-11 18:36:11 +01:00
|
|
|
return;
|
|
|
|
}
|
2023-01-21 11:18:54 +01:00
|
|
|
CommandDistributor::setClockTime(p[1], p[2], 1);
|
2023-01-11 18:36:11 +01:00
|
|
|
return;
|
2023-03-02 13:56:30 +01:00
|
|
|
|
|
|
|
case HASH_KEYWORD_G: // <JG> current gauge limits
|
|
|
|
if (params>1) break;
|
|
|
|
TrackManager::reportGauges(stream); // <g limit...limit>
|
|
|
|
return;
|
|
|
|
|
|
|
|
case HASH_KEYWORD_I: // <JI> current values
|
|
|
|
if (params>1) break;
|
|
|
|
TrackManager::reportCurrent(stream); // <g limit...limit>
|
|
|
|
return;
|
2023-01-21 11:18:54 +01:00
|
|
|
|
2022-04-08 12:41:50 +02:00
|
|
|
case HASH_KEYWORD_A: // <JA> returns automations/routes
|
|
|
|
StringFormatter::send(stream, F("<jA"));
|
2022-04-08 17:13:15 +02:00
|
|
|
if (params==1) {// <JA>
|
2022-04-08 12:41:50 +02:00
|
|
|
#ifdef EXRAIL_ACTIVE
|
2022-12-16 14:14:48 +01:00
|
|
|
SENDFLASHLIST(stream,RMFT2::routeIdList)
|
|
|
|
SENDFLASHLIST(stream,RMFT2::automationIdList)
|
2022-04-08 17:13:15 +02:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
else { // <JA id>
|
|
|
|
StringFormatter::send(stream,F(" %d %c \"%S\""),
|
|
|
|
id,
|
|
|
|
#ifdef EXRAIL_ACTIVE
|
|
|
|
RMFT2::getRouteType(id), // A/R
|
|
|
|
RMFT2::getRouteDescription(id)
|
|
|
|
#else
|
|
|
|
'X',F("")
|
|
|
|
#endif
|
|
|
|
);
|
|
|
|
}
|
2022-04-08 12:41:50 +02:00
|
|
|
StringFormatter::send(stream, F(">\n"));
|
|
|
|
return;
|
|
|
|
case HASH_KEYWORD_R: // <JR> returns rosters
|
|
|
|
StringFormatter::send(stream, F("<jR"));
|
|
|
|
#ifdef EXRAIL_ACTIVE
|
2022-12-16 14:14:48 +01:00
|
|
|
if (params==1) {
|
|
|
|
SENDFLASHLIST(stream,RMFT2::rosterIdList)
|
|
|
|
}
|
2023-05-25 10:29:01 +02:00
|
|
|
else {
|
|
|
|
const FSH * functionNames= RMFT2::getRosterFunctions(id);
|
|
|
|
StringFormatter::send(stream,F(" %d \"%S\" \"%S\""),
|
|
|
|
id, RMFT2::getRosterName(id),
|
|
|
|
functionNames == NULL ? RMFT2::getRosterFunctions(0) : functionNames);
|
|
|
|
}
|
2022-04-08 12:41:50 +02:00
|
|
|
#endif
|
|
|
|
StringFormatter::send(stream, F(">\n"));
|
|
|
|
return;
|
|
|
|
case HASH_KEYWORD_T: // <JT> returns turnout list
|
|
|
|
StringFormatter::send(stream, F("<jT"));
|
|
|
|
if (params==1) { // <JT>
|
|
|
|
for ( Turnout * t=Turnout::first(); t; t=t->next()) {
|
2022-04-13 00:10:29 +02:00
|
|
|
if (t->isHidden()) continue;
|
|
|
|
StringFormatter::send(stream, F(" %d"),t->getId());
|
2022-04-08 12:41:50 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else { // <JT id>
|
|
|
|
Turnout * t=Turnout::get(id);
|
2022-04-13 00:10:29 +02:00
|
|
|
if (!t || t->isHidden()) StringFormatter::send(stream, F(" %d X"),id);
|
2023-01-27 18:42:26 +01:00
|
|
|
else {
|
|
|
|
const FSH *tdesc = NULL;
|
2022-04-08 12:41:50 +02:00
|
|
|
#ifdef EXRAIL_ACTIVE
|
2023-01-27 18:42:26 +01:00
|
|
|
tdesc = RMFT2::getTurnoutDescription(id);
|
|
|
|
#endif
|
|
|
|
if (tdesc == NULL)
|
2023-01-28 19:07:59 +01:00
|
|
|
tdesc = F("");
|
|
|
|
StringFormatter::send(stream, F(" %d %c \"%S\""),
|
|
|
|
id,t->isThrown()?'T':'C',
|
|
|
|
tdesc);
|
2023-01-27 18:42:26 +01:00
|
|
|
}
|
2022-04-08 12:41:50 +02:00
|
|
|
}
|
|
|
|
StringFormatter::send(stream, F(">\n"));
|
|
|
|
return;
|
|
|
|
default: break;
|
|
|
|
} // switch(p[1])
|
|
|
|
break; // case J
|
|
|
|
}
|
2020-09-26 11:54:11 +02:00
|
|
|
|
2023-08-20 11:26:04 +02:00
|
|
|
case 'I': // TURNTABLE <I ...>
|
|
|
|
if (parseI(stream, params, p))
|
|
|
|
return;
|
|
|
|
break;
|
|
|
|
|
2020-09-25 19:51:08 +02:00
|
|
|
default: //anything else will diagnose and drop out to <X>
|
2021-03-25 15:23:38 +01:00
|
|
|
DIAG(F("Opcode=%c params=%d"), opcode, params);
|
2020-09-25 19:51:08 +02:00
|
|
|
for (int i = 0; i < params; i++)
|
2021-03-25 15:23:38 +01:00
|
|
|
DIAG(F("p[%d]=%d (0x%x)"), i, p[i], p[i]);
|
2020-06-07 21:11:44 +02:00
|
|
|
break;
|
2020-09-25 19:51:08 +02:00
|
|
|
|
|
|
|
} // end of opcode switch
|
2020-06-03 15:26:49 +02:00
|
|
|
|
|
|
|
// Any fallout here sends an <X>
|
2021-03-30 23:01:37 +02:00
|
|
|
StringFormatter::send(stream, F("<X>\n"));
|
2020-05-25 14:38:18 +02:00
|
|
|
}
|
|
|
|
|
2021-03-25 18:16:12 +01:00
|
|
|
bool DCCEXParser::parseZ(Print *stream, int16_t params, int16_t p[])
|
2020-09-25 19:51:08 +02:00
|
|
|
{
|
2020-06-03 15:26:49 +02:00
|
|
|
|
2020-09-25 19:51:08 +02:00
|
|
|
switch (params)
|
|
|
|
{
|
2020-09-29 23:19:02 +02:00
|
|
|
|
2020-09-25 19:51:08 +02:00
|
|
|
case 2: // <Z ID ACTIVATE>
|
|
|
|
{
|
|
|
|
Output *o = Output::get(p[0]);
|
|
|
|
if (o == NULL)
|
|
|
|
return false;
|
|
|
|
o->activate(p[1]);
|
2021-03-30 23:01:37 +02:00
|
|
|
StringFormatter::send(stream, F("<Y %d %d>\n"), p[0], p[1]);
|
2020-09-25 19:51:08 +02:00
|
|
|
}
|
|
|
|
return true;
|
|
|
|
|
2021-07-24 23:44:24 +02:00
|
|
|
case 3: // <Z ID PIN IFLAG>
|
2021-08-03 23:12:25 +02:00
|
|
|
if (p[0] < 0 || p[2] < 0 || p[2] > 7 )
|
|
|
|
return false;
|
2020-10-26 17:57:37 +01:00
|
|
|
if (!Output::create(p[0], p[1], p[2], 1))
|
2020-10-27 07:24:48 +01:00
|
|
|
return false;
|
2021-03-30 23:01:37 +02:00
|
|
|
StringFormatter::send(stream, F("<O>\n"));
|
2020-09-25 19:51:08 +02:00
|
|
|
return true;
|
|
|
|
|
|
|
|
case 1: // <Z ID>
|
2020-10-26 17:57:37 +01:00
|
|
|
if (!Output::remove(p[0]))
|
|
|
|
return false;
|
2021-03-30 23:01:37 +02:00
|
|
|
StringFormatter::send(stream, F("<O>\n"));
|
2020-10-26 17:57:37 +01:00
|
|
|
return true;
|
2020-09-25 19:51:08 +02:00
|
|
|
|
2021-01-04 16:57:03 +01:00
|
|
|
case 0: // <Z> list Output definitions
|
2020-09-25 19:51:08 +02:00
|
|
|
{
|
|
|
|
bool gotone = false;
|
|
|
|
for (Output *tt = Output::firstOutput; tt != NULL; tt = tt->nextOutput)
|
|
|
|
{
|
|
|
|
gotone = true;
|
2021-08-03 23:12:25 +02:00
|
|
|
StringFormatter::send(stream, F("<Y %d %d %d %d>\n"), tt->data.id, tt->data.pin, tt->data.flags, tt->data.active);
|
2020-06-03 15:26:49 +02:00
|
|
|
}
|
2020-09-25 19:51:08 +02:00
|
|
|
return gotone;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
2020-06-03 15:26:49 +02:00
|
|
|
|
2020-06-22 11:54:57 +02:00
|
|
|
//===================================
|
2021-03-25 18:16:12 +01:00
|
|
|
bool DCCEXParser::parsef(Print *stream, int16_t params, int16_t p[])
|
2020-09-25 19:51:08 +02:00
|
|
|
{
|
2022-08-20 18:15:18 +02:00
|
|
|
// JMRI sends this info in DCC message format but it's not exactly
|
|
|
|
// convenient for other processing
|
|
|
|
if (params == 2) {
|
|
|
|
byte instructionField = p[1] & 0xE0; // 1110 0000
|
|
|
|
if (instructionField == 0x80) { // 1000 0000 Function group 1
|
|
|
|
// Shuffle bits from order F0 F4 F3 F2 F1 to F4 F3 F2 F1 F0
|
|
|
|
byte normalized = (p[1] << 1 & 0x1e) | (p[1] >> 4 & 0x01);
|
|
|
|
return (funcmap(p[0], normalized, 0, 4));
|
|
|
|
} else if (instructionField == 0xA0) { // 1010 0000 Function group 2
|
|
|
|
if (p[1] & 0x10) // 0001 0000 Bit selects F5toF8 / F9toF12
|
|
|
|
return (funcmap(p[0], p[1], 5, 8));
|
|
|
|
else
|
|
|
|
return (funcmap(p[0], p[1], 9, 12));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (params == 3) {
|
|
|
|
if (p[1] == 222) {
|
|
|
|
return (funcmap(p[0], p[2], 13, 20));
|
|
|
|
} else if (p[1] == 223) {
|
|
|
|
return (funcmap(p[0], p[2], 21, 28));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
(void)stream; // NO RESPONSE
|
|
|
|
return false;
|
2020-06-22 11:54:57 +02:00
|
|
|
}
|
|
|
|
|
2022-08-20 18:15:18 +02:00
|
|
|
bool DCCEXParser::funcmap(int16_t cab, byte value, byte fstart, byte fstop)
|
2020-09-25 19:51:08 +02:00
|
|
|
{
|
2022-08-20 18:15:18 +02:00
|
|
|
for (int16_t i = fstart; i <= fstop; i++) {
|
|
|
|
if (! DCC::setFn(cab, i, value & 1)) return false;
|
|
|
|
value >>= 1;
|
|
|
|
}
|
|
|
|
return true;
|
2020-06-22 11:54:57 +02:00
|
|
|
}
|
2020-06-03 15:26:49 +02:00
|
|
|
|
|
|
|
//===================================
|
2021-03-25 18:16:12 +01:00
|
|
|
bool DCCEXParser::parseT(Print *stream, int16_t params, int16_t p[])
|
2020-09-25 19:51:08 +02:00
|
|
|
{
|
|
|
|
switch (params)
|
|
|
|
{
|
2021-01-04 16:57:03 +01:00
|
|
|
case 0: // <T> list turnout definitions
|
2022-11-04 23:15:29 +01:00
|
|
|
return Turnout::printAll(stream); // will <X> if none found
|
2020-06-07 21:11:44 +02:00
|
|
|
|
2020-09-25 19:51:08 +02:00
|
|
|
case 1: // <T id> delete turnout
|
|
|
|
if (!Turnout::remove(p[0]))
|
|
|
|
return false;
|
2021-03-30 23:01:37 +02:00
|
|
|
StringFormatter::send(stream, F("<O>\n"));
|
2020-09-25 19:51:08 +02:00
|
|
|
return true;
|
|
|
|
|
2021-08-19 22:22:59 +02:00
|
|
|
case 2: // <T id 0|1|T|C>
|
2021-08-20 15:36:18 +02:00
|
|
|
{
|
|
|
|
bool state = false;
|
|
|
|
switch (p[1]) {
|
2021-08-24 23:18:51 +02:00
|
|
|
// Turnout messages use 1=throw, 0=close.
|
2021-08-20 15:36:18 +02:00
|
|
|
case 0:
|
|
|
|
case HASH_KEYWORD_C:
|
|
|
|
state = true;
|
|
|
|
break;
|
2021-08-24 23:18:51 +02:00
|
|
|
case 1:
|
2021-08-20 15:36:18 +02:00
|
|
|
case HASH_KEYWORD_T:
|
|
|
|
state= false;
|
|
|
|
break;
|
2022-11-05 23:11:54 +01:00
|
|
|
case HASH_KEYWORD_X:
|
|
|
|
{
|
2022-11-04 23:43:26 +01:00
|
|
|
Turnout *tt = Turnout::get(p[0]);
|
|
|
|
if (tt) {
|
|
|
|
tt->print(stream);
|
2022-11-05 23:11:54 +01:00
|
|
|
return true;
|
2022-11-04 23:43:26 +01:00
|
|
|
}
|
|
|
|
return false;
|
2022-11-05 23:11:54 +01:00
|
|
|
}
|
|
|
|
default: // Invalid parameter
|
|
|
|
return false;
|
2021-08-20 15:36:18 +02:00
|
|
|
}
|
|
|
|
if (!Turnout::setClosed(p[0], state)) return false;
|
|
|
|
return true;
|
2021-08-19 22:22:59 +02:00
|
|
|
}
|
2020-06-03 15:26:49 +02:00
|
|
|
|
2021-08-20 15:36:18 +02:00
|
|
|
default: // Anything else is some kind of turnout create function.
|
|
|
|
if (params == 6 && p[1] == HASH_KEYWORD_SERVO) { // <T id SERVO n n n n>
|
|
|
|
if (!ServoTurnout::create(p[0], (VPIN)p[2], (uint16_t)p[3], (uint16_t)p[4], (uint8_t)p[5]))
|
2021-08-19 22:22:59 +02:00
|
|
|
return false;
|
|
|
|
} else
|
2021-08-20 15:36:18 +02:00
|
|
|
if (params == 3 && p[1] == HASH_KEYWORD_VPIN) { // <T id VPIN n>
|
|
|
|
if (!VpinTurnout::create(p[0], p[2])) return false;
|
|
|
|
} else
|
|
|
|
if (params >= 3 && p[1] == HASH_KEYWORD_DCC) {
|
2021-09-22 11:38:11 +02:00
|
|
|
// <T id DCC addr subadd> 0<=addr<=511, 0<=subadd<=3 (like <a> command).<T>
|
|
|
|
if (params==4 && p[2]>=0 && p[2]<512 && p[3]>=0 && p[3]<4) { // <T id DCC n m>
|
2021-08-19 22:22:59 +02:00
|
|
|
if (!DCCTurnout::create(p[0], p[2], p[3])) return false;
|
2021-08-20 15:36:18 +02:00
|
|
|
} else if (params==3 && p[2]>0 && p[2]<=512*4) { // <T id DCC nn>, 1<=nn<=2048
|
2021-09-22 11:38:11 +02:00
|
|
|
// Linearaddress 1 maps onto decoder address 1/0 (not 0/0!).
|
2021-08-19 22:22:59 +02:00
|
|
|
if (!DCCTurnout::create(p[0], (p[2]-1)/4+1, (p[2]-1)%4)) return false;
|
|
|
|
} else
|
|
|
|
return false;
|
2021-08-20 15:36:18 +02:00
|
|
|
} else
|
2021-09-22 11:38:11 +02:00
|
|
|
if (params==3) { // legacy <T id addr subadd> for DCC accessory
|
|
|
|
if (p[1]>=0 && p[1]<512 && p[2]>=0 && p[2]<4) {
|
2021-08-20 15:36:18 +02:00
|
|
|
if (!DCCTurnout::create(p[0], p[1], p[2])) return false;
|
|
|
|
} else
|
|
|
|
return false;
|
2021-08-19 22:22:59 +02:00
|
|
|
}
|
2021-08-20 15:36:18 +02:00
|
|
|
else
|
|
|
|
if (params==4) { // legacy <T id n n n> for Servo
|
2021-08-19 22:22:59 +02:00
|
|
|
if (!ServoTurnout::create(p[0], (VPIN)p[1], (uint16_t)p[2], (uint16_t)p[3], 1)) return false;
|
2021-08-20 15:36:18 +02:00
|
|
|
} else
|
|
|
|
return false;
|
|
|
|
|
2021-08-19 22:22:59 +02:00
|
|
|
StringFormatter::send(stream, F("<O>\n"));
|
|
|
|
return true;
|
2020-09-25 19:51:08 +02:00
|
|
|
}
|
2020-06-03 15:26:49 +02:00
|
|
|
}
|
|
|
|
|
2021-03-25 18:16:12 +01:00
|
|
|
bool DCCEXParser::parseS(Print *stream, int16_t params, int16_t p[])
|
2020-09-25 19:51:08 +02:00
|
|
|
{
|
2020-06-03 15:26:49 +02:00
|
|
|
|
2020-09-25 19:51:08 +02:00
|
|
|
switch (params)
|
|
|
|
{
|
|
|
|
case 3: // <S id pin pullup> create sensor. pullUp indicator (0=LOW/1=HIGH)
|
2020-10-26 17:57:37 +01:00
|
|
|
if (!Sensor::create(p[0], p[1], p[2]))
|
|
|
|
return false;
|
2021-03-30 23:01:37 +02:00
|
|
|
StringFormatter::send(stream, F("<O>\n"));
|
2020-09-25 19:51:08 +02:00
|
|
|
return true;
|
2020-06-03 15:26:49 +02:00
|
|
|
|
2020-09-25 19:51:08 +02:00
|
|
|
case 1: // S id> remove sensor
|
2020-10-26 17:57:37 +01:00
|
|
|
if (!Sensor::remove(p[0]))
|
|
|
|
return false;
|
2021-03-30 23:01:37 +02:00
|
|
|
StringFormatter::send(stream, F("<O>\n"));
|
2020-10-26 17:57:37 +01:00
|
|
|
return true;
|
2020-06-03 15:26:49 +02:00
|
|
|
|
2021-01-04 16:57:03 +01:00
|
|
|
case 0: // <S> list sensor definitions
|
2021-08-03 23:12:25 +02:00
|
|
|
if (Sensor::firstSensor == NULL)
|
|
|
|
return false;
|
|
|
|
for (Sensor *tt = Sensor::firstSensor; tt != NULL; tt = tt->nextSensor)
|
|
|
|
{
|
|
|
|
StringFormatter::send(stream, F("<Q %d %d %d>\n"), tt->data.snum, tt->data.pin, tt->data.pullUp);
|
|
|
|
}
|
|
|
|
return true;
|
2020-09-25 19:51:08 +02:00
|
|
|
|
|
|
|
default: // invalid number of arguments
|
|
|
|
break;
|
|
|
|
}
|
2020-06-03 15:26:49 +02:00
|
|
|
return false;
|
|
|
|
}
|
2020-06-07 14:48:42 +02:00
|
|
|
|
2021-03-25 18:16:12 +01:00
|
|
|
bool DCCEXParser::parseD(Print *stream, int16_t params, int16_t p[])
|
2020-09-25 19:51:08 +02:00
|
|
|
{
|
|
|
|
if (params == 0)
|
|
|
|
return false;
|
|
|
|
bool onOff = (params > 0) && (p[1] == 1 || p[1] == HASH_KEYWORD_ON); // dont care if other stuff or missing... just means off
|
|
|
|
switch (p[0])
|
|
|
|
{
|
|
|
|
case HASH_KEYWORD_CABS: // <D CABS>
|
|
|
|
DCC::displayCabList(stream);
|
|
|
|
return true;
|
|
|
|
|
|
|
|
case HASH_KEYWORD_RAM: // <D RAM>
|
2022-03-01 13:52:25 +01:00
|
|
|
StringFormatter::send(stream, F("Free memory=%d\n"), DCCTimer::getMinimumFreeMemory());
|
2020-09-25 19:51:08 +02:00
|
|
|
break;
|
2020-09-10 14:09:32 +02:00
|
|
|
|
2023-04-20 00:26:17 +02:00
|
|
|
#ifndef DISABLE_PROG
|
2021-08-23 12:58:48 +02:00
|
|
|
case HASH_KEYWORD_ACK: // <D ACK ON/OFF> <D ACK [LIMIT|MIN|MAX|RETRY] Value>
|
2020-11-24 21:39:21 +01:00
|
|
|
if (params >= 3) {
|
|
|
|
if (p[1] == HASH_KEYWORD_LIMIT) {
|
2022-02-23 16:44:34 +01:00
|
|
|
DCCACK::setAckLimit(p[2]);
|
2021-08-23 13:35:42 +02:00
|
|
|
LCD(1, F("Ack Limit=%dmA"), p[2]); // <D ACK LIMIT 42>
|
2020-11-24 21:39:21 +01:00
|
|
|
} else if (p[1] == HASH_KEYWORD_MIN) {
|
2022-02-23 16:44:34 +01:00
|
|
|
DCCACK::setMinAckPulseDuration(p[2]);
|
2022-01-17 16:56:16 +01:00
|
|
|
LCD(0, F("Ack Min=%uus"), p[2]); // <D ACK MIN 1500>
|
2020-11-24 21:39:21 +01:00
|
|
|
} else if (p[1] == HASH_KEYWORD_MAX) {
|
2022-02-23 16:44:34 +01:00
|
|
|
DCCACK::setMaxAckPulseDuration(p[2]);
|
2022-01-17 16:56:16 +01:00
|
|
|
LCD(0, F("Ack Max=%uus"), p[2]); // <D ACK MAX 9000>
|
2021-08-23 12:58:48 +02:00
|
|
|
} else if (p[1] == HASH_KEYWORD_RETRY) {
|
|
|
|
if (p[2] >255) p[2]=3;
|
2022-02-23 16:44:34 +01:00
|
|
|
LCD(0, F("Ack Retry=%d Sum=%d"), p[2], DCCACK::setAckRetry(p[2])); // <D ACK RETRY 2>
|
2020-11-24 21:39:21 +01:00
|
|
|
}
|
2020-11-24 21:12:55 +01:00
|
|
|
} else {
|
2021-03-30 23:01:37 +02:00
|
|
|
StringFormatter::send(stream, F("Ack diag %S\n"), onOff ? F("on") : F("off"));
|
2020-10-08 23:39:04 +02:00
|
|
|
Diag::ACK = onOff;
|
2020-11-24 21:12:55 +01:00
|
|
|
}
|
2020-09-25 19:51:08 +02:00
|
|
|
return true;
|
2023-04-20 00:26:17 +02:00
|
|
|
#endif
|
2020-09-10 14:09:32 +02:00
|
|
|
|
2020-09-25 19:51:08 +02:00
|
|
|
case HASH_KEYWORD_CMD: // <D CMD ON/OFF>
|
|
|
|
Diag::CMD = onOff;
|
|
|
|
return true;
|
2020-09-10 14:09:32 +02:00
|
|
|
|
2021-08-23 12:58:48 +02:00
|
|
|
#ifdef HAS_ENOUGH_MEMORY
|
2020-09-25 19:51:08 +02:00
|
|
|
case HASH_KEYWORD_WIFI: // <D WIFI ON/OFF>
|
|
|
|
Diag::WIFI = onOff;
|
|
|
|
return true;
|
2020-09-10 14:09:32 +02:00
|
|
|
|
2021-08-23 12:58:48 +02:00
|
|
|
case HASH_KEYWORD_ETHERNET: // <D ETHERNET ON/OFF>
|
2020-10-30 14:00:02 +01:00
|
|
|
Diag::ETHERNET = onOff;
|
|
|
|
return true;
|
|
|
|
|
2020-09-25 19:51:08 +02:00
|
|
|
case HASH_KEYWORD_WIT: // <D WIT ON/OFF>
|
|
|
|
Diag::WITHROTTLE = onOff;
|
|
|
|
return true;
|
2021-08-23 12:58:48 +02:00
|
|
|
|
2021-03-23 15:37:05 +01:00
|
|
|
case HASH_KEYWORD_LCN: // <D LCN ON/OFF>
|
|
|
|
Diag::LCN = onOff;
|
|
|
|
return true;
|
2021-08-23 12:58:48 +02:00
|
|
|
#endif
|
2023-04-23 20:24:29 +02:00
|
|
|
#ifndef DISABLE_PROG
|
2020-09-27 13:03:46 +02:00
|
|
|
case HASH_KEYWORD_PROGBOOST:
|
2022-03-19 12:22:31 +01:00
|
|
|
TrackManager::progTrackBoosted=true;
|
|
|
|
return true;
|
2023-04-23 20:24:29 +02:00
|
|
|
#endif
|
2021-03-23 15:37:05 +01:00
|
|
|
case HASH_KEYWORD_RESET:
|
2022-07-08 16:01:40 +02:00
|
|
|
DCCTimer::reset();
|
|
|
|
break; // and <X> if we didnt restart
|
|
|
|
|
2021-11-08 02:07:21 +01:00
|
|
|
|
|
|
|
#ifndef DISABLE_EEPROM
|
2020-11-24 21:39:21 +01:00
|
|
|
case HASH_KEYWORD_EEPROM: // <D EEPROM NumEntries>
|
|
|
|
if (params >= 2)
|
2020-10-04 21:20:13 +02:00
|
|
|
EEStore::dump(p[1]);
|
|
|
|
return true;
|
2021-11-08 02:07:21 +01:00
|
|
|
#endif
|
2020-10-04 21:20:13 +02:00
|
|
|
|
2021-03-16 22:51:33 +01:00
|
|
|
case HASH_KEYWORD_SPEED28:
|
|
|
|
DCC::setGlobalSpeedsteps(28);
|
|
|
|
StringFormatter::send(stream, F("28 Speedsteps"));
|
|
|
|
return true;
|
|
|
|
|
|
|
|
case HASH_KEYWORD_SPEED128:
|
|
|
|
DCC::setGlobalSpeedsteps(128);
|
|
|
|
StringFormatter::send(stream, F("128 Speedsteps"));
|
|
|
|
return true;
|
|
|
|
|
2021-08-19 22:22:59 +02:00
|
|
|
case HASH_KEYWORD_SERVO: // <D SERVO vpin position [profile]>
|
2021-10-08 14:30:23 +02:00
|
|
|
case HASH_KEYWORD_ANOUT: // <D ANOUT vpin position [profile]>
|
2021-08-18 00:41:34 +02:00
|
|
|
IODevice::writeAnalogue(p[1], p[2], params>3 ? p[3] : 0);
|
|
|
|
break;
|
|
|
|
|
2021-10-08 14:30:23 +02:00
|
|
|
case HASH_KEYWORD_ANIN: // <D ANIN vpin> Display analogue input value
|
2023-03-27 14:08:14 +02:00
|
|
|
DIAG(F("VPIN=%u value=%d"), p[1], IODevice::readAnalogue(p[1]));
|
2021-10-08 14:30:23 +02:00
|
|
|
break;
|
|
|
|
|
2023-02-10 16:29:09 +01:00
|
|
|
#if !defined(IO_NO_HAL)
|
2021-08-27 16:44:26 +02:00
|
|
|
case HASH_KEYWORD_HAL:
|
|
|
|
if (p[1] == HASH_KEYWORD_SHOW)
|
|
|
|
IODevice::DumpAll();
|
2023-02-09 01:16:39 +01:00
|
|
|
else if (p[1] == HASH_KEYWORD_RESET)
|
|
|
|
IODevice::reset();
|
2021-08-27 16:44:26 +02:00
|
|
|
break;
|
|
|
|
#endif
|
|
|
|
|
2022-08-13 22:58:20 +02:00
|
|
|
case HASH_KEYWORD_TT: // <D TT vpin steps activity>
|
|
|
|
IODevice::writeAnalogue(p[1], p[2], params>3 ? p[3] : 0);
|
|
|
|
break;
|
|
|
|
|
2020-09-25 19:51:08 +02:00
|
|
|
default: // invalid/unknown
|
|
|
|
break;
|
|
|
|
}
|
2020-09-10 14:09:32 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2023-08-20 11:26:04 +02:00
|
|
|
// ==========================
|
|
|
|
// Turntable
|
2023-08-20 22:43:06 +02:00
|
|
|
// <I> - list all
|
|
|
|
// <I id> - delete
|
|
|
|
// <I id steps> - operate (DCC)
|
|
|
|
// <I id steps activity> - operate (EXTT)
|
|
|
|
// <I id EXTT i2caddress vpin position1 position2 ...> - create EXTT
|
|
|
|
// <I id DCC linear1 linear2 ...> - create DCC? - This TBA
|
2023-08-20 11:26:04 +02:00
|
|
|
bool DCCEXParser::parseI(Print *stream, int16_t params, int16_t p[])
|
|
|
|
{
|
|
|
|
switch (params)
|
|
|
|
{
|
|
|
|
case 0: // <I> list turntable objects
|
2023-08-22 11:30:22 +02:00
|
|
|
return Turntable::printAll(stream);
|
2023-08-20 11:26:04 +02:00
|
|
|
|
2023-08-23 11:08:04 +02:00
|
|
|
case 1: // <I id> delete turntable
|
2023-08-22 11:30:22 +02:00
|
|
|
if (!Turntable::remove(p[0]))
|
|
|
|
return false;
|
|
|
|
StringFormatter::send(stream, F("<O>\n"));
|
2023-08-20 11:26:04 +02:00
|
|
|
return true;
|
|
|
|
|
2023-08-23 11:08:04 +02:00
|
|
|
case 2: // <I id position> - rotate to position for DCC turntables
|
2023-08-21 11:33:45 +02:00
|
|
|
DIAG(F("Rotate DCC turntable %d to position %d"), p[0], p[1]);
|
|
|
|
return true;
|
|
|
|
|
2023-08-23 11:08:04 +02:00
|
|
|
case 3: // <I id position activity> rotate to position for EX-Turntable
|
2023-08-21 11:33:45 +02:00
|
|
|
DIAG(F("Rotate EXTT turntable %d to angle %d with activity %d"), p[0], p[1], p[2]);
|
|
|
|
return true;
|
2023-08-20 22:43:06 +02:00
|
|
|
|
2023-08-21 11:33:45 +02:00
|
|
|
default: // If we're here, it must be creating a turntable object
|
2023-08-20 22:43:06 +02:00
|
|
|
{
|
2023-08-22 11:30:22 +02:00
|
|
|
if (params > 5 && params < 41 && p[1] == HASH_KEYWORD_EXTT) {
|
|
|
|
DIAG(F("Create EXTT turntable %d on vpin %d and address %d with %d positions"), p[0], p[2], p[3], params - 4);
|
|
|
|
if (!EXTTTurntable::create(p[0], (uint8_t)p[1], (VPIN)p[2])) return false;
|
|
|
|
} else if (params > 3 && params < 39 && p[1] == HASH_KEYWORD_DCC) {
|
2023-08-21 11:33:45 +02:00
|
|
|
DIAG(F("Create DCC turntable %d at base address %d with %d positions"), p[0], p[2], params - 2);
|
2023-08-22 11:30:22 +02:00
|
|
|
} else {
|
|
|
|
return false;
|
2023-08-20 22:43:06 +02:00
|
|
|
}
|
|
|
|
}
|
2023-08-22 11:30:22 +02:00
|
|
|
return true;
|
2023-08-20 11:26:04 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-09-25 19:51:08 +02:00
|
|
|
// CALLBACKS must be static
|
2021-03-25 19:02:33 +01:00
|
|
|
bool DCCEXParser::stashCallback(Print *stream, int16_t p[MAX_COMMAND_PARAMS], RingStream * ringStream)
|
2020-09-25 19:51:08 +02:00
|
|
|
{
|
2020-10-05 19:42:31 +02:00
|
|
|
if (stashBusy )
|
2020-09-25 19:51:08 +02:00
|
|
|
return false;
|
|
|
|
stashBusy = true;
|
|
|
|
stashStream = stream;
|
2021-03-08 11:40:32 +01:00
|
|
|
stashRingStream=ringStream;
|
|
|
|
if (ringStream) stashTarget= ringStream->peekTargetMark();
|
Nano every2 (#129)
* Start adding back unowifi stuffz
* Uno Wifi compiling
* Fixes for compile arduino unowifi r2
* FlasString and Timers for Uno Wifi
ALL these changes should be portable back to master
* Remove extra timer that was already added
* Changed to EveryTimerB
* Add everytimerb.h
* Cleanup
* Linear address <a> cmd
* Allow lower case keywords
* Add the F define to be on safe side if it is not present in the library core code
* Clean simple Timer interface
Removes overkill files, puts all timer in a single small file. (DCCTimer)
* Timer port
* Timer working
And slow wave command removed
* Correcting non-portables merged from master
* Wave-state machine ( part 11)
* Microtuning waveform
Significant reduction in code paths and call overheads
* Current check cleanup
* Fix no-loco id
Has to handle -1 correctly
* fix wrong format letter
* redo flow through wifisetup again
* version++
* bugfixes wifi setup
* Retry harder for AP mode
* Remove unued if
* DIO2 replacement
Currently for writing signal pins during waveform.
* Drop analogReadFast (see DCCTimer)
AnalogRead speed set in DCCTimer for ease of porting.
Code tidy and diagnostics in MotorDriver
* UNTESTED fast power,brake,fault pins
* Distunguish between in/out of FASTPIN
* minor performance tweaks
* Config comments and example use
* Config/example loading
* IP/PORT on LCD
* Ethernet simulated mac
Plus fixed listening port
* Github SHA
* Committing a SHA
* Fix for nano compile
* Comments and a reliability fix.
* UnoRev2 protection
* PWM pin implementation
* fix wifi setup issue
* Reinstate IP_PORT
* Wifi channel and code cleaninga
* Reduce duplicated F() macros
Compiler isn't as clever as one might expect
* Committing a SHA
* Update config.example.h
Add comment to wifi channel section
* Committing a SHA
* Handle shields with common fault pins (Pololu)
* Committing a SHA
* remove warning
* Committing a SHA
* only do the sha generation on master
* yaml syntax
* Fast SSD1306 OLED driver
Incorporate code from SSD1306Ascii library to speed up OLED screen updates, reduce memory requirements and eliminate some library dependences.
* Fix auto-configure from cold boot.
Add call to Wire.begin().
* Update comment for OLED_DRIVER define.
* Update MotorDrivers.h
Add a motor board definition for using the IBT_2 board for a high current to the main track and keep the Arduino Motor Shield for operating the programming track.
* Committing a SHA
* Fix missing F in motor drivers
* JOIN relay pin
* Swap Join Relay high/low
* Hide WIFI_CONNECT_TIMEOUT
This is not what the config suggests it is... The timeout is in the ES and defaults to 15 seconds. Abandoning it early leads to confused setup.
* Enhance OLED/LCD speed
Write one character or position command per loop entry so as not to hold up the loop. Add support for SH1106 OLED as 132x64 size option.
* Enhance OLED/LCD speed
* Delete comment about OLED on UNO.
* Trim unwanted code
* Handle display types correctly
* Update comments
* Speed up OLED writes
Add new flushDisplay() to end any in-progress I2C transaction. Previously, an redundant command was sent that ended the in-progress transaction but also sent another complete, but unnecessary, transaction.
* Comments and copyright update
* Reduce RAM and flash requirement a few more bytes.
* Move statics into LCDDisplay class, and reduce RAM.
Some state variables were static in LCDDisplay.write(). Moved to class members. Also, types of data items like row, column & character position changed to int8_t to save a few bytes of RAM.
* Type lcdCols and lcdRows to unsigned.
Since lcdCols is normally 128, it needs to be uint8_t, not int8_t.
* remove timeout from user config
* faultpin is common only if it exists ; make code prettier
* Rationalisation of SSD1306 driver
Merge SSD1306AsciiWire.cpp into SSD1306Ascii.cpp and rename SSD1306AsciiWire.h as SSD1306Ascii.h.
Merge allFonts.h into System5x7.h and rename as SSD1306font.h.
Move all SSD1306 files into root folder to facilitate compilation in Arduino IDE.
* Fix some font attributes as const.
* Remove unused initialisation sequences for tiny oled screens
* Add m_ to variables
* Bump up I2C speed
Speed was 100kHz (default). Max for OLEDis 400kHz.
* Revert "Bump up I2C speed"
This reverts commit 1c1168f43314d3a6855738fbc406d5654e801831.
* Bump up I2C speed
Speed was 100kHz (default). Max for OLEDis 400kHz.
* Drop duplicate DIAG
* ignore mySetup.h files
* Restore uno to default_envs
Restore uno (previously commented out) to default_envs.
* Update objdump.bat
Allows other editors as Notepad is very slow on large files
* Prog Track overload during cv read
* Faster LCD Driver
Extract LCD driver from library;
Trim unused functionality;
Reduce I2C communications to minimum;
Speed up I2C clock to 400kHz.
* Update config.example.h
Add IBT_2_WITH_ARDUINO to example config
* Update config.example.h
* Screen enhancements (#126)
* Add I2CManager to coordinate I2C shared parameters.
* Add use of I2CManager, and experimental scrolling strategies.
New scrolling capability by defining SCROLLMODE in Config.h to 0 (original), 1 (by page) or 2 (by line). If not defined, defaults to 0.
* Scrolling updates
New scrolling capability by defining SCROLLMODE in Config.h to 0 (original), 1 (by page) or 2 (by line). If not defined, defaults to 0.
Reformat.
* Add I2CManager calls. Remove unnecessary delays.
* Add I2CManager calls, remove unnecessary I2C delays.
* SSD1306: Move methods from .h to .cpp and reformat.
* Fix compiler warning in LiquidCrystal_I2C
* Allow forcing of I2C clock speed.
New method forceClock allows the I2C speed to be overridden. For example, if the I2C bus is long then the speed can be forced lower. It can also be forced higher to gain performance if devices are capable.
* Make Config.h conditionally included.
Allow for non-existence of Config.h.
* Correct scrolling and allow longer messages
Correct the handling of scrolling in scrollmode 1 to avoid a blank page being displayed. Also, allow MAX_MSG_SIZE to be optionally configured to override maximum message length on screens.
* compiler warning on uno
Co-authored-by: dexslab <dex35803@gmail.com>
Co-authored-by: Asbelos <asbelos@btinternet.com>
Co-authored-by: Harald Barth <haba@kth.se>
Co-authored-by: Neil McKechnie <neilmck999@gmail.com>
Co-authored-by: Neil McKechnie <75813993+Neil-McK@users.noreply.github.com>
2021-03-07 21:58:35 +01:00
|
|
|
memcpy(stashP, p, MAX_COMMAND_PARAMS * sizeof(p[0]));
|
2020-09-25 19:51:08 +02:00
|
|
|
return true;
|
|
|
|
}
|
2021-03-08 11:40:32 +01:00
|
|
|
|
|
|
|
Print * DCCEXParser::getAsyncReplyStream() {
|
|
|
|
if (stashRingStream) {
|
|
|
|
stashRingStream->mark(stashTarget);
|
|
|
|
return stashRingStream;
|
|
|
|
}
|
|
|
|
return stashStream;
|
|
|
|
}
|
|
|
|
|
|
|
|
void DCCEXParser::commitAsyncReplyStream() {
|
|
|
|
if (stashRingStream) stashRingStream->commit();
|
|
|
|
stashBusy = false;
|
|
|
|
}
|
|
|
|
|
2021-03-25 19:02:33 +01:00
|
|
|
void DCCEXParser::callback_W(int16_t result)
|
2020-09-25 19:51:08 +02:00
|
|
|
{
|
2021-03-08 11:40:32 +01:00
|
|
|
StringFormatter::send(getAsyncReplyStream(),
|
2022-04-30 06:23:15 +02:00
|
|
|
F("<r %d %d>\n"), stashP[0], result == 1 ? stashP[1] : -1);
|
|
|
|
commitAsyncReplyStream();
|
|
|
|
}
|
|
|
|
|
|
|
|
void DCCEXParser::callback_W4(int16_t result)
|
|
|
|
{
|
|
|
|
StringFormatter::send(getAsyncReplyStream(),
|
|
|
|
F("<r%d|%d|%d %d>\n"), stashP[2], stashP[3], stashP[0], result == 1 ? stashP[1] : -1);
|
2021-03-08 11:40:32 +01:00
|
|
|
commitAsyncReplyStream();
|
2020-09-25 19:51:08 +02:00
|
|
|
}
|
2020-06-10 18:31:26 +02:00
|
|
|
|
2021-03-25 19:02:33 +01:00
|
|
|
void DCCEXParser::callback_B(int16_t result)
|
2020-09-25 19:51:08 +02:00
|
|
|
{
|
2021-03-08 11:40:32 +01:00
|
|
|
StringFormatter::send(getAsyncReplyStream(),
|
2021-03-30 23:01:37 +02:00
|
|
|
F("<r%d|%d|%d %d %d>\n"), stashP[3], stashP[4], stashP[0], stashP[1], result == 1 ? stashP[2] : -1);
|
2021-03-08 11:40:32 +01:00
|
|
|
commitAsyncReplyStream();
|
2020-06-07 14:48:42 +02:00
|
|
|
}
|
2021-03-25 19:02:33 +01:00
|
|
|
void DCCEXParser::callback_Vbit(int16_t result)
|
2020-09-25 19:51:08 +02:00
|
|
|
{
|
2021-03-30 23:01:37 +02:00
|
|
|
StringFormatter::send(getAsyncReplyStream(), F("<v %d %d %d>\n"), stashP[0], stashP[1], result);
|
2021-03-08 11:40:32 +01:00
|
|
|
commitAsyncReplyStream();
|
2020-09-18 01:04:42 +02:00
|
|
|
}
|
2021-03-25 19:02:33 +01:00
|
|
|
void DCCEXParser::callback_Vbyte(int16_t result)
|
2020-09-25 19:51:08 +02:00
|
|
|
{
|
2021-03-30 23:01:37 +02:00
|
|
|
StringFormatter::send(getAsyncReplyStream(), F("<v %d %d>\n"), stashP[0], result);
|
2021-03-08 11:40:32 +01:00
|
|
|
commitAsyncReplyStream();
|
2020-09-18 01:04:42 +02:00
|
|
|
}
|
|
|
|
|
2021-03-25 19:02:33 +01:00
|
|
|
void DCCEXParser::callback_R(int16_t result)
|
2020-09-25 19:51:08 +02:00
|
|
|
{
|
2021-03-30 23:01:37 +02:00
|
|
|
StringFormatter::send(getAsyncReplyStream(), F("<r%d|%d|%d %d>\n"), stashP[1], stashP[2], stashP[0], result);
|
2021-03-08 11:40:32 +01:00
|
|
|
commitAsyncReplyStream();
|
2020-06-07 14:48:42 +02:00
|
|
|
}
|
2020-09-20 01:59:07 +02:00
|
|
|
|
2021-11-26 19:32:45 +01:00
|
|
|
void DCCEXParser::callback_Rloco(int16_t result) {
|
|
|
|
const FSH * detail;
|
|
|
|
if (result<=0) {
|
2022-01-30 23:58:34 +01:00
|
|
|
detail=F("<r %d>\n");
|
2021-11-26 19:32:45 +01:00
|
|
|
} else {
|
|
|
|
bool longAddr=result & LONG_ADDR_MARKER; //long addr
|
|
|
|
if (longAddr)
|
|
|
|
result = result^LONG_ADDR_MARKER;
|
|
|
|
if (longAddr && result <= HIGHEST_SHORT_ADDR)
|
|
|
|
detail=F("<r LONG %d UNSUPPORTED>\n");
|
2021-11-25 00:10:11 +01:00
|
|
|
else
|
2021-11-26 19:32:45 +01:00
|
|
|
detail=F("<r %d>\n");
|
|
|
|
}
|
|
|
|
StringFormatter::send(getAsyncReplyStream(), detail, result);
|
2021-11-25 00:10:11 +01:00
|
|
|
commitAsyncReplyStream();
|
2021-01-18 11:06:46 +01:00
|
|
|
}
|
|
|
|
|
2021-03-25 19:02:33 +01:00
|
|
|
void DCCEXParser::callback_Wloco(int16_t result)
|
2021-01-18 11:06:46 +01:00
|
|
|
{
|
|
|
|
if (result==1) result=stashP[0]; // pick up original requested id from command
|
2021-03-30 23:01:37 +02:00
|
|
|
StringFormatter::send(getAsyncReplyStream(), F("<w %d>\n"), result);
|
2021-03-08 11:40:32 +01:00
|
|
|
commitAsyncReplyStream();
|
2020-09-20 01:59:07 +02:00
|
|
|
}
|