WPILibC++  unspecified
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Pages
DigitalOutput.h
1 /*----------------------------------------------------------------------------*/
2 /* Copyright (c) FIRST 2008-2017. 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 <memory>
11 #include <string>
12 
13 #include "DigitalSource.h"
14 #include "HAL/Types.h"
15 #include "LiveWindow/LiveWindowSendable.h"
16 #include "tables/ITableListener.h"
17 
18 namespace frc {
19 
27  public ITableListener,
28  public LiveWindowSendable {
29  public:
30  explicit DigitalOutput(int channel);
31  virtual ~DigitalOutput();
32  void Set(bool value);
33  bool Get() const;
34  int GetChannel() const override;
35  void Pulse(double length);
36  bool IsPulsing() const;
37  void SetPWMRate(double rate);
38  void EnablePWM(double initialDutyCycle);
39  void DisablePWM();
40  void UpdateDutyCycle(double dutyCycle);
41 
42  // Digital Source Interface
43  HAL_Handle GetPortHandleForRouting() const override;
44  AnalogTriggerType GetAnalogTriggerTypeForRouting() const override;
45  bool IsAnalogTrigger() const override;
46 
47  void ValueChanged(ITable* source, llvm::StringRef key,
48  std::shared_ptr<nt::Value> value, bool isNew) override;
49  void UpdateTable();
50  void StartLiveWindowMode();
51  void StopLiveWindowMode();
52  std::string GetSmartDashboardType() const;
53  void InitTable(std::shared_ptr<ITable> subTable);
54  std::shared_ptr<ITable> GetTable() const;
55 
56  private:
57  int m_channel;
58  HAL_DigitalHandle m_handle;
59  HAL_DigitalPWMHandle m_pwmGenerator;
60 
61  std::shared_ptr<ITable> m_table;
62 };
63 
64 } // namespace frc
A table whose values can be read and written to.
Definition: ITable.h:22
bool IsPulsing() const
Determine if the pulse is still going.
Definition: DigitalOutput.cpp:122
void InitTable(std::shared_ptr< ITable > subTable)
Initializes a table for this sendable object.
Definition: DigitalOutput.cpp:258
Live Window Sendable is a special type of object sendable to the live window.
Definition: LiveWindowSendable.h:17
std::string GetSmartDashboardType() const
Definition: DigitalOutput.cpp:254
void EnablePWM(double initialDutyCycle)
Enable a PWM Output on this line.
Definition: DigitalOutput.cpp:162
void UpdateTable()
Update the table for this sendable object with the latest values.
Definition: DigitalOutput.cpp:240
DigitalOutput(int channel)
Create an instance of a digital output.
Definition: DigitalOutput.cpp:29
AnalogTriggerType GetAnalogTriggerTypeForRouting() const override
Definition: DigitalOutput.cpp:230
void StopLiveWindowMode()
Stop having this sendable object automatically respond to value changes.
Definition: DigitalOutput.cpp:248
void Set(bool value)
Set the value of a digital output.
Definition: DigitalOutput.cpp:74
bool IsAnalogTrigger() const override
Is source an AnalogTrigger.
Definition: DigitalOutput.cpp:225
int GetChannel() const override
Definition: DigitalOutput.cpp:99
void SetPWMRate(double rate)
Change the PWM frequency of the PWM output on a Digital Output line.
Definition: DigitalOutput.cpp:141
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: DigitalOutput.cpp:234
void DisablePWM()
Change this line from a PWM output back to a static Digital Output line.
Definition: DigitalOutput.cpp:185
DigitalSource Interface.
Definition: DigitalSource.h:25
A listener that listens to changes in values in a ITable.
Definition: ITableListener.h:18
std::shared_ptr< ITable > GetTable() const
Definition: DigitalOutput.cpp:263
void Pulse(double length)
Output a single pulse on the digital output line.
Definition: DigitalOutput.cpp:109
virtual ~DigitalOutput()
Free the resources associated with a digital output.
Definition: DigitalOutput.cpp:58
Class to write to digital outputs.
Definition: DigitalOutput.h:26
bool Get() const
Gets the value being output from the Digital Output.
Definition: DigitalOutput.cpp:87
void UpdateDutyCycle(double dutyCycle)
Change the duty-cycle that is being generated on the line.
Definition: DigitalOutput.cpp:209
void StartLiveWindowMode()
Start having this sendable object automatically respond to value changes reflect the value on the tab...
Definition: DigitalOutput.cpp:242
HAL_Handle GetPortHandleForRouting() const override
Definition: DigitalOutput.cpp:220