mirror of
https://github.com/DCC-EX/CommandStation-EX.git
synced 2025-06-29 18:45:23 +02:00
5.5.33 config_servo
This commit is contained in:
parent
36c773df7a
commit
e6c6f78bb6
@ -95,21 +95,29 @@
|
|||||||
#define STEALTH_GLOBAL(code...) code
|
#define STEALTH_GLOBAL(code...) code
|
||||||
#include "myAutomation.h"
|
#include "myAutomation.h"
|
||||||
|
|
||||||
// Pass 1h Implements HAL macro by creating exrailHalSetup function
|
// Pass 1h Implements HAL macro by creating exrailHalSetup1 function
|
||||||
// Also allows creating EXTurntable object
|
// Also allows creating EXTurntable object
|
||||||
#include "EXRAIL2MacroReset.h"
|
#include "EXRAIL2MacroReset.h"
|
||||||
#undef HAL
|
#undef HAL
|
||||||
#define HAL(haltype,params...) haltype::create(params);
|
#define HAL(haltype,params...) haltype::create(params);
|
||||||
#undef HAL_IGNORE_DEFAULTS
|
#undef HAL_IGNORE_DEFAULTS
|
||||||
#define HAL_IGNORE_DEFAULTS ignore_defaults=true;
|
#define HAL_IGNORE_DEFAULTS ignore_defaults=true;
|
||||||
|
bool exrailHalSetup1() {
|
||||||
|
bool ignore_defaults=false;
|
||||||
|
#include "myAutomation.h"
|
||||||
|
return ignore_defaults;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Pass 1s Implements servos by creating exrailHalSetup2
|
||||||
|
// TODO Turnout and turntable creation should be moved to here instead of
|
||||||
|
// the first pass from the opcode table.
|
||||||
|
#include "EXRAIL2MacroReset.h"
|
||||||
#undef JMRI_SENSOR
|
#undef JMRI_SENSOR
|
||||||
#define JMRI_SENSOR(vpin,count...) Sensor::createMultiple(vpin,##count);
|
#define JMRI_SENSOR(vpin,count...) Sensor::createMultiple(vpin,##count);
|
||||||
#undef CONFIGURE_SERVO
|
#undef CONFIGURE_SERVO
|
||||||
#define CONFIGURE_SERVO(vpin,pos1,pos2,profile) IODevice::configureServo(vpin,pos1,pos2,PCA9685::profile);
|
#define CONFIGURE_SERVO(vpin,pos1,pos2,profile) IODevice::configureServo(vpin,pos1,pos2,PCA9685::profile);
|
||||||
bool exrailHalSetup() {
|
void exrailHalSetup2() {
|
||||||
bool ignore_defaults=false;
|
|
||||||
#include "myAutomation.h"
|
#include "myAutomation.h"
|
||||||
return ignore_defaults;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Pass 1c detect compile time featurtes
|
// Pass 1c detect compile time featurtes
|
||||||
|
62
IODevice.cpp
62
IODevice.cpp
@ -33,7 +33,9 @@
|
|||||||
|
|
||||||
// Link to halSetup function. If not defined, the function reference will be NULL.
|
// Link to halSetup function. If not defined, the function reference will be NULL.
|
||||||
extern __attribute__((weak)) void halSetup();
|
extern __attribute__((weak)) void halSetup();
|
||||||
extern __attribute__((weak)) bool exrailHalSetup();
|
extern __attribute__((weak)) bool exrailHalSetup1();
|
||||||
|
extern __attribute__((weak)) bool exrailHalSetup2();
|
||||||
|
|
||||||
|
|
||||||
//==================================================================================================================
|
//==================================================================================================================
|
||||||
// Static methods
|
// Static methods
|
||||||
@ -59,32 +61,46 @@ void IODevice::begin() {
|
|||||||
if (halSetup)
|
if (halSetup)
|
||||||
halSetup();
|
halSetup();
|
||||||
|
|
||||||
// include any HAL devices defined in exrail.
|
// Include any HAL devices defined in exrail.
|
||||||
|
// The first pass call only creates HAL devices,
|
||||||
|
// the second pass will apply servo settings etc which can only be
|
||||||
|
// done after all devices (including the defaults) are created.
|
||||||
|
// If exrailHalSetup1 is not defined, then it will be NULL and the call
|
||||||
|
// will be ignored.
|
||||||
|
// If it returns true, then the default HAL devices will not be created.
|
||||||
|
|
||||||
bool ignoreDefaults=false;
|
bool ignoreDefaults=false;
|
||||||
if (exrailHalSetup)
|
if (exrailHalSetup1)
|
||||||
ignoreDefaults=exrailHalSetup();
|
ignoreDefaults=exrailHalSetup1();
|
||||||
if (ignoreDefaults) return;
|
|
||||||
|
|
||||||
// Predefine two PCA9685 modules 0x40-0x41 if no conflicts
|
if (!ignoreDefaults) {
|
||||||
// Allocates 32 pins 100-131
|
|
||||||
const bool silent=true; // no message if these conflict
|
// Predefine two PCA9685 modules 0x40-0x41 if no conflicts
|
||||||
if (checkNoOverlap(100, 16, 0x40, silent)) {
|
// Allocates 32 pins 100-131
|
||||||
PCA9685::create(100, 16, 0x40);
|
const bool silent=true; // no message if these conflict
|
||||||
|
if (checkNoOverlap(100, 16, 0x40, silent)) {
|
||||||
|
PCA9685::create(100, 16, 0x40);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (checkNoOverlap(116, 16, 0x41, silent)) {
|
||||||
|
PCA9685::create(116, 16, 0x41);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Predefine two MCP23017 module 0x20/0x21 if no conflicts
|
||||||
|
// Allocates 32 pins 164-195
|
||||||
|
if (checkNoOverlap(164, 16, 0x20, silent)) {
|
||||||
|
MCP23017::create(164, 16, 0x20);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (checkNoOverlap(180, 16, 0x21, silent)) {
|
||||||
|
MCP23017::create(180, 16, 0x21);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (checkNoOverlap(116, 16, 0x41, silent)) {
|
// apply any second pass HAL setup from EXRAIL.
|
||||||
PCA9685::create(116, 16, 0x41);
|
// This will typically set up servo profiles, or create turnouts.
|
||||||
}
|
if (exrailHalSetup2)
|
||||||
|
exrailHalSetup2();
|
||||||
// Predefine two MCP23017 module 0x20/0x21 if no conflicts
|
|
||||||
// Allocates 32 pins 164-195
|
|
||||||
if (checkNoOverlap(164, 16, 0x20, silent)) {
|
|
||||||
MCP23017::create(164, 16, 0x20);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (checkNoOverlap(180, 16, 0x21, silent)) {
|
|
||||||
MCP23017::create(180, 16, 0x21);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// reset() function to reinitialise all devices
|
// reset() function to reinitialise all devices
|
||||||
|
@ -3,7 +3,8 @@
|
|||||||
|
|
||||||
#include "StringFormatter.h"
|
#include "StringFormatter.h"
|
||||||
|
|
||||||
#define VERSION "5.5.32"
|
#define VERSION "5.5.33"
|
||||||
|
// 5.5.33 - Fix CONFIG_SERVO when default PCA9685 definition used.
|
||||||
// 5.5.32 - Feature: Enable sniffer on CSB-1
|
// 5.5.32 - Feature: Enable sniffer on CSB-1
|
||||||
// 5.5.31 - <JL screen startRow> track status command
|
// 5.5.31 - <JL screen startRow> track status command
|
||||||
// - myTrackStatus.example.h added
|
// - myTrackStatus.example.h added
|
||||||
|
Loading…
x
Reference in New Issue
Block a user