1
0
mirror of https://github.com/DCC-EX/CommandStation-EX.git synced 2025-07-28 18:03:45 +02:00

Make defaults for PWM (servo) positions 0 (PWM off) if not configured.

When writing to a PWM device (servo or LED for example), it is possible to request the target position in the call, or to ask for a SET or RESET position.  In the latter case, the positions corresponding to SET and RESET must be known, i.e. preconfigured.  Defaults were assigned for this, but because the correct values will depend on the hardware device being driven, the defaults have been removed.
In addition, the <T> command, when defining a servo turnout, now configures the PWM positions (not required by <T> commands, but desirable for consistency with other commands).
This commit is contained in:
Neil McKechnie
2021-08-29 12:04:13 +01:00
parent 09eae0ea91
commit 1bb7b5cc77
3 changed files with 20 additions and 23 deletions

View File

@@ -249,9 +249,10 @@
// Don't touch the _closed parameter, retain the original value.
// We don't really need to do the following, since a call to IODevice::_writeAnalogue
// will provide all the data that is required!
// int params[] = {(int)thrownPosition, (int)closedPosition, profile, closed};
// IODevice::configure(vpin, IODevice::CONFIGURE_SERVO, 4, params);
// will provide all the data that is required! However, if someone has configured
// a Turnout, we should ensure that the SET() RESET() and other commands that use write()
// behave consistently with the turnout commands.
IODevice::configureServo(vpin, thrownPosition, closedPosition, profile, 0, closed);
// Set position directly to specified position - we don't know where it is moving from.
IODevice::writeAnalogue(vpin, closed ? closedPosition : thrownPosition, PCA9685::Instant);