Tutorial for first mbed project

Dependencies:   mbed lib_workshop_2019

Revision:
9:19255172362f
Parent:
7:c7ff04228b11
--- a/src/test_motor/ft_run_motor.cpp	Thu Oct 24 06:06:55 2019 +0000
+++ b/src/test_motor/ft_run_motor.cpp	Mon Oct 28 05:29:08 2019 +0000
@@ -1,5 +1,7 @@
 #include "mbed.h"
 #include "test_motor.h"
+#include "console_output.h"
+
 
 /**********************************************************************/
 /**                         ft_run_motor                             **/
@@ -28,3 +30,30 @@
     /* TO DO : apply duty cycle to pwm_mot */
 
 }
+
+
+double ft_get_duty_cycle_choice(Serial pc) {
+    double duty_cycle = 0;
+    
+    if (pc.readable() )
+        {
+            int user_int = ft_get_user_int(pc);
+            if (user_int < 10 && user_int >= 0) duty_cycle = user_int/10.0; 
+        }
+        return duty_cycle;
+}
+
+void ft_test_motor(PwmOut pin_pwm_mot, DigitalOut pin_dirA, DigitalOut pin_dirB,
+                    Serial &pc)
+{
+    e_direction direction = FORWARD;
+    
+    double duty_cycle =0.1;
+    
+    do{
+        duty_cycle = ft_get_duty_cycle_choice(pc);
+        ft_run_motor(direction, duty_cycle, pin_pwm_mot, pin_dirA, pin_dirB);
+    } while (duty_cycle > 0.0);
+    
+    return;
+}
\ No newline at end of file