mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +00:00
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:
@@ -311,8 +311,8 @@ void PWM::SetZeroLatch() {
|
||||
}
|
||||
|
||||
void PWM::InitSendable(SendableBuilder& builder) {
|
||||
builder.SetSmartDashboardType("Speed Controller");
|
||||
builder.SetSmartDashboardType("PWM");
|
||||
builder.SetSafeState([=]() { SetDisabled(); });
|
||||
builder.AddDoubleProperty("Value", [=]() { return GetSpeed(); },
|
||||
[=](double value) { SetSpeed(value); });
|
||||
builder.AddDoubleProperty("Value", [=]() { return GetRaw(); },
|
||||
[=](double value) { SetRaw(value); });
|
||||
}
|
||||
|
||||
@@ -7,6 +7,8 @@
|
||||
|
||||
#include "PWMSpeedController.h"
|
||||
|
||||
#include "SmartDashboard/SendableBuilder.h"
|
||||
|
||||
using namespace frc;
|
||||
|
||||
/**
|
||||
@@ -52,3 +54,10 @@ void PWMSpeedController::StopMotor() { SafePWM::StopMotor(); }
|
||||
* @param output Write out the PWM value as was found in the PIDController
|
||||
*/
|
||||
void PWMSpeedController::PIDWrite(double output) { Set(output); }
|
||||
|
||||
void PWMSpeedController::InitSendable(SendableBuilder& builder) {
|
||||
builder.SetSmartDashboardType("Speed Controller");
|
||||
builder.SetSafeState([=]() { SetDisabled(); });
|
||||
builder.AddDoubleProperty("Value", [=]() { return GetSpeed(); },
|
||||
[=](double value) { SetSpeed(value); });
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@ class PWMSpeedController : public SafePWM, public SpeedController {
|
||||
|
||||
protected:
|
||||
explicit PWMSpeedController(int channel);
|
||||
void InitSendable(SendableBuilder& builder) override;
|
||||
|
||||
private:
|
||||
bool m_isInverted = false;
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user