Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
MultiClick.h
00001 /* 00002 MultiClick.h: 00003 For one button operation. 00004 This library suports these events, 00005 * Single click 00006 * Double click 00007 * N times click (over 3 times click) 00008 * Long press 00009 00010 The MIT License (MIT) 00011 00012 Copyright (c) 2016 Uematsu Electric Co.,Ltd. Toru OHTSUKA 00013 <t-ohtsuka@jupiter.ocn.ne.jp> 00014 00015 Permission is hereby granted, free of charge, to any person obtaining a copy 00016 of this software and associated documentation files (the "Software"), to deal 00017 in the Software without restriction, including without limitation the rights 00018 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 00019 copies of the Software, and to permit persons to whom the Software is 00020 furnished to do so, subject to the following conditions: 00021 00022 The above copyright notice and this permission notice shall be included in 00023 all copies or substantial portions of the Software. 00024 00025 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 00026 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 00027 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 00028 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 00029 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 00030 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 00031 THE SOFTWARE. 00032 */ 00033 00034 /* 00035 * Modified version to work with an EventQueue 00036 * Removed deprecated code 00037 */ 00038 00039 #include "mbed.h" 00040 00041 class MultiClick { 00042 public: 00043 MultiClick(PinName pin, EventQueue *q); 00044 MultiClick(PinName pin, PinMode m, EventQueue *q); 00045 void attach_clicked(void (*function)(void)); 00046 void attach_doubleclicked(void (*function)(void)); 00047 void attach_n_clicked(void (*function)(int)); 00048 void attach_longpressed(void (*function)(void)); 00049 00050 private: 00051 void isr_pressed(void); 00052 void click_detect_timeout(void); 00053 void press_check_func(void); 00054 00055 InterruptIn *_iin; 00056 PinMode _mode; 00057 00058 Ticker *_press_check; 00059 Timeout *_click_detect_timeout; 00060 00061 int _shortpress_num; 00062 int _longpress_num; 00063 00064 int _press_check_interval_us; 00065 int _click_interval_us; 00066 int _click_times; 00067 00068 int _pressed_count; 00069 bool _longpressed; 00070 00071 EventQueue *_queue; 00072 00073 void (*_c_callback_clicked)(void); 00074 void (*_c_callback_doubleclicked)(void); 00075 void (*_c_callback_n_clicked)(int); 00076 void (*_c_callback_longpressed)(void); 00077 };
Generated on Sat Jul 16 2022 11:27:18 by
1.7.2