mirror of
https://github.com/DCC-EX/CommandStation-EX.git
synced 2024-11-27 01:56:14 +01:00
Merge branch 'master' into neil-network
This commit is contained in:
commit
b8ee7f034b
|
@ -88,16 +88,9 @@ void setup()
|
||||||
// Start RMFT (ignored if no automnation)
|
// Start RMFT (ignored if no automnation)
|
||||||
RMFT::begin();
|
RMFT::begin();
|
||||||
|
|
||||||
// Link to and call mySetup() function (if defined in the build in mySetup.cpp).
|
|
||||||
// The contents will depend on the user's system hardware configuration.
|
|
||||||
// The mySetup.cpp file is a standard C++ module so has access to all of the DCC++EX APIs.
|
|
||||||
extern __attribute__((weak)) void mySetup();
|
|
||||||
if (mySetup) {
|
|
||||||
mySetup();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Invoke any DCC++EX commands in the form "SETUP("xxxx");"" found in optional file mySetup.h.
|
// Invoke any DCC++EX commands in the form "SETUP("xxxx");"" found in optional file mySetup.h.
|
||||||
// This can be used to create turnouts, outputs, sensors etc. throught the normal text commands.
|
// This can be used to create turnouts, outputs, sensors etc. through the normal text commands.
|
||||||
#if __has_include ( "mySetup.h")
|
#if __has_include ( "mySetup.h")
|
||||||
#define SETUP(cmd) serialParser.parse(F(cmd))
|
#define SETUP(cmd) serialParser.parse(F(cmd))
|
||||||
#include "mySetup.h"
|
#include "mySetup.h"
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
#define GITHUB_SHA "6c75563"
|
#define GITHUB_SHA "ee5db61"
|
||||||
|
|
61
IODevice.cpp
61
IODevice.cpp
|
@ -28,6 +28,9 @@
|
||||||
#define USE_FAST_IO
|
#define USE_FAST_IO
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// Link to mySetup function. If not defined, the function reference will be NULL.
|
||||||
|
extern __attribute__((weak)) void mySetup();
|
||||||
|
|
||||||
//==================================================================================================================
|
//==================================================================================================================
|
||||||
// Static methods
|
// Static methods
|
||||||
//------------------------------------------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -57,6 +60,13 @@ void IODevice::begin() {
|
||||||
dev->_begin();
|
dev->_begin();
|
||||||
}
|
}
|
||||||
_initPhase = false;
|
_initPhase = false;
|
||||||
|
|
||||||
|
// Call user's mySetup() function (if defined in the build in mySetup.cpp).
|
||||||
|
// The contents will depend on the user's system hardware configuration.
|
||||||
|
// The mySetup.cpp file is a standard C++ module so has access to all of the DCC++EX APIs.
|
||||||
|
if (mySetup) {
|
||||||
|
mySetup();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Overarching static loop() method for the IODevice subsystem. Works through the
|
// Overarching static loop() method for the IODevice subsystem. Works through the
|
||||||
|
@ -148,6 +158,33 @@ void IODevice::_display() {
|
||||||
bool IODevice::configure(VPIN vpin, ConfigTypeEnum configType, int paramCount, int params[]) {
|
bool IODevice::configure(VPIN vpin, ConfigTypeEnum configType, int paramCount, int params[]) {
|
||||||
IODevice *dev = findDevice(vpin);
|
IODevice *dev = findDevice(vpin);
|
||||||
if (dev) return dev->_configure(vpin, configType, paramCount, params);
|
if (dev) return dev->_configure(vpin, configType, paramCount, params);
|
||||||
|
#ifdef DIAG_IO
|
||||||
|
DIAG(F("IODevice::configure(): Vpin ID %d not found!"), (int)vpin);
|
||||||
|
#endif
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Read value from virtual pin.
|
||||||
|
int IODevice::read(VPIN vpin) {
|
||||||
|
for (IODevice *dev = _firstDevice; dev != 0; dev = dev->_nextDevice) {
|
||||||
|
if (dev->owns(vpin))
|
||||||
|
return dev->_read(vpin);
|
||||||
|
}
|
||||||
|
#ifdef DIAG_IO
|
||||||
|
DIAG(F("IODevice::read(): Vpin %d not found!"), (int)vpin);
|
||||||
|
#endif
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Read analogue value from virtual pin.
|
||||||
|
int IODevice::readAnalogue(VPIN vpin) {
|
||||||
|
for (IODevice *dev = _firstDevice; dev != 0; dev = dev->_nextDevice) {
|
||||||
|
if (dev->owns(vpin))
|
||||||
|
return dev->_readAnalogue(vpin);
|
||||||
|
}
|
||||||
|
#ifdef DIAG_IO
|
||||||
|
DIAG(F("IODevice::readAnalogue(): Vpin %d not found!"), (int)vpin);
|
||||||
|
#endif
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -258,30 +295,6 @@ bool IODevice::owns(VPIN id) {
|
||||||
return (id >= _firstVpin && id < _firstVpin + _nPins);
|
return (id >= _firstVpin && id < _firstVpin + _nPins);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Read value from virtual pin.
|
|
||||||
int IODevice::read(VPIN vpin) {
|
|
||||||
for (IODevice *dev = _firstDevice; dev != 0; dev = dev->_nextDevice) {
|
|
||||||
if (dev->owns(vpin))
|
|
||||||
return dev->_read(vpin);
|
|
||||||
}
|
|
||||||
#ifdef DIAG_IO
|
|
||||||
DIAG(F("IODevice::read(): Vpin %d not found!"), (int)vpin);
|
|
||||||
#endif
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Read analogue value from virtual pin.
|
|
||||||
int IODevice::readAnalogue(VPIN vpin) {
|
|
||||||
for (IODevice *dev = _firstDevice; dev != 0; dev = dev->_nextDevice) {
|
|
||||||
if (dev->owns(vpin))
|
|
||||||
return dev->_readAnalogue(vpin);
|
|
||||||
}
|
|
||||||
#ifdef DIAG_IO
|
|
||||||
DIAG(F("IODevice::readAnalogue(): Vpin %d not found!"), (int)vpin);
|
|
||||||
#endif
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#else // !defined(IO_NO_HAL)
|
#else // !defined(IO_NO_HAL)
|
||||||
|
|
||||||
|
|
|
@ -11,8 +11,6 @@
|
||||||
|
|
||||||
// Only the #include directives relating to the devices in use need be included here.
|
// Only the #include directives relating to the devices in use need be included here.
|
||||||
#include "IODevice.h"
|
#include "IODevice.h"
|
||||||
#include "Turnouts.h"
|
|
||||||
#include "Sensors.h"
|
|
||||||
#include "IO_HCSR04.h"
|
#include "IO_HCSR04.h"
|
||||||
#include "IO_VL53L0X.h"
|
#include "IO_VL53L0X.h"
|
||||||
#include "DFPlayer.h"
|
#include "DFPlayer.h"
|
||||||
|
@ -97,90 +95,6 @@ void mySetup() {
|
||||||
//MCP23017::create(196, 16, 0x22);
|
//MCP23017::create(196, 16, 0x22);
|
||||||
|
|
||||||
|
|
||||||
//=======================================================================
|
|
||||||
// Creating a Turnout
|
|
||||||
//=======================================================================
|
|
||||||
// Parameters: same as <T> command for Servo turnouts
|
|
||||||
// ID and VPIN are 100, sonar moves between positions 102 and 490 with slow profile.
|
|
||||||
// Profile may be Instant, Fast, Medium, Slow or Bounce.
|
|
||||||
|
|
||||||
//ServoTurnout::create(100, 100, 490, 102, PCA9685::Slow);
|
|
||||||
|
|
||||||
|
|
||||||
//=======================================================================
|
|
||||||
// DCC Accessory turnout
|
|
||||||
//=======================================================================
|
|
||||||
// Parameters: same as <T> command for DCC Accessory turnouts
|
|
||||||
// ID=3000
|
|
||||||
// Decoder address=23
|
|
||||||
// Decoder subaddress = 1
|
|
||||||
|
|
||||||
//DCCTurnout::create(3000, 23, 1);
|
|
||||||
|
|
||||||
|
|
||||||
//=======================================================================
|
|
||||||
// Creating a Sensor
|
|
||||||
//=======================================================================
|
|
||||||
// Parameters: As for the <S> command,
|
|
||||||
// id = 164,
|
|
||||||
// Vpin = 164 (configured above as pin 0 of an MCP23017)
|
|
||||||
// Pullup enable = 1 (enabled)
|
|
||||||
|
|
||||||
//Sensor::create(164, 164, 1);
|
|
||||||
|
|
||||||
|
|
||||||
//=======================================================================
|
|
||||||
// Way of creating lots of identical sensors in a range
|
|
||||||
//=======================================================================
|
|
||||||
|
|
||||||
//for (int i=165; i<180; i++)
|
|
||||||
// Sensor::create(i, i, 1);
|
|
||||||
|
|
||||||
|
|
||||||
//=======================================================================
|
|
||||||
// The following directive defines an HCSR04 ultrasonic ranging module.
|
|
||||||
//=======================================================================
|
|
||||||
// The parameters are:
|
|
||||||
// Vpin=2000 (only one VPIN per directive)
|
|
||||||
// Number of VPINs=1
|
|
||||||
// Arduino pin connected to TRIG=30
|
|
||||||
// Arduino pin connected to ECHO=31
|
|
||||||
// Minimum trigger range=20cm (VPIN goes to 1 when <20cm)
|
|
||||||
// Maximum trigger range=25cm (VPIN goes to 0 when >25cm)
|
|
||||||
// Note: Multiple devices can be configured by using a different ECHO pin
|
|
||||||
// for each one. The TRIG pin can be shared between multiple devices.
|
|
||||||
// Be aware that the 'ping' of one device may be received by another
|
|
||||||
// device and position them accordingly!
|
|
||||||
|
|
||||||
//HCSR04 sonarModule1(2000, 30, 31, 20, 25);
|
|
||||||
//HCSR04 sonarModule2(2001, 30, 32, 20, 25);
|
|
||||||
|
|
||||||
|
|
||||||
//=======================================================================
|
|
||||||
// VL53L0X Time-of-Flight range sensor.
|
|
||||||
//=======================================================================
|
|
||||||
// The following directive defines a single VL53L0X Time-of-Flight range sensor.
|
|
||||||
// The parameters are:
|
|
||||||
// VPIN=5000
|
|
||||||
// Number of VPINs=1
|
|
||||||
// I2C address=0x29 (default for this chip)
|
|
||||||
// Minimum trigger range=200mm (VPIN goes to 1 when <20cm)
|
|
||||||
// Maximum trigger range=250mm (VPIN goes to 0 when >25cm)
|
|
||||||
|
|
||||||
//VL53L0X::create(5000, 1, 0x29, 200, 250);
|
|
||||||
|
|
||||||
// For multiple VL53L0X modules, add another parameter which is a VPIN connected to the
|
|
||||||
// module's XSHUT pin. This allows the modules to be configured, at start,
|
|
||||||
// with distinct I2C addresses. In this case, the address 0x29 is only used during
|
|
||||||
// initialisation to configure each device in turn with the desired unique I2C address.
|
|
||||||
// The examples below have the modules' XSHUT pins connected to the first two pins of
|
|
||||||
// the first MCP23017 module (164 and 165), but Arduino pins may be used instead.
|
|
||||||
// The first module here is given I2C address 0x30 and the second is 0x31.
|
|
||||||
|
|
||||||
//VL53L0X::create(5000, 1, 0x30, 200, 250, 164);
|
|
||||||
//VL53L0X::create(5001, 1, 0x31, 200, 250, 165);
|
|
||||||
|
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
// Play mp3 files from a Micro-SD card, using a DFPlayer MP3 Module.
|
// Play mp3 files from a Micro-SD card, using a DFPlayer MP3 Module.
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
#include "StringFormatter.h"
|
#include "StringFormatter.h"
|
||||||
|
|
||||||
#define VERSION "3.2.0 rc2"
|
#define VERSION "3.2.0 rc3"
|
||||||
// 3.2.0 Major functional and non-functional changes.
|
// 3.2.0 Major functional and non-functional changes.
|
||||||
// New HAL added for I/O (digital and analogue inputs and outputs, servos etc).
|
// New HAL added for I/O (digital and analogue inputs and outputs, servos etc).
|
||||||
// Support for MCP23008, MCP23017 and PCF9584 I2C GPIO Extender modules.
|
// Support for MCP23008, MCP23017 and PCF9584 I2C GPIO Extender modules.
|
||||||
|
|
Loading…
Reference in New Issue
Block a user