Sistemas Operativos Mercedes / Mbed 2 deprecated ControlLed

Dependencies:   Led SDFileSystem mbed

Files at this revision

API Documentation at this revision

Comitter:
MAlmazan
Date:
Sun Jun 11 06:40:38 2017 +0000
Parent:
1:f9b782703658
Commit message:
Version final?

Changed in this revision

Led.lib Show diff for this revision Revisions of this file
LedSetup.lib 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/Led.lib	Sat Jun 10 14:48:05 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-https://developer.mbed.org/teams/Sistemas-Operativos-Mercedes/code/Led/#a7fdb950e0e2
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/LedSetup.lib	Sun Jun 11 06:40:38 2017 +0000
@@ -0,0 +1,1 @@
+https://developer.mbed.org/teams/Sistemas-Operativos-Mercedes/code/Led/#79b1f5409850
--- a/main.cpp	Sat Jun 10 14:48:05 2017 +0000
+++ b/main.cpp	Sun Jun 11 06:40:38 2017 +0000
@@ -1,38 +1,62 @@
 #include "mbed.h"
 #include "SDFileSystem.h"
-#include "Led.h"
+#include "LedSetup.h"
 
 
 DigitalIn sw2(SW2);
 DigitalIn sw3(SW3);
+SDFileSystem sd(PTE3, PTE1, PTE2, PTE4, "sd");
+FILE *fp;
 
 
-//TODO
-//Funcion para manejar el boton 3 (ciclo de colores)
-//Funcion principal que haga un ciclo para ve el estado del boton y escribe en la SD
+bool valorLED = false;
 
-bool LED = false;
-
-void Boton2() {
+//Prende/Apaga el LED
+int Boton2() {
     if (sw2 == 0) {
-        if (LED) {
+        if (valorLED) {
             LEDEstado(false);
+            return 0;
         } else {
             LEDEstado(true);
+            return 1;
         }
-        wait(0.2f);
+    } else {
+        return -1;
     }
 }
 
-void Boton3() {
+//Setea el color del LED al azar
+bool Boton3() {
     if (sw3 == 0) {
-        
+        ColorLEDRandom();
+        return true;
+    } else {
+        return false;
     }
 }
 
+//No lo cierra porque se va a usar permanentemente
+void CrearArchivo() {
+    mkdir("/sd", 0777);
+    fp = fopen("/sd/log.txt", "w");
+}
 
 int main() {
-
-    
+    CrearArchivo();    
+    while (true) {
+        if ((Boton2()) == 1){
+            fprintf(fp, "Se prendio el LED! (Boton 2)\n");
+        } else if ((Boton2()) == 0){
+            fprintf(fp, "Se apago el LED (Boton 2)\n");
+        }
+        //para evitar que el boton sense constantemente sus cambios
+        wait(0.2f);
+        if (Boton3()) {
+            fprintf(fp, "Se cambio el color aleatoriamente! (Boton 3)\n");
+        }
+        //para evitar que el boton sense constantemente sus cambios
+        wait(0.2f);    
+    }  
 }
     
\ No newline at end of file