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

Cleaned up PWM start

This commit is contained in:
peteGSX 2023-01-31 19:29:39 +10:00 committed by peteGSX
parent fa38583772
commit d375723a13

View File

@ -78,7 +78,6 @@ private:
_analoguePinBytes = _numAnaloguePins * 2; _analoguePinBytes = _numAnaloguePins * 2;
_analogueInputStates = (byte*) calloc(_analoguePinBytes, 1); _analogueInputStates = (byte*) calloc(_analoguePinBytes, 1);
_analoguePinMap = (uint8_t*) calloc(_numAnaloguePins, 1); _analoguePinMap = (uint8_t*) calloc(_numAnaloguePins, 1);
_servoData = (struct ServoData*) calloc(_numPWMPins, 14);
} else { } else {
DIAG(F("ERROR configuring EX-IOExpander device, I2C:x%x"), _i2cAddress); DIAG(F("ERROR configuring EX-IOExpander device, I2C:x%x"), _i2cAddress);
@ -198,26 +197,6 @@ private:
uint8_t* _analoguePinMap; uint8_t* _analoguePinMap;
uint8_t _numPWMPins = 0; uint8_t _numPWMPins = 0;
struct ServoData {
uint16_t activePosition : 12; // Config parameter
uint16_t inactivePosition : 12; // Config parameter
uint16_t currentPosition : 12;
uint16_t fromPosition : 12;
uint16_t toPosition : 12;
uint8_t profile; // Config parameter
uint16_t stepNumber; // Index of current step (starting from 0)
uint16_t numSteps; // Number of steps in animation, or 0 if none in progress.
uint8_t currentProfile; // profile being used for current animation.
uint16_t duration; // time (tenths of a second) for animation to complete.
} ServoData; // 14 bytes per element, i.e. per pin in use
struct ServoData* _servoData;
static const uint8_t _catchupSteps = 5; // number of steps to wait before switching servo off
static const byte FLASH _bounceProfile[30];
const unsigned int refreshInterval = 50; // refresh every 50ms
enum { enum {
EXIOINIT = 0xE0, // Flag to initialise setup procedure EXIOINIT = 0xE0, // Flag to initialise setup procedure
EXIORDY = 0xE1, // Flag we have completed setup procedure, also for EX-IO to ACK setup EXIORDY = 0xE1, // Flag we have completed setup procedure, also for EX-IO to ACK setup