WPILibC++  unspecified
DigitalOutput.h
1 /*----------------------------------------------------------------------------*/
2 /* Copyright (c) 2008-2018 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 <HAL/Types.h>
11 
12 #include "ErrorBase.h"
13 #include "SmartDashboard/SendableBase.h"
14 
15 namespace frc {
16 
24 class DigitalOutput : public ErrorBase, public SendableBase {
25  public:
34  explicit DigitalOutput(int channel);
35 
36  ~DigitalOutput() override;
37 
45  void Set(bool value);
46 
52  bool Get() const;
53 
57  int GetChannel() const;
58 
67  void Pulse(double length);
68 
74  bool IsPulsing() const;
75 
86  void SetPWMRate(double rate);
87 
101  void EnablePWM(double initialDutyCycle);
102 
108  void DisablePWM();
109 
118  void UpdateDutyCycle(double dutyCycle);
119 
120  void InitSendable(SendableBuilder& builder) override;
121 
122  private:
123  int m_channel;
124  HAL_DigitalHandle m_handle;
125  HAL_DigitalPWMHandle m_pwmGenerator;
126 };
127 
128 } // namespace frc
Definition: Utility.cpp:119
bool IsPulsing() const
Determine if the pulse is still going.
Definition: DigitalOutput.cpp:81
void EnablePWM(double initialDutyCycle)
Enable a PWM Output on this line.
Definition: DigitalOutput.cpp:98
DigitalOutput(int channel)
Create an instance of a digital output.
Definition: DigitalOutput.cpp:22
void Set(bool value)
Set the value of a digital output.
Definition: DigitalOutput.cpp:54
int GetChannel() const
Definition: DigitalOutput.cpp:71
void SetPWMRate(double rate)
Change the PWM frequency of the PWM output on a Digital Output line.
Definition: DigitalOutput.cpp:90
void DisablePWM()
Change this line from a PWM output back to a static Digital Output line.
Definition: DigitalOutput.cpp:116
void Pulse(double length)
Output a single pulse on the digital output line.
Definition: DigitalOutput.cpp:73
Base class for most objects.
Definition: ErrorBase.h:74
Definition: SendableBase.h:19
Class to write to digital outputs.
Definition: DigitalOutput.h:24
void InitSendable(SendableBuilder &builder) override
Initializes this Sendable object.
Definition: DigitalOutput.cpp:141
bool Get() const
Gets the value being output from the Digital Output.
Definition: DigitalOutput.cpp:62
void UpdateDutyCycle(double dutyCycle)
Change the duty-cycle that is being generated on the line.
Definition: DigitalOutput.cpp:133
Definition: SendableBuilder.h:23