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

35 Commits

Author SHA1 Message Date
Neil McKechnie
5f9705d1b7 Improve IODevice::reset function
Ensure that the _loop() function is able to run after a device is reset.
2023-02-10 15:30:35 +00:00
Neil McKechnie
9dd9990979 Improve formatting of I2CAddress data type in diagnostics. 2023-02-09 00:16:06 +00:00
Neil McKechnie
9435869ee3 Prepare HAL device drivers to support Extended I2C Addresses
Cast I2CAddress variables in DIAG calls to (int).
2023-02-07 15:04:03 +00:00
Neil McKechnie
81559998ec Update IODevice base class to better support filter drivers
Filter drivers provide extra functionality above a hardware driver.  For example, a hardware driver for a PWM module may just set the PWM ratio, but a separate filter driver could animate motors or servos over time, calling the PWM driver to output the pulses.  This would allow the animations to be easily implemented on a different type of PWM module.
2023-02-03 12:55:25 +00:00
Neil McKechnie
ccf463b507 IODevice.cpp: Fix error in overlap checking.
The checkNoOverlap() function didn't work correctly in the case where one device has nPins=0.  All devices configured after that were rejected, even when no overlap was present.
2023-01-16 23:03:53 +00:00
Neil McKechnie
3c5b7bbcfe HAL updates
Remove redundant deferment of device _begin() calls (no longer necessary).
Improve diagnostic loop measurement.
2023-01-14 17:15:30 +00:00
Harald Barth
452ffc5725 changed IODevice code to use ADCee 2022-10-05 23:14:07 +02:00
Asbelos
044b467085 Implement HAL macro in exrail 2022-06-15 11:44:46 +01:00
Asbelos
3496b99197 HAL minor simplification 2022-06-14 17:50:57 +01:00
Asbelos
6b7c2ccdf0 I2C address checks cleaned up 2022-06-14 17:35:29 +01:00
Asbelos
08eaa8ddb7 I2C overlap checks (working but messy)
Needs disgnostic clean and promotion of i2c address to IODevice.
2022-06-14 17:21:11 +01:00
Asbelos
10a0cfcccb change halSetup order 2022-06-14 15:28:13 +01:00
Asbelos
e11d2d08d1 HAL catch pin overlaps 2022-06-14 15:15:42 +01:00
Harald Barth
d45585ce3d update copyright notes 2022-01-07 02:28:35 +01:00
Neil McKechnie
c90ea0c6df Improve validation of parameters to non-HAL digital calls.
When testing CS in minimal HAL mode but with mySetup.h and myAutomation.h files present, I experienced freezing of the arduino because the standard pinMode, digitalWrite etc don't validate the pin number passed to them.  So I've added checks on the pin number to the configure, write and read functions in the minimal HAL.
2021-11-15 13:25:11 +00:00
Neil McKechnie
d08f14be3b Rename user module mySetup.cpp to myHal.cpp, and function mySetup() to halSetup() within it. 2021-11-15 12:50:02 +00:00
Neil McKechnie
b384d6c14d Move call to mySetup into IODevice::begin().
Ensure that HAL devices are created before use by moving the call to mySetup into IODevice::begin().  The need for this became evident when it was noted that RMFT (EX-RAIL) interacts with HAL devices during its initialisation, by enabling pull-ups on digital inputs.
Any
2021-11-12 00:05:16 +00:00
Harald Barth
a16f6c8749 configure pins correct even when HAL not used 2021-11-06 22:12:32 +01:00
Neil McKechnie
b7bcd13347 Fix Arduino pin pullup initial state.
If an Arduino pin was used as an input (e.g. by EXRAIL) without previously configuring it, the default pullup wouldn't be set up.  Now, on first call to the _read() method the pullup will be enabled.
2021-10-21 16:43:42 +01:00
Neil McKechnie
9fc805831d HAL: Minor optimisations
Remove virtual method hasCallback().
Optimise findDevice() method (used by read, write etc.).
Simplify Sensor handling with regard to IO Devices that support callbacks.
2021-09-23 10:54:27 +01:00
Neil McKechnie
e59e07b971 Improved HAL diagnostics
Looptime diagnostic enhanced, and duplicated diagnostic messages removed from DFPlayer class.
2021-09-21 13:43:52 +01:00
Neil McKechnie
302b16547e HAL driver enhancements
Performance enhancements in IODevice::loop() function.
Improved error handling, device is placed off line if not responding.
Improved error reporting, device shown as offline if not operational (faulty or not present).
2021-09-21 11:02:23 +01:00
Neil McKechnie
afe2ecdc14 Update IODevice.cpp
Remove potentially irritating diag messages
2021-09-17 12:44:27 +01:00
Neil McKechnie
ad7cd5f401 Remove virtual _isBusy() function in favor of _read().
When writing to analogue outputs pins, the digital _read() function now returns the 'busy' status of the analogue pin.  Consequently, the _isBusy() function becomes superfluous and has been removed.  The static IODevice::isBusy() function now calls the object's _read() function instead.
Also, limit in DFPlayer of 3 pins has been removed.
2021-09-17 11:36:08 +01:00
Neil McKechnie
2ed578821f Add analogue inputs to HAL.
Add ability to read analogue inputs on arduino and on external ADS1115 I2C modules.
2021-09-11 13:35:11 +01:00
Neil McKechnie
0f55835b8b Add RMFT WAITFOR() and SERVO2() commands.
WAITFOR(pin) waits until the corresponding pin is not busy (e.g. has finished moving the servo).  SERVO2(pin, value, ms) moves to the nominated position in a time given in milliseconds by ms.
2021-08-28 17:39:48 +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
0aea9169b1 Rename IODevice::isActive(vpin) to isBusy(vpin). 2021-08-27 11:18:15 +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
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
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
Neil McKechnie
5f5efa7d23 Correct number of usable pins for ArduinoPins class. 2021-08-12 21:18:06 +01:00
Neil McKechnie
ec503e7d3e Make IODevice::read function return type consistent with underlying _read calls.
IODevice::read() now returns int, instead of bool.  This is consistent with the IODevice::_read() return and also allows for future devices that return a non-boolean value.
2021-08-12 12:01:10 +01:00
FrightRisk
5eff4c5ee5 Squash all commits on RMFT branch to create EX-RAIL branch 2021-08-03 17:12:25 -04:00