diff --git a/IO_EXIOExpander.h b/IO_EXIOExpander.h index db08e70..2e83eb7 100644 --- a/IO_EXIOExpander.h +++ b/IO_EXIOExpander.h @@ -23,13 +23,10 @@ * This device driver will configure the device on startup, along with * interacting with the device for all input/output duties. * -* To create EX-IOExpander devices, these are defined in myHal.cpp: +* To create EX-IOExpander devices, these are defined in myAutomation.h: * (Note the device driver is included by default) * -* void halSetup() { -* // EXIOExpander::create(vpin, num_vpins, i2c_address); -* EXIOExpander::create(800, 18, 0x65); -* } +* HAL(EXIOExpander,800,18,0x65) * * All pins on an EX-IOExpander device are allocated according to the pin map for the specific * device in use. There is no way for the device driver to sanity check pins are used for the @@ -105,15 +102,16 @@ private: // Not enough space, free any existing buffer and allocate a new one if (_digitalPinBytes > 0) free(_digitalInputStates); if ((_digitalInputStates = (byte*) calloc(digitalBytesNeeded, 1)) != NULL) { - _digitalPinBytes = digitalBytesNeeded; - } else { - DIAG(F("EX-IOExpander I2C:%s ERROR alloc %d bytes"), _I2CAddress.toString(), digitalBytesNeeded); - _deviceState = DEVSTATE_FAILED; - _digitalPinBytes = 0; - return; - } + _digitalPinBytes = digitalBytesNeeded; + } else { + DIAG(F("EX-IOExpander I2C:%s ERROR alloc %d bytes"), _I2CAddress.toString(), digitalBytesNeeded); + _deviceState = DEVSTATE_FAILED; + _digitalPinBytes = 0; + return; + } } } + if (_numAnaloguePins>0) { size_t analogueBytesNeeded = _numAnaloguePins * 2; if (_analoguePinBytes < analogueBytesNeeded) { @@ -136,14 +134,14 @@ private: _analoguePinBytes = 0; return; } - } - } - } else { - DIAG(F("EX-IOExpander I2C:%s ERROR configuring device"), _I2CAddress.toString()); - _deviceState = DEVSTATE_FAILED; - return; - } - } + } + } + } else { + DIAG(F("EX-IOExpander I2C:%s ERROR configuring device"), _I2CAddress.toString()); + _deviceState = DEVSTATE_FAILED; + return; + } + } // We now need to retrieve the analogue pin map if there are analogue pins if (status == I2C_STATUS_OK && _numAnaloguePins>0) { commandBuffer[0] = EXIOINITA; diff --git a/README.md b/README.md index 9c8f627..f820075 100644 --- a/README.md +++ b/README.md @@ -1,39 +1,77 @@ -# What is DCC-EX? -DCC-EX is a team of dedicated enthusiasts producing open source DCC & DC solutions for you to run your complete model railroad layout. Our easy to use, do-it-yourself, and free open source products run on off-the-shelf Arduino technology and are supported by numerous third party hardware and apps like JMRI, Engine Driver, wiThrottle, Rocrail and more. +# What is DCC++ EX? +DCC++ EX is the organization maintaining several codebases that together represent a fully open source DCC system. Currently, this includes the following: -Currently, our products include the following: +* [CommandStation-EX](https://github.com/DCC-EX/CommandStation-EX/releases) - the latest take on the DCC++ command station for controlling your trains. Runs on an Arduino board, and includes advanced features such as a WiThrottle server implementation, turnout operation, general purpose inputs and outputs (I/O), and JMRI integration. +* [exWebThrottle](https://github.com/DCC-EX/exWebThrottle) - a simple web based controller for your DCC++ command station. +* [BaseStation-installer](https://github.com/DCC-EX/BaseStation-Installer) - an installer executable that takes care of downloading and installing DCC++ firmware onto your hardware setup. +* [BaseStation-Classic](https://github.com/DCC-EX/BaseStation-Classic) - the original DCC++ software, packaged in a stable release. No active development, bug fixes only. -* [EX-CommandStation](https://github.com/DCC-EX/CommandStation-EX/releases) -* [EX-WebThrottle](https://github.com/DCC-EX/exWebThrottle) -* [EX-Installer](https://github.com/DCC-EX/EX-Installer) -* [EX-MotoShield8874](https://dcc-ex.com/reference/hardware/motorboards/ex-motor-shield-8874.html#gsc.tab=0) -* [EX-DCCInspector](https://github.com/DCC-EX/DCCInspector-EX) -* [EX-Toolbox](https://github.com/DCC-EX/EX-Toolbox) -* [EX-Turntable](https://github.com/DCC-EX/EX-Turntable) -* [EX-IOExpander](https://github.com/DCC-EX/EX-IOExpander) -* [EX-FastClock](https://github.com/DCC-EX/EX-FastClock) -* [DCCEXProtocol](https://github.com/DCC-EX/DCCEXProtocol) +A basic DCC++ EX hardware setup can use easy to find, widely avalable Arduino boards that you can assemble yourself. + +Both CommandStation-EX and BaseStation-Classic support much of the NMRA Digital Command Control (DCC) [standards](http://www.nmra.org/dcc-working-group "NMRA DCC Working Group"), including: + +* simultaneous control of multiple locomotives +* 2-byte and 4-byte locomotive addressing +* 28 or 128-step speed throttling +* Activate/de-activate all accessory function addresses 0-2048 +* Control of all cab functions F0-F28 and F29-F68 +* Main Track: Write configuration variable bytes and set/clear specific configuration variable (CV) bits (aka Programming on Main or POM) +* Programming Track: Same as the main track with the addition of reading configuration variable bytes +* And many more custom features. see [What's new in CommandStation-EX?](#whats-new-in-commandstation-ex) -Details of these projects can be found on [our web site](https://dcc-ex.com/). # What’s in this Repository? -This repository, CommandStation-EX, contains a complete DCC-EX *EX-CommmandStation* sketch designed for compiling and uploading into an Arduino Uno, Mega, or Nano. +This repository, CommandStation-EX, contains a complete DCC++ EX Commmand Station sketch designed for compiling and uploading into an Arduino Uno, Mega, or Nano. To utilize this sketch, you can use the following: -1. (recommended for all levels of user) our [automated installer](https://github.com/DCC-EX/EX-Installer) +1. (beginner) our [automated installer](https://github.com/DCC-EX/BaseStation-Installer) 2. (intermediate) download the latest version from the [releases page](https://github.com/DCC-EX/CommandStation-EX/releases) 3. (advanced) use git clone on this repository -Refer to [our web site](https://https://dcc-ex.com/ex-commandstation/get-started/index.html#/) for the hardware required for this project. +Not using the installer? Open the file "CommandStation-EX.ino" in the +Arduino IDE. Please do not rename the folder containing the sketch +code, nor add any files in that folder. The Arduino IDE relies on the +structure and name of the folder to properly display and compile the +code. Rename or copy config.example.h to config.h. If you do not have +the standard setup, you must edit config.h according to the help texts +in config.h. -**We seriously recommend using the EX-Installer**, however if you choose not to use the installer... +## What's new in CommandStation-EX? -* Open the file ``CommandStation-EX.ino`` in the Arduino IDE or Visual Studio Code (VSC). Please do not rename the folder containing the sketch code, nor add any files in that folder. The Arduino IDE relies on the structure and name of the folder to properly display and compile the code. -* Rename or copy ``config.example.h`` to ``config.h``. -* You must edit ``config.h`` according to the help texts in ``config.h``. +* WiThrottle server built in. Connect Engine Driver or WiThrottle clients directly to your Command Station (or through JMRI as before) +* WiFi and Ethernet shield support +* No more jumpers or soldering! +* Direct support for all the most popular motor control boards including single pin (Arduino) or dual pin (IBT_2) type PWM inputs without the need for an adapter circuit +* I2C Display support (LCD and OLED) +* Improved short circuit detection and automatic reset from an overload +* Current reading, sensing and ACK detection settings in milliAmps instead of just pin readings +* Improved adherence to the NMRA DCC specification +* Complete support for all the old commands and front ends like JMRI +* Railcom cutout (beta) +* Simpler, modular, faster code with an API Library for developers for easy expansion +* New features and functions in JMRI +* Ability to join MAIN and PROG tracks into one MAIN track to run your locos +* "Drive-Away" feature - Throttles with support, like Engine Driver, can allow a loco to be programmed on a usable, electrically isolated programming track and then drive off onto the main track +* Diagnostic commands to test decoders that aren't reading or writing correctly +* Support for Uno, Nano, Mega, Nano Every and Teensy microcontrollers +* User Functions: Filter regular commands (like a turnout or output command) and pass it to your own function or accessory +* Support for LCN (layout control nodes) +* mySetup.h file that acts like an Autoexec.Bat command to send startup commands to the CS +* High Accuracty Waveform option for rock steady DCC signals +* New current response outputs current in mA, overlimit current, and maximum board capable current. Support for new current meter in JMRI +* USB Browser based EX-WebThrottle +* New, simpler, function control command +* Number of locos discovery command `<#>` +* Emergency stop command +* Release cabs from memory command <-> all cabs, <- CAB> for just one loco address +* Automatic slot (register) management +* Automation (coming soon) + +NOTE: DCC-EX is a major rewrite to the code. We started over and rebuilt it from the ground up! For what that means, you can read [HERE](https://dcc-ex.com/about/rewrite.html). # More information -You can learn more at the [DCC-EX website](https://dcc-ex.com/) +You can learn more at the [DCC++ EX website](https://dcc-ex.com/) +- November 14, 2020 diff --git a/version.h b/version.h index bf7048f..1f11713 100644 --- a/version.h +++ b/version.h @@ -3,16 +3,104 @@ #include "StringFormatter.h" -#define VERSION "5.0.9" -// 5.0.9 - EX-IOExpander bug fix for memory allocation -// - EX-IOExpander bug fix to allow for devices with no analogue or no digital pins -// 5.0.8 - Bugfix: Do not crash on turnouts without description -// 5.0.7 - Only flag 2.2.0.0-dev as broken, not 2.2.0.0 -// 5.0.6 - Bugfix lost TURNOUTL description -// 5.0.5 - Bugfix version detection logic and better message -// 5.0.4 - Bugfix: misses default roster. -// 5.0.3 - Check bad AT firmware version -// 5.0.2 - Bugfix: ESP32 30ms off time +#define VERSION "5.2.42" +// 5.2.42 - ESP32 Bugfix: Uninitialized stack variable +// 5.2.41 - Update rotary encoder default address to 0x67 +// 5.2.40 - Allow no shield +// 5.2.39 - Functions for DC frequency: Use func up to F31 +// 5.2.38 - Exrail MESSAGE("text") to send a user message to all +// connected throttles (uses and withrottle Hmtext. +// 5.2.37 - Bugfix ESP32: Use BOOSTER_INPUT define +// 5.2.36 - Variable frequency for DC mode +// 5.2.35 - Bugfix: Make DCC Extended Accessories follow RCN-213 +// 5.2.34 - Command fopr DCC Extended Accessories +// - Exrail ASPECT(address,aspect) for above. +// - EXRAIL DCCX_SIGNAL(Address,redAspect,amberAspect,greenAspect) +// - Exrail intercept for DCC Signals. +// 5.2.33 - Exrail CONFIGURE_SERVO(vpin,pos1,pos2,profile) +// 5.2.32 - Railcom Cutout (Initial trial Mega2560 only) +// 5.2.31 - Exrail JMRI_SENSOR(vpin [,count]) creates types. +// 5.2.30 - Bugfix: WiThrottle sendIntro after initial N message as well +// 5.2.29 - Added IO_I2CDFPlayer.h to support DFPLayer over I2C connected to NXP SC16IS750/SC16IS752 (currently only single UART for SC16IS752) +// - Added enhanced IO_I2CDFPLayer enum commands to EXRAIL2.h +// - Added PLAYSOUND alias of ANOUT to EXRAILMacros.h +// - Added UART detection to I2CManager.cpp +// 5.2.28 - ESP32: Can all Wifi channels. +// - ESP32: Only write Wifi password to display if it is a well known one +// 5.2.27 - Bugfix: IOExpander memory allocation +// 5.2.26 - Silently ignore overridden HAL defaults +// - include HAL_IGNORE_DEFAULTS macro in EXRAIL +// 5.2.25 - Fix bug causing after working & <1 A> etc. and update to <=> +// Added EXRAIL SET_POWER(track, ON/OFF) +// Fixed a problem whereby <1 MAIN> also powered on PROG track +// Added functions to TrackManager.cpp to allow UserAddin code for power display on OLED/LCD +// Added - returnMode(byte t), returnDCAddr(byte t) & getModeName(byte Mode) +// 5.1.11 - STM32F4xx revised I2C clock setup, no correctly sets clock and has fully variable frequency selection +// 5.1.10 - STM32F4xx DCCEXanalogWrite to handle PWM generation for TrackManager DC/DCX +// - STM32F4xx DCC 58uS timer now using non-PWM output timers where possible +// - ESP32 brakeCanPWM check now detects UNUSED_PIN +// - ARM architecture brakeCanPWM now uses digitalPinHasPWM() +// - STM32F4xx shadowpin extensions to handle pins on ports D, E and F +// 5.1.9 - Fixed IO_PCA9555'h to work with PCA9548 mux, tested OK +// 5.1.8 - STM32Fxx ADCee extension to support ADCs #2 and #3 +// 5.1.7 - Fix turntable broadcasts for non-movement activities and result +// 5.1.6 - STM32F4xx native I2C driver added +// 5.1.5 - Added turntable object and EXRAIL commands +// - , , - turntable commands +// - DCC_TURNTABLE, EXTT_TURNTABLE, IFTTPOSITION, ONROTATE, ROTATE, ROTATE_DCC, TT_ADDPOSITION, WAITFORTT EXRAIL +// 5.1.4 - Added ONOVERLOAD & AFTEROVERLOAD to EXRAIL +// 5.1.3 - Make parser more fool proof +// 5.1.2 - Bugfix: ESP32 30ms off time +// 5.1.1 - Check bad AT firmware version +// - Update IO_PCA9555.h reflecting IO_MCP23017.h changes to support PCA9548 mux // 5.0.1 - Bugfix: execute 30ms off time before rejoin // 5.0.0 - Make 4.2.69 the 5.0.0 release // 4.2.69 - Bugfix: Make work in DC mode