blob: c6139ce6a6cc9e4c1d1338cf4109c6527fea4c36 [file] [log] [blame]
Parker Schuhd3b7a8872018-02-19 16:42:27 -08001/*----------------------------------------------------------------------------*/
2/* Copyright (c) FIRST 2008-2017. 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 <memory>
11#include <string>
12
Austin Schuhf6b94632019-02-02 22:11:27 -080013#include "hal/Types.h"
Parker Schuhd3b7a8872018-02-19 16:42:27 -080014#include "frc971/wpilib/ahal/DigitalSource.h"
15
16namespace frc {
17
18/**
19 * Class to write to digital outputs.
20 * Write values to the digital output channels. Other devices implemented
21 * elsewhere will allocate channels automatically so for those devices it
22 * shouldn't be done here.
23 */
24class DigitalOutput : public DigitalSource {
25 public:
26 explicit DigitalOutput(int channel);
27 virtual ~DigitalOutput();
28 void Set(bool value);
29 bool Get() const;
30 int GetChannel() const override;
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 // Digital Source Interface
39 HAL_Handle GetPortHandleForRouting() const override;
40 AnalogTriggerType GetAnalogTriggerTypeForRouting() const override;
41 bool IsAnalogTrigger() const override;
42
43 private:
44 int m_channel;
45 HAL_DigitalHandle m_handle;
46 HAL_DigitalPWMHandle m_pwmGenerator;
47};
48
49} // namespace frc