WPILibC++  2020.3.2-60-g3011ebe
DigitalOutput.h
1 /*----------------------------------------------------------------------------*/
2 /* Copyright (c) 2008-2019 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/DigitalSource.h"
13 #include "frc/smartdashboard/Sendable.h"
14 #include "frc/smartdashboard/SendableHelper.h"
15 
16 namespace frc {
17 
18 class SendableBuilder;
19 
28  public Sendable,
29  public SendableHelper<DigitalOutput> {
30  public:
39  explicit DigitalOutput(int channel);
40 
41  ~DigitalOutput() override;
42 
43  DigitalOutput(DigitalOutput&&) = default;
44  DigitalOutput& operator=(DigitalOutput&&) = default;
45 
53  void Set(bool value);
54 
60  bool Get() const;
61 
62  // Digital Source Interface
66  HAL_Handle GetPortHandleForRouting() const override;
67 
71  AnalogTriggerType GetAnalogTriggerTypeForRouting() const override;
72 
76  bool IsAnalogTrigger() const override;
77 
81  int GetChannel() const override;
82 
91  void Pulse(double length);
92 
98  bool IsPulsing() const;
99 
110  void SetPWMRate(double rate);
111 
125  void EnablePWM(double initialDutyCycle);
126 
132  void DisablePWM();
133 
142  void UpdateDutyCycle(double dutyCycle);
143 
149  void SetSimDevice(HAL_SimDeviceHandle device);
150 
151  void InitSendable(SendableBuilder& builder) override;
152 
153  private:
154  int m_channel;
155  hal::Handle<HAL_DigitalHandle> m_handle;
156  hal::Handle<HAL_DigitalPWMHandle> m_pwmGenerator;
157 };
158 
159 } // namespace frc
frc::DigitalOutput::GetChannel
int GetChannel() const override
frc::DigitalOutput::DigitalOutput
DigitalOutput(int channel)
Create an instance of a digital output.
frc::DigitalOutput::DisablePWM
void DisablePWM()
Change this line from a PWM output back to a static Digital Output line.
frc::DigitalOutput::Get
bool Get() const
Gets the value being output from the Digital Output.
frc::DigitalOutput
Class to write to digital outputs.
Definition: DigitalOutput.h:27
frc::DigitalOutput::Set
void Set(bool value)
Set the value of a digital output.
frc::DigitalOutput::GetPortHandleForRouting
HAL_Handle GetPortHandleForRouting() const override
frc::DigitalOutput::InitSendable
void InitSendable(SendableBuilder &builder) override
Initializes this Sendable object.
frc::DigitalOutput::EnablePWM
void EnablePWM(double initialDutyCycle)
Enable a PWM Output on this line.
frc::DigitalOutput::SetSimDevice
void SetSimDevice(HAL_SimDeviceHandle device)
Indicates this output is used by a simulated device.
frc::DigitalOutput::Pulse
void Pulse(double length)
Output a single pulse on the digital output line.
frc::DigitalOutput::SetPWMRate
void SetPWMRate(double rate)
Change the PWM frequency of the PWM output on a Digital Output line.
frc::Sendable
Interface for Sendable objects.
Definition: Sendable.h:17
frc::DigitalOutput::GetAnalogTriggerTypeForRouting
AnalogTriggerType GetAnalogTriggerTypeForRouting() const override
frc::DigitalOutput::IsAnalogTrigger
bool IsAnalogTrigger() const override
Is source an AnalogTrigger.
frc
A class that enforces constraints on the differential drive kinematics.
Definition: PDPSim.h:16
frc::DigitalOutput::IsPulsing
bool IsPulsing() const
Determine if the pulse is still going.
frc::DigitalOutput::UpdateDutyCycle
void UpdateDutyCycle(double dutyCycle)
Change the duty-cycle that is being generated on the line.
frc::DigitalSource
DigitalSource Interface.
Definition: DigitalSource.h:25
frc::SendableHelper
A helper class for use with objects that add themselves to SendableRegistry.
Definition: SendableHelper.h:28
frc::SendableBuilder
Definition: SendableBuilder.h:23