Andrew Reed / Mbed 2 deprecated Pushbutton_Debounce_Interrupt_V2

Dependencies:   mbed PinDetect

Files at this revision

API Documentation at this revision

Comitter:
reedas
Date:
Tue Nov 12 10:16:26 2019 +0000
Parent:
1:768b8bd42e33
Commit message:
CITY1082 debounced button example

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed-os.lib Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
mbed_app.json Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Tue Jan 29 02:34:03 2013 +0000
+++ b/main.cpp	Tue Nov 12 10:16:26 2019 +0000
@@ -4,12 +4,12 @@
 // URL: http://mbed.org/users/AjK/libraries/PinDetect/lkyxpw
 
 DigitalOut myled(LED1);
-DigitalOut myled2(LED2);
-DigitalOut myled3(LED3);
-DigitalOut myled4(LED4);
+DigitalOut myled2(LED5);
+DigitalOut myled3(LED4);
+DigitalOut myled4(LED3);
 
-PinDetect pb1(p8);
-PinDetect pb2(p7);
+PinDetect pb1(P0_4);
+//PinDetect pb2(p7);
 // SPST Pushbutton debounced count demo using interrupts and callback
 // no external PullUp resistor needed
 // Pushbutton from P8 to GND.
@@ -18,35 +18,36 @@
 // after the switch is debounced
 
 // Global count variable
-int volatile count=0;
+int volatile countit=0;
 
 // Callback routine is interrupt activated by a debounced pb1 hit
 void pb1_hit_callback (void) {
-    count++;
-    myled4 = count & 0x01;
-    myled3 = (count & 0x02)>>1;
-    myled2 = (count & 0x04)>>2;
+//   printf("Count is %d\n", ++countit);
+    countit--;
+    myled4 = countit & 0x01;
+    myled3 = (countit & 0x02)>>1;
+    myled2 = (countit & 0x04)>>2;
 }
 // Callback routine is interrupt activated by a debounced pb2 hit
-void pb2_hit_callback (void) {
+/*void pb2_hit_callback (void) {
     count--;
     myled4 = count & 0x01;
     myled3 = (count & 0x02)>>1;
     myled2 = (count & 0x04)>>2;
-}
+}*/
 int main() {
 
     // Use internal pullups for pushbutton
     pb1.mode(PullUp);    
-    pb2.mode(PullUp);
+//    pb2.mode(PullUp);
     // Delay for initial pullup to take effect
     wait(.01);
     // Setup Interrupt callback functions for a pb hit
     pb1.attach_deasserted(&pb1_hit_callback);
-    pb2.attach_deasserted(&pb2_hit_callback);
+//    pb2.attach_deasserted(&pb2_hit_callback);
     // Start sampling pb inputs using interrupts
     pb1.setSampleFrequency();
-    pb2.setSampleFrequency();
+//    pb2.setSampleFrequency();
     //Blink myled in main routine forever while responding to pb changes
     // via interrupts that activate the callback counter function
     while (1) {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed-os.lib	Tue Nov 12 10:16:26 2019 +0000
@@ -0,0 +1,1 @@
+https://github.com/ARMmbed/mbed-os/#808c45062f940790e1287bd6b8420290c062775c
--- a/mbed.bld	Tue Jan 29 02:34:03 2013 +0000
+++ b/mbed.bld	Tue Nov 12 10:16:26 2019 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/mbed_official/code/mbed/builds/63bcd7ba4912
+https://os.mbed.com/users/mbed_official/code/mbed/builds/65be27845400
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed_app.json	Tue Nov 12 10:16:26 2019 +0000
@@ -0,0 +1,15 @@
+{
+    "target_overrides": {
+        "*": {
+            "platform.stack-stats-enabled": true,
+            "platform.heap-stats-enabled": true,
+            "platform.cpu-stats-enabled": true,
+            "platform.thread-stats-enabled": true,
+            "platform.sys-stats-enabled": true,
+            "platform.stdio-convert-newlines": true,
+            "platform.stdio-baud-rate": 115200,
+            "platform.default-serial-baud-rate": 115200
+
+        }
+    }
+}