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.
button.h
00001 /* 00002 * 00003 * This program is free software; you can redistribute it and/or modify 00004 * it under the terms of the GNU General Public License as published by 00005 * the Free Software Foundation; either version 3 of the License, or 00006 * (at your option) any later version. 00007 * 00008 * This program is distributed in the hope that it will be useful, 00009 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00010 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00011 * GNU General Public License for more details. 00012 * 00013 * You should have received a copy of the GNU General Public License 00014 * along with this program. If not, see <http://www.gnu.org/licenses/>. 00015 * 00016 * @file button.h 00017 * @author Andre Moehl 00018 * @date 01/2011 00019 * @brief Button Class definition 00020 */ 00021 00022 00023 /** 00024 * Usage: 00025 * 00026 * #include "button.h" 00027 * 00028 * void main() 00029 * { 00030 * Button button(p10); 00031 * int state=0; 00032 * 00033 * while(1) 00034 * { 00035 * if(button) do_something(); 00036 * } 00037 * } 00038 */ 00039 00040 #ifndef __BUTTON_H 00041 #define __BUTTON_H 00042 00043 /*--- Includes ------------------------*/ 00044 #include "mbed.h" 00045 00046 /*--- Class Declaration----------------*/ 00047 00048 /** 00049 Class Button - derived from Class DigitalIn 00050 */ 00051 class Button: public DigitalIn 00052 { 00053 public: 00054 /** @brief Contructor 00055 * @parameter pin button pin 00056 * @parameter name for Pin 00057 */ 00058 Button(PinName pin, const char *name = NULL); 00059 00060 /** @brief returns the Button state as integer */ 00061 int read(void); 00062 00063 /** @brief overwrites the int operator for easy use*/ 00064 operator int(); 00065 00066 /** @brief Sets the Debounce Time 00067 * @parameter i debounce time in microseconds */ 00068 void set_debounce_us(int i); 00069 /** @brief Sets the Oscillations to count until Button is debounced 00070 * @parameter i Number of Samples */ 00071 void set_samples(int i); 00072 00073 protected: 00074 void _callback(void); 00075 Ticker _ticker; 00076 int _counter; 00077 int _samples; 00078 int _shadow; 00079 }; 00080 00081 #endif
Generated on Thu Jul 14 2022 18:59:33 by
1.7.2