2020-07-03 18:35:02 +02:00
/*
2022-01-07 02:28:35 +01:00
* © 2021 Neil McKechnie
* © 2021 Mike S
* © 2021 Fred Decker
* © 2021 Herb Morton
* © 2020 - 2022 Harald Barth
* © 2020 - 2021 M Steve Todd
* © 2020 - 2021 Chris Harlow
* All rights reserved .
2022-01-06 23:03:57 +01:00
*
2020-07-03 18:35:02 +02:00
* This file is part of Asbelos DCC API
*
* 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/>.
*/
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
# include "DIAG.h"
2020-05-24 17:07:16 +02:00
# include "DCC.h"
# include "DCCWaveform.h"
2021-11-08 02:07:21 +01:00
# ifndef DISABLE_EEPROM
2020-10-04 21:20:13 +02:00
# include "EEStore.h"
2021-11-08 02:07:21 +01:00
# endif
2020-10-02 18:12:48 +02:00
# include "GITHUB_SHA.h"
# include "version.h"
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
# include "FSH.h"
2021-08-03 23:12:25 +02:00
# include "IODevice.h"
2022-01-30 18:31:26 +01:00
# include "EXRAIL2.h"
2021-12-05 19:06:28 +01:00
# include "CommandDistributor.h"
2020-08-15 12:32:32 +02:00
2020-05-24 17:07:16 +02:00
// This module is responsible for converting API calls into
// messages to be sent to the waveform generator.
// It has no visibility of the hardware, timers, interrupts
// nor of the waveform issues such as preambles, start bits checksums or cutouts.
//
// Nor should it have to deal with JMRI responsess other than the OK/FAIL
// or cv value returned. I will move that back to the JMRI interface later
//
// The interface to the waveform generator is narrowed down to merely:
// Scheduling a message on the prog or main track using a function
// Obtaining ACKs from the prog track using a function
// There are no volatiles here.
2022-01-06 23:03:57 +01:00
const byte FN_GROUP_1 = 0x01 ;
const byte FN_GROUP_2 = 0x02 ;
const byte FN_GROUP_3 = 0x04 ;
const byte FN_GROUP_4 = 0x08 ;
const byte FN_GROUP_5 = 0x10 ;
2020-06-22 11:54:57 +02:00
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
FSH * DCC : : shieldName = NULL ;
byte DCC : : joinRelay = UNUSED_PIN ;
2021-03-16 22:51:33 +01:00
byte DCC : : globalSpeedsteps = 128 ;
2020-06-22 11:54:57 +02:00
2021-03-23 15:37:05 +01:00
void DCC : : begin ( const FSH * motorShieldName , MotorDriver * mainDriver , MotorDriver * progDriver ) {
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
shieldName = ( FSH * ) motorShieldName ;
2021-03-30 23:01:37 +02:00
StringFormatter : : send ( Serial , F ( " <iDCC-EX V-%S / %S / %S G-%S> \n " ) , F ( VERSION ) , F ( ARDUINO_TYPE ) , shieldName , F ( GITHUB_SHA ) ) ;
2020-10-04 21:20:13 +02:00
2021-08-03 23:12:25 +02:00
// Initialise HAL layer before reading EEprom.
IODevice : : begin ( ) ;
2021-11-08 02:07:21 +01:00
# ifndef DISABLE_EEPROM
2020-10-04 21:20:13 +02:00
// Load stuff from EEprom
( void ) EEPROM ; // tell compiler not to warn this is unused
EEStore : : init ( ) ;
2021-11-08 02:07:21 +01:00
# endif
2020-10-04 21:20:13 +02:00
2022-01-06 23:03:57 +01:00
DCCWaveform : : begin ( mainDriver , progDriver ) ;
2020-05-24 17:07:16 +02:00
}
2021-03-23 15:37:05 +01:00
void DCC : : setJoinRelayPin ( byte joinRelayPin ) {
joinRelay = joinRelayPin ;
if ( joinRelay ! = UNUSED_PIN ) {
pinMode ( joinRelay , OUTPUT ) ;
digitalWrite ( joinRelay , LOW ) ; // LOW is relay disengaged
}
}
2020-05-24 17:07:16 +02:00
void DCC : : setThrottle ( uint16_t cab , uint8_t tSpeed , bool tDirection ) {
2022-01-06 23:03:57 +01:00
byte speedCode = ( tSpeed & 0x7F ) + tDirection * 128 ;
2020-06-03 11:36:01 +02:00
setThrottle2 ( cab , speedCode ) ;
2020-05-24 17:07:16 +02:00
// retain speed for loco reminders
2020-06-03 11:36:01 +02:00
updateLocoReminder ( cab , speedCode ) ;
2020-05-24 17:07:16 +02:00
}
2020-06-03 11:36:01 +02:00
void DCC : : setThrottle2 ( uint16_t cab , byte speedCode ) {
2020-06-07 14:48:42 +02:00
2020-06-01 14:56:02 +02:00
uint8_t b [ 4 ] ;
2020-05-24 17:07:16 +02:00
uint8_t nB = 0 ;
2021-03-25 15:23:38 +01:00
// DIAG(F("setSpeedInternal %d %x"),cab,speedCode);
2022-01-06 23:03:57 +01:00
2021-11-25 00:10:11 +01:00
if ( cab > HIGHEST_SHORT_ADDR )
2020-05-24 17:07:16 +02:00
b [ nB + + ] = highByte ( cab ) | 0xC0 ; // convert train number into a two-byte address
b [ nB + + ] = lowByte ( cab ) ;
2021-03-16 10:59:14 +01:00
2021-03-16 22:51:33 +01:00
if ( globalSpeedsteps < = 28 ) {
2021-03-16 10:59:14 +01:00
2021-03-16 22:51:33 +01:00
uint8_t speed128 = speedCode & 0x7F ;
uint8_t speed28 ;
uint8_t code28 ;
2021-03-16 10:59:14 +01:00
2021-03-16 22:51:33 +01:00
if ( speed128 = = 0 | | speed128 = = 1 ) { // stop or emergency stop
2021-03-16 10:59:14 +01:00
code28 = speed128 ;
2021-03-16 22:51:33 +01:00
} else {
2021-03-16 10:59:14 +01:00
speed28 = ( speed128 * 10 + 36 ) / 46 ; // convert 2-127 to 1-28
2021-03-16 22:51:33 +01:00
/*
if ( globalSpeedsteps < = 14 ) // Don't want to do 14 steps, to get F0 there is ugly
code28 = ( speed28 + 3 ) / 2 | ( Value of F0 ) ; // convert 1-28 to DCC 14 step speed code
else
*/
code28 = ( speed28 + 3 ) / 2 | ( ( speed28 & 1 ) ? 0 : 0b00010000 ) ; // convert 1-28 to DCC 28 step speed code
}
// Construct command byte from:
// command speed direction
2021-03-16 23:20:30 +01:00
b [ nB + + ] = 0b01000000 | code28 | ( ( speedCode & 0x80 ) ? 0b00100000 : 0 ) ;
2021-03-16 10:59:14 +01:00
2021-03-16 22:51:33 +01:00
} else { // 128 speedsteps
2021-03-16 10:59:14 +01:00
2021-03-16 22:51:33 +01:00
b [ nB + + ] = SET_SPEED ; // 128-step speed control byte
b [ nB + + ] = speedCode ; // for encoding see setThrottle
2020-06-07 14:48:42 +02:00
2021-03-16 22:51:33 +01:00
}
2020-06-07 14:48:42 +02:00
2020-05-24 17:07:16 +02:00
DCCWaveform : : mainTrack . schedulePacket ( b , nB , 0 ) ;
}
2020-06-22 11:54:57 +02:00
void DCC : : setFunctionInternal ( int cab , byte byte1 , byte byte2 ) {
2021-03-25 15:23:38 +01:00
// DIAG(F("setFunctionInternal %d %x %x"),cab,byte1,byte2);
2020-06-01 14:56:02 +02:00
byte b [ 4 ] ;
2020-05-24 17:07:16 +02:00
byte nB = 0 ;
2021-11-25 00:10:11 +01:00
if ( cab > HIGHEST_SHORT_ADDR )
2020-05-24 17:07:16 +02:00
b [ nB + + ] = highByte ( cab ) | 0xC0 ; // convert train number into a two-byte address
b [ nB + + ] = lowByte ( cab ) ;
2020-06-22 11:54:57 +02:00
if ( byte1 ! = 0 ) b [ nB + + ] = byte1 ;
2020-05-24 17:07:16 +02:00
b [ nB + + ] = byte2 ;
2021-05-09 20:04:16 +02:00
DCCWaveform : : mainTrack . schedulePacket ( b , nB , 0 ) ;
2020-06-22 11:54:57 +02:00
}
2020-06-27 16:36:32 +02:00
uint8_t DCC : : getThrottleSpeed ( int cab ) {
int reg = lookupSpeedTable ( cab ) ;
if ( reg < 0 ) return - 1 ;
return speedTable [ reg ] . speedCode & 0x7F ;
}
bool DCC : : getThrottleDirection ( int cab ) {
int reg = lookupSpeedTable ( cab ) ;
2021-10-31 22:20:59 +01:00
if ( reg < 0 ) return true ;
2020-06-27 16:36:32 +02:00
return ( speedTable [ reg ] . speedCode & 0x80 ) ! = 0 ;
}
2020-08-01 15:03:15 +02:00
// Set function to value on or off
2021-04-27 16:45:26 +02:00
void DCC : : setFn ( int cab , int16_t functionNumber , bool on ) {
2021-03-23 15:37:05 +01:00
if ( cab < = 0 ) return ;
2022-01-06 23:03:57 +01:00
if ( functionNumber > 28 ) {
//non reminding advanced binary bit set
2021-03-23 15:37:05 +01:00
byte b [ 5 ] ;
byte nB = 0 ;
2021-11-25 00:10:11 +01:00
if ( cab > HIGHEST_SHORT_ADDR )
2021-03-23 15:37:05 +01:00
b [ nB + + ] = highByte ( cab ) | 0xC0 ; // convert train number into a two-byte address
b [ nB + + ] = lowByte ( cab ) ;
if ( functionNumber < = 127 ) {
2022-01-06 23:03:57 +01:00
b [ nB + + ] = 0b11011101 ; // Binary State Control Instruction short form
2021-03-23 15:37:05 +01:00
b [ nB + + ] = functionNumber | ( on ? 0x80 : 0 ) ;
}
else {
2022-01-06 23:03:57 +01:00
b [ nB + + ] = 0b11000000 ; // Binary State Control Instruction long form
2021-03-23 15:37:05 +01:00
b [ nB + + ] = ( functionNumber & 0x7F ) | ( on ? 0x80 : 0 ) ; // low order bits and state flag
2021-04-27 16:45:26 +02:00
b [ nB + + ] = functionNumber > > 7 ; // high order bits
2021-03-23 15:37:05 +01:00
}
DCCWaveform : : mainTrack . schedulePacket ( b , nB , 4 ) ;
return ;
}
2022-01-06 23:03:57 +01:00
2020-06-22 11:54:57 +02:00
int reg = lookupSpeedTable ( cab ) ;
2022-01-06 23:03:57 +01:00
if ( reg < 0 ) return ;
2020-08-01 00:35:22 +02:00
2020-08-01 14:06:39 +02:00
// Take care of functions:
// Set state of function
2021-12-14 12:50:59 +01:00
unsigned long previous = speedTable [ reg ] . functions ;
2020-08-01 15:03:15 +02:00
unsigned long funcmask = ( 1UL < < functionNumber ) ;
2022-01-06 23:03:57 +01:00
if ( on ) {
2020-08-01 14:06:39 +02:00
speedTable [ reg ] . functions | = funcmask ;
} else {
speedTable [ reg ] . functions & = ~ funcmask ;
}
2021-12-14 12:50:59 +01:00
if ( speedTable [ reg ] . functions ! = previous ) {
updateGroupflags ( speedTable [ reg ] . groupFlags , functionNumber ) ;
CommandDistributor : : broadcastLoco ( reg ) ;
}
2020-08-01 14:06:39 +02:00
}
2021-12-16 11:28:41 +01:00
// Flip function state
void DCC : : changeFn ( int cab , int16_t functionNumber ) {
if ( cab < = 0 | | functionNumber > 28 ) return ;
2020-08-01 14:06:39 +02:00
int reg = lookupSpeedTable ( cab ) ;
2022-01-06 23:03:57 +01:00
if ( reg < 0 ) return ;
2020-08-01 15:03:15 +02:00
unsigned long funcmask = ( 1UL < < functionNumber ) ;
2021-12-16 11:28:41 +01:00
speedTable [ reg ] . functions ^ = funcmask ;
2022-01-06 23:03:57 +01:00
updateGroupflags ( speedTable [ reg ] . groupFlags , functionNumber ) ;
2021-12-05 19:06:28 +01:00
CommandDistributor : : broadcastLoco ( reg ) ;
2020-08-01 14:06:39 +02:00
}
2021-04-27 16:45:26 +02:00
int DCC : : getFn ( int cab , int16_t functionNumber ) {
2020-10-12 23:18:55 +02:00
if ( cab < = 0 | | functionNumber > 28 ) return - 1 ; // unknown
int reg = lookupSpeedTable ( cab ) ;
2022-01-06 23:03:57 +01:00
if ( reg < 0 ) return - 1 ;
2020-10-12 23:18:55 +02:00
unsigned long funcmask = ( 1UL < < functionNumber ) ;
return ( speedTable [ reg ] . functions & funcmask ) ? 1 : 0 ;
}
2020-08-01 14:06:39 +02:00
// Set the group flag to say we have touched the particular group.
2022-01-06 23:03:57 +01:00
// A group will be reminded only if it has been touched.
2021-04-27 16:45:26 +02:00
void DCC : : updateGroupflags ( byte & flags , int16_t functionNumber ) {
2020-08-01 00:35:22 +02:00
byte groupMask ;
if ( functionNumber < = 4 ) groupMask = FN_GROUP_1 ;
else if ( functionNumber < = 8 ) groupMask = FN_GROUP_2 ;
else if ( functionNumber < = 12 ) groupMask = FN_GROUP_3 ;
else if ( functionNumber < = 20 ) groupMask = FN_GROUP_4 ;
else groupMask = FN_GROUP_5 ;
2022-01-06 23:03:57 +01:00
flags | = groupMask ;
2020-05-24 17:07:16 +02:00
}
2021-12-15 21:53:55 +01:00
uint32_t DCC : : getFunctionMap ( int cab ) {
2021-12-15 20:51:01 +01:00
if ( cab < = 0 ) return 0 ; // unknown pretend all functions off
int reg = lookupSpeedTable ( cab ) ;
2022-01-06 23:03:57 +01:00
return ( reg < 0 ) ? 0 : speedTable [ reg ] . functions ;
2021-12-15 20:51:01 +01:00
}
2020-05-24 17:07:16 +02:00
void DCC : : setAccessory ( int address , byte number , bool activate ) {
2021-08-27 22:43:24 +02:00
# ifdef DIAG_IO
DIAG ( F ( " DCC::setAccessory(%d,%d,%d) " ) , address , number , activate ) ;
# endif
2020-06-23 21:00:34 +02:00
// use masks to detect wrong values and do nothing
2020-06-29 14:03:08 +02:00
if ( address ! = ( address & 511 ) )
2020-06-23 21:00:34 +02:00
return ;
2020-06-29 14:03:08 +02:00
if ( number ! = ( number & 3 ) )
2020-06-23 21:00:34 +02:00
return ;
2020-06-07 14:48:42 +02:00
byte b [ 2 ] ;
2020-05-24 17:07:16 +02:00
b [ 0 ] = address % 64 + 128 ; // first byte is of the form 10AAAAAA, where AAAAAA represent 6 least signifcant bits of accessory address
b [ 1 ] = ( ( ( ( address / 64 ) % 8 ) < < 4 ) + ( number % 4 < < 1 ) + activate % 2 ) ^ 0xF8 ; // second byte is of the form 1AAACDDD, where C should be 1, and the least significant D represent activate/deactivate
DCCWaveform : : mainTrack . schedulePacket ( b , 2 , 4 ) ; // Repeat the packet four times
2022-01-30 18:31:26 +01:00
# if defined(EXRAIL_ACTIVE)
2021-11-25 12:36:05 +01:00
RMFT2 : : activateEvent ( address < < 2 | number , activate ) ;
# endif
2020-05-24 17:07:16 +02:00
}
2021-03-12 22:12:13 +01:00
//
// writeCVByteMain: Write a byte with PoM on main. This writes
// the 5 byte sized packet to implement this DCC function
//
2020-05-24 17:07:16 +02:00
void DCC : : writeCVByteMain ( int cab , int cv , byte bValue ) {
2020-06-07 14:48:42 +02:00
byte b [ 5 ] ;
2020-05-24 17:07:16 +02:00
byte nB = 0 ;
2021-11-25 00:10:11 +01:00
if ( cab > HIGHEST_SHORT_ADDR )
2020-05-24 17:07:16 +02:00
b [ nB + + ] = highByte ( cab ) | 0xC0 ; // convert train number into a two-byte address
b [ nB + + ] = lowByte ( cab ) ;
2020-06-01 14:56:02 +02:00
b [ nB + + ] = cv1 ( WRITE_BYTE_MAIN , cv ) ; // any CV>1023 will become modulus(1024) due to bit-mask of 0x03
2020-05-24 17:07:16 +02:00
b [ nB + + ] = cv2 ( cv ) ;
b [ nB + + ] = bValue ;
DCCWaveform : : mainTrack . schedulePacket ( b , nB , 4 ) ;
}
2021-03-12 22:12:13 +01:00
//
// writeCVBitMain: Write a bit of a byte with PoM on main. This writes
// the 5 byte sized packet to implement this DCC function
//
2020-05-24 17:07:16 +02:00
void DCC : : writeCVBitMain ( int cab , int cv , byte bNum , bool bValue ) {
2020-06-07 14:48:42 +02:00
byte b [ 5 ] ;
2020-05-24 17:07:16 +02:00
byte nB = 0 ;
bValue = bValue % 2 ;
bNum = bNum % 8 ;
2021-11-25 00:10:11 +01:00
if ( cab > HIGHEST_SHORT_ADDR )
2020-05-24 17:07:16 +02:00
b [ nB + + ] = highByte ( cab ) | 0xC0 ; // convert train number into a two-byte address
b [ nB + + ] = lowByte ( cab ) ;
2020-06-01 14:56:02 +02:00
b [ nB + + ] = cv1 ( WRITE_BIT_MAIN , cv ) ; // any CV>1023 will become modulus(1024) due to bit-mask of 0x03
2020-05-24 17:07:16 +02:00
b [ nB + + ] = cv2 ( cv ) ;
2020-06-07 14:48:42 +02:00
b [ nB + + ] = WRITE_BIT | ( bValue ? BIT_ON : BIT_OFF ) | bNum ;
2020-05-24 17:07:16 +02:00
DCCWaveform : : mainTrack . schedulePacket ( b , nB , 4 ) ;
}
2020-07-12 01:11:30 +02:00
void DCC : : setProgTrackSyncMain ( bool on ) {
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 ( joinRelay ! = UNUSED_PIN ) digitalWrite ( joinRelay , on ? HIGH : LOW ) ;
2020-07-12 01:11:30 +02:00
DCCWaveform : : progTrackSyncMain = on ;
}
2020-09-27 13:03:46 +02:00
void DCC : : setProgTrackBoost ( bool on ) {
DCCWaveform : : progTrackBoosted = on ;
}
2020-05-24 17:07:16 +02:00
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
FSH * DCC : : getMotorShieldName ( ) {
2020-09-24 10:51:09 +02:00
return shieldName ;
}
2022-01-06 23:03:57 +01:00
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
const ackOp FLASH WRITE_BIT0_PROG [ ] = {
2020-06-07 14:48:42 +02:00
BASELINE ,
W0 , WACK ,
2022-01-06 23:03:57 +01:00
V0 , WACK , // validate bit is 0
2020-06-07 14:48:42 +02:00
ITC1 , // if acked, callback(1)
2021-09-21 00:31:05 +02:00
CALLFAIL // callback (-1)
2020-06-07 14:48:42 +02:00
} ;
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
const ackOp FLASH WRITE_BIT1_PROG [ ] = {
2020-06-07 14:48:42 +02:00
BASELINE ,
W1 , WACK ,
2022-01-06 23:03:57 +01:00
V1 , WACK , // validate bit is 1
2020-06-07 14:48:42 +02:00
ITC1 , // if acked, callback(1)
2021-09-21 00:31:05 +02:00
CALLFAIL // callback (-1)
2020-06-07 14:48:42 +02:00
} ;
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
const ackOp FLASH VERIFY_BIT0_PROG [ ] = {
2020-09-18 01:04:42 +02:00
BASELINE ,
2022-01-06 23:03:57 +01:00
V0 , WACK , // validate bit is 0
2020-09-18 01:04:42 +02:00
ITC0 , // if acked, callback(0)
V1 , WACK , // validate bit is 1
ITC1 ,
2021-09-21 00:31:05 +02:00
CALLFAIL // callback (-1)
2020-09-18 01:04:42 +02:00
} ;
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
const ackOp FLASH VERIFY_BIT1_PROG [ ] = {
2020-09-18 01:04:42 +02:00
BASELINE ,
2022-01-06 23:03:57 +01:00
V1 , WACK , // validate bit is 1
2020-09-18 01:04:42 +02:00
ITC1 , // if acked, callback(1)
2022-01-06 23:03:57 +01:00
V0 , WACK ,
2020-09-18 01:04:42 +02:00
ITC0 ,
2021-09-21 00:31:05 +02:00
CALLFAIL // callback (-1)
2020-09-18 01:04:42 +02:00
} ;
2020-06-07 14:48:42 +02:00
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
const ackOp FLASH READ_BIT_PROG [ ] = {
2020-06-07 14:48:42 +02:00
BASELINE ,
2022-01-06 23:03:57 +01:00
V1 , WACK , // validate bit is 1
2020-06-07 14:48:42 +02:00
ITC1 , // if acked, callback(1)
V0 , WACK , // validate bit is zero
ITC0 , // if acked callback 0
2021-09-21 00:31:05 +02:00
CALLFAIL // bit not readable
2020-09-08 21:39:54 +02:00
} ;
2022-01-06 23:03:57 +01:00
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
const ackOp FLASH WRITE_BYTE_PROG [ ] = {
2020-06-07 14:48:42 +02:00
BASELINE ,
2021-03-24 10:51:31 +01:00
WB , WACK , ITC1 , // Write and callback(1) if ACK
// handle decoders that dont ack a write
VB , WACK , ITC1 , // validate byte and callback(1) if correct
2021-09-21 00:31:05 +02:00
CALLFAIL // callback (-1)
2020-09-08 21:39:54 +02:00
} ;
2022-01-06 23:03:57 +01:00
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
const ackOp FLASH VERIFY_BYTE_PROG [ ] = {
2020-09-18 01:04:42 +02:00
BASELINE ,
2021-09-05 23:43:24 +02:00
BIV , // ackManagerByte initial value
2022-01-06 23:03:57 +01:00
VB , WACK , // validate byte
2021-09-05 23:43:24 +02:00
ITCB , // if ok callback value
2020-09-18 01:04:42 +02:00
STARTMERGE , //clear bit and byte values ready for merge pass
// each bit is validated against 0 and the result inverted in MERGE
2022-01-06 23:03:57 +01:00
// this is because there tend to be more zeros in cv values than ones.
2020-09-18 01:04:42 +02:00
// There is no need for one validation as entire byte is validated at the end
V0 , WACK , MERGE , // read and merge first tested bit (7)
ITSKIP , // do small excursion if there was no ack
SETBIT , ( ackOp ) 7 ,
V1 , WACK , NAKFAIL , // test if there is an ack on the inverse of this bit (7)
SETBIT , ( ackOp ) 6 , // and abort whole test if not else continue with bit (6)
SKIPTARGET ,
V0 , WACK , MERGE , // read and merge second tested bit (6)
V0 , WACK , MERGE , // read and merge third tested bit (5) ...
V0 , WACK , MERGE ,
V0 , WACK , MERGE ,
V0 , WACK , MERGE ,
V0 , WACK , MERGE ,
V0 , WACK , MERGE ,
VB , WACK , ITCB , // verify merged byte and return it if acked ok
2021-09-21 00:31:05 +02:00
CALLFAIL } ;
2020-09-18 01:04:42 +02:00
2022-02-06 06:00:19 +01:00
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
const ackOp FLASH READ_CV_PROG [ ] = {
2020-06-07 14:48:42 +02:00
BASELINE ,
2020-06-07 17:29:53 +02:00
STARTMERGE , //clear bit and byte values ready for merge pass
2020-06-07 18:02:22 +02:00
// each bit is validated against 0 and the result inverted in MERGE
2022-01-06 23:03:57 +01:00
// this is because there tend to be more zeros in cv values than ones.
2020-06-07 18:02:22 +02:00
// There is no need for one validation as entire byte is validated at the end
2020-09-08 10:12:40 +02:00
V0 , WACK , MERGE , // read and merge first tested bit (7)
ITSKIP , // do small excursion if there was no ack
SETBIT , ( ackOp ) 7 ,
V1 , WACK , NAKFAIL , // test if there is an ack on the inverse of this bit (7)
SETBIT , ( ackOp ) 6 , // and abort whole test if not else continue with bit (6)
SKIPTARGET ,
V0 , WACK , MERGE , // read and merge second tested bit (6)
V0 , WACK , MERGE , // read and merge third tested bit (5) ...
2020-06-07 18:02:22 +02:00
V0 , WACK , MERGE ,
V0 , WACK , MERGE ,
V0 , WACK , MERGE ,
V0 , WACK , MERGE ,
V0 , WACK , MERGE ,
2020-06-07 14:48:42 +02:00
VB , WACK , ITCB , // verify merged byte and return it if acked ok
2021-09-21 00:31:05 +02:00
CALLFAIL } ; // verification failed
2020-06-07 14:48:42 +02:00
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
const ackOp FLASH LOCO_ID_PROG [ ] = {
2020-06-08 14:04:47 +02:00
BASELINE ,
2021-01-17 14:22:16 +01:00
SETCV , ( ackOp ) 19 , // CV 19 is consist setting
2022-01-06 23:03:57 +01:00
SETBYTE , ( ackOp ) 0 ,
2021-01-17 14:22:16 +01:00
VB , WACK , ITSKIP , // ignore consist if cv19 is zero (no consist)
SETBYTE , ( ackOp ) 128 ,
VB , WACK , ITSKIP , // ignore consist if cv19 is 128 (no consist, direction bit set)
STARTMERGE , // Setup to read cv 19
2022-01-06 23:03:57 +01:00
V0 , WACK , MERGE ,
V0 , WACK , MERGE ,
2021-01-17 14:22:16 +01:00
V0 , WACK , MERGE ,
V0 , WACK , MERGE ,
V0 , WACK , MERGE ,
V0 , WACK , MERGE ,
V0 , WACK , MERGE ,
V0 , WACK , MERGE ,
VB , WACK , ITCB7 , // return 7 bits only, No_ACK means CV19 not supported so ignore it
2022-01-06 23:03:57 +01:00
SKIPTARGET , // continue here if CV 19 is zero or fails all validation
2020-06-08 14:04:47 +02:00
SETCV , ( ackOp ) 29 ,
SETBIT , ( ackOp ) 5 ,
V0 , WACK , ITSKIP , // Skip to SKIPTARGET if bit 5 of CV29 is zero
2022-01-06 23:03:57 +01:00
// Long locoid
2020-06-08 14:04:47 +02:00
SETCV , ( ackOp ) 17 , // CV 17 is part of locoid
STARTMERGE ,
V0 , WACK , MERGE , // read and merge bit 1 etc
V0 , WACK , MERGE ,
V0 , WACK , MERGE ,
V0 , WACK , MERGE ,
V0 , WACK , MERGE ,
V0 , WACK , MERGE ,
V0 , WACK , MERGE ,
V0 , WACK , MERGE ,
VB , WACK , NAKFAIL , // verify merged byte and return -1 it if not acked ok
2022-01-06 23:03:57 +01:00
STASHLOCOID , // keep stashed cv 17 for later
// Read 2nd part from CV 18
2020-06-08 14:04:47 +02:00
SETCV , ( ackOp ) 18 ,
STARTMERGE ,
V0 , WACK , MERGE , // read and merge bit 1 etc
V0 , WACK , MERGE ,
V0 , WACK , MERGE ,
V0 , WACK , MERGE ,
V0 , WACK , MERGE ,
V0 , WACK , MERGE ,
V0 , WACK , MERGE ,
V0 , WACK , MERGE ,
VB , WACK , NAKFAIL , // verify merged byte and return -1 it if not acked ok
COMBINELOCOID , // Combile byte with stash to make long locoid and callback
2022-01-06 23:03:57 +01:00
// ITSKIP Skips to here if CV 29 bit 5 was zero. so read CV 1 and return that
2020-06-08 14:04:47 +02:00
SKIPTARGET ,
SETCV , ( ackOp ) 1 ,
STARTMERGE ,
2021-01-17 14:22:16 +01:00
SETBIT , ( ackOp ) 6 , // skip over first bit as we know its a zero
2020-06-08 14:04:47 +02:00
V0 , WACK , MERGE ,
V0 , WACK , MERGE ,
V0 , WACK , MERGE ,
V0 , WACK , MERGE ,
V0 , WACK , MERGE ,
V0 , WACK , MERGE ,
V0 , WACK , MERGE ,
VB , WACK , ITCB , // verify merged byte and callback
2021-09-21 00:31:05 +02:00
CALLFAIL
2020-09-08 21:39:54 +02:00
} ;
2020-06-08 14:04:47 +02:00
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
const ackOp FLASH SHORT_LOCO_ID_PROG [ ] = {
2021-01-18 11:06:46 +01:00
BASELINE ,
SETCV , ( ackOp ) 19 ,
SETBYTE , ( ackOp ) 0 ,
2021-03-24 10:51:31 +01:00
WB , WACK , // ignore dedcoder without cv19 support
2021-01-18 11:06:46 +01:00
// Turn off long address flag
SETCV , ( ackOp ) 29 ,
SETBIT , ( ackOp ) 5 ,
2021-03-24 10:51:31 +01:00
W0 , WACK ,
V0 , WACK , NAKFAIL ,
2022-01-06 23:03:57 +01:00
SETCV , ( ackOp ) 1 ,
SETBYTEL , // low byte of word
2021-03-24 10:51:31 +01:00
WB , WACK , // some decoders don't ACK writes
2021-01-18 11:06:46 +01:00
VB , WACK , ITCB ,
2021-09-21 00:31:05 +02:00
CALLFAIL
2021-01-18 11:06:46 +01:00
} ;
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
const ackOp FLASH LONG_LOCO_ID_PROG [ ] = {
2021-01-18 11:06:46 +01:00
BASELINE ,
// Clear consist CV 19
SETCV , ( ackOp ) 19 ,
SETBYTE , ( ackOp ) 0 ,
2021-03-24 10:51:31 +01:00
WB , WACK , // ignore decoder without cv19 support
2021-01-18 11:06:46 +01:00
// Turn on long address flag cv29 bit 5
SETCV , ( ackOp ) 29 ,
SETBIT , ( ackOp ) 5 ,
2021-03-24 10:51:31 +01:00
W1 , WACK ,
V1 , WACK , NAKFAIL ,
2021-01-18 11:06:46 +01:00
// Store high byte of address in cv 17
SETCV , ( ackOp ) 17 ,
2022-01-06 23:03:57 +01:00
SETBYTEH , // high byte of word
2021-03-24 10:51:31 +01:00
WB , WACK ,
2021-01-18 11:06:46 +01:00
VB , WACK , NAKFAIL ,
2022-01-06 23:03:57 +01:00
// store
2021-01-18 11:06:46 +01:00
SETCV , ( ackOp ) 18 ,
2022-01-06 23:03:57 +01:00
SETBYTEL , // low byte of word
2021-03-24 10:51:31 +01:00
WB , WACK ,
2021-01-18 11:06:46 +01:00
VB , WACK , ITC1 , // callback(1) means Ok
2021-09-21 00:31:05 +02:00
CALLFAIL
2021-01-18 11:06:46 +01:00
} ;
2020-06-08 14:04:47 +02:00
2021-03-25 18:16:12 +01:00
void DCC : : writeCVByte ( int16_t cv , byte byteValue , ACK_CALLBACK callback ) {
2021-03-08 11:40:32 +01:00
ackManagerSetup ( cv , byteValue , WRITE_BYTE_PROG , callback ) ;
2020-06-01 14:56:02 +02:00
}
2020-05-24 17:07:16 +02:00
2021-03-25 18:16:12 +01:00
void DCC : : writeCVBit ( int16_t cv , byte bitNum , bool bitValue , ACK_CALLBACK callback ) {
2020-06-07 14:48:42 +02:00
if ( bitNum > = 8 ) callback ( - 1 ) ;
2021-03-08 11:40:32 +01:00
else ackManagerSetup ( cv , bitNum , bitValue ? WRITE_BIT1_PROG : WRITE_BIT0_PROG , callback ) ;
2020-06-03 10:42:17 +02:00
}
2020-05-24 17:07:16 +02:00
2021-03-25 18:16:12 +01:00
void DCC : : verifyCVByte ( int16_t cv , byte byteValue , ACK_CALLBACK callback ) {
2021-03-08 11:40:32 +01:00
ackManagerSetup ( cv , byteValue , VERIFY_BYTE_PROG , callback ) ;
2020-09-18 01:04:42 +02:00
}
2021-03-25 18:16:12 +01:00
void DCC : : verifyCVBit ( int16_t cv , byte bitNum , bool bitValue , ACK_CALLBACK callback ) {
2020-09-18 01:04:42 +02:00
if ( bitNum > = 8 ) callback ( - 1 ) ;
2021-03-08 11:40:32 +01:00
else ackManagerSetup ( cv , bitNum , bitValue ? VERIFY_BIT1_PROG : VERIFY_BIT0_PROG , callback ) ;
2020-09-18 01:04:42 +02:00
}
2020-05-24 17:07:16 +02:00
2021-03-25 18:16:12 +01:00
void DCC : : readCVBit ( int16_t cv , byte bitNum , ACK_CALLBACK callback ) {
2020-06-07 14:48:42 +02:00
if ( bitNum > = 8 ) callback ( - 1 ) ;
2021-03-08 11:40:32 +01:00
else ackManagerSetup ( cv , bitNum , READ_BIT_PROG , callback ) ;
2020-06-07 14:48:42 +02:00
}
2021-03-25 18:16:12 +01:00
void DCC : : readCV ( int16_t cv , ACK_CALLBACK callback ) {
2021-03-08 11:40:32 +01:00
ackManagerSetup ( cv , 0 , READ_CV_PROG , callback ) ;
2020-05-24 17:07:16 +02:00
}
2021-03-08 11:40:32 +01:00
void DCC : : getLocoId ( ACK_CALLBACK callback ) {
ackManagerSetup ( 0 , 0 , LOCO_ID_PROG , callback ) ;
2020-06-08 14:04:47 +02:00
}
2020-06-07 14:48:42 +02:00
2021-03-08 11:40:32 +01:00
void DCC : : setLocoId ( int id , ACK_CALLBACK callback ) {
2021-01-30 22:53:05 +01:00
if ( id < 1 | | id > 10239 ) { //0x27FF according to standard
callback ( - 1 ) ;
return ;
}
2021-11-25 00:10:11 +01:00
if ( id < = HIGHEST_SHORT_ADDR )
2021-03-08 11:40:32 +01:00
ackManagerSetup ( id , SHORT_LOCO_ID_PROG , callback ) ;
2021-01-30 22:53:05 +01:00
else
2021-03-08 11:40:32 +01:00
ackManagerSetup ( id | 0xc000 , LONG_LOCO_ID_PROG , callback ) ;
2021-01-18 11:06:46 +01:00
}
2021-03-23 15:37:05 +01:00
void DCC : : forgetLoco ( int cab ) { // removes any speed reminders for this loco
2022-01-06 23:03:57 +01:00
setThrottle2 ( cab , 1 ) ; // ESTOP this loco if still on track
2020-06-22 11:54:57 +02:00
int reg = lookupSpeedTable ( cab ) ;
if ( reg > = 0 ) speedTable [ reg ] . loco = 0 ;
2021-03-23 15:37:05 +01:00
setThrottle2 ( cab , 1 ) ; // ESTOP if this loco still on track
2020-06-18 20:36:37 +02:00
}
void DCC : : forgetAllLocos ( ) { // removes all speed reminders
2022-01-06 23:03:57 +01:00
setThrottle2 ( 0 , 1 ) ; // ESTOP all locos still on track
2021-03-23 15:37:05 +01:00
for ( int i = 0 ; i < MAX_LOCOS ; i + + ) speedTable [ i ] . loco = 0 ;
2020-06-18 20:36:37 +02:00
}
2020-06-22 11:54:57 +02:00
2022-01-06 23:03:57 +01:00
byte DCC : : loopStatus = 0 ;
2020-06-18 20:36:37 +02:00
2020-05-24 17:07:16 +02:00
void DCC : : loop ( ) {
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
DCCWaveform : : loop ( ackManagerProg ! = NULL ) ; // power overload checks
2021-03-08 11:40:32 +01:00
ackManagerLoop ( ) ; // maintain prog track ack manager
2020-06-22 11:54:57 +02:00
issueReminders ( ) ;
}
void DCC : : issueReminders ( ) {
// if the main track transmitter still has a pending packet, skip this time around.
2020-05-24 17:07:16 +02:00
if ( DCCWaveform : : mainTrack . packetPending ) return ;
2020-06-22 11:54:57 +02:00
// This loop searches for a loco in the speed table starting at nextLoco and cycling back around
for ( int reg = 0 ; reg < MAX_LOCOS ; reg + + ) {
int slot = reg + nextLoco ;
2022-01-06 23:03:57 +01:00
if ( slot > = MAX_LOCOS ) slot - = MAX_LOCOS ;
2020-06-22 11:54:57 +02:00
if ( speedTable [ slot ] . loco > 0 ) {
2022-01-06 23:03:57 +01:00
// have found the next loco to remind
2020-06-22 11:54:57 +02:00
// issueReminder will return true if this loco is completed (ie speed and functions)
2022-01-06 23:03:57 +01:00
if ( issueReminder ( slot ) ) nextLoco = slot + 1 ;
2020-06-22 11:54:57 +02:00
return ;
}
2020-05-24 17:07:16 +02:00
}
}
2022-01-06 23:03:57 +01:00
2020-06-22 11:54:57 +02:00
bool DCC : : issueReminder ( int reg ) {
2020-08-01 14:06:39 +02:00
unsigned long functions = speedTable [ reg ] . functions ;
2020-06-22 11:54:57 +02:00
int loco = speedTable [ reg ] . loco ;
byte flags = speedTable [ reg ] . groupFlags ;
2022-01-06 23:03:57 +01:00
2020-06-22 11:54:57 +02:00
switch ( loopStatus ) {
case 0 :
2021-03-25 15:23:38 +01:00
// DIAG(F("Reminder %d speed %d"),loco,speedTable[reg].speedCode);
2020-06-22 11:54:57 +02:00
setThrottle2 ( loco , speedTable [ reg ] . speedCode ) ;
break ;
case 1 : // remind function group 1 (F0-F4)
2022-01-06 23:03:57 +01:00
if ( flags & FN_GROUP_1 )
2020-10-13 23:08:19 +02:00
setFunctionInternal ( loco , 0 , 128 | ( ( functions > > 1 ) & 0x0F ) | ( ( functions & 0x01 ) < < 4 ) ) ; // 100D DDDD
2022-01-06 23:03:57 +01:00
break ;
2020-06-22 11:54:57 +02:00
case 2 : // remind function group 2 F5-F8
2022-01-06 23:03:57 +01:00
if ( flags & FN_GROUP_2 )
2020-10-13 23:08:19 +02:00
setFunctionInternal ( loco , 0 , 176 | ( ( functions > > 5 ) & 0x0F ) ) ; // 1011 DDDD
2022-01-06 23:03:57 +01:00
break ;
2020-06-22 11:54:57 +02:00
case 3 : // remind function group 3 F9-F12
2022-01-06 23:03:57 +01:00
if ( flags & FN_GROUP_3 )
2020-10-13 23:08:19 +02:00
setFunctionInternal ( loco , 0 , 160 | ( ( functions > > 9 ) & 0x0F ) ) ; // 1010 DDDD
2022-01-06 23:03:57 +01:00
break ;
2020-06-22 11:54:57 +02:00
case 4 : // remind function group 4 F13-F20
2022-01-06 23:03:57 +01:00
if ( flags & FN_GROUP_4 )
setFunctionInternal ( loco , 222 , ( ( functions > > 13 ) & 0xFF ) ) ;
2020-07-05 22:24:54 +02:00
flags & = ~ FN_GROUP_4 ; // dont send them again
2022-01-06 23:03:57 +01:00
break ;
2020-06-22 11:54:57 +02:00
case 5 : // remind function group 5 F21-F28
if ( flags & FN_GROUP_5 )
2022-01-06 23:03:57 +01:00
setFunctionInternal ( loco , 223 , ( ( functions > > 21 ) & 0xFF ) ) ;
2020-07-05 22:24:54 +02:00
flags & = ~ FN_GROUP_5 ; // dont send them again
2022-01-06 23:03:57 +01:00
break ;
2020-06-22 11:54:57 +02:00
}
loopStatus + + ;
// if we reach status 6 then this loco is done so
2022-01-06 23:03:57 +01:00
// reset status to 0 for next loco and return true so caller
// moves on to next loco.
2020-06-22 11:54:57 +02:00
if ( loopStatus > 5 ) loopStatus = 0 ;
return loopStatus = = 0 ;
}
2022-01-06 23:03:57 +01:00
2020-05-24 17:07:16 +02:00
2020-06-03 10:42:17 +02:00
2020-05-24 17:07:16 +02:00
///// Private helper functions below here /////////////////////
2020-06-01 14:56:02 +02:00
2020-05-24 17:07:16 +02:00
byte DCC : : cv1 ( byte opcode , int cv ) {
cv - - ;
return ( highByte ( cv ) & ( byte ) 0x03 ) | opcode ;
}
byte DCC : : cv2 ( int cv ) {
cv - - ;
return lowByte ( cv ) ;
}
2020-06-22 11:54:57 +02:00
int DCC : : lookupSpeedTable ( int locoId ) {
2020-06-16 12:06:36 +02:00
// determine speed reg for this loco
2020-05-24 17:07:16 +02:00
int firstEmpty = MAX_LOCOS ;
2020-06-22 11:54:57 +02:00
int reg ;
2020-05-24 17:07:16 +02:00
for ( reg = 0 ; reg < MAX_LOCOS ; reg + + ) {
2020-06-22 11:54:57 +02:00
if ( speedTable [ reg ] . loco = = locoId ) break ;
2020-05-24 17:07:16 +02:00
if ( speedTable [ reg ] . loco = = 0 & & firstEmpty = = MAX_LOCOS ) firstEmpty = reg ;
}
if ( reg = = MAX_LOCOS ) reg = firstEmpty ;
if ( reg > = MAX_LOCOS ) {
2021-03-25 15:23:38 +01:00
DIAG ( F ( " Too many locos " ) ) ;
2020-06-22 11:54:57 +02:00
return - 1 ;
2020-05-24 17:07:16 +02:00
}
2020-06-22 11:54:57 +02:00
if ( reg = = firstEmpty ) {
speedTable [ reg ] . loco = locoId ;
2020-07-05 22:00:27 +02:00
speedTable [ reg ] . speedCode = 128 ; // default direction forward
2020-06-22 11:54:57 +02:00
speedTable [ reg ] . groupFlags = 0 ;
speedTable [ reg ] . functions = 0 ;
}
return reg ;
}
2022-01-06 23:03:57 +01:00
2020-06-22 11:54:57 +02:00
void DCC : : updateLocoReminder ( int loco , byte speedCode ) {
2022-01-06 23:03:57 +01:00
2020-06-22 11:54:57 +02:00
if ( loco = = 0 ) {
2020-09-03 12:28:52 +02:00
// broadcast stop/estop but dont change direction
for ( int reg = 0 ; reg < MAX_LOCOS ; reg + + ) {
2021-12-21 10:14:27 +01:00
if ( speedTable [ reg ] . loco = = 0 ) continue ;
byte newspeed = ( speedTable [ reg ] . speedCode & 0x80 ) | ( speedCode & 0x7f ) ;
if ( speedTable [ reg ] . speedCode ! = newspeed ) {
speedTable [ reg ] . speedCode = newspeed ;
CommandDistributor : : broadcastLoco ( reg ) ;
}
2020-09-03 12:28:52 +02:00
}
2022-01-06 23:03:57 +01:00
return ;
2020-06-22 11:54:57 +02:00
}
2022-01-06 23:03:57 +01:00
2020-06-22 11:54:57 +02:00
// determine speed reg for this loco
2022-01-06 23:03:57 +01:00
int reg = lookupSpeedTable ( loco ) ;
2021-12-15 23:04:09 +01:00
if ( reg > = 0 & & speedTable [ reg ] . speedCode ! = speedCode ) {
2021-12-05 19:06:28 +01:00
speedTable [ reg ] . speedCode = speedCode ;
CommandDistributor : : broadcastLoco ( reg ) ;
}
2020-06-07 14:48:42 +02:00
}
2020-05-24 17:07:16 +02:00
DCC : : LOCO DCC : : speedTable [ MAX_LOCOS ] ;
2020-05-26 13:44:02 +02:00
int DCC : : nextLoco = 0 ;
2020-06-07 14:48:42 +02:00
//ACK MANAGER
ackOp const * DCC : : ackManagerProg ;
2021-08-23 12:58:48 +02:00
ackOp const * DCC : : ackManagerProgStart ;
2020-06-07 14:48:42 +02:00
byte DCC : : ackManagerByte ;
2021-09-05 23:43:24 +02:00
byte DCC : : ackManagerByteVerify ;
2020-06-08 14:04:47 +02:00
byte DCC : : ackManagerStash ;
2021-01-18 11:06:46 +01:00
int DCC : : ackManagerWord ;
2021-08-23 12:58:48 +02:00
byte DCC : : ackManagerRetry ;
byte DCC : : ackRetry = 2 ;
int16_t DCC : : ackRetrySum ;
2021-08-30 23:52:50 +02:00
int16_t DCC : : ackRetryPSum ;
2021-01-18 11:06:46 +01:00
int DCC : : ackManagerCv ;
2020-06-07 14:48:42 +02:00
byte DCC : : ackManagerBitNum ;
bool DCC : : ackReceived ;
2021-03-23 15:37:05 +01:00
bool DCC : : ackManagerRejoin ;
2020-06-07 14:48:42 +02:00
2021-05-07 19:24:34 +02:00
CALLBACK_STATE DCC : : callbackState = READY ;
2020-06-07 14:48:42 +02:00
ACK_CALLBACK DCC : : ackManagerCallback ;
2021-03-08 11:40:32 +01:00
void DCC : : ackManagerSetup ( int cv , byte byteValueOrBitnum , ackOp const program [ ] , ACK_CALLBACK callback ) {
2021-05-07 19:24:34 +02:00
if ( ! DCCWaveform : : progTrack . canMeasureCurrent ( ) ) {
callback ( - 2 ) ;
return ;
}
2022-01-06 23:03:57 +01:00
ackManagerRejoin = DCCWaveform : : progTrackSyncMain ;
2021-05-07 19:24:34 +02:00
if ( ackManagerRejoin ) {
// Change from JOIN must zero resets packet.
setProgTrackSyncMain ( false ) ;
2022-01-06 23:03:57 +01:00
DCCWaveform : : progTrack . sentResetsSincePacket = 0 ;
2021-05-07 19:24:34 +02:00
}
2022-01-06 23:03:57 +01:00
DCCWaveform : : progTrack . autoPowerOff = false ;
2021-05-07 19:24:34 +02:00
if ( DCCWaveform : : progTrack . getPowerMode ( ) = = POWERMODE : : OFF ) {
2022-01-06 23:03:57 +01:00
DCCWaveform : : progTrack . autoPowerOff = true ; // power off afterwards
2021-05-07 19:24:34 +02:00
if ( Diag : : ACK ) DIAG ( F ( " Auto Prog power on " ) ) ;
DCCWaveform : : progTrack . setPowerMode ( POWERMODE : : ON ) ;
2022-01-08 21:44:32 +01:00
if ( MotorDriver : : commonFaultPin )
DCCWaveform : : mainTrack . setPowerMode ( POWERMODE : : ON ) ;
2022-01-06 23:03:57 +01:00
DCCWaveform : : progTrack . sentResetsSincePacket = 0 ;
2021-05-07 19:24:34 +02:00
}
2020-06-07 14:48:42 +02:00
ackManagerCv = cv ;
ackManagerProg = program ;
2021-08-23 12:58:48 +02:00
ackManagerProgStart = program ;
ackManagerRetry = ackRetry ;
2020-06-07 16:29:09 +02:00
ackManagerByte = byteValueOrBitnum ;
2021-09-05 23:43:24 +02:00
ackManagerByteVerify = byteValueOrBitnum ;
2020-06-07 16:29:09 +02:00
ackManagerBitNum = byteValueOrBitnum ;
2020-06-07 14:48:42 +02:00
ackManagerCallback = callback ;
2020-06-07 16:29:09 +02:00
}
2020-06-07 14:48:42 +02:00
2021-03-08 11:40:32 +01:00
void DCC : : ackManagerSetup ( int wordval , ackOp const program [ ] , ACK_CALLBACK callback ) {
2021-01-18 11:06:46 +01:00
ackManagerWord = wordval ;
2021-05-07 19:24:34 +02:00
ackManagerSetup ( 0 , 0 , program , callback ) ;
2021-03-08 11:40:32 +01:00
}
2021-01-18 11:06:46 +01:00
2020-06-07 17:29:53 +02:00
const byte RESET_MIN = 8 ; // tuning of reset counter before sending message
2020-07-19 19:39:08 +02:00
// checkRessets return true if the caller should yield back to loop and try later.
2021-03-08 11:40:32 +01:00
bool DCC : : checkResets ( uint8_t numResets ) {
2020-09-08 09:24:37 +02:00
return DCCWaveform : : progTrack . sentResetsSincePacket < numResets ;
2020-07-19 19:39:08 +02:00
}
2020-06-07 14:48:42 +02:00
2021-03-08 11:40:32 +01:00
void DCC : : ackManagerLoop ( ) {
2020-07-19 19:39:08 +02:00
while ( ackManagerProg ) {
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
byte opcode = GETFLASH ( ackManagerProg ) ;
2022-01-06 23:03:57 +01:00
2020-07-19 19:39:08 +02:00
// breaks from this switch will step to next prog entry
// returns from this switch will stay on same entry
// (typically waiting for a reset counter or ACK waiting, or when all finished.)
2020-06-07 14:48:42 +02:00
switch ( opcode ) {
2020-06-07 17:29:53 +02:00
case BASELINE :
2021-09-09 11:23:27 +02:00
if ( DCCWaveform : : progTrack . getPowerMode ( ) = = POWERMODE : : OVERLOAD ) return ;
2021-05-07 19:24:34 +02:00
if ( checkResets ( DCCWaveform : : progTrack . autoPowerOff | | ackManagerRejoin ? 20 : 3 ) ) return ;
2020-09-10 14:09:32 +02:00
DCCWaveform : : progTrack . setAckBaseline ( ) ;
2021-05-07 19:24:34 +02:00
callbackState = READY ;
2022-01-06 23:03:57 +01:00
break ;
case W0 : // write 0 bit
case W1 : // write 1 bit
2020-06-07 14:48:42 +02:00
{
2021-03-08 11:40:32 +01:00
if ( checkResets ( RESET_MIN ) ) return ;
2022-01-06 23:03:57 +01:00
if ( Diag : : ACK ) DIAG ( F ( " W%d cv=%d bit=%d " ) , opcode = = W1 , ackManagerCv , ackManagerBitNum ) ;
2020-06-07 16:29:09 +02:00
byte instruction = WRITE_BIT | ( opcode = = W1 ? BIT_ON : BIT_OFF ) | ackManagerBitNum ;
2020-06-07 14:48:42 +02:00
byte message [ ] = { cv1 ( BIT_MANIPULATE , ackManagerCv ) , cv2 ( ackManagerCv ) , instruction } ;
2020-07-11 10:35:57 +02:00
DCCWaveform : : progTrack . schedulePacket ( message , sizeof ( message ) , PROG_REPEATS ) ;
2022-01-06 23:03:57 +01:00
DCCWaveform : : progTrack . setAckPending ( ) ;
2021-05-07 19:24:34 +02:00
callbackState = AFTER_WRITE ;
2020-07-02 13:49:35 +02:00
}
2022-01-06 23:03:57 +01:00
break ;
case WB : // write byte
2020-06-07 14:48:42 +02:00
{
2021-03-08 11:40:32 +01:00
if ( checkResets ( RESET_MIN ) ) return ;
2021-03-25 15:23:38 +01:00
if ( Diag : : ACK ) DIAG ( F ( " WB cv=%d value=%d " ) , ackManagerCv , ackManagerByte ) ;
2020-06-07 14:48:42 +02:00
byte message [ ] = { cv1 ( WRITE_BYTE , ackManagerCv ) , cv2 ( ackManagerCv ) , ackManagerByte } ;
2020-07-11 10:35:57 +02:00
DCCWaveform : : progTrack . schedulePacket ( message , sizeof ( message ) , PROG_REPEATS ) ;
2022-01-06 23:03:57 +01:00
DCCWaveform : : progTrack . setAckPending ( ) ;
2021-05-07 19:24:34 +02:00
callbackState = AFTER_WRITE ;
2020-06-07 14:48:42 +02:00
}
break ;
2022-01-06 23:03:57 +01:00
2020-06-07 14:48:42 +02:00
case VB : // Issue validate Byte packet
{
2022-01-06 23:03:57 +01:00
if ( checkResets ( RESET_MIN ) ) return ;
2021-03-25 15:23:38 +01:00
if ( Diag : : ACK ) DIAG ( F ( " VB cv=%d value=%d " ) , ackManagerCv , ackManagerByte ) ;
2020-06-07 14:48:42 +02:00
byte message [ ] = { cv1 ( VERIFY_BYTE , ackManagerCv ) , cv2 ( ackManagerCv ) , ackManagerByte } ;
2020-07-11 10:35:57 +02:00
DCCWaveform : : progTrack . schedulePacket ( message , sizeof ( message ) , PROG_REPEATS ) ;
2022-01-06 23:03:57 +01:00
DCCWaveform : : progTrack . setAckPending ( ) ;
2020-06-07 14:48:42 +02:00
}
break ;
2022-01-06 23:03:57 +01:00
2020-06-07 14:48:42 +02:00
case V0 :
case V1 : // Issue validate bit=0 or bit=1 packet
{
2022-01-06 23:03:57 +01:00
if ( checkResets ( RESET_MIN ) ) return ;
if ( Diag : : ACK ) DIAG ( F ( " V%d cv=%d bit=%d " ) , opcode = = V1 , ackManagerCv , ackManagerBitNum ) ;
2020-06-07 16:29:09 +02:00
byte instruction = VERIFY_BIT | ( opcode = = V0 ? BIT_OFF : BIT_ON ) | ackManagerBitNum ;
2020-06-07 14:48:42 +02:00
byte message [ ] = { cv1 ( BIT_MANIPULATE , ackManagerCv ) , cv2 ( ackManagerCv ) , instruction } ;
2020-07-11 10:35:57 +02:00
DCCWaveform : : progTrack . schedulePacket ( message , sizeof ( message ) , PROG_REPEATS ) ;
2022-01-06 23:03:57 +01:00
DCCWaveform : : progTrack . setAckPending ( ) ;
2020-06-07 14:48:42 +02:00
}
break ;
2022-01-06 23:03:57 +01:00
2020-06-07 14:48:42 +02:00
case WACK : // wait for ack (or absence of ack)
2020-07-01 11:27:53 +02:00
{
2020-07-19 19:39:08 +02:00
byte ackState = 2 ; // keep polling
2022-01-06 23:03:57 +01:00
2021-03-08 11:40:32 +01:00
ackState = DCCWaveform : : progTrack . getAck ( ) ;
if ( ackState = = 2 ) return ; // keep polling
2020-07-02 13:49:35 +02:00
ackReceived = ackState = = 1 ;
break ; // we have a genuine ACK result
2020-07-01 11:27:53 +02:00
}
2020-06-07 14:48:42 +02:00
case ITC0 :
case ITC1 : // If True Callback(0 or 1) (if prevous WACK got an ACK)
if ( ackReceived ) {
2021-03-11 14:35:47 +01:00
callback ( opcode = = ITC0 ? 0 : 1 ) ;
2020-06-07 14:48:42 +02:00
return ;
}
break ;
2022-01-06 23:03:57 +01:00
2020-06-07 14:48:42 +02:00
case ITCB : // If True callback(byte)
if ( ackReceived ) {
2021-01-17 14:22:16 +01:00
callback ( ackManagerByte ) ;
return ;
}
break ;
2022-01-06 23:03:57 +01:00
2021-09-05 23:43:24 +02:00
case ITCBV : // If True callback(byte) - Verify
if ( ackReceived ) {
if ( ackManagerByte = = ackManagerByteVerify ) {
ackRetrySum + + ;
LCD ( 1 , F ( " v %d %d Sum=%d " ) , ackManagerCv , ackManagerByte , ackRetrySum ) ;
}
callback ( ackManagerByte ) ;
return ;
}
break ;
2022-01-06 23:03:57 +01:00
2021-03-11 14:35:47 +01:00
case ITCB7 : // If True callback(byte & 0x7F)
2021-01-17 14:22:16 +01:00
if ( ackReceived ) {
callback ( ackManagerByte & 0x7F ) ;
2020-06-07 14:48:42 +02:00
return ;
}
break ;
2022-01-06 23:03:57 +01:00
2020-06-08 14:04:47 +02:00
case NAKFAIL : // If nack callback(-1)
if ( ! ackReceived ) {
2021-03-11 14:35:47 +01:00
callback ( - 1 ) ;
2020-06-08 14:04:47 +02:00
return ;
}
break ;
2021-09-21 00:31:05 +02:00
case CALLFAIL : // callback(-1)
2021-03-11 14:35:47 +01:00
callback ( - 1 ) ;
2020-06-07 14:48:42 +02:00
return ;
2021-08-30 23:52:50 +02:00
2021-09-05 23:43:24 +02:00
case BIV : // ackManagerByte initial value
ackManagerByte = ackManagerByteVerify ;
2021-08-30 23:52:50 +02:00
break ;
2020-06-07 17:29:53 +02:00
case STARTMERGE :
2020-06-07 16:29:09 +02:00
ackManagerBitNum = 7 ;
2022-01-06 23:03:57 +01:00
ackManagerByte = 0 ;
2020-06-07 14:48:42 +02:00
break ;
2022-01-06 23:03:57 +01:00
2020-06-07 18:02:22 +02:00
case MERGE : // Merge previous Validate zero wack response with byte value and update bit number (use for reading CV bytes)
2020-06-07 17:29:53 +02:00
ackManagerByte < < = 1 ;
2022-01-06 23:03:57 +01:00
// ackReceived means bit is zero.
2020-06-07 18:02:22 +02:00
if ( ! ackReceived ) ackManagerByte | = 1 ;
2020-06-07 17:29:53 +02:00
ackManagerBitNum - - ;
2020-06-07 14:48:42 +02:00
break ;
2020-06-08 14:04:47 +02:00
case SETBIT :
2022-01-06 23:03:57 +01:00
ackManagerProg + + ;
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
ackManagerBitNum = GETFLASH ( ackManagerProg ) ;
2020-06-08 14:04:47 +02:00
break ;
case SETCV :
2022-01-06 23:03:57 +01:00
ackManagerProg + + ;
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
ackManagerCv = GETFLASH ( ackManagerProg ) ;
2020-06-08 14:04:47 +02:00
break ;
2021-01-17 14:22:16 +01:00
case SETBYTE :
2022-01-06 23:03:57 +01:00
ackManagerProg + + ;
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
ackManagerByte = GETFLASH ( ackManagerProg ) ;
2021-01-17 14:22:16 +01:00
break ;
2021-01-18 11:06:46 +01:00
case SETBYTEH :
ackManagerByte = highByte ( ackManagerWord ) ;
break ;
2022-01-06 23:03:57 +01:00
2021-01-18 11:06:46 +01:00
case SETBYTEL :
ackManagerByte = lowByte ( ackManagerWord ) ;
break ;
2020-06-08 14:04:47 +02:00
case STASHLOCOID :
2022-01-06 23:03:57 +01:00
ackManagerStash = ackManagerByte ; // stash value from CV17
2020-06-08 14:04:47 +02:00
break ;
2022-01-06 23:03:57 +01:00
case COMBINELOCOID :
2020-06-08 14:04:47 +02:00
// ackManagerStash is cv17, ackManagerByte is CV 18
2021-11-25 00:10:11 +01:00
callback ( LONG_ADDR_MARKER | ( ackManagerByte + ( ( ackManagerStash - 192 ) < < 8 ) ) ) ;
2022-01-06 23:03:57 +01:00
return ;
2020-06-08 14:04:47 +02:00
case ITSKIP :
2022-01-06 23:03:57 +01:00
if ( ! ackReceived ) break ;
2020-06-08 14:04:47 +02:00
// SKIP opcodes until SKIPTARGET found
while ( opcode ! = SKIPTARGET ) {
2022-01-06 23:03:57 +01:00
ackManagerProg + + ;
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
opcode = GETFLASH ( ackManagerProg ) ;
2020-06-08 14:04:47 +02:00
}
break ;
2022-01-06 23:03:57 +01:00
case SKIPTARGET :
break ;
default :
2021-03-25 15:23:38 +01:00
DIAG ( F ( " !! ackOp %d FAULT!! " ) , opcode ) ;
2020-07-01 11:27:53 +02:00
callback ( - 1 ) ;
2022-01-06 23:03:57 +01:00
return ;
2020-06-07 17:29:53 +02:00
} // end of switch
2020-06-07 14:48:42 +02:00
ackManagerProg + + ;
}
}
2021-03-23 15:37:05 +01:00
2021-05-07 19:24:34 +02:00
void DCC : : callback ( int value ) {
2021-08-23 12:58:48 +02:00
// check for automatic retry
if ( value = = - 1 & & ackManagerRetry > 0 ) {
ackRetrySum + + ;
2021-09-05 23:43:24 +02:00
LCD ( 0 , F ( " Retry %d %d Sum=%d " ) , ackManagerCv , ackManagerRetry , ackRetrySum ) ;
2021-08-23 12:58:48 +02:00
ackManagerRetry - - ;
ackManagerProg = ackManagerProgStart ;
return ;
}
2021-05-07 19:24:34 +02:00
static unsigned long callbackStart ;
// We are about to leave programming mode
// Rule 1: If we have written to a decoder we must maintain power for 100mS
// Rule 2: If we are re-joining the main track we must power off for 30mS
2022-01-06 23:03:57 +01:00
switch ( callbackState ) {
2021-05-07 19:24:34 +02:00
case AFTER_WRITE : // first attempt to callback after a write operation
2021-06-10 20:23:00 +02:00
if ( ! ackManagerRejoin & & ! DCCWaveform : : progTrack . autoPowerOff ) {
callbackState = READY ;
break ;
} // lines 906-910 added. avoid wait after write. use 1 PROG
2021-05-07 19:24:34 +02:00
callbackStart = millis ( ) ;
callbackState = WAITING_100 ;
if ( Diag : : ACK ) DIAG ( F ( " Stable 100mS " ) ) ;
break ;
2022-01-06 23:03:57 +01:00
2021-05-07 19:24:34 +02:00
case WAITING_100 : // waiting for 100mS
if ( millis ( ) - callbackStart < 100 ) break ;
// stable after power maintained for 100mS
// If we are going to power off anyway, it doesnt matter
// but if we will keep the power on, we must off it for 30mS
if ( DCCWaveform : : progTrack . autoPowerOff ) callbackState = READY ;
else { // Need to cycle power off and on
2022-01-06 23:03:57 +01:00
DCCWaveform : : progTrack . setPowerMode ( POWERMODE : : OFF ) ;
2021-05-07 19:24:34 +02:00
callbackStart = millis ( ) ;
callbackState = WAITING_30 ;
if ( Diag : : ACK ) DIAG ( F ( " OFF 30mS " ) ) ;
}
break ;
2022-01-06 23:03:57 +01:00
2021-05-07 19:24:34 +02:00
case WAITING_30 : // waiting for 30mS with power off
if ( millis ( ) - callbackStart < 30 ) break ;
//power has been off for 30mS
2022-01-06 23:03:57 +01:00
DCCWaveform : : progTrack . setPowerMode ( POWERMODE : : ON ) ;
2021-05-07 19:24:34 +02:00
callbackState = READY ;
break ;
2022-01-06 23:03:57 +01:00
2021-05-07 19:24:34 +02:00
case READY : // ready after read, or write after power delay and off period.
// power off if we powered it on
if ( DCCWaveform : : progTrack . autoPowerOff ) {
if ( Diag : : ACK ) DIAG ( F ( " Auto Prog power off " ) ) ;
DCCWaveform : : progTrack . doAutoPowerOff ( ) ;
2022-01-08 21:44:32 +01:00
if ( MotorDriver : : commonFaultPin )
DCCWaveform : : mainTrack . setPowerMode ( POWERMODE : : OFF ) ;
2021-05-07 19:24:34 +02:00
}
// Restore <1 JOIN> to state before BASELINE
if ( ackManagerRejoin ) {
setProgTrackSyncMain ( true ) ;
if ( Diag : : ACK ) DIAG ( F ( " Auto JOIN " ) ) ;
2022-01-06 23:03:57 +01:00
}
2021-05-07 19:24:34 +02:00
ackManagerProg = NULL ; // no more steps to execute
if ( Diag : : ACK ) DIAG ( F ( " Callback(%d) " ) , value ) ;
( ackManagerCallback ) ( value ) ;
}
2020-07-01 11:27:53 +02:00
}
2020-09-10 14:09:32 +02:00
2021-05-07 19:24:34 +02:00
void DCC : : displayCabList ( Print * stream ) {
2020-09-10 14:09:32 +02:00
int used = 0 ;
for ( int reg = 0 ; reg < MAX_LOCOS ; reg + + ) {
if ( speedTable [ reg ] . loco > 0 ) {
used + + ;
2022-01-06 23:03:57 +01:00
StringFormatter : : send ( stream , F ( " cab=%d, speed=%d, dir=%c \n " ) ,
2020-09-10 14:09:32 +02:00
speedTable [ reg ] . loco , speedTable [ reg ] . speedCode & 0x7f , ( speedTable [ reg ] . speedCode & 0x80 ) ? ' F ' : ' R ' ) ;
}
}
2021-03-30 23:01:37 +02:00
StringFormatter : : send ( stream , F ( " Used=%d, max=%d \n " ) , used , MAX_LOCOS ) ;
2022-01-06 23:03:57 +01:00
2020-09-10 14:09:32 +02:00
}