SmartWheels self-driving race car. Designed for NXP Cup. Uses FRDM-KL25Z, area-scan camera, and simple image processing to detect and navigate any NXP spec track.
Dependencies: TSI USBDevice mbed-dev
Fork of SmartWheels by
Diff: Hardwares/Servo.cpp
- Revision:
- 46:a5eb9bd3bb55
- Parent:
- 45:501b7909139a
- Child:
- 87:15fcf7891bf9
--- a/Hardwares/Servo.cpp Thu Mar 30 03:50:23 2017 +0000 +++ b/Hardwares/Servo.cpp Thu Mar 30 22:34:20 2017 +0000 @@ -3,6 +3,7 @@ #include "Core.h" #include "PinAssignment.h" #include "SWUSBServer.h" +#include "GlobalVariable.h" #include "mbed.h" @@ -27,43 +28,14 @@ angle = SERVO_LF * SERVO_MAX_ANGLE; servo_pulseWidth = (0.0015 + (0.00001667 * angle)); - //char buf[10]; - //sprintf(buf, "%f", m_pulseWidth); - //m_core.GetUSBServer().PushUnreliableMsg('D', buf); servo_pwm.pulsewidth(servo_pulseWidth); + //servo_pwm = (servo_pulseWidth / 0.020); + + //char buf[20]; + //sprintf(buf, "Serv %f", (float)servo_pwm); + //g_core.GetUSBServer().PushUnreliableMsg('D', buf); } #ifdef __cplusplus } #endif -/* -Servo::Servo(SW::Core& core) : - m_core(core), - m_pwm(PwmOut(PIN_SC_SERVO)) - -{ - m_pulseWidth = 0.0015; - m_pwm.period(0.020); - m_pwm.pulsewidth(m_pulseWidth); -} - - -void Servo::Update(float deltaTime) -{ - -} - -void Servo::setAngle(float angle) -{ - if(angle > SERVO_RT * SERVO_MAX_ANGLE) - angle = SERVO_RT * SERVO_MAX_ANGLE; - else if(angle < SERVO_LF * SERVO_MAX_ANGLE) - angle = SERVO_LF * SERVO_MAX_ANGLE; - - m_pulseWidth = (0.0015 + (0.00001667 * angle)); - //char buf[10]; - //sprintf(buf, "%f", m_pulseWidth); - //m_core.GetUSBServer().PushUnreliableMsg('D', buf); - m_pwm.pulsewidth(m_pulseWidth); -} -*/ \ No newline at end of file