10 #include "SensorBase.h"
11 #include "LiveWindow/LiveWindowSendable.h"
12 #include "tables/ITableListener.h"
32 class PWM :
public SensorBase,
public ITableListener,
public LiveWindowSendable
36 typedef enum {kPeriodMultiplier_1X = 1, kPeriodMultiplier_2X = 2, kPeriodMultiplier_4X = 4} PeriodMultiplier;
38 explicit PWM(uint32_t channel);
39 PWM(uint8_t moduleNumber, uint32_t channel);
41 virtual void SetRaw(uint8_t value);
45 void SetBounds(int32_t max, int32_t deadbandMax, int32_t center, int32_t deadbandMin, int32_t min);
46 void SetBounds(
double max,
double deadbandMax,
double center,
double deadbandMin,
double min);
47 uint32_t GetChannel() {
return m_channel;}
48 uint32_t GetModuleNumber();
76 static const int32_t kPwmDisabled = 0;
83 bool m_eliminateDeadband;
85 int32_t m_deadbandMaxPwm;
87 int32_t m_deadbandMinPwm;
90 void ValueChanged(ITable* source,
const std::string& key, EntryValue value,
bool isNew);
92 void StartLiveWindowMode();
93 void StopLiveWindowMode();
94 std::string GetSmartDashboardType();
95 void InitTable(ITable *subTable);
101 void InitPWM(uint8_t moduleNumber, uint32_t channel);
104 int32_t GetMaxPositivePwm() {
return m_maxPwm; };
105 int32_t GetMinPositivePwm() {
return m_eliminateDeadband ? m_deadbandMaxPwm : m_centerPwm + 1; };
106 int32_t GetCenterPwm() {
return m_centerPwm; };
107 int32_t GetMaxNegativePwm() {
return m_eliminateDeadband ? m_deadbandMinPwm : m_centerPwm - 1; };
108 int32_t GetMinNegativePwm() {
return m_minPwm; };
109 int32_t GetPositiveScaleFactor() {
return GetMaxPositivePwm() - GetMinPositivePwm();}
110 int32_t GetNegativeScaleFactor() {
return GetMaxNegativePwm() - GetMinNegativePwm();}
111 int32_t GetFullRangeScaleFactor() {
return GetMaxPositivePwm() - GetMinNegativePwm();}
static const int32_t kDefaultPwmStepsDown
Definition: PWM.h:75
virtual float GetPosition()
Definition: PWM.cpp:205
PWM(uint32_t channel)
Definition: PWM.cpp:81
Definition: SensorBase.h:20
static constexpr float kDefaultPwmCenter
Definition: PWM.h:71
virtual ~PWM()
Definition: PWM.cpp:92
virtual void SetPosition(float pos)
Definition: PWM.cpp:172
virtual void SetRaw(uint8_t value)
Definition: PWM.cpp:323
virtual float GetSpeed()
Definition: PWM.cpp:286
virtual uint8_t GetRaw()
Definition: PWM.cpp:336
void SetBounds(int32_t max, int32_t deadbandMax, int32_t center, int32_t deadbandMin, int32_t min)
Definition: PWM.cpp:123
static constexpr float kDefaultPwmPeriod
Definition: PWM.h:67
void EnableDeadbandElimination(bool eliminateDeadband)
Definition: PWM.cpp:107
virtual void SetSpeed(float speed)
Definition: PWM.cpp:236
void SetPeriodMultiplier(PeriodMultiplier mult)
Definition: PWM.cpp:347
Definition: DigitalModule.h:17