2222#include " GPIO.h"
2323
2424/* *
25- * Debounced input pin template class using GPIO. Internal pullup
25+ * Debounced Input Pin template class using GPIO. The internal pullup
2626 * resistor is used. The button/switch should be connected to ground.
2727 * @param[in] PIN board pin for input signal.
2828 */
2929template <BOARD::pin_t PIN>
3030class Button {
3131public:
3232 /* *
33- * Construct debounced input pin (Button) instance with given
34- * template parameters. Initiate GPIO pins input mode with pullup
35- * resistor.
36- * @param[in] ms debouce time (Default 50 ms).
33+ * Construct debounced input pin instance with given template
34+ * parameters. Initiate GPIO pins input mode with pullup resistor.
35+ * @param[in] ms debounce time limit (Default 50 ms).
3736 */
3837 Button (uint16_t ms = 50 ) :
3938 DEBOUNCE (ms),
@@ -44,18 +43,18 @@ class Button {
4443 }
4544
4645 /* *
47- * Return true(1) if button change was detected, otherwise false(0).
48- * Rising or falling edge is determined by reading the debounced pin
49- * state.
50- * @return true(1) if button change was detected, otherwise false(0) .
46+ * Return true(1) if a button state change was detected, otherwise
47+ * false(0). Rising or falling edge is determined by reading the
48+ * debounced pin state.
49+ * @return bool .
5150 */
5251 bool ischanged ()
5352 {
54- // Check debounce time has elapsed
53+ // Check if debounce time limit has elapsed
5554 if (millis () - m_timestamp < DEBOUNCE) return (false );
5655 m_timestamp = millis ();
5756
58- // Check for pin state change
57+ // Check for the pin state has changed
5958 bool state = m_pin;
6059 if (state == m_state) return (false );
6160 m_state = state;
@@ -100,7 +99,7 @@ class Button {
10099 /* * Timestamp for latest pin read. */
101100 uint16_t m_timestamp;
102101
103- /* * Latest pin read. */
102+ /* * Latest pin read; debounced pin state . */
104103 bool m_state;
105104};
106105
0 commit comments