WPILibC++  2018.4.1-20180920141831-1187-gd2a5aaa
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Modules Pages
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 "frc/ErrorBase.h"
13 #include "frc/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
WPILib FRC namespace.
Definition: SPIAccelerometerSim.h:18
void EnablePWM(double initialDutyCycle)
Enable a PWM Output on this line.
bool IsPulsing() const
Determine if the pulse is still going.
bool Get() const
Gets the value being output from the Digital Output.
void UpdateDutyCycle(double dutyCycle)
Change the duty-cycle that is being generated on the line.
DigitalOutput(int channel)
Create an instance of a digital output.
void SetPWMRate(double rate)
Change the PWM frequency of the PWM output on a Digital Output line.
void DisablePWM()
Change this line from a PWM output back to a static Digital Output line.
void InitSendable(SendableBuilder &builder) override
Initializes this Sendable object.
void Set(bool value)
Set the value of a digital output.
Base class for most objects.
Definition: ErrorBase.h:74
Definition: SendableBase.h:19
Class to write to digital outputs.
Definition: DigitalOutput.h:24
Definition: SendableBuilder.h:23
void Pulse(double length)
Output a single pulse on the digital output line.
int GetChannel() const