WPILibC++  unspecified
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Pages
DigitalOutput.h
1 /*----------------------------------------------------------------------------*/
2 /* Copyright (c) FIRST 2008-2016. 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 #pragma once
9 
10 #include "DigitalSource.h"
11 #include "LiveWindow/LiveWindowSendable.h"
12 #include "tables/ITableListener.h"
13 
14 #include <memory>
15 
23  public ITableListener,
24  public LiveWindowSendable {
25  public:
26  explicit DigitalOutput(uint32_t channel);
27  virtual ~DigitalOutput();
28  void Set(uint32_t value);
29  uint32_t GetChannel() const;
30  void Pulse(float length);
31  bool IsPulsing() const;
32  void SetPWMRate(float rate);
33  void EnablePWM(float initialDutyCycle);
34  void DisablePWM();
35  void UpdateDutyCycle(float dutyCycle);
36 
37  // Digital Source Interface
38  virtual uint32_t GetChannelForRouting() const;
39  virtual uint32_t GetModuleForRouting() const;
40  virtual bool GetAnalogTriggerForRouting() const;
41 
42  virtual void ValueChanged(ITable* source, llvm::StringRef key,
43  std::shared_ptr<nt::Value> value, bool isNew);
44  void UpdateTable();
45  void StartLiveWindowMode();
46  void StopLiveWindowMode();
47  std::string GetSmartDashboardType() const;
48  void InitTable(std::shared_ptr<ITable> subTable);
49  std::shared_ptr<ITable> GetTable() const;
50 
51  private:
52  uint32_t m_channel;
53  void *m_pwmGenerator;
54 
55  std::shared_ptr<ITable> m_table;
56 };
A table whose values can be read and written to.
Definition: ITable.h:43
bool IsPulsing() const
Determine if the pulse is still going.
Definition: DigitalOutput.cpp:92
void SetPWMRate(float rate)
Change the PWM frequency of the PWM output on a Digital Output line.
Definition: DigitalOutput.cpp:111
DigitalSource Interface.
Definition: DigitalSource.h:22
Live Window Sendable is a special type of object sendable to the live window.
Definition: LiveWindowSendable.h:18
virtual bool GetAnalogTriggerForRouting() const
Definition: DigitalOutput.cpp:200
Class to write to digital outputs.
Definition: DigitalOutput.h:22
void StopLiveWindowMode()
Stop having this sendable object automatically respond to value changes.
Definition: DigitalOutput.cpp:216
std::shared_ptr< ITable > GetTable() const
Definition: DigitalOutput.cpp:231
void DisablePWM()
Change this line from a PWM output back to a static Digital Output line.
Definition: DigitalOutput.cpp:155
void Pulse(float length)
Output a single pulse on the digital output line.
Definition: DigitalOutput.cpp:80
void StartLiveWindowMode()
Start having this sendable object automatically respond to value changes reflect the value on the tab...
Definition: DigitalOutput.cpp:210
DigitalOutput(uint32_t channel)
Create an instance of a digital output.
Definition: DigitalOutput.cpp:22
void Set(uint32_t value)
Set the value of a digital output.
Definition: DigitalOutput.cpp:60
void UpdateTable()
Update the table for this sendable object with the latest values.
Definition: DigitalOutput.cpp:208
virtual uint32_t GetChannelForRouting() const
Definition: DigitalOutput.cpp:190
void UpdateDutyCycle(float dutyCycle)
Change the duty-cycle that is being generated on the line.
Definition: DigitalOutput.cpp:179
std::string GetSmartDashboardType() const
Definition: DigitalOutput.cpp:222
virtual ~DigitalOutput()
Free the resources associated with a digital output.
Definition: DigitalOutput.cpp:44
virtual uint32_t GetModuleForRouting() const
Definition: DigitalOutput.cpp:195
A listener that listens to changes in values in a ITable.
Definition: ITableListener.h:18
void InitTable(std::shared_ptr< ITable > subTable)
Initializes a table for this sendable object.
Definition: DigitalOutput.cpp:226
void EnablePWM(float initialDutyCycle)
Enable a PWM Output on this line.
Definition: DigitalOutput.cpp:132
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:39
uint32_t GetChannel() const
Definition: DigitalOutput.cpp:71
virtual void ValueChanged(ITable *source, llvm::StringRef key, std::shared_ptr< nt::Value > value, bool isNew)
Called when a key-value pair is changed in a ITable.
Definition: DigitalOutput.cpp:202