zhouhang shao
/
test
test
Embed:
(wiki syntax)
Show/hide line numbers
left_motor.cpp
00001 #include "left_motor.h" 00002 const int ONE_MILLISECOND = 0.001; 00003 PwmOut motor_left_sig(PB_7); 00004 DigitalOut dir_left(PB_6); 00005 00006 00007 LeftMotor::LeftMotor() { 00008 curr_speed = 0; 00009 dir_left = 1; 00010 } 00011 00012 //Sets motor speed 00013 void LeftMotor::speed(float speed) { 00014 curr_speed = speed; 00015 motor_left_sig.write(speed); 00016 } 00017 00018 void LeftMotor::inv_dir(bool dir){ 00019 if(dir == 1) 00020 dir_left = 1; 00021 else 00022 dir_left = 0; 00023 } 00024 00025 void LeftMotor::set_period(float period) { 00026 motor_left_sig.period(period); 00027 } 00028 00029 //Sets motor speed to 0 00030 void LeftMotor::stop() { 00031 speed(0); 00032 }
Generated on Sun Sep 11 2022 08:09:41 by 1.7.2