From 5e60fb4e2701e5ad1d1099f3e4e6d655c9b46df6 Mon Sep 17 00:00:00 2001 From: Asbelos Date: Sat, 11 Mar 2023 22:46:11 +0000 Subject: [PATCH 01/13] SAMD21 odd byte boundary --- EXRAIL2.cpp | 9 +++------ version.h | 5 +++-- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/EXRAIL2.cpp b/EXRAIL2.cpp index 3bd8da7..8541cd2 100644 --- a/EXRAIL2.cpp +++ b/EXRAIL2.cpp @@ -105,12 +105,9 @@ uint16_t RMFT2::getOperand(byte n) { // getOperand static version, must be provided prog counter from loop etc. uint16_t RMFT2::getOperand(int progCounter,byte n) { int offset=progCounter+1+(n*3); - if (offset&1) { - byte lsb=GETHIGHFLASH(RouteCode,offset); - byte msb=GETHIGHFLASH(RouteCode,offset+1); - return msb<<8|lsb; - } - return GETHIGHFLASHW(RouteCode,offset); + byte lsb=GETHIGHFLASH(RouteCode,offset); + byte msb=GETHIGHFLASH(RouteCode,offset+1); + return msb<<8|lsb; } LookList::LookList(int16_t size) { diff --git a/version.h b/version.h index 6e2d0ba..8afe38a 100644 --- a/version.h +++ b/version.h @@ -4,8 +4,9 @@ #include "StringFormatter.h" -#define VERSION "4.2.24" -// 4.3.24 - Bugfix Ethernet shield: Static IP now possible +#define VERSION "4.2.25" +// 4.2.25 - Bugfix SAMD21 Exrail odd byte boundary +// 4.2.24 - Bugfix Ethernet shield: Static IP now possible // 4.2.23 - Bugfix signalpin2 was not set up in shadow port // 4.2.22 - Implement broadcast of Track Manager changes // 4.2.21 - Implement non-blocking I2C for EX-IOExpander device driver From 0cc07ed1dff8afd1d9727bb911bf9e3b957698ed Mon Sep 17 00:00:00 2001 From: peteGSX Date: Mon, 13 Mar 2023 05:29:22 +1000 Subject: [PATCH 02/13] Starting on driver feedback --- IO_EXIOExpander.h | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/IO_EXIOExpander.h b/IO_EXIOExpander.h index 0296c93..da01ae7 100644 --- a/IO_EXIOExpander.h +++ b/IO_EXIOExpander.h @@ -156,10 +156,15 @@ private: void _loop(unsigned long currentMicros) override { (void)currentMicros; // remove warning if (_deviceState == DEVSTATE_FAILED) return; - _command1Buffer[0] = EXIORDD; - I2CManager.read(_i2cAddress, _digitalInputStates, _digitalPinBytes, _command1Buffer, 1, &_i2crb); - _command1Buffer[0] = EXIORDAN; - I2CManager.read(_i2cAddress, _analogueInputStates, _analoguePinBytes, _command1Buffer, 1, &_i2crb); + if (_i2crb.isBusy()) return; + if (_commandFlag) { + _command1Buffer[0] = EXIORDD; + I2CManager.read(_i2cAddress, _digitalInputStates, _digitalPinBytes, _command1Buffer, 1, &_i2crb); + } else { + _command1Buffer[0] = EXIORDAN; + I2CManager.read(_i2cAddress, _analogueInputStates, _analoguePinBytes, _command1Buffer, 1, &_i2crb); + } + _commandFlag = !_commandFlag; } // Obtain the correct analogue input value @@ -243,6 +248,7 @@ private: byte _servoBuffer[7]; uint8_t* _analoguePinMap; I2CRB _i2crb; + bool _commandFlag = 0; // EX-IOExpander protocol flags enum { From 95d01202045dceda8babb746dfa2015a28aabf7a Mon Sep 17 00:00:00 2001 From: peteGSX <97784652+peteGSX@users.noreply.github.com> Date: Mon, 13 Mar 2023 08:38:28 +1000 Subject: [PATCH 03/13] Implement status checks --- IO_EXIOExpander.h | 49 ++++++++++++++++++++++++++++++++--------------- 1 file changed, 34 insertions(+), 15 deletions(-) diff --git a/IO_EXIOExpander.h b/IO_EXIOExpander.h index da01ae7..ddcdf56 100644 --- a/IO_EXIOExpander.h +++ b/IO_EXIOExpander.h @@ -155,16 +155,25 @@ private: // Main loop, collect both digital and analogue pin states continuously (faster sensor/input reads) void _loop(unsigned long currentMicros) override { (void)currentMicros; // remove warning - if (_deviceState == DEVSTATE_FAILED) return; - if (_i2crb.isBusy()) return; - if (_commandFlag) { - _command1Buffer[0] = EXIORDD; - I2CManager.read(_i2cAddress, _digitalInputStates, _digitalPinBytes, _command1Buffer, 1, &_i2crb); + if (_deviceState == DEVSTATE_FAILED) return; // If device failed, return + uint8_t status = _i2crb.status; + if (status == I2C_STATUS_PENDING) return; // If device busy, return + if (status == I2C_STATUS_OK) { // If device ok, read input data + if (_commandFlag) { + _command1Buffer[0] = EXIORDD; + I2CManager.read(_i2cAddress, _digitalInputStates, _digitalPinBytes, _command1Buffer, 1, &_i2crb); + } else { + _command1Buffer[0] = EXIORDAN; + byte _tempAnalogue[_analoguePinBytes]; // Setup temp buffer so reads come from known state + I2CManager.read(_i2cAddress, _tempAnalogue, _analoguePinBytes, _command1Buffer, 1, &_i2crb); + memcpy(_analogueInputStates, _tempAnalogue, _analoguePinBytes); // Copy temp buffer to states + } + _commandFlag = !_commandFlag; + // Need to delay here: digital in IO_Base 4000UL, analogue in IO_AnalogueInputs 10000UL (fast) or 1000000UL(slow) } else { - _command1Buffer[0] = EXIORDAN; - I2CManager.read(_i2cAddress, _analogueInputStates, _analoguePinBytes, _command1Buffer, 1, &_i2crb); + DIAG(F("EX-IOExpander I2C:%s Error:%d %S"), _I2CAddress.toString(), status, I2CManager.getErrorMessage(status)); + _deviceState = DEVSTATE_FAILED; } - _commandFlag = !_commandFlag; } // Obtain the correct analogue input value @@ -196,9 +205,14 @@ private: _digitalOutBuffer[0] = EXIOWRD; _digitalOutBuffer[1] = pin; _digitalOutBuffer[2] = value; - I2CManager.read(_i2cAddress, _command1Buffer, 1, _digitalOutBuffer, 3, &_i2crb); - if (_command1Buffer[0] != EXIORDY) { - DIAG(F("Vpin %d cannot be used as a digital output pin"), (int)vpin); + uint8_t status = I2CManager.read(_i2cAddress, _command1Buffer, 1, _digitalOutBuffer, 3); + if (status != I2C_STATUS_OK) { + DIAG(F("EX-IOExpander I2C:%s Error:%d %S"), _I2CAddress.toString(), status, I2CManager.getErrorMessage(status)); + _deviceState = DEVSTATE_FAILED; + } else { + if (_command1Buffer[0] != EXIORDY) { + DIAG(F("Vpin %d cannot be used as a digital output pin"), (int)vpin); + } } } @@ -216,9 +230,14 @@ private: _servoBuffer[4] = profile; _servoBuffer[5] = duration & 0xFF; _servoBuffer[6] = duration >> 8; - I2CManager.read(_i2cAddress, _command1Buffer, 1, _servoBuffer, 7, &_i2crb); - if (_command1Buffer[0] != EXIORDY) { - DIAG(F("Vpin %d cannot be used as a servo/PWM pin"), (int)vpin); + uint8_t status = I2CManager.read(_i2cAddress, _command1Buffer, 1, _servoBuffer, 7); + if (status != I2C_STATUS_OK) { + DIAG(F("EX-IOExpander I2C:%s Error:%d %S"), _I2CAddress.toString(), status, I2CManager.getErrorMessage(status)); + _deviceState = DEVSTATE_FAILED; + } else { + if (_command1Buffer[0] != EXIORDY) { + DIAG(F("Vpin %d cannot be used as a servo/PWM pin"), (int)vpin); + } } } @@ -248,7 +267,7 @@ private: byte _servoBuffer[7]; uint8_t* _analoguePinMap; I2CRB _i2crb; - bool _commandFlag = 0; + bool _commandFlag = 1; // EX-IOExpander protocol flags enum { From d89dd0d1fa4a05161b5ac9955c7dd893e070f95d Mon Sep 17 00:00:00 2001 From: Asbelos Date: Mon, 13 Mar 2023 00:53:42 +0000 Subject: [PATCH 04/13] command ref work in progress --- Release_Notes/CommandRef.md | 76 +++++++++++++++++++++++-------------- 1 file changed, 48 insertions(+), 28 deletions(-) diff --git a/Release_Notes/CommandRef.md b/Release_Notes/CommandRef.md index 6420471..c06e388 100644 --- a/Release_Notes/CommandRef.md +++ b/Release_Notes/CommandRef.md @@ -4,24 +4,37 @@ General points: - Commands below have a single character opcode and parameters. Even is actually read as - Keyword parameters are shown in upper case but may be entered in mixed case. - - value parameters are numeric. + - value parameters are decimal numeric (unless otherwise noted) - [something] indicates its optional. - - Not all commands have a response, and not all responses come from the last commands that you have issued. + - Not all commands have a response, and broadcasts mean that not all responses come from the last commands that you have issued. Startup status - + Return status like + + also returns defined turnout list: + 1=thrown -Track power management -<1> -<1 MAIN|PROG|JOIN> -<0> -<0 MAIN|PROG> +Track power management. After power commands a power state is broadcast to all throttles. + +<1> Power on all +<1 MAIN|PROG|JOIN> Power on MAIN or PROG track +<1 JOIN> Power on MAIN and PROG track but send main track data on both. +<0> Power off all tracks +<0 MAIN|PROG> Power off main or prog track + +Basic manual loco control + Throttle loco. + speed in JMRI-form (-1=ESTOP, 0=STOP, 1..126 = DCC speeds 2..127) + direction 1=forward, 0=reverse + For response see broadcast + + Set loco function 1=ON, 0-OFF + For response see broadcast + + emergency stop all locos + Control turnout id, 0=C=Closed, 1=T=Thrown + response broadcast -Basic manual control - - - - DCC accessory control @@ -35,25 +48,30 @@ Note: Turnouts are best defined in myAutomation.h where a turnout description ca + Valid commands respond with + +Outputs (Used by JMRI, not required by EXRAIL) + Define an output pin that JMRI can set by id + Activate an output pin by id -Outputs - - +Sensors (Used by JMRI, not required by EXRAIL) + define a sensor to be monitored. + Responses and as sensor changes -Sensors - +Decoder programming - main track + POM write value to cv on loco + POM write bit to cv on loco -Decoder programming - - - - - - - - - +Decoder Programming - prog track + Clear consist and write new cab id (includes long/short settings) + Responds or for error + Write value to cv + + Read cv value, much faster if prediction is correct. + Read CV bit + + Read drive-away loco id. (May be a consist id) @@ -152,6 +170,8 @@ Obsolete commands/formats + V command is much faster if prediction is correct. + V command is much faster if prediction is correct. Broadcast responses Note: broadcasts are sent to all throttles when appropriate (usually because something has changed) From df3eb11eb9e0d0f721c22937b03af6c9f0cb4d11 Mon Sep 17 00:00:00 2001 From: peteGSX <97784652+peteGSX@users.noreply.github.com> Date: Tue, 14 Mar 2023 07:19:20 +1000 Subject: [PATCH 05/13] Add read refresh delays --- .vscode/settings.json | 3 ++- IO_EXIOExpander.h | 23 ++++++++++++++++------- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index ffa498a..6f7d828 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -8,5 +8,6 @@ "string_view": "cpp", "initializer_list": "cpp", "cstdint": "cpp" - } + }, + "cmake.configureOnOpen": false } diff --git a/IO_EXIOExpander.h b/IO_EXIOExpander.h index ddcdf56..9efe8f9 100644 --- a/IO_EXIOExpander.h +++ b/IO_EXIOExpander.h @@ -154,19 +154,24 @@ private: // Main loop, collect both digital and analogue pin states continuously (faster sensor/input reads) void _loop(unsigned long currentMicros) override { - (void)currentMicros; // remove warning if (_deviceState == DEVSTATE_FAILED) return; // If device failed, return uint8_t status = _i2crb.status; if (status == I2C_STATUS_PENDING) return; // If device busy, return if (status == I2C_STATUS_OK) { // If device ok, read input data if (_commandFlag) { - _command1Buffer[0] = EXIORDD; - I2CManager.read(_i2cAddress, _digitalInputStates, _digitalPinBytes, _command1Buffer, 1, &_i2crb); + if (currentMicros - _lastDigitalRead > _digitalRefresh) { // Delay 10ms for digital read refresh + _lastDigitalRead = currentMicros; + _command1Buffer[0] = EXIORDD; + I2CManager.read(_i2cAddress, _digitalInputStates, _digitalPinBytes, _command1Buffer, 1, &_i2crb); + } } else { - _command1Buffer[0] = EXIORDAN; - byte _tempAnalogue[_analoguePinBytes]; // Setup temp buffer so reads come from known state - I2CManager.read(_i2cAddress, _tempAnalogue, _analoguePinBytes, _command1Buffer, 1, &_i2crb); - memcpy(_analogueInputStates, _tempAnalogue, _analoguePinBytes); // Copy temp buffer to states + if (currentMicros - _lastAnalogueRead > _analogueRefresh) { // Delay 50ms for analogue read refresh + _lastAnalogueRead = currentMicros; + _command1Buffer[0] = EXIORDAN; + byte _tempAnalogue[_analoguePinBytes]; // Setup temp buffer so reads come from known state + I2CManager.read(_i2cAddress, _tempAnalogue, _analoguePinBytes, _command1Buffer, 1, &_i2crb); + memcpy(_analogueInputStates, _tempAnalogue, _analoguePinBytes); // Copy temp buffer to states + } } _commandFlag = !_commandFlag; // Need to delay here: digital in IO_Base 4000UL, analogue in IO_AnalogueInputs 10000UL (fast) or 1000000UL(slow) @@ -268,6 +273,10 @@ private: uint8_t* _analoguePinMap; I2CRB _i2crb; bool _commandFlag = 1; + unsigned long _lastDigitalRead = 0; + unsigned long _lastAnalogueRead = 0; + const unsigned long _digitalRefresh = 10000UL; + const unsigned long _analogueRefresh = 50000UL; // EX-IOExpander protocol flags enum { From c83741d2b4a29e1dfa71dfb7184a617b1e270eec Mon Sep 17 00:00:00 2001 From: peteGSX <97784652+peteGSX@users.noreply.github.com> Date: Tue, 14 Mar 2023 07:20:27 +1000 Subject: [PATCH 06/13] Add read refresh delays --- IO_EXIOExpander.h | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/IO_EXIOExpander.h b/IO_EXIOExpander.h index ddcdf56..9efe8f9 100644 --- a/IO_EXIOExpander.h +++ b/IO_EXIOExpander.h @@ -154,19 +154,24 @@ private: // Main loop, collect both digital and analogue pin states continuously (faster sensor/input reads) void _loop(unsigned long currentMicros) override { - (void)currentMicros; // remove warning if (_deviceState == DEVSTATE_FAILED) return; // If device failed, return uint8_t status = _i2crb.status; if (status == I2C_STATUS_PENDING) return; // If device busy, return if (status == I2C_STATUS_OK) { // If device ok, read input data if (_commandFlag) { - _command1Buffer[0] = EXIORDD; - I2CManager.read(_i2cAddress, _digitalInputStates, _digitalPinBytes, _command1Buffer, 1, &_i2crb); + if (currentMicros - _lastDigitalRead > _digitalRefresh) { // Delay 10ms for digital read refresh + _lastDigitalRead = currentMicros; + _command1Buffer[0] = EXIORDD; + I2CManager.read(_i2cAddress, _digitalInputStates, _digitalPinBytes, _command1Buffer, 1, &_i2crb); + } } else { - _command1Buffer[0] = EXIORDAN; - byte _tempAnalogue[_analoguePinBytes]; // Setup temp buffer so reads come from known state - I2CManager.read(_i2cAddress, _tempAnalogue, _analoguePinBytes, _command1Buffer, 1, &_i2crb); - memcpy(_analogueInputStates, _tempAnalogue, _analoguePinBytes); // Copy temp buffer to states + if (currentMicros - _lastAnalogueRead > _analogueRefresh) { // Delay 50ms for analogue read refresh + _lastAnalogueRead = currentMicros; + _command1Buffer[0] = EXIORDAN; + byte _tempAnalogue[_analoguePinBytes]; // Setup temp buffer so reads come from known state + I2CManager.read(_i2cAddress, _tempAnalogue, _analoguePinBytes, _command1Buffer, 1, &_i2crb); + memcpy(_analogueInputStates, _tempAnalogue, _analoguePinBytes); // Copy temp buffer to states + } } _commandFlag = !_commandFlag; // Need to delay here: digital in IO_Base 4000UL, analogue in IO_AnalogueInputs 10000UL (fast) or 1000000UL(slow) @@ -268,6 +273,10 @@ private: uint8_t* _analoguePinMap; I2CRB _i2crb; bool _commandFlag = 1; + unsigned long _lastDigitalRead = 0; + unsigned long _lastAnalogueRead = 0; + const unsigned long _digitalRefresh = 10000UL; + const unsigned long _analogueRefresh = 50000UL; // EX-IOExpander protocol flags enum { From ca2e5e6ce3c956af843357e4dd594c175089a5c4 Mon Sep 17 00:00:00 2001 From: peteGSX <97784652+peteGSX@users.noreply.github.com> Date: Tue, 14 Mar 2023 07:21:55 +1000 Subject: [PATCH 07/13] Undo vscode change --- .vscode/settings.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 6f7d828..ffa498a 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -8,6 +8,5 @@ "string_view": "cpp", "initializer_list": "cpp", "cstdint": "cpp" - }, - "cmake.configureOnOpen": false + } } From 5fc925bfc6d6431f90a072219e2d14e3dcd56979 Mon Sep 17 00:00:00 2001 From: peteGSX <97784652+peteGSX@users.noreply.github.com> Date: Tue, 14 Mar 2023 07:23:42 +1000 Subject: [PATCH 08/13] Delete extensions.json --- .vscode/extensions.json | 10 ---------- 1 file changed, 10 deletions(-) delete mode 100644 .vscode/extensions.json diff --git a/.vscode/extensions.json b/.vscode/extensions.json deleted file mode 100644 index 080e70d..0000000 --- a/.vscode/extensions.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - // See http://go.microsoft.com/fwlink/?LinkId=827846 - // for the documentation about the extensions.json format - "recommendations": [ - "platformio.platformio-ide" - ], - "unwantedRecommendations": [ - "ms-vscode.cpptools-extension-pack" - ] -} From a51cefbdeb60d1bdabebfa234f1c5378878b0760 Mon Sep 17 00:00:00 2001 From: peteGSX <97784652+peteGSX@users.noreply.github.com> Date: Tue, 14 Mar 2023 07:23:55 +1000 Subject: [PATCH 09/13] Delete settings.json --- .vscode/settings.json | 12 ------------ 1 file changed, 12 deletions(-) delete mode 100644 .vscode/settings.json diff --git a/.vscode/settings.json b/.vscode/settings.json deleted file mode 100644 index ffa498a..0000000 --- a/.vscode/settings.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "files.associations": { - "array": "cpp", - "deque": "cpp", - "string": "cpp", - "unordered_map": "cpp", - "vector": "cpp", - "string_view": "cpp", - "initializer_list": "cpp", - "cstdint": "cpp" - } -} From 42bddb587ed7500de89eb37110c68cf03695c70a Mon Sep 17 00:00:00 2001 From: peteGSX <97784652+peteGSX@users.noreply.github.com> Date: Tue, 14 Mar 2023 07:25:30 +1000 Subject: [PATCH 10/13] Update .gitignore --- .gitignore | 7 ------- 1 file changed, 7 deletions(-) diff --git a/.gitignore b/.gitignore index 8f01818..6237359 100644 --- a/.gitignore +++ b/.gitignore @@ -7,16 +7,9 @@ Release/* .pio/ .vscode/ config.h -.vscode/* -# mySetup.h mySetup.cpp myHal.cpp -# myAutomation.h myFilter.cpp -# myAutomation.h -# myLayout.h my*.h !my*.example.h -.vscode/extensions.json -.vscode/extensions.json compile_commands.json From 25676aab6b50a480807f7339672a4853245129ea Mon Sep 17 00:00:00 2001 From: peteGSX <97784652+peteGSX@users.noreply.github.com> Date: Tue, 14 Mar 2023 07:32:08 +1000 Subject: [PATCH 11/13] Update comments --- IO_EXIOExpander.h | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/IO_EXIOExpander.h b/IO_EXIOExpander.h index 9efe8f9..84433b7 100644 --- a/IO_EXIOExpander.h +++ b/IO_EXIOExpander.h @@ -159,13 +159,13 @@ private: if (status == I2C_STATUS_PENDING) return; // If device busy, return if (status == I2C_STATUS_OK) { // If device ok, read input data if (_commandFlag) { - if (currentMicros - _lastDigitalRead > _digitalRefresh) { // Delay 10ms for digital read refresh + if (currentMicros - _lastDigitalRead > _digitalRefresh) { // Delay for digital read refresh _lastDigitalRead = currentMicros; _command1Buffer[0] = EXIORDD; I2CManager.read(_i2cAddress, _digitalInputStates, _digitalPinBytes, _command1Buffer, 1, &_i2crb); } } else { - if (currentMicros - _lastAnalogueRead > _analogueRefresh) { // Delay 50ms for analogue read refresh + if (currentMicros - _lastAnalogueRead > _analogueRefresh) { // Delay for analogue read refresh _lastAnalogueRead = currentMicros; _command1Buffer[0] = EXIORDAN; byte _tempAnalogue[_analoguePinBytes]; // Setup temp buffer so reads come from known state @@ -174,7 +174,6 @@ private: } } _commandFlag = !_commandFlag; - // Need to delay here: digital in IO_Base 4000UL, analogue in IO_AnalogueInputs 10000UL (fast) or 1000000UL(slow) } else { DIAG(F("EX-IOExpander I2C:%s Error:%d %S"), _I2CAddress.toString(), status, I2CManager.getErrorMessage(status)); _deviceState = DEVSTATE_FAILED; @@ -275,8 +274,8 @@ private: bool _commandFlag = 1; unsigned long _lastDigitalRead = 0; unsigned long _lastAnalogueRead = 0; - const unsigned long _digitalRefresh = 10000UL; - const unsigned long _analogueRefresh = 50000UL; + const unsigned long _digitalRefresh = 10000UL; // Delay refreshing digital inputs for 10ms + const unsigned long _analogueRefresh = 50000UL; // Delay refreshing analogue inputs for 50ms // EX-IOExpander protocol flags enum { From 48cd567bda87482d7e5e5287d9290ca0c96a98eb Mon Sep 17 00:00:00 2001 From: peteGSX Date: Tue, 14 Mar 2023 19:04:08 +1000 Subject: [PATCH 12/13] Update version after testing --- version.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/version.h b/version.h index 8afe38a..21f8e5e 100644 --- a/version.h +++ b/version.h @@ -4,7 +4,11 @@ #include "StringFormatter.h" -#define VERSION "4.2.25" +#define VERSION "4.2.26" +// 4.2.26 - EX-IOExpander device driver enhancements +// - Enhance I2C error checking +// - Introduce delays to _loop to allow room for other I2C device comms +// - Improve analogue read reliability // 4.2.25 - Bugfix SAMD21 Exrail odd byte boundary // 4.2.24 - Bugfix Ethernet shield: Static IP now possible // 4.2.23 - Bugfix signalpin2 was not set up in shadow port From 27ba55198679610b37cd2c2542fc5d3ab6f21b85 Mon Sep 17 00:00:00 2001 From: Harald Barth Date: Tue, 14 Mar 2023 20:50:24 +0100 Subject: [PATCH 13/13] Bugfix LCD showed random characters in SCROLLMODE 2 --- Display.cpp | 15 +++++++++------ GITHUB_SHA.h | 2 +- version.h | 3 ++- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/Display.cpp b/Display.cpp index 2c44778..a1a1ec1 100644 --- a/Display.cpp +++ b/Display.cpp @@ -1,5 +1,6 @@ /* * © 2021, Chris Harlow, Neil McKechnie. All rights reserved. + * © 2023, Harald Barth. * * This file is part of CommandStation-EX * @@ -52,7 +53,7 @@ Display::Display(DisplayDevice *deviceDriver) { _deviceDriver = deviceDriver; // Get device dimensions in characters (e.g. 16x2). numCharacterColumns = _deviceDriver->getNumCols(); - numCharacterRows = _deviceDriver->getNumRows();; + numCharacterRows = _deviceDriver->getNumRows(); for (uint8_t row = 0; row < MAX_CHARACTER_ROWS; row++) rowBuffer[row][0] = '\0'; topRow = ROW_INITIAL; // loop2 will fill from row 0 @@ -173,16 +174,18 @@ bool Display::findNextNonBlankRow() { rowNext = 0; else rowNext = rowNext + 1; - if (rowNext >= MAX_CHARACTER_ROWS) rowNext = ROW_INITIAL; #if SCROLLMODE == 1 - // Finished if we've looped back to start - if (rowNext == ROW_INITIAL) { + if (rowNext >= MAX_CHARACTER_ROWS) { + // Finished if we've looped back to start + rowNext = ROW_INITIAL; noMoreRowsToDisplay = true; return false; } #else - // Finished if we're back to the first one shown + if (rowNext >= MAX_CHARACTER_ROWS) + rowNext = 0; if (rowNext == rowFirst) { + // Finished if we're back to the first one shown noMoreRowsToDisplay = true; return false; } @@ -193,4 +196,4 @@ bool Display::findNextNonBlankRow() { } } return false; -} \ No newline at end of file +} diff --git a/GITHUB_SHA.h b/GITHUB_SHA.h index db56eac..be808f8 100644 --- a/GITHUB_SHA.h +++ b/GITHUB_SHA.h @@ -1 +1 @@ -#define GITHUB_SHA "devel-202303101548Z" +#define GITHUB_SHA "devel-202303141949Z" diff --git a/version.h b/version.h index 21f8e5e..b8f547f 100644 --- a/version.h +++ b/version.h @@ -4,7 +4,8 @@ #include "StringFormatter.h" -#define VERSION "4.2.26" +#define VERSION "4.2.27" +// 4.2.27 - Bugfix LCD showed random characters in SCROLLMODE 2 // 4.2.26 - EX-IOExpander device driver enhancements // - Enhance I2C error checking // - Introduce delays to _loop to allow room for other I2C device comms