1
0
mirror of https://github.com/DCC-EX/CommandStation-EX.git synced 2024-11-30 03:26:13 +01:00
Commit Graph

804 Commits

Author SHA1 Message Date
Neil McKechnie
f8858b952e Servo positioning - correct handling of profile 0.
Ensure that profile 0 uses the duration parameter to calculate the number of steps.
2021-08-27 16:59:04 +01:00
Neil McKechnie
6ebf908802 Ensure Turnout changes are notified on LCN activity.
Also, some comment updates.
2021-08-27 15:45:22 +01:00
Neil McKechnie
93dfdcce53 Add <D HAL SHOW> command to list HAL device configuration.
Also, only display HAL device configurations at startup if DIAG_IO is #defined.
2021-08-27 15:44:26 +01:00
Neil McKechnie
7e601c38c4 HAL writeAnalogue function change.
IODevice::writeAnalogue() has an additional optional parameter "duration", specifying the time taken for the animation in units of 100ms (max 3276 seconds, or about 54 minutes).
2021-08-27 15:42:47 +01:00
Neil McKechnie
1dd574dc03 On <E> commmand, output EEPROM size and amount used.
Also, formatting and indentation fixed.
2021-08-27 12:56:27 +01:00
Neil McKechnie
0aea9169b1 Rename IODevice::isActive(vpin) to isBusy(vpin). 2021-08-27 11:18:15 +01:00
Neil McKechnie
0c218e1e13 Add HAL function configureInput(vpin,...) and configureServo(vpin,...). 2021-08-27 10:58:00 +01:00
Neil McKechnie
0a9fcf6ebc
Neil bugfixes. (#186)
* Re-enable native I2C driver.

* Minor non-functional changes to native I2C Manager.

* Minor changes to make variable types explicit in comparisons.

* Fix IODevice::loop() to avoid null pointer dereference.

Strange problems with LCD driver tracked down to being caused by a call to p->_loop() when p is NULL.

* Correct sense of comparison in LCN support function Turnout::setClosedStateOnly()

* Remove code (now unused) from LCD driver.

* Add I2C textual error messages.

* Add I2C textual error messages.

* Fix compile error in 4809 I2C driver.

* Remove init function call from SSD1306 driver.
2021-08-26 23:04:13 +01:00
Asbelos
5e30740c5b fix EXRAIL CALL/RETURN 2021-08-26 21:49:44 +01:00
Neil McKechnie
2469629cbb Temporarily use Wire for I2C. 2021-08-25 10:26:45 +01:00
Neil McKechnie
bad9e866f8
Merge pull request #185 from DCC-EX/EX-RAIL-neil-RCN213
Ex rail neil rcn213
2021-08-25 00:42:16 +01:00
Neil McKechnie
77d4d7c400
Merge branch 'EX-RAIL' into EX-RAIL-neil-RCN213 2021-08-25 00:38:38 +01:00
Neil McKechnie
fa04fa5084 I2C Manager, adjust loop code.
loop() contains startTransaction which is called after handleInterrupt().  However, startTransaction is called within handleInterrupt so remove the extra call.  This appears to solve strange problems encountered with the LCD display.
2021-08-25 00:34:19 +01:00
Neil McKechnie
80fc9e8a68 Make LCD Display I2C calls synchronous. 2021-08-25 00:29:57 +01:00
Neil McKechnie
d0fed2dd38 Make LCD output to I2C synchronous.
Temporary work-around to problems with LCD driver, until I can look at it in depth.
2021-08-24 23:02:24 +01:00
Neil McKechnie
08cfe41cf3 Revert to original DCC++ Classic Turnout command polarity.
Revert to <T id 1> command being 'throw' and <T id 0> being 'close', for turnouts.
2021-08-24 22:18:51 +01:00
Neil McKechnie
777d189cc5 Enable pullups for Arduino input pins as a default 2021-08-24 22:15:50 +01:00
Neil McKechnie
c45337d5d4 Enable pullups for Arduino input pins as a default (to match GPIO Extender modules). 2021-08-24 22:13:52 +01:00
Asbelos
8b498b8b49 </ROUTES> cmd for JMRI/Withrottle 2021-08-24 09:45:11 +01:00
Neil McKechnie
425de3fcc7 Create mySetup.cpp_example.txt
Provide an example showing directives for HAL device configuration.
2021-08-23 20:41:30 +01:00
Neil McKechnie
0d235b65d3 Turnouts - make code clearer.
Overlay of flags bits added in struct TurnoutData,, called flags.  This simplifies the the EEPROM update code.
2021-08-23 17:36:50 +01:00
Neil McKechnie
69c4733f2b Initialise turnouts to Closed by default
Ensure that the servo, VPIN and LCN turnouts are all initialised to closed if no initial state is provided in the create call or in EEPROM.  This applies irrespective of the RCN-213 configuration settings.
2021-08-23 15:26:23 +01:00
Neil McKechnie
f0cd96fed3 Changes associated with RCN-213 DCC Accessory Packet format 2021-08-23 12:43:14 +01:00
Asbelos
161b35ae84 indentation and LCD macro use
No actual code change.
2021-08-23 12:35:42 +01:00
Asbelos
214e6c643f Squashed commit of the following:
commit b34205b142
Merge: 8703248 2829716
Author: Neil McKechnie <75813993+Neil-McK@users.noreply.github.com>
Date:   Mon Aug 23 10:05:54 2021 +0100

    Merge branch 'EX-RAIL' into ackRetry

commit 8703248c49
Author: Ash-4 <81280775+Ash-4@users.noreply.github.com>
Date:   Sun Aug 22 16:47:38 2021 -0500

    ACK RETRY max 255 with fallback to 3 if greater

    And includes LCD lines for power and ACK diags.

commit f5d4522ed7
Author: Ash-4 <81280775+Ash-4@users.noreply.github.com>
Date:   Sun Aug 22 16:40:13 2021 -0500

    ACK RETRY updated datatypes

commit 1dbf236697
Author: Ash-4 <81280775+Ash-4@users.noreply.github.com>
Date:   Sun Aug 22 16:35:14 2021 -0500

    ACK RETRY updated datatypes

commit d93584e9a4
Author: Ash-4 <81280775+Ash-4@users.noreply.github.com>
Date:   Sun Aug 22 13:16:24 2021 -0500

    ACK RETRY updated default is 2 retries.

commit f58ebac670
Author: Ash-4 <81280775+Ash-4@users.noreply.github.com>
Date:   Sat Aug 21 16:43:21 2021 -0500

    ACK RETRY is 3 or less (default is 1)

commit 08350b215a
Author: Ash-4 <81280775+Ash-4@users.noreply.github.com>
Date:   Sat Aug 21 11:55:17 2021 -0500

    ACK RETRY

    LCD display update.
    lcd(0, F("RETRY %d %d %d %d"), ackManagerCv, ackManagerRetry, ackRetry, ackRetrySum);

commit 11cd216017
Author: Ash-4 <81280775+Ash-4@users.noreply.github.com>
Date:   Sat Aug 21 00:54:28 2021 -0500

    ACK RETRY

    ACK retry code added to ackManagerSetup and callback.
    The default is <D ACK RETRY 1>.  For ACK tuning, set retry to zero.
    Retry count is captured on the LCD display, and lines in the serial monitor.

commit b67027a1ed
Author: Ash-4 <81280775+Ash-4@users.noreply.github.com>
Date:   Sat Aug 21 00:33:01 2021 -0500

    ACK RETRY variables added

commit 34d2ab3543
Author: Ash-4 <81280775+Ash-4@users.noreply.github.com>
Date:   Sat Aug 21 00:23:34 2021 -0500

    Update DCCEXParser.cpp

    LCD lines added to display power commands and ACK settings, when updated.
    Also new command <D ACK RETRY 1>.

commit 8ca4011cb0
Author: Ash-4 <81280775+Ash-4@users.noreply.github.com>
Date:   Fri Aug 20 23:58:13 2021 -0500

    Update CommandStation-EX.ino

    Update LCD row number for Ready and Free RAM.

commit 6571138389
Author: Harald Barth <haba@kth.se>
Date:   Sun Aug 1 22:08:34 2021 +0200

    optimize command parser for size

commit c4f659243e
Author: Harald Barth <haba@kth.se>
Date:   Sun Aug 1 15:07:06 2021 +0200

    optimize for loops for size (and speed)

commit 55b7091d5a
Author: Harald Barth <haba@kth.se>
Date:   Sun Aug 1 12:45:29 2021 +0200

    take less progmem for messages

commit 6d7c1925b0
Author: Harald Barth <haba@kth.se>
Date:   Sun Aug 1 11:56:12 2021 +0200

    only pragma -O3 critical functions
2021-08-23 11:58:48 +01:00
Asbelos
50a9e08d1f defines/configig include tidy
now just 2 places where config is included...
1) in defines.h
2) At the start of the .ino so it can be made obvious to the user what is happening.
2021-08-23 11:55:42 +01:00
Neil McKechnie
ca55834051 Update defines.h
Add #include config.h (on which defines.h is reliant).
2021-08-23 10:46:12 +01:00
Neil McKechnie
2829716ea6 Merge branch 'EX-RAIL-neil2' into EX-RAIL 2021-08-22 22:40:14 +01:00
Neil McKechnie
00138be90d Increase default display line length to 20 (from 16). 2021-08-22 22:39:00 +01:00
Neil McKechnie
fdaa7b51b9 Move Turnout code from .h to .cpp.
Move implementation of Turnout::printState from Turnouts.h to Turnouts.cpp.  No functional changes.
2021-08-22 22:30:09 +01:00
Neil McKechnie
7b47b86143 Turnouts: adjust the split of code between .h and .cpp file. No functional changes. 2021-08-22 22:25:23 +01:00
Neil McKechnie
3e50a6bdad Add include guard to defines.h
Ensure that defines.h is only process once, even if included multiple times.
2021-08-22 22:23:08 +01:00
Asbelos
240b18a0df Merge branch 'EX-RAIL-neil2' into EX-RAIL 2021-08-22 19:36:08 +01:00
Asbelos
b35ce88fdd Deeay long values 2021-08-22 17:01:55 +01:00
Neil McKechnie
0875d27b0a Remove 'activate' functions from turnout classes.
Remove the static 'activate' function and rename the virtual 'activate' function to 'setClosedInternal'.
2021-08-22 14:07:16 +01:00
Neil McKechnie
39a69e340e Turnout EEPROM improvements.
Ensure state is saved and restored from EEPROM as expected.
Make constructors for turnouts private.  Otherwise, a statically created turnout may be initialising itself before the underlying HAL device has been created.  By requiring the create() call be used, there is more control over the timing of the turnout object's creation.
2021-08-21 23:16:52 +01:00
Neil McKechnie
dbabfdca80 Improvements to PCA9685 operation
Rationalise duplicated code;  improve initialisation;
2021-08-21 23:13:34 +01:00
Asbelos
60718f5eac int->int16_t to keep pedantic compilers happy 2021-08-21 13:17:14 +01:00
Neil McKechnie
071389a04b Remove compiler warnings in Turnout.h 2021-08-21 00:34:28 +01:00
Neil McKechnie
d8366f33c8 Make <s> output turnout state rather than full turnout definition.
<s> command currently prints the current states for outputs and for sensors, but prints the full configuration of turnouts.  This change makes the turnout output consistent, i.e. just <H id state> is output for each turnout.  The <T> command still outputs the full turnout definition.
2021-08-21 00:25:00 +01:00
Asbelos
ddcd40860f UNTESTED Allow ALIAS of ROUTE/AUTOMATION id
Runs ALIAS on first pass and creates a routine to emit the route stuff to withrottle because previous technique wouldnt compile for aliased ids.
2021-08-20 19:18:30 +01:00
Neil McKechnie
133c65bc42 Report Turnout configuration in old and new formats.
JMRI currently isn't aware of the newer types of turnout in DCC++EX, so when it receives the definitions of turnouts it barfs on them.  It still knows a turnout exists, but isn't able to display its full configuration.  For DCC Accessory turnouts, the configuration message has changed so that it includes the DCC string (to distinguish them from other types of turnout).  To enable current and older versions of JMRI to continue working with DCC turnouts, CS now reports the old and new formats, i.e. <T id addr subaddr state> and <T id DCC addr subadd state>.  It currently accepts the first one and ignores the second one, but in the fullness of time it might accept the second one too.
2021-08-20 15:43:03 +01:00
Neil McKechnie
482f4b1c79 Tidy up recent changes to Turnout class. 2021-08-20 14:36:18 +01:00
Neil McKechnie
b4a3b503bc Turnout notification handling enhanced.
Ensure that the <H> message is sent on the serial USB (to JMRI) whenever the turnout is closed or thrown, even if the request didn't originate on the serial USB.
2021-08-20 00:07:50 +01:00
Neil McKechnie
7f6173825f Various corrections to Turnout code. 2021-08-19 21:43:55 +01:00
Neil McKechnie
fd36ca2b92 Restructure Turnout class.
Turnout class split into a base class for common code and specific subclasses for Servo, DCC, VPIN and LCN turnouts.
Interface further narrowed to reduce direct access to member variables.
Turnout creation command handling has been moved into the DCCEXParser class.
Turnout function and parameter names changed to make the Throw and Close functionality explicit.
Turnout commands <T id C> (close) and <T id T> (throw) added.
2021-08-19 21:22:59 +01:00
Neil McKechnie
776a098a72 Bump EESTORE_ID version.
TurnoutData struct size has been reduced by one byte during rewrite of Turnout class.  Consequently, this renders any previous turnout definitions in EEPROM incompatible with the new format.  For safety, the version is increased so that incompatible EEPROM contents are discarded.
2021-08-19 20:17:48 +01:00
Asbelos
36f6e2f9ce Narrowing Turnout publics 2021-08-18 18:55:22 +01:00
Neil McKechnie
9dacd24d27
Various HAL enhancements. (#182)
* Add <D SERVO vpin position> command

Allow a PWM servo to be driven to any arbitrary position.

* Enhancements for HAL drivers

Add state change notification for external GPIO module drivers;
Allow drivers to be installed statically by declaration (as an alternative to the 'create' call).

* Create IO_HCSR04.h

HAL driver for HC-SR04 ultrasonic distance sensor (sonar).

* Enable servo commands in NO-HAL mode, but return error.

Avoid compile errors in RMFT.cpp when compiled with basic HAL by including the Turnout::createServo function as a stub that returns NULL.

* Update IO_HCSR04.h

Minor changes

* Change <D SERVO>

Give the <D SERVO> command an optional parameter of the profile.  For example, <D SERVO 100 200 3> will slowly move the servo on pin 100 to PWM position corresponding to 200.  If omitted, the servo will move immediately (no animation).

* IODevice (HAL) changes

1) Put new devices on the end of the chain instead of the beginning.  This will give better performance for devices created first (ArduinoPins and extender GPIO devices, typically).
2) Remove unused functions.

* Update IO_HCSR04.h

Allow thresholds for ON and OFF to be separately configured at creation.

* Update IODevice.cpp

Fix compile error on IO_NO_HAL minimal HAL version.

* Update IO_PCA9685.cpp

Remove unnecessary duplicated call to min() function.
2021-08-17 23:41:34 +01:00
Asbelos
552e1bf3d8 Merge remote-tracking branch 'origin/RCN-213' into EX-RAIL 2021-08-17 19:48:06 +01:00