You can use multiple clicks event with one button. This library supports follow events, Single click, Double click, over 3 times click, Long press.

Dependents:   multiclick_test

Revision:
7:7d56935ba84d
Parent:
5:cb4d45f41e17
--- a/MultiClick.h	Wed Jun 15 10:21:28 2016 +0000
+++ b/MultiClick.h	Thu Jun 16 01:29:43 2016 +0000
@@ -1,3 +1,35 @@
+/*
+MultiClick.h:
+  For one button operation.
+  This library suports these events,
+    * Single click
+    * Double click
+    * N times click (over 3 times click)
+    * Long press
+
+The MIT License (MIT)
+
+Copyright (c) 2016 Uematsu Electric Co.,Ltd. Toru OHTSUKA <t-ohtsuka@jupiter.ocn.ne.jp>
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
+*/
+
 #include "mbed.h"
 
 //#define DEBUG
@@ -23,11 +55,11 @@
     void click_detect_timeout( void );
     void press_check_func( void );
 
-    Timer *_t;
+    InterruptIn *_iin;
+    PinMode _mode;
+
     Ticker *_press_check;
     Timeout *_click_detect_timeout;
-    InterruptIn *_iin;
-    PinMode _mode;
     
     int _shortpress_num;
     int _longpress_num;