mirror of
https://github.com/DCC-EX/CommandStation-EX.git
synced 2024-12-24 13:21:23 +01:00
Servo functional
This commit is contained in:
parent
06827a42b7
commit
6874ddca9b
@ -187,10 +187,15 @@ private:
|
||||
I2CManager.read(_i2cAddress, _digitalInputStates, _digitalPinBytes, _command1Buffer, 1);
|
||||
_command1Buffer[0] = EXIORDAN;
|
||||
I2CManager.read(_i2cAddress, _analogueInputStates, _analoguePinBytes, _command1Buffer, 1);
|
||||
if ((currentMicros - _lastRefresh) / 1000UL > refreshInterval) {
|
||||
_lastRefresh = currentMicros;
|
||||
for (int pin=0; pin<_nPins; pin++) {
|
||||
if (_servoData[pin] != NULL) {
|
||||
updatePosition(pin);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Obtain the correct analogue input value
|
||||
int _readAnalogue(VPIN vpin) override {
|
||||
@ -247,16 +252,8 @@ private:
|
||||
}
|
||||
}
|
||||
|
||||
// void _writeAnalogue(VPIN vpin, int value, uint8_t param1, uint16_t param2) override {
|
||||
void _writeAnalogue(VPIN vpin, int value, uint8_t profile, uint16_t duration) override {
|
||||
int pin = vpin - _firstVpin;
|
||||
/* Initial _writeAnalogue here
|
||||
_command4Buffer[0] = EXIOWRAN;
|
||||
_command4Buffer[1] = pin;
|
||||
_command4Buffer[2] = value & 0xFF;
|
||||
_command4Buffer[3] = value >> 8;
|
||||
I2CManager.write(_i2cAddress, _command4Buffer, 4);
|
||||
*/
|
||||
#ifdef DIAG_IO
|
||||
DIAG(F("Servo: WriteAnalogue Vpin:%d Value:%d Profile:%d Duration:%d %S"),
|
||||
vpin, value, profile, duration, _deviceState == DEVSTATE_FAILED?F("DEVSTATE_FAILED"):F(""));
|
||||
@ -318,12 +315,6 @@ private:
|
||||
s->stepNumber++;
|
||||
} else if (s->stepNumber == s->numSteps + _catchupSteps
|
||||
&& s->currentPosition != 0) {
|
||||
// #ifdef IO_SWITCH_OFF_SERVO
|
||||
// if ((s->currentProfile & NoPowerOff) == 0) {
|
||||
// // Wait has finished, so switch off PWM to prevent annoying servo buzz
|
||||
// // _slaveDevice->writeAnalogue(_firstSlavePin+pin, 0);
|
||||
// }
|
||||
// #endif
|
||||
s->numSteps = 0; // Done now.
|
||||
}
|
||||
}
|
||||
@ -378,9 +369,9 @@ private:
|
||||
struct ServoData *_servoData[256];
|
||||
|
||||
static const uint8_t _catchupSteps = 5; // number of steps to wait before switching servo off
|
||||
// static const uint8_t FLASH _bounceProfile[30];
|
||||
|
||||
const unsigned int refreshInterval = 50; // refresh every 50ms
|
||||
unsigned long _lastRefresh = 0;
|
||||
|
||||
// Profile for a bouncing signal or turnout
|
||||
// The profile below is in the range 0-100% and should be combined with the desired limits
|
||||
|
Loading…
Reference in New Issue
Block a user