Parker Schuh | d3b7a887 | 2018-02-19 16:42:27 -0800 | [diff] [blame] | 1 | /*----------------------------------------------------------------------------*/ |
| 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 Schuh | f6b9463 | 2019-02-02 22:11:27 -0800 | [diff] [blame] | 13 | #include "hal/Types.h" |
Parker Schuh | d3b7a887 | 2018-02-19 16:42:27 -0800 | [diff] [blame] | 14 | #include "frc971/wpilib/ahal/DigitalSource.h" |
| 15 | |
| 16 | namespace 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 | */ |
| 24 | class 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 |