1
0
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:
Asbelos 2025-06-28 11:00:35 +01:00
parent 36c773df7a
commit e6c6f78bb6
3 changed files with 53 additions and 28 deletions

View File

@ -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

View File

@ -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,11 +61,19 @@ 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;
if (!ignoreDefaults) {
// Predefine two PCA9685 modules 0x40-0x41 if no conflicts // Predefine two PCA9685 modules 0x40-0x41 if no conflicts
// Allocates 32 pins 100-131 // Allocates 32 pins 100-131
@ -87,6 +97,12 @@ void IODevice::begin() {
} }
} }
// apply any second pass HAL setup from EXRAIL.
// This will typically set up servo profiles, or create turnouts.
if (exrailHalSetup2)
exrailHalSetup2();
}
// reset() function to reinitialise all devices // reset() function to reinitialise all devices
void IODevice::reset() { void IODevice::reset() {
unsigned long currentMicros = micros(); unsigned long currentMicros = micros();

View File

@ -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