TRR2018 omar

Dependencies:   mbed

Fork of biniou by TRR 2018

Revision:
8:1d8c3ca5e508
Parent:
1:abed67ad1d03
Child:
11:bc24b3ba51a9
diff -r c81c8934c192 -r 1d8c3ca5e508 main.cpp
--- a/main.cpp	Fri Aug 31 16:58:32 2018 +0000
+++ b/main.cpp	Sat Sep 08 22:17:15 2018 +0000
@@ -1,108 +1,22 @@
-#include "mbed.h"
-AnalogIn front_G(PC_0);
-AnalogIn front_C(PC_1);
-AnalogIn front_D(PC_2);
-
-AnalogIn analog_left(A0);
-AnalogIn analog_right(A1);
-AnalogIn analog_front(A2);
-
-//DigitalOut enable_right(D0);
-//DigitalOut forward_right(PA_10,0);
-//DigitalOut backward_right(PA_9,0);
-
-//DigitalOut backward_left(PA_10,0);
-//DigitalOut forward_left(PB_3,0);
-//DigitalOut enable_left(D5);
-
-PwmOut pwm_right(PB_4);
-PwmOut pwm_left(PB_5);
-
-int on_off = 0 ;
-InterruptIn button(USER_BUTTON);
-
-DigitalOut led(LED1);
-
-void pressed()
-{
-    if (on_off == 0) {
-        on_off = 1 ;
-    } else {
-        on_off = 0;
-    }
-}
+#include "stateMachines.h"
 
 int main()
 {
-    float front_meas;
-    float left_meas;
-    float right_meas;
 
-    button.fall(&pressed);
-
-    pwm_right.period_us(500);
-    pwm_left.period_us(500);
-    pwm_right.pulsewidth_us(0);
-    pwm_left.pulsewidth_us(0);
-
-   // backward_right.write(0);//ok
-   // forward_right.write(1);//ko
-
- //   forward_left.write(1); //ok
-  //  backward_left.write(0); //ok
-
-    while(1) {
-        /*
-        if (on_off == 1 ) {
-            led = 1;
-
-            front_meas = analog_front.read();
-            left_meas = analog_left.read();
-            right_meas = analog_right.read();
+murs_init();
+obstacle_init();
+section_init();
+throttle_init();
 
-            if (front_meas > 0.5) {
-                if (left_meas > right_meas) {
-                    backward_right.write(0);//ok
-                    forward_right.write(1);//ko
-                    forward_left.write(0); //ok
-                    backward_left.write(1); //ok
-                } else {
-                    backward_right.write(1);//ok
-                    forward_right.write(0);//ko
-                    forward_left.write(1); //ok
-                    backward_left.write(0); //ok
-                }
-            } else {
-                if(left_meas < 0.5) {
-                    forward_left.write(1); //ok
-                    backward_left.write(0); //ok
-                } else {
-                    forward_left.write(0); //ok
-                    backward_left.write(1); //ok
-                }
-                if(right_meas > 0.5) {
-                    forward_right.write(0); //ok
-                    backward_right.write(1); //ok
-                } else {
-                    forward_right.write(1); //ok
-                    backward_right.write(0); //ok
-                }
-            }
-            pwm_right.pulsewidth_us(200);
-            pwm_left.pulsewidth_us(200);
-
-
-        } else {
-            led = 0;
-            pwm_right.pulsewidth_us(0);
-            pwm_left.pulsewidth_us(0);
-        }*/
-        wait(0.2); // 200 ms
-
+    while (1) {
+        murs_update();
+        obstacle_update();
+        section_update();
+        throttle_update();
+    
+        murs_output();
+        obstacle_output();
+        section_output();
+        throttle_output();
     }
-}
-
-
-
-
-
+}
\ No newline at end of file