Vote Controller IOT

Dependencies:   MQTT

Fork of PGO6_VoteController_template by Jens de hoog

Revision:
3:b2c9de2f45c7
Parent:
2:5b7d055dbc91
diff -r 5b7d055dbc91 -r b2c9de2f45c7 debounce_button.cpp
--- a/debounce_button.cpp	Tue Oct 31 09:01:56 2017 +0000
+++ b/debounce_button.cpp	Mon Nov 06 14:18:21 2017 +0000
@@ -1,5 +1,7 @@
 #include "debounce_button.h"
-
+DigitalOut led1(LED1);
+Timeout second;
+Timeout debounce;
 /**
     Some tips and tricks:
     -   To use the built-in LED:
@@ -36,7 +38,7 @@
 */
 void button1_enabled_cb(void)
 {
-    
+    button1_enabled = true;
 }
 
 /**
@@ -54,5 +56,26 @@
 */
 void button1_onpressed_cb(void)
 {
+    if(button1_enabled){
+        button1_enabled = false;
+        debounce.attach(&button1_enabled_cb,0.08);
+        
+        if(countSecond == false){
+            led1 = 1;
+            multiclick_state = 1;
+            countSecond = true;
+        }
+        else{
+            multiclick_state++;
+        }
+        second.attach(&second_ended_cd,1);
+        
+    }
+}
     
+void second_ended_cd(void)
+{
+    led1 = 0;
+    countSecond = false;
+    readyClick =true;
 }
\ No newline at end of file