WPILib 2012
WPILibRoboticsLibraryforFRC
|
00001 /*----------------------------------------------------------------------------*/ 00002 /* Copyright (c) FIRST 2008. All Rights Reserved. */ 00003 /* Open Source Software - may be modified and shared by FRC teams. The code */ 00004 /* must be accompanied by the FIRST BSD license file in $(WIND_BASE)/WPILib. */ 00005 /*----------------------------------------------------------------------------*/ 00006 00007 #ifndef DIGITAL_OUTPUT_H_ 00008 #define DIGITAL_OUTPUT_H_ 00009 00010 #include "DigitalSource.h" 00011 00012 class DigitalModule; 00013 00019 class DigitalOutput : public DigitalSource 00020 { 00021 public: 00022 explicit DigitalOutput(UINT32 channel); 00023 DigitalOutput(UINT8 moduleNumber, UINT32 channel); 00024 virtual ~DigitalOutput(); 00025 void Set(UINT32 value); 00026 UINT32 GetChannel(); 00027 void Pulse(float length); 00028 bool IsPulsing(); 00029 void SetPWMRate(float rate); 00030 void EnablePWM(float initialDutyCycle); 00031 void DisablePWM(); 00032 void UpdateDutyCycle(float dutyCycle); 00033 00034 // Digital Source Interface 00035 virtual UINT32 GetChannelForRouting(); 00036 virtual UINT32 GetModuleForRouting(); 00037 virtual bool GetAnalogTriggerForRouting(); 00038 virtual void RequestInterrupts(tInterruptHandler handler, void *param); 00039 virtual void RequestInterrupts(); 00040 00041 void SetUpSourceEdge(bool risingEdge, bool fallingEdge); 00042 00043 private: 00044 void InitDigitalOutput(UINT8 moduleNumber, UINT32 channel); 00045 00046 UINT32 m_channel; 00047 UINT32 m_pwmGenerator; 00048 DigitalModule *m_module; 00049 }; 00050 00051 #endif