WPILibC++  2019.1.1-beta-2-2-gf54c0f7
 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 
39  DigitalOutput& operator=(DigitalOutput&& rhs);
40 
48  void Set(bool value);
49 
55  bool Get() const;
56 
60  int GetChannel() const;
61 
70  void Pulse(double length);
71 
77  bool IsPulsing() const;
78 
89  void SetPWMRate(double rate);
90 
104  void EnablePWM(double initialDutyCycle);
105 
111  void DisablePWM();
112 
121  void UpdateDutyCycle(double dutyCycle);
122 
123  void InitSendable(SendableBuilder& builder) override;
124 
125  private:
126  int m_channel;
127  HAL_DigitalHandle m_handle = HAL_kInvalidHandle;
128  HAL_DigitalPWMHandle m_pwmGenerator = HAL_kInvalidHandle;
129 };
130 
131 } // 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