PWM: Use getRaw and setRaw for Sendable "Value" property. (#963)

Also change type to "PWM".  Move old PWM Sendable behavior for both value
and type to PWMSpeedController.
This commit is contained in:
Peter Johnson
2018-03-03 21:36:25 -08:00
committed by GitHub
parent 9d7293734a
commit 5175829bab
5 changed files with 24 additions and 5 deletions

View File

@@ -244,8 +244,8 @@ public class PWM extends SendableBase implements Sendable {
@Override
public void initSendable(SendableBuilder builder) {
builder.setSmartDashboardType("Speed Controller");
builder.setSmartDashboardType("PWM");
builder.setSafeState(this::setDisabled);
builder.addDoubleProperty("Value", this::getSpeed, this::setSpeed);
builder.addDoubleProperty("Value", this::getRaw, value -> setRaw((int) value));
}
}

View File

@@ -7,6 +7,8 @@
package edu.wpi.first.wpilibj;
import edu.wpi.first.wpilibj.smartdashboard.SendableBuilder;
/**
* Common base class for all PWM Speed Controllers.
*/
@@ -66,4 +68,11 @@ public abstract class PWMSpeedController extends SafePWM implements SpeedControl
public void pidWrite(double output) {
set(output);
}
@Override
public void initSendable(SendableBuilder builder) {
builder.setSmartDashboardType("Speed Controller");
builder.setSafeState(this::setDisabled);
builder.addDoubleProperty("Value", this::getSpeed, this::setSpeed);
}
}