Sistemas Embebidos / Mbed 2 deprecated Antirrebote_Puls

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
Tom_87
Date:
Thu May 03 23:33:41 2018 +0000
Parent:
0:2834a9185461
Commit message:
Debounce Program

Changed in this revision

PRUEBA1_LIB_ANTIREBOTE.cpp Show annotated file Show diff for this revision Revisions of this file
antirrebote.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
prog_in_antirrebote.cpp Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/PRUEBA1_LIB_ANTIREBOTE.cpp	Thu May 03 23:33:41 2018 +0000
@@ -0,0 +1,41 @@
+#include "mbed.h"
+#include "antirrebote.h"
+
+DigitalOut LR(LED1);
+DigitalOut LV(LED2);
+
+
+AntReb detector_pulso;
+
+Ticker timer;
+
+char tiempo = 15;
+
+void attime(void);
+
+int main()
+{   LR = 1;
+    LV = 1;
+    char prendete = 1;
+    timer.attach(&attime, 0.001);
+    while(1)
+    {
+        detector_pulso.setPin(PTE5);
+        if(tiempo == 0)
+        {
+        tiempo = 15;
+        prendete = detector_pulso.antiRebote();
+        }
+        if(prendete == 0)
+            LR = 0;
+        if (prendete==1)
+            LR=1;
+    }
+}
+
+void attime (void)
+{
+    if(tiempo > 0){
+        tiempo--;
+    }
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/antirrebote.lib	Thu May 03 23:33:41 2018 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/teams/Sistemas-Embebidos/code/antirrebote/#16d62113f1d5
--- a/main.cpp	Wed Apr 18 23:58:24 2018 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,76 +0,0 @@
-#include "mbed.h"
-#define TIME 0.001
-
-enum{ENCENDIDO, APAGADO};
-enum{NO_APRETADO, APRETADO};
-enum{PULS_NA, PULS_FLC1, PULS_A, PULS_FLC2};
-
-Ticker timer;
-
-DigitalIn PULS(PTB8);
-DigitalOut LED_R(LED1);
-
-unsigned char e_PULS = PULS_NA; 
-unsigned char PULS_tout = 5;
-unsigned char OUT;
-
-void SET_UP(void);
-void attime(void);
-void PULS_Step(void);
-
-int main(void) {
-    SET_UP();
-    
-    while(1) {
-        PULS_Step();
-    }
-}
-
-void SET_UP(void){
-    timer.attach(&attime,TIME);
-}
-
-void PULS_Step(void){
-    switch(e_PULS){
-        default:
-        case PULS_NA:
-            LED_R = APAGADO;
-            if(PULS == APRETADO && PULS_tout == 0) {
-                e_PULS = PULS_FLC1;
-                PULS_tout = 5;
-                }
-            break;
-        case PULS_FLC1:
-            LED_R = APAGADO;
-            if(PULS == APRETADO && PULS_tout == 0) {
-                e_PULS = PULS_A;
-                PULS_tout = 5;
-                LED_R = ENCENDIDO;
-            }else if(PULS == NO_APRETADO) {
-                e_PULS = PULS_NA;
-            }
-            break;
-        case PULS_A:
-            LED_R = APAGADO;
-            if(PULS == NO_APRETADO && PULS_tout == 0) {
-                e_PULS = PULS_FLC2;
-                PULS_tout = 5;
-            }
-            break;
-        case PULS_FLC2:
-            LED_R = APAGADO;
-            if(PULS == APRETADO) {
-                e_PULS = PULS_A;
-            }else if(PULS == NO_APRETADO && PULS_tout == 0) {
-                e_PULS = PULS_NA;
-                PULS_tout = 5;
-            }
-            break;
-    }
-}
-
-void attime(void) {
-    if (PULS_tout > 0) {
-        PULS_tout--;
-    }
-}
\ No newline at end of file
--- a/mbed.bld	Wed Apr 18 23:58:24 2018 +0000
+++ b/mbed.bld	Thu May 03 23:33:41 2018 +0000
@@ -1,1 +1,1 @@
-https://os.mbed.com/users/mbed_official/code/mbed/builds/994bdf8177cb
\ No newline at end of file
+https://os.mbed.com/users/mbed_official/code/mbed/builds/5aab5a7997ee
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/prog_in_antirrebote.cpp	Thu May 03 23:33:41 2018 +0000
@@ -0,0 +1,76 @@
+/*#include "mbed.h"
+
+enum{ENCENDIDO, APAGADO};
+enum{NO_APRETADO, APRETADO};
+enum{PULS_NA, PULS_FLC1, PULS_A, PULS_FLC2};
+
+Ticker timer;
+
+DigitalIn PULS(PTB8);
+DigitalOut LED_R(LED1);
+
+unsigned char e_PULS = PULS_NA; 
+unsigned char PULS_tout = 5;
+unsigned char OUT;
+
+void SET_UP(void);
+void attime(void);
+void PULS_Step(void);
+
+int main(void) {
+    SET_UP();
+    
+    while(1) {
+        PULS_Step();
+    }
+}
+
+void SET_UP(void){
+    timer.attach(&attime,TIME);
+}
+
+void PULS_Step(void){
+    switch(e_PULS){
+        default:
+        case PULS_NA:
+            LED_R = APAGADO;
+            if(PULS == APRETADO && PULS_tout == 0) {
+                e_PULS = PULS_FLC1;
+                PULS_tout = 5;
+                }
+            break;
+        case PULS_FLC1:
+            LED_R = APAGADO;
+            if(PULS == APRETADO && PULS_tout == 0) {
+                e_PULS = PULS_A;
+                PULS_tout = 5;
+                LED_R = ENCENDIDO;
+            }else if(PULS == NO_APRETADO) {
+                e_PULS = PULS_NA;
+            }
+            break;
+        case PULS_A:
+            LED_R = APAGADO;
+            if(PULS == NO_APRETADO && PULS_tout == 0) {
+                e_PULS = PULS_FLC2;
+                PULS_tout = 5;
+            }
+            break;
+        case PULS_FLC2:
+            LED_R = APAGADO;
+            if(PULS == APRETADO) {
+                e_PULS = PULS_A;
+            }else if(PULS == NO_APRETADO && PULS_tout == 0) {
+                e_PULS = PULS_NA;
+                PULS_tout = 5;
+            }
+            break;
+    }
+}
+
+void attime(void) {
+    if (PULS_tout > 0) {
+        PULS_tout--;
+    }
+}
+*/
\ No newline at end of file