2013-12-15 18:30:16 -05:00
|
|
|
/*----------------------------------------------------------------------------*/
|
2017-01-01 01:05:57 -07:00
|
|
|
/* Copyright (c) FIRST 2008-2017. 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
|
|
|
/*----------------------------------------------------------------------------*/
|
|
|
|
|
|
2016-12-21 21:55:31 -08:00
|
|
|
#include "HAL/PWM.h"
|
2013-12-15 18:30:16 -05:00
|
|
|
#include "PWM.h"
|
|
|
|
|
|
2016-09-05 13:55:31 -07:00
|
|
|
#include <sstream>
|
|
|
|
|
|
2016-05-22 21:41:22 -07:00
|
|
|
#include "HAL/HAL.h"
|
2016-12-21 21:55:31 -08:00
|
|
|
#include "HAL/Ports.h"
|
2013-12-15 18:30:16 -05:00
|
|
|
#include "Utility.h"
|
|
|
|
|
#include "WPIErrors.h"
|
|
|
|
|
|
2016-11-01 22:33:12 -07:00
|
|
|
using namespace frc;
|
|
|
|
|
|
2013-12-15 18:30:16 -05:00
|
|
|
/**
|
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
|
|
|
*/
|
2016-09-06 00:01:45 -07:00
|
|
|
PWM::PWM(int 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-07-09 00:24:26 -07:00
|
|
|
m_handle = HAL_InitializePWMPort(HAL_GetPort(channel), &status);
|
2016-06-30 21:39:09 -07:00
|
|
|
if (status != 0) {
|
2016-08-12 13:45:28 -07:00
|
|
|
wpi_setErrorWithContextRange(status, 0, HAL_GetNumPWMChannels(), channel,
|
2016-07-13 20:29:28 -07:00
|
|
|
HAL_GetErrorMessage(status));
|
2016-09-06 00:01:45 -07:00
|
|
|
m_channel = std::numeric_limits<int>::max();
|
2016-07-09 00:24:26 -07:00
|
|
|
m_handle = HAL_kInvalidHandle;
|
2016-07-08 21:29:29 -07:00
|
|
|
return;
|
2016-06-30 21:39:09 -07:00
|
|
|
}
|
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-07-09 00:24:26 -07:00
|
|
|
HAL_SetPWMDisabled(m_handle, &status);
|
|
|
|
|
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
2016-07-08 21:29:29 -07:00
|
|
|
status = 0;
|
2016-07-09 00:24:26 -07:00
|
|
|
HAL_SetPWMEliminateDeadband(m_handle, false, &status);
|
|
|
|
|
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
2013-12-15 18:30:16 -05:00
|
|
|
|
2016-07-09 00:24:26 -07:00
|
|
|
HAL_Report(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-07-09 00:24:26 -07:00
|
|
|
HAL_SetPWMDisabled(m_handle, &status);
|
|
|
|
|
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
2014-07-21 16:32:36 -04:00
|
|
|
|
2016-07-09 00:24:26 -07:00
|
|
|
HAL_FreePWMPort(m_handle, &status);
|
|
|
|
|
wpi_setErrorWithContext(status, HAL_GetErrorMessage(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;
|
2016-07-08 21:29:29 -07:00
|
|
|
int32_t status = 0;
|
2016-07-09 00:24:26 -07:00
|
|
|
HAL_SetPWMEliminateDeadband(m_handle, eliminateDeadband, &status);
|
|
|
|
|
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
2016-07-08 21:29:29 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Set the bounds on the PWM pulse widths.
|
|
|
|
|
*
|
|
|
|
|
* This sets the bounds on the PWM values for a particular type of controller.
|
|
|
|
|
* The values determine the upper and lower speeds as well as the deadband
|
|
|
|
|
* bracket.
|
|
|
|
|
*
|
|
|
|
|
* @param max The max PWM pulse width in ms
|
|
|
|
|
* @param deadbandMax The high end of the deadband range pulse width in ms
|
|
|
|
|
* @param center The center (off) pulse width in ms
|
|
|
|
|
* @param deadbandMin The low end of the deadband pulse width in ms
|
|
|
|
|
* @param min The minimum pulse width in ms
|
|
|
|
|
*/
|
2016-11-20 07:25:03 -08:00
|
|
|
void PWM::SetBounds(double max, double deadbandMax, double center,
|
|
|
|
|
double deadbandMin, double min) {
|
2016-07-08 21:29:29 -07:00
|
|
|
if (StatusIsFatal()) return;
|
|
|
|
|
int32_t status = 0;
|
2016-07-09 00:24:26 -07:00
|
|
|
HAL_SetPWMConfig(m_handle, max, deadbandMax, center, deadbandMin, min,
|
|
|
|
|
&status);
|
|
|
|
|
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
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
|
|
|
*/
|
2016-09-06 00:01:45 -07:00
|
|
|
void PWM::SetRawBounds(int max, int deadbandMax, int center, int deadbandMin,
|
|
|
|
|
int min) {
|
2015-06-25 15:07:55 -04:00
|
|
|
if (StatusIsFatal()) return;
|
2016-07-08 21:29:29 -07:00
|
|
|
int32_t status = 0;
|
2016-07-09 00:24:26 -07:00
|
|
|
HAL_SetPWMConfigRaw(m_handle, max, deadbandMax, center, deadbandMin, min,
|
|
|
|
|
&status);
|
|
|
|
|
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
2013-12-15 18:30:16 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2016-07-08 21:29:29 -07:00
|
|
|
* Get the bounds on the PWM values.
|
2016-05-20 17:30:37 -07:00
|
|
|
*
|
2016-07-08 21:29:29 -07:00
|
|
|
* This Gets the bounds on the PWM values for a particular each type of
|
|
|
|
|
* controller. The values determine the upper and lower speeds as well as the
|
|
|
|
|
* deadband bracket.
|
2016-05-20 17:30:37 -07:00
|
|
|
*
|
2016-07-08 21:29:29 -07:00
|
|
|
* @param max The Minimum pwm value
|
|
|
|
|
* @param deadbandMax The high end of the deadband range
|
|
|
|
|
* @param center The center speed (off)
|
|
|
|
|
* @param deadbandMin The low end of the deadband range
|
|
|
|
|
* @param min The minimum pwm value
|
2013-12-15 18:30:16 -05:00
|
|
|
*/
|
2016-09-06 00:01:45 -07:00
|
|
|
void PWM::GetRawBounds(int* max, int* deadbandMax, int* center,
|
|
|
|
|
int* deadbandMin, int* min) {
|
2015-06-25 15:07:55 -04:00
|
|
|
int32_t status = 0;
|
2016-07-09 00:24:26 -07:00
|
|
|
HAL_GetPWMConfigRaw(m_handle, max, deadbandMax, center, deadbandMin, min,
|
|
|
|
|
&status);
|
|
|
|
|
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
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.
|
|
|
|
|
*/
|
2016-11-20 07:25:03 -08:00
|
|
|
void PWM::SetPosition(double pos) {
|
2015-06-25 15:07:55 -04:00
|
|
|
if (StatusIsFatal()) return;
|
2016-07-08 21:29:29 -07:00
|
|
|
int32_t status = 0;
|
2016-07-09 00:24:26 -07:00
|
|
|
HAL_SetPWMPosition(m_handle, pos, &status);
|
|
|
|
|
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
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.
|
|
|
|
|
*/
|
2016-11-20 07:25:03 -08:00
|
|
|
double PWM::GetPosition() const {
|
2015-06-25 15:07:55 -04:00
|
|
|
if (StatusIsFatal()) return 0.0;
|
2016-07-08 21:29:29 -07:00
|
|
|
int32_t status = 0;
|
2016-11-20 07:25:03 -08:00
|
|
|
double position = HAL_GetPWMPosition(m_handle, &status);
|
2016-07-09 00:24:26 -07:00
|
|
|
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
2016-07-08 21:29:29 -07:00
|
|
|
return position;
|
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.
|
|
|
|
|
*/
|
2016-11-20 07:25:03 -08:00
|
|
|
void PWM::SetSpeed(double speed) {
|
2015-06-25 15:07:55 -04:00
|
|
|
if (StatusIsFatal()) return;
|
2016-07-08 21:29:29 -07:00
|
|
|
int32_t status = 0;
|
2016-07-09 00:24:26 -07:00
|
|
|
HAL_SetPWMSpeed(m_handle, speed, &status);
|
|
|
|
|
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
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.
|
|
|
|
|
*/
|
2016-11-20 07:25:03 -08:00
|
|
|
double PWM::GetSpeed() const {
|
2015-06-25 15:07:55 -04:00
|
|
|
if (StatusIsFatal()) return 0.0;
|
2016-07-08 21:29:29 -07:00
|
|
|
int32_t status = 0;
|
2016-11-20 07:25:03 -08:00
|
|
|
double speed = HAL_GetPWMSpeed(m_handle, &status);
|
2016-07-09 00:24:26 -07:00
|
|
|
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
2016-07-08 21:29:29 -07:00
|
|
|
return speed;
|
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
|
|
|
*/
|
2016-07-10 17:47:44 -07:00
|
|
|
void PWM::SetRaw(uint16_t value) {
|
2015-06-25 15:07:55 -04:00
|
|
|
if (StatusIsFatal()) return;
|
2014-07-21 16:32:36 -04:00
|
|
|
|
2015-06-25 15:07:55 -04:00
|
|
|
int32_t status = 0;
|
2016-07-09 00:24:26 -07:00
|
|
|
HAL_SetPWMRaw(m_handle, value, &status);
|
|
|
|
|
wpi_setErrorWithContext(status, HAL_GetErrorMessage(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
|
|
|
*/
|
2016-07-10 17:47:44 -07:00
|
|
|
uint16_t PWM::GetRaw() const {
|
2015-06-25 15:07:55 -04:00
|
|
|
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-07-10 17:47:44 -07:00
|
|
|
uint16_t value = HAL_GetPWMRaw(m_handle, &status);
|
2016-07-09 00:24:26 -07:00
|
|
|
wpi_setErrorWithContext(status, HAL_GetErrorMessage(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-07-09 00:24:26 -07:00
|
|
|
HAL_SetPWMPeriodScale(m_handle, 3,
|
|
|
|
|
&status); // Squelch 3 out of 4 outputs
|
2015-06-25 15:07:55 -04:00
|
|
|
break;
|
|
|
|
|
case kPeriodMultiplier_2X:
|
2016-07-09 00:24:26 -07:00
|
|
|
HAL_SetPWMPeriodScale(m_handle, 1,
|
|
|
|
|
&status); // Squelch 1 out of 2 outputs
|
2015-06-25 15:07:55 -04:00
|
|
|
break;
|
|
|
|
|
case kPeriodMultiplier_1X:
|
2016-07-09 00:24:26 -07:00
|
|
|
HAL_SetPWMPeriodScale(m_handle, 0, &status); // Don't squelch any outputs
|
2015-06-25 15:07:55 -04:00
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
wpi_assert(false);
|
|
|
|
|
}
|
|
|
|
|
|
2016-07-09 00:24:26 -07:00
|
|
|
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
2016-07-08 21:29:29 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Temporarily disables the PWM output. The next set call will reenable
|
|
|
|
|
* the output.
|
|
|
|
|
*/
|
|
|
|
|
void PWM::SetDisabled() {
|
|
|
|
|
if (StatusIsFatal()) return;
|
|
|
|
|
|
|
|
|
|
int32_t status = 0;
|
|
|
|
|
|
2016-07-09 00:24:26 -07:00
|
|
|
HAL_SetPWMDisabled(m_handle, &status);
|
|
|
|
|
wpi_setErrorWithContext(status, HAL_GetErrorMessage(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-07-09 00:24:26 -07:00
|
|
|
HAL_LatchPWMZero(m_handle, &status);
|
|
|
|
|
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
2015-06-25 15:07:55 -04:00
|
|
|
}
|
|
|
|
|
|
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; }
|