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:
26  explicit DigitalOutput(int channel);
27  ~DigitalOutput() override;
28  void Set(bool value);
29  bool Get() const;
30  int GetChannel() const;
31  void Pulse(double length);
32  bool IsPulsing() const;
33  void SetPWMRate(double rate);
34  void EnablePWM(double initialDutyCycle);
35  void DisablePWM();
36  void UpdateDutyCycle(double dutyCycle);
37 
38  void InitSendable(SendableBuilder& builder) override;
39 
40  private:
41  int m_channel;
42  HAL_DigitalHandle m_handle;
43  HAL_DigitalPWMHandle m_pwmGenerator;
44 };
45 
46 } // namespace frc
~DigitalOutput() override
Free the resources associated with a digital output.
Definition: DigitalOutput.cpp:57
Definition: RobotController.cpp:14
bool IsPulsing() const
Determine if the pulse is still going.
Definition: DigitalOutput.cpp:120
void EnablePWM(double initialDutyCycle)
Enable a PWM Output on this line.
Definition: DigitalOutput.cpp:160
DigitalOutput(int channel)
Create an instance of a digital output.
Definition: DigitalOutput.cpp:30
void Set(bool value)
Set the value of a digital output.
Definition: DigitalOutput.cpp:72
int GetChannel() const
Definition: DigitalOutput.cpp:97
void SetPWMRate(double rate)
Change the PWM frequency of the PWM output on a Digital Output line.
Definition: DigitalOutput.cpp:139
void DisablePWM()
Change this line from a PWM output back to a static Digital Output line.
Definition: DigitalOutput.cpp:183
void Pulse(double length)
Output a single pulse on the digital output line.
Definition: DigitalOutput.cpp:107
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:216
bool Get() const
Gets the value being output from the Digital Output.
Definition: DigitalOutput.cpp:85
void UpdateDutyCycle(double dutyCycle)
Change the duty-cycle that is being generated on the line.
Definition: DigitalOutput.cpp:208
Definition: SendableBuilder.h:23