2013-12-15 18:30:16 -05:00
|
|
|
/*----------------------------------------------------------------------------*/
|
2016-01-02 03:02:34 -08:00
|
|
|
/* Copyright (c) FIRST 2008-2016. All Rights Reserved. */
|
2013-12-15 18:30:16 -05:00
|
|
|
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
2016-01-02 03:02:34 -08:00
|
|
|
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
|
|
|
|
/* the project. */
|
2013-12-15 18:30:16 -05:00
|
|
|
/*----------------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
|
|
#include "PWM.h"
|
|
|
|
|
|
2016-05-22 21:41:22 -07:00
|
|
|
#include "HAL/HAL.h"
|
2013-12-15 18:30:16 -05:00
|
|
|
#include "Utility.h"
|
|
|
|
|
#include "WPIErrors.h"
|
|
|
|
|
|
2015-06-30 15:01:20 -04:00
|
|
|
#include <sstream>
|
|
|
|
|
|
2013-12-15 18:30:16 -05:00
|
|
|
constexpr float PWM::kDefaultPwmPeriod;
|
|
|
|
|
constexpr float PWM::kDefaultPwmCenter;
|
|
|
|
|
const int32_t PWM::kDefaultPwmStepsDown;
|
|
|
|
|
const int32_t PWM::kPwmDisabled;
|
|
|
|
|
|
|
|
|
|
/**
|
2015-06-29 02:43:44 -07:00
|
|
|
* Allocate a PWM given a channel number.
|
2014-06-13 17:45:10 -04:00
|
|
|
*
|
2015-06-29 02:43:44 -07:00
|
|
|
* Checks channel value range and allocates the appropriate channel.
|
2015-06-25 15:07:55 -04:00
|
|
|
* The allocation is only done to help users ensure that they don't double
|
|
|
|
|
* assign channels.
|
2016-05-20 17:30:37 -07:00
|
|
|
*
|
|
|
|
|
* @param channel The PWM channel number. 0-9 are on-board, 10-19 are on the
|
|
|
|
|
* MXP port
|
2013-12-15 18:30:16 -05:00
|
|
|
*/
|
2015-06-29 02:43:44 -07:00
|
|
|
PWM::PWM(uint32_t channel) {
|
2015-06-30 15:01:20 -04:00
|
|
|
std::stringstream buf;
|
2014-06-13 17:45:10 -04:00
|
|
|
|
2015-06-25 15:07:55 -04:00
|
|
|
if (!CheckPWMChannel(channel)) {
|
2015-06-30 15:01:20 -04:00
|
|
|
buf << "PWM Channel " << channel;
|
|
|
|
|
wpi_setWPIErrorWithContext(ChannelIndexOutOfRange, buf.str());
|
2015-06-25 15:07:55 -04:00
|
|
|
return;
|
|
|
|
|
}
|
2013-12-15 18:30:16 -05:00
|
|
|
|
2015-06-25 15:07:55 -04:00
|
|
|
int32_t status = 0;
|
2016-06-30 21:39:09 -07:00
|
|
|
m_handle = initializePWMPort(getPort(channel), &status);
|
|
|
|
|
if (status != 0) {
|
|
|
|
|
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
|
|
|
|
m_channel = std::numeric_limits<uint32_t>::max();
|
|
|
|
|
m_handle = HAL_INVALID_HANDLE;
|
|
|
|
|
}
|
2014-07-21 16:32:36 -04:00
|
|
|
|
2015-06-25 15:07:55 -04:00
|
|
|
m_channel = channel;
|
2014-07-21 16:32:36 -04:00
|
|
|
|
2016-06-30 21:39:09 -07:00
|
|
|
setPWM(m_handle, kPwmDisabled, &status);
|
2015-06-25 15:07:55 -04:00
|
|
|
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
2014-07-21 16:32:36 -04:00
|
|
|
|
2015-06-25 15:07:55 -04:00
|
|
|
m_eliminateDeadband = false;
|
2013-12-15 18:30:16 -05:00
|
|
|
|
2015-06-25 15:07:55 -04:00
|
|
|
HALReport(HALUsageReporting::kResourceType_PWM, channel);
|
2013-12-15 18:30:16 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Free the PWM channel.
|
2014-06-13 17:45:10 -04:00
|
|
|
*
|
2013-12-15 18:30:16 -05:00
|
|
|
* Free the resource associated with the PWM channel and set the value to 0.
|
|
|
|
|
*/
|
2015-06-25 15:07:55 -04:00
|
|
|
PWM::~PWM() {
|
|
|
|
|
int32_t status = 0;
|
2014-08-05 17:27:43 -04:00
|
|
|
|
2016-06-30 21:39:09 -07:00
|
|
|
setPWM(m_handle, kPwmDisabled, &status);
|
2015-06-25 15:07:55 -04:00
|
|
|
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
2014-07-21 16:32:36 -04:00
|
|
|
|
2016-06-30 21:39:09 -07:00
|
|
|
freePWMPort(m_handle, &status);
|
2015-06-25 15:07:55 -04:00
|
|
|
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
2015-08-13 23:17:19 -07:00
|
|
|
|
|
|
|
|
if (m_table != nullptr) m_table->RemoveTableListener(this);
|
2013-12-15 18:30:16 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Optionally eliminate the deadband from a speed controller.
|
2016-05-20 17:30:37 -07:00
|
|
|
*
|
2015-06-25 15:07:55 -04:00
|
|
|
* @param eliminateDeadband If true, set the motor curve on the Jaguar to
|
2016-05-20 17:30:37 -07:00
|
|
|
* eliminate the deadband in the middle of the range.
|
|
|
|
|
* Otherwise, keep the full range without modifying
|
|
|
|
|
* any values.
|
2013-12-15 18:30:16 -05:00
|
|
|
*/
|
2015-06-25 15:07:55 -04:00
|
|
|
void PWM::EnableDeadbandElimination(bool eliminateDeadband) {
|
|
|
|
|
if (StatusIsFatal()) return;
|
|
|
|
|
m_eliminateDeadband = eliminateDeadband;
|
2013-12-15 18:30:16 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Set the bounds on the PWM values.
|
2016-05-20 17:30:37 -07:00
|
|
|
*
|
2015-06-25 15:07:55 -04:00
|
|
|
* This sets the bounds on the PWM values for a particular each type of
|
2016-05-20 17:30:37 -07:00
|
|
|
* controller. The values determine the upper and lower speeds as well as the
|
|
|
|
|
* deadband bracket.
|
|
|
|
|
*
|
|
|
|
|
* @param max The Minimum pwm value
|
2013-12-15 18:30:16 -05:00
|
|
|
* @param deadbandMax The high end of the deadband range
|
2016-05-20 17:30:37 -07:00
|
|
|
* @param center The center speed (off)
|
2013-12-15 18:30:16 -05:00
|
|
|
* @param deadbandMin The low end of the deadband range
|
2016-05-20 17:30:37 -07:00
|
|
|
* @param min The minimum pwm value
|
2013-12-15 18:30:16 -05:00
|
|
|
*/
|
2015-06-25 15:07:55 -04:00
|
|
|
void PWM::SetBounds(int32_t max, int32_t deadbandMax, int32_t center,
|
|
|
|
|
int32_t deadbandMin, int32_t min) {
|
|
|
|
|
if (StatusIsFatal()) return;
|
|
|
|
|
m_maxPwm = max;
|
|
|
|
|
m_deadbandMaxPwm = deadbandMax;
|
|
|
|
|
m_centerPwm = center;
|
|
|
|
|
m_deadbandMinPwm = deadbandMin;
|
|
|
|
|
m_minPwm = min;
|
2013-12-15 18:30:16 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Set the bounds on the PWM pulse widths.
|
2016-05-20 17:30:37 -07:00
|
|
|
*
|
2015-06-25 15:07:55 -04:00
|
|
|
* This sets the bounds on the PWM values for a particular type of controller.
|
2016-05-20 17:30:37 -07:00
|
|
|
* The values determine the upper and lower speeds as well as the deadband
|
|
|
|
|
* bracket.
|
|
|
|
|
*
|
|
|
|
|
* @param max The max PWM pulse width in ms
|
2013-12-15 18:30:16 -05:00
|
|
|
* @param deadbandMax The high end of the deadband range pulse width in ms
|
2016-05-20 17:30:37 -07:00
|
|
|
* @param center The center (off) pulse width in ms
|
2013-12-15 18:30:16 -05:00
|
|
|
* @param deadbandMin The low end of the deadband pulse width in ms
|
2016-05-20 17:30:37 -07:00
|
|
|
* @param min The minimum pulse width in ms
|
2013-12-15 18:30:16 -05:00
|
|
|
*/
|
2015-06-25 15:07:55 -04:00
|
|
|
void PWM::SetBounds(double max, double deadbandMax, double center,
|
|
|
|
|
double deadbandMin, double min) {
|
|
|
|
|
// calculate the loop time in milliseconds
|
|
|
|
|
int32_t status = 0;
|
|
|
|
|
double loopTime =
|
2016-07-08 00:08:07 -07:00
|
|
|
getLoopTiming(&status) / (HAL_getSystemClockTicksPerMicrosecond() * 1e3);
|
2015-06-25 15:07:55 -04:00
|
|
|
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
|
|
|
|
|
|
|
|
|
if (StatusIsFatal()) return;
|
|
|
|
|
|
|
|
|
|
m_maxPwm = (int32_t)((max - kDefaultPwmCenter) / loopTime +
|
|
|
|
|
kDefaultPwmStepsDown - 1);
|
|
|
|
|
m_deadbandMaxPwm = (int32_t)((deadbandMax - kDefaultPwmCenter) / loopTime +
|
|
|
|
|
kDefaultPwmStepsDown - 1);
|
|
|
|
|
m_centerPwm = (int32_t)((center - kDefaultPwmCenter) / loopTime +
|
|
|
|
|
kDefaultPwmStepsDown - 1);
|
|
|
|
|
m_deadbandMinPwm = (int32_t)((deadbandMin - kDefaultPwmCenter) / loopTime +
|
|
|
|
|
kDefaultPwmStepsDown - 1);
|
|
|
|
|
m_minPwm = (int32_t)((min - kDefaultPwmCenter) / loopTime +
|
|
|
|
|
kDefaultPwmStepsDown - 1);
|
2013-12-15 18:30:16 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Set the PWM value based on a position.
|
2014-06-13 17:45:10 -04:00
|
|
|
*
|
2013-12-15 18:30:16 -05:00
|
|
|
* This is intended to be used by servos.
|
2014-06-13 17:45:10 -04:00
|
|
|
*
|
2013-12-15 18:30:16 -05:00
|
|
|
* @pre SetMaxPositivePwm() called.
|
|
|
|
|
* @pre SetMinNegativePwm() called.
|
2014-06-13 17:45:10 -04:00
|
|
|
*
|
2013-12-15 18:30:16 -05:00
|
|
|
* @param pos The position to set the servo between 0.0 and 1.0.
|
|
|
|
|
*/
|
2015-06-25 15:07:55 -04:00
|
|
|
void PWM::SetPosition(float pos) {
|
|
|
|
|
if (StatusIsFatal()) return;
|
|
|
|
|
if (pos < 0.0) {
|
|
|
|
|
pos = 0.0;
|
|
|
|
|
} else if (pos > 1.0) {
|
|
|
|
|
pos = 1.0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// note, need to perform the multiplication below as floating point before
|
|
|
|
|
// converting to int
|
|
|
|
|
unsigned short rawValue =
|
|
|
|
|
(int32_t)((pos * (float)GetFullRangeScaleFactor()) + GetMinNegativePwm());
|
|
|
|
|
|
|
|
|
|
wpi_assert(rawValue != kPwmDisabled);
|
|
|
|
|
|
|
|
|
|
// send the computed pwm value to the FPGA
|
|
|
|
|
SetRaw((unsigned short)rawValue);
|
2013-12-15 18:30:16 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get the PWM value in terms of a position.
|
2014-06-13 17:45:10 -04:00
|
|
|
*
|
2013-12-15 18:30:16 -05:00
|
|
|
* This is intended to be used by servos.
|
2014-06-13 17:45:10 -04:00
|
|
|
*
|
2013-12-15 18:30:16 -05:00
|
|
|
* @pre SetMaxPositivePwm() called.
|
|
|
|
|
* @pre SetMinNegativePwm() called.
|
2014-06-13 17:45:10 -04:00
|
|
|
*
|
2013-12-15 18:30:16 -05:00
|
|
|
* @return The position the servo is set to between 0.0 and 1.0.
|
|
|
|
|
*/
|
2015-06-25 15:07:55 -04:00
|
|
|
float PWM::GetPosition() const {
|
|
|
|
|
if (StatusIsFatal()) return 0.0;
|
|
|
|
|
int32_t value = GetRaw();
|
|
|
|
|
if (value < GetMinNegativePwm()) {
|
|
|
|
|
return 0.0;
|
|
|
|
|
} else if (value > GetMaxPositivePwm()) {
|
|
|
|
|
return 1.0;
|
|
|
|
|
} else {
|
|
|
|
|
return (float)(value - GetMinNegativePwm()) /
|
|
|
|
|
(float)GetFullRangeScaleFactor();
|
|
|
|
|
}
|
2013-12-15 18:30:16 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Set the PWM value based on a speed.
|
2014-06-13 17:45:10 -04:00
|
|
|
*
|
2013-12-15 18:30:16 -05:00
|
|
|
* This is intended to be used by speed controllers.
|
2014-06-13 17:45:10 -04:00
|
|
|
*
|
2013-12-15 18:30:16 -05:00
|
|
|
* @pre SetMaxPositivePwm() called.
|
|
|
|
|
* @pre SetMinPositivePwm() called.
|
|
|
|
|
* @pre SetCenterPwm() called.
|
|
|
|
|
* @pre SetMaxNegativePwm() called.
|
|
|
|
|
* @pre SetMinNegativePwm() called.
|
2014-06-13 17:45:10 -04:00
|
|
|
*
|
2013-12-15 18:30:16 -05:00
|
|
|
* @param speed The speed to set the speed controller between -1.0 and 1.0.
|
|
|
|
|
*/
|
2015-06-25 15:07:55 -04:00
|
|
|
void PWM::SetSpeed(float speed) {
|
|
|
|
|
if (StatusIsFatal()) return;
|
|
|
|
|
// clamp speed to be in the range 1.0 >= speed >= -1.0
|
|
|
|
|
if (speed < -1.0) {
|
|
|
|
|
speed = -1.0;
|
|
|
|
|
} else if (speed > 1.0) {
|
|
|
|
|
speed = 1.0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// calculate the desired output pwm value by scaling the speed appropriately
|
|
|
|
|
int32_t rawValue;
|
|
|
|
|
if (speed == 0.0) {
|
|
|
|
|
rawValue = GetCenterPwm();
|
|
|
|
|
} else if (speed > 0.0) {
|
|
|
|
|
rawValue = (int32_t)(speed * ((float)GetPositiveScaleFactor()) +
|
|
|
|
|
((float)GetMinPositivePwm()) + 0.5);
|
|
|
|
|
} else {
|
|
|
|
|
rawValue = (int32_t)(speed * ((float)GetNegativeScaleFactor()) +
|
|
|
|
|
((float)GetMaxNegativePwm()) + 0.5);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// the above should result in a pwm_value in the valid range
|
|
|
|
|
wpi_assert((rawValue >= GetMinNegativePwm()) &&
|
|
|
|
|
(rawValue <= GetMaxPositivePwm()));
|
|
|
|
|
wpi_assert(rawValue != kPwmDisabled);
|
|
|
|
|
|
|
|
|
|
// send the computed pwm value to the FPGA
|
|
|
|
|
SetRaw(rawValue);
|
2013-12-15 18:30:16 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get the PWM value in terms of speed.
|
2014-06-13 17:45:10 -04:00
|
|
|
*
|
2013-12-15 18:30:16 -05:00
|
|
|
* This is intended to be used by speed controllers.
|
2014-06-13 17:45:10 -04:00
|
|
|
*
|
2013-12-15 18:30:16 -05:00
|
|
|
* @pre SetMaxPositivePwm() called.
|
|
|
|
|
* @pre SetMinPositivePwm() called.
|
|
|
|
|
* @pre SetMaxNegativePwm() called.
|
|
|
|
|
* @pre SetMinNegativePwm() called.
|
2014-06-13 17:45:10 -04:00
|
|
|
*
|
2013-12-15 18:30:16 -05:00
|
|
|
* @return The most recently set speed between -1.0 and 1.0.
|
|
|
|
|
*/
|
2015-06-25 15:07:55 -04:00
|
|
|
float PWM::GetSpeed() const {
|
|
|
|
|
if (StatusIsFatal()) return 0.0;
|
|
|
|
|
int32_t value = GetRaw();
|
|
|
|
|
if (value == PWM::kPwmDisabled) {
|
|
|
|
|
return 0.0;
|
|
|
|
|
} else if (value > GetMaxPositivePwm()) {
|
|
|
|
|
return 1.0;
|
|
|
|
|
} else if (value < GetMinNegativePwm()) {
|
|
|
|
|
return -1.0;
|
|
|
|
|
} else if (value > GetMinPositivePwm()) {
|
|
|
|
|
return (float)(value - GetMinPositivePwm()) /
|
|
|
|
|
(float)GetPositiveScaleFactor();
|
|
|
|
|
} else if (value < GetMaxNegativePwm()) {
|
|
|
|
|
return (float)(value - GetMaxNegativePwm()) /
|
|
|
|
|
(float)GetNegativeScaleFactor();
|
|
|
|
|
} else {
|
|
|
|
|
return 0.0;
|
|
|
|
|
}
|
2013-12-15 18:30:16 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Set the PWM value directly to the hardware.
|
2014-06-13 17:45:10 -04:00
|
|
|
*
|
2013-12-15 18:30:16 -05:00
|
|
|
* Write a raw value to a PWM channel.
|
2014-06-13 17:45:10 -04:00
|
|
|
*
|
2014-06-04 11:06:37 -04:00
|
|
|
* @param value Raw PWM value.
|
2013-12-15 18:30:16 -05:00
|
|
|
*/
|
2015-06-25 15:07:55 -04:00
|
|
|
void PWM::SetRaw(unsigned short value) {
|
|
|
|
|
if (StatusIsFatal()) return;
|
2014-07-21 16:32:36 -04:00
|
|
|
|
2015-06-25 15:07:55 -04:00
|
|
|
int32_t status = 0;
|
2016-06-30 21:39:09 -07:00
|
|
|
setPWM(m_handle, value, &status);
|
2015-06-25 15:07:55 -04:00
|
|
|
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
2013-12-15 18:30:16 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get the PWM value directly from the hardware.
|
2014-06-13 17:45:10 -04:00
|
|
|
*
|
2013-12-15 18:30:16 -05:00
|
|
|
* Read a raw value from a PWM channel.
|
2014-06-13 17:45:10 -04:00
|
|
|
*
|
2014-06-04 11:06:37 -04:00
|
|
|
* @return Raw PWM control value.
|
2013-12-15 18:30:16 -05:00
|
|
|
*/
|
2015-06-25 15:07:55 -04:00
|
|
|
unsigned short PWM::GetRaw() const {
|
|
|
|
|
if (StatusIsFatal()) return 0;
|
2014-07-21 16:32:36 -04:00
|
|
|
|
2015-06-25 15:07:55 -04:00
|
|
|
int32_t status = 0;
|
2016-06-30 21:39:09 -07:00
|
|
|
unsigned short value = getPWM(m_handle, &status);
|
2015-06-25 15:07:55 -04:00
|
|
|
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
2014-07-21 16:32:36 -04:00
|
|
|
|
2015-06-25 15:07:55 -04:00
|
|
|
return value;
|
2013-12-15 18:30:16 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Slow down the PWM signal for old devices.
|
2014-06-13 17:45:10 -04:00
|
|
|
*
|
2013-12-15 18:30:16 -05:00
|
|
|
* @param mult The period multiplier to apply to this channel
|
|
|
|
|
*/
|
2015-06-25 15:07:55 -04:00
|
|
|
void PWM::SetPeriodMultiplier(PeriodMultiplier mult) {
|
|
|
|
|
if (StatusIsFatal()) return;
|
|
|
|
|
|
|
|
|
|
int32_t status = 0;
|
|
|
|
|
|
|
|
|
|
switch (mult) {
|
|
|
|
|
case kPeriodMultiplier_4X:
|
2016-06-30 21:39:09 -07:00
|
|
|
setPWMPeriodScale(m_handle, 3, &status); // Squelch 3 out of 4 outputs
|
2015-06-25 15:07:55 -04:00
|
|
|
break;
|
|
|
|
|
case kPeriodMultiplier_2X:
|
2016-06-30 21:39:09 -07:00
|
|
|
setPWMPeriodScale(m_handle, 1, &status); // Squelch 1 out of 2 outputs
|
2015-06-25 15:07:55 -04:00
|
|
|
break;
|
|
|
|
|
case kPeriodMultiplier_1X:
|
2016-06-30 21:39:09 -07:00
|
|
|
setPWMPeriodScale(m_handle, 0, &status); // Don't squelch any outputs
|
2015-06-25 15:07:55 -04:00
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
wpi_assert(false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
2013-12-15 18:30:16 -05:00
|
|
|
}
|
|
|
|
|
|
2015-06-25 15:07:55 -04:00
|
|
|
void PWM::SetZeroLatch() {
|
|
|
|
|
if (StatusIsFatal()) return;
|
2014-09-26 17:20:57 -04:00
|
|
|
|
2015-06-25 15:07:55 -04:00
|
|
|
int32_t status = 0;
|
2013-12-15 18:30:16 -05:00
|
|
|
|
2016-06-30 21:39:09 -07:00
|
|
|
latchPWMZero(m_handle, &status);
|
2015-06-25 15:07:55 -04:00
|
|
|
wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
|
|
|
|
}
|
|
|
|
|
|
2015-08-13 23:17:19 -07:00
|
|
|
void PWM::ValueChanged(ITable* source, llvm::StringRef key,
|
|
|
|
|
std::shared_ptr<nt::Value> value, bool isNew) {
|
|
|
|
|
if (!value->IsDouble()) return;
|
|
|
|
|
SetSpeed(value->GetDouble());
|
2013-12-15 18:30:16 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void PWM::UpdateTable() {
|
2015-06-23 04:49:51 -07:00
|
|
|
if (m_table != nullptr) {
|
2015-06-25 15:07:55 -04:00
|
|
|
m_table->PutNumber("Value", GetSpeed());
|
|
|
|
|
}
|
2013-12-15 18:30:16 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void PWM::StartLiveWindowMode() {
|
2015-06-25 15:07:55 -04:00
|
|
|
SetSpeed(0);
|
2015-06-23 04:49:51 -07:00
|
|
|
if (m_table != nullptr) {
|
2015-06-25 15:07:55 -04:00
|
|
|
m_table->AddTableListener("Value", this, true);
|
|
|
|
|
}
|
2013-12-15 18:30:16 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void PWM::StopLiveWindowMode() {
|
2015-06-25 15:07:55 -04:00
|
|
|
SetSpeed(0);
|
2015-06-23 04:49:51 -07:00
|
|
|
if (m_table != nullptr) {
|
2015-06-25 15:07:55 -04:00
|
|
|
m_table->RemoveTableListener(this);
|
|
|
|
|
}
|
2013-12-15 18:30:16 -05:00
|
|
|
}
|
|
|
|
|
|
2015-06-25 15:07:55 -04:00
|
|
|
std::string PWM::GetSmartDashboardType() const { return "Speed Controller"; }
|
2013-12-15 18:30:16 -05:00
|
|
|
|
2015-07-29 16:48:04 -04:00
|
|
|
void PWM::InitTable(std::shared_ptr<ITable> subTable) {
|
2015-06-25 15:07:55 -04:00
|
|
|
m_table = subTable;
|
|
|
|
|
UpdateTable();
|
2013-12-15 18:30:16 -05:00
|
|
|
}
|
|
|
|
|
|
2015-07-29 16:48:04 -04:00
|
|
|
std::shared_ptr<ITable> PWM::GetTable() const { return m_table; }
|