APS de Sistemas Operacionais / Controle 2 FINAL

Dependencies:   EthernetInterface HCSR04 PID Servo mbed-rtos mbed

Fork of aps_so_c2_old by Felipe dos Santos Neves

Revision:
2:f3ba67384801
Parent:
1:c07ed2436cd8
Child:
3:3d094a31a283
--- a/main.cpp	Mon Oct 30 23:34:06 2017 +0000
+++ b/main.cpp	Sat Nov 18 17:19:53 2017 +0000
@@ -1,49 +1,43 @@
 #include "mbed.h"
 #include "rtos.h"
- #include "ultrasonic.h"
+#include "EthernetInterface.h"
+
+enum status{ IDLE, ADJUSTING, STABLE };
 
-DigitalOut led1(LED1);
+status statusFlag;
+
+DigitalOut ledR(LED1);
+DigitalOut ledG(LED2);
+DigitalOut ledB(LED3);
+
 InterruptIn sw2(SW2);
-uint32_t button_pressed;
-Thread *thread2;
-ultrasonic us = ultrasonic(PTC2, PTC3, 100, 1000);
+InterruptIn sw3(SW3);
 
 void sw2_press(void)
-{
-    thread2->signal_set(0x1);
-    
+{    
 }
 
 void led_thread(void const *argument)
 {
     while (true) {
-        led1 = !led1;
-        Thread::wait(1000);
+        switch(statusFlag)
+        {
+            default:
+                ledR = !ledR;
+                Thread::wait(1000);
+                break;
+        }
     }
 }
 
 void button_thread(void const *argument)
 {
-    while (true) {
-        Thread::signal_wait(0x1);
-        float x = us.getCurrentDistance();
-        printf("distance = %f\n", x);
-        button_pressed++;
-    }
+
 }
 
 int main()
 {
-    Thread thread(led_thread);
-    thread2 = new Thread(button_thread);
-    //teste
+    printf("APS Sistemas Operacionais / Controle 2\n");
+    printf("Alunos: Felipe, Juliana, Rafael\n");
 
-    button_pressed = 0;
-    sw2.fall(&sw2_press);
-    while (true) {
-        Thread::wait(5000);
-        printf("SW2 was pressed (last 5 seconds): %d \n", button_pressed);
-        fflush(stdout);
-        button_pressed = 0;
-    }
 }