13 #include "HAL/Types.h"
14 #include "LiveWindow/LiveWindowSendable.h"
15 #include "SensorBase.h"
16 #include "tables/ITableListener.h"
41 enum PeriodMultiplier {
42 kPeriodMultiplier_1X = 1,
43 kPeriodMultiplier_2X = 2,
44 kPeriodMultiplier_4X = 4
47 explicit PWM(
int channel);
49 virtual void SetRaw(uint16_t value);
50 virtual uint16_t
GetRaw()
const;
59 void SetBounds(
double max,
double deadbandMax,
double center,
60 double deadbandMin,
double min);
61 void SetRawBounds(
int max,
int deadbandMax,
int center,
int deadbandMin,
63 void GetRawBounds(int32_t* max, int32_t* deadbandMax, int32_t* center,
64 int32_t* deadbandMin, int32_t* min);
65 int GetChannel()
const {
return m_channel; }
69 std::shared_ptr<nt::Value> value,
bool isNew)
override;
74 void InitTable(std::shared_ptr<ITable> subTable)
override;
75 std::shared_ptr<ITable>
GetTable()
const override;
77 std::shared_ptr<ITable> m_table;
81 HAL_DigitalHandle m_handle;
virtual ~PWM()
Free the PWM channel.
Definition: PWM.cpp:63
A table whose values can be read and written to.
Definition: ITable.h:22
void SetBounds(double max, double deadbandMax, double center, double deadbandMin, double min)
Set the bounds on the PWM pulse widths.
Definition: PWM.cpp:103
Live Window Sendable is a special type of object sendable to the live window.
Definition: LiveWindowSendable.h:17
Base class for all sensors.
Definition: SensorBase.h:22
void InitTable(std::shared_ptr< ITable > subTable) override
Initializes a table for this sendable object.
Definition: PWM.cpp:341
void GetRawBounds(int32_t *max, int32_t *deadbandMax, int32_t *center, int32_t *deadbandMin, int32_t *min)
Get the bounds on the PWM values.
Definition: PWM.cpp:147
virtual void SetSpeed(double speed)
Set the PWM value based on a speed.
Definition: PWM.cpp:203
void UpdateTable() override
Update the table for this sendable object with the latest values.
Definition: PWM.cpp:319
virtual double GetSpeed() const
Get the PWM value in terms of speed.
Definition: PWM.cpp:222
void StopLiveWindowMode() override
Stop having this sendable object automatically respond to value changes.
Definition: PWM.cpp:332
PWM(int channel)
Allocate a PWM given a channel number.
Definition: PWM.cpp:28
void SetRawBounds(int max, int deadbandMax, int center, int deadbandMin, int min)
Set the bounds on the PWM values.
Definition: PWM.cpp:125
void ValueChanged(ITable *source, llvm::StringRef key, std::shared_ptr< nt::Value > value, bool isNew) override
Called when a key-value pair is changed in a ITable.
Definition: PWM.cpp:313
void EnableDeadbandElimination(bool eliminateDeadband)
Optionally eliminate the deadband from a speed controller.
Definition: PWM.cpp:83
virtual uint16_t GetRaw() const
Get the PWM value directly from the hardware.
Definition: PWM.cpp:252
A listener that listens to changes in values in a ITable.
Definition: ITableListener.h:18
std::shared_ptr< ITable > GetTable() const override
Definition: PWM.cpp:346
void SetPeriodMultiplier(PeriodMultiplier mult)
Slow down the PWM signal for old devices.
Definition: PWM.cpp:267
virtual double GetPosition() const
Get the PWM value in terms of a position.
Definition: PWM.cpp:182
virtual void SetRaw(uint16_t value)
Set the PWM value directly to the hardware.
Definition: PWM.cpp:237
virtual void SetPosition(double pos)
Set the PWM value based on a position.
Definition: PWM.cpp:165
Class implements the PWM generation in the FPGA.
Definition: PWM.h:37
std::string GetSmartDashboardType() const override
Definition: PWM.cpp:339
virtual void SetDisabled()
Temporarily disables the PWM output.
Definition: PWM.cpp:295
void StartLiveWindowMode() override
Start having this sendable object automatically respond to value changes reflect the value on the tab...
Definition: PWM.cpp:325