Now you can download a copy of these docs so you can use them offline! Download now
SafePWM.cpp
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 #include "SafePWM.h" 00008 00009 #include "MotorSafetyHelper.h" 00010 00014 void SafePWM::InitSafePWM() 00015 { 00016 m_safetyHelper = new MotorSafetyHelper(this); 00017 m_safetyHelper->SetSafetyEnabled(false); 00018 } 00019 00024 SafePWM::SafePWM(UINT32 channel): PWM(channel) 00025 { 00026 InitSafePWM(); 00027 } 00028 00034 SafePWM::SafePWM(UINT8 moduleNumber, UINT32 channel): PWM(moduleNumber, channel) 00035 { 00036 InitSafePWM(); 00037 } 00038 00039 SafePWM::~SafePWM() 00040 { 00041 delete m_safetyHelper; 00042 } 00043 00044 /* 00045 * Set the expiration time for the PWM object 00046 * @param timeout The timeout (in seconds) for this motor object 00047 */ 00048 void SafePWM::SetExpiration(float timeout) 00049 { 00050 m_safetyHelper->SetExpiration(timeout); 00051 } 00052 00057 float SafePWM::GetExpiration() 00058 { 00059 return m_safetyHelper->GetExpiration(); 00060 } 00061 00067 bool SafePWM::IsAlive() 00068 { 00069 return m_safetyHelper->IsAlive(); 00070 } 00071 00077 void SafePWM::StopMotor() 00078 { 00079 SetRaw(kPwmDisabled); 00080 } 00081 00087 void SafePWM::SetSafetyEnabled(bool enabled) 00088 { 00089 m_safetyHelper->SetSafetyEnabled(enabled); 00090 } 00091 00096 bool SafePWM::IsSafetyEnabled() 00097 { 00098 return m_safetyHelper->IsSafetyEnabled(); 00099 } 00100 00101 void SafePWM::GetDescription(char *desc) 00102 { 00103 sprintf(desc, "PWM %d on module %d", GetChannel(), GetModuleNumber()); 00104 } 00105 00112 void SafePWM::SetSpeed(float speed) 00113 { 00114 PWM::SetSpeed(speed); 00115 m_safetyHelper->Feed(); 00116 } 00117
Generated on Thu Jan 12 2012 22:35:23 for WPILibC++ by
1.7.1