yotaro morizumi / Mbed 2 deprecated zoomy_customLibrary

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
yootee
Date:
Fri Jun 10 08:09:09 2022 +0000
Parent:
7:1c09bcc18c14
Child:
10:b64f586efb2d
Commit message:
unt6i

Changed in this revision

actuator/IMC_motorDrive.cpp Show annotated file Show diff for this revision Revisions of this file
actuator/IMC_motorDrive.hpp Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/actuator/IMC_motorDrive.cpp	Sat Apr 09 03:39:36 2022 +0000
+++ b/actuator/IMC_motorDrive.cpp	Fri Jun 10 08:09:09 2022 +0000
@@ -1,6 +1,6 @@
 #include<IMC_motorDrive.hpp>
 
-IMC_motor::IMC_motor(Port encoder,int resolution,double wheel_ensyu,Port motor_,double K_,double Tau_,double dt_):K(K_),Tau(Tau_),dt(dt_),motor(motor_){
+IMC_motor::IMC_motor(Port encoder,int resolution,double wheel_ensyu,Port motor_,double K_,double Tau_,double dt_,bool CW_flag):K(K_),Tau(Tau_),dt(dt_),motor(motor_),cw_flag(CW_flag){
     motor_enc.specinit(encoder.pin[0],encoder.pin[1],wheel_ensyu,resolution,4);
     IMCreset();
 }
@@ -16,6 +16,9 @@
 
 void IMC_motor::drive(int pwm){
     float output_pwm = constrain(pwm,-200,200)/255;
+    if(cw_flag){
+        pwm = -pwm;    
+    }
     if(!pwm) {
         DigitalOut Moter1(motor.pin[0],0);
         DigitalOut Moter2(motor.pin[1],0);
--- a/actuator/IMC_motorDrive.hpp	Sat Apr 09 03:39:36 2022 +0000
+++ b/actuator/IMC_motorDrive.hpp	Fri Jun 10 08:09:09 2022 +0000
@@ -12,7 +12,7 @@
 class IMC_motor
 {
 public:
-    IMC_motor(Port encoder,int resolution,double wheel_ensyu,Port motor_,double K_,double Tau_,double dt_);
+    IMC_motor(Port encoder,int resolution,double wheel_ensyu,Port motor_,double K_,double Tau_,double dt_,bool CW_flag);
     void IMCdrive(double target);
     void IMCreset();
     void drive(int pwm);
@@ -26,5 +26,6 @@
     double K;
     double Tau;
     double dt;
+    bool cw_flag;
     Port motor;
 };
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Fri Jun 10 08:09:09 2022 +0000
@@ -0,0 +1,3 @@
+#include<mbed.h>
+
+int main(){}
\ No newline at end of file