WPILibC++  unspecified
DigitalOutput.h
1 /*----------------------------------------------------------------------------*/
2 /* Copyright (c) 2008-2017 FIRST. 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 <HAL/Types.h>
14 
15 #include "DigitalSource.h"
16 #include "LiveWindow/LiveWindowSendable.h"
17 #include "networktables/NetworkTableEntry.h"
18 
19 namespace frc {
20 
28  public:
29  explicit DigitalOutput(int channel);
30  virtual ~DigitalOutput();
31  void Set(bool value);
32  bool Get() const;
33  int GetChannel() const override;
34  void Pulse(double length);
35  bool IsPulsing() const;
36  void SetPWMRate(double rate);
37  void EnablePWM(double initialDutyCycle);
38  void DisablePWM();
39  void UpdateDutyCycle(double dutyCycle);
40 
41  // Digital Source Interface
42  HAL_Handle GetPortHandleForRouting() const override;
43  AnalogTriggerType GetAnalogTriggerTypeForRouting() const override;
44  bool IsAnalogTrigger() const override;
45 
46  void UpdateTable() override;
47  void StartLiveWindowMode() override;
48  void StopLiveWindowMode() override;
49  std::string GetSmartDashboardType() const override;
50  void InitTable(std::shared_ptr<nt::NetworkTable> subTable) override;
51 
52  private:
53  int m_channel;
54  HAL_DigitalHandle m_handle;
55  HAL_DigitalPWMHandle m_pwmGenerator;
56 
57  nt::NetworkTableEntry m_valueEntry;
58  NT_EntryListener m_valueListener = 0;
59 };
60 
61 } // namespace frc
Definition: Timer.cpp:18
bool IsPulsing() const
Determine if the pulse is still going.
Definition: DigitalOutput.cpp:123
Live Window Sendable is a special type of object sendable to the live window.
Definition: LiveWindowSendable.h:17
void EnablePWM(double initialDutyCycle)
Enable a PWM Output on this line.
Definition: DigitalOutput.cpp:163
void UpdateTable() override
Update the table for this sendable object with the latest values.
Definition: DigitalOutput.cpp:235
DigitalOutput(int channel)
Create an instance of a digital output.
Definition: DigitalOutput.cpp:30
AnalogTriggerType GetAnalogTriggerTypeForRouting() const override
Definition: DigitalOutput.cpp:231
void InitTable(std::shared_ptr< nt::NetworkTable > subTable) override
Initializes a table for this sendable object.
Definition: DigitalOutput.cpp:259
void Set(bool value)
Set the value of a digital output.
Definition: DigitalOutput.cpp:75
bool IsAnalogTrigger() const override
Is source an AnalogTrigger.
Definition: DigitalOutput.cpp:226
int GetChannel() const override
Definition: DigitalOutput.cpp:100
void SetPWMRate(double rate)
Change the PWM frequency of the PWM output on a Digital Output line.
Definition: DigitalOutput.cpp:142
void DisablePWM()
Change this line from a PWM output back to a static Digital Output line.
Definition: DigitalOutput.cpp:186
std::string GetSmartDashboardType() const override
Definition: DigitalOutput.cpp:255
DigitalSource Interface.
Definition: DigitalSource.h:26
void StopLiveWindowMode() override
Stop having this sendable object automatically respond to value changes.
Definition: DigitalOutput.cpp:248
void Pulse(double length)
Output a single pulse on the digital output line.
Definition: DigitalOutput.cpp:110
virtual ~DigitalOutput()
Free the resources associated with a digital output.
Definition: DigitalOutput.cpp:59
Class to write to digital outputs.
Definition: DigitalOutput.h:27
bool Get() const
Gets the value being output from the Digital Output.
Definition: DigitalOutput.cpp:88
void UpdateDutyCycle(double dutyCycle)
Change the duty-cycle that is being generated on the line.
Definition: DigitalOutput.cpp:210
NetworkTables Entry.
Definition: NetworkTableEntry.h:30
void StartLiveWindowMode() override
Start having this sendable object automatically respond to value changes reflect the value on the tab...
Definition: DigitalOutput.cpp:237
HAL_Handle GetPortHandleForRouting() const override
Definition: DigitalOutput.cpp:221