blob: ea298de6c29e3860589781c5008d8a028f7aab39 [file] [log] [blame]
Brian Silverman41cdd3e2019-01-19 19:48:58 -08001/*----------------------------------------------------------------------------*/
2/* Copyright (c) 2008-2018 FIRST. All Rights Reserved. */
3/* Open Source Software - may be modified and shared by FRC teams. The code */
4/* must be accompanied by the FIRST BSD license file in the root directory of */
5/* the project. */
6/*----------------------------------------------------------------------------*/
7
8#include "frc/PWMSpeedController.h"
9
10#include "frc/smartdashboard/SendableBuilder.h"
11
12using namespace frc;
13
14void PWMSpeedController::Set(double speed) {
15 SetSpeed(m_isInverted ? -speed : speed);
16}
17
18double PWMSpeedController::Get() const { return GetSpeed(); }
19
20void PWMSpeedController::SetInverted(bool isInverted) {
21 m_isInverted = isInverted;
22}
23
24bool PWMSpeedController::GetInverted() const { return m_isInverted; }
25
26void PWMSpeedController::Disable() { SetDisabled(); }
27
28void PWMSpeedController::StopMotor() { PWM::StopMotor(); }
29
30void PWMSpeedController::PIDWrite(double output) { Set(output); }
31
32PWMSpeedController::PWMSpeedController(int channel) : PWM(channel) {}
33
34void PWMSpeedController::InitSendable(SendableBuilder& builder) {
35 builder.SetSmartDashboardType("Speed Controller");
36 builder.SetActuator(true);
37 builder.SetSafeState([=]() { SetDisabled(); });
38 builder.AddDoubleProperty("Value", [=]() { return GetSpeed(); },
39 [=](double value) { SetSpeed(value); });
40}