Control de plaqueta
Dependencies: Led SDFileSystem mbed
Diff: main.cpp
- Revision:
- 2:f3ceb5d7b70c
- Parent:
- 0:7373f4ac36fb
--- 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