Skip to content

Commit 0ac41ba

Browse files
committed
Added a a function to read raw clicks from the button (added it to the source code, the docs, and the att_use_cases example)
1 parent e66913b commit 0ac41ba

5 files changed

Lines changed: 17 additions & 1 deletion

File tree

docs/pages/MyButton.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ The ``NORMAL_UP``, and ``NORMAL_DOWN`` keywords refer to whether the push button
3535
2.2. Available methods
3636
++++++++++++++++++++++
3737

38+
- ``bool readRawClick();``
39+
+ Returns whether the button was pressed or not **NON-DEBOUNCED**
40+
3841
- ``bool readRisingClick();``
3942

4043
+ Returns a boolean value corresponding to the occurrence of a ``rising`` edge on the button pin.

examples/MyButton_all_use_cases/MyButton_all_use_cases.ino

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ void setup() {
3737

3838
void loop() {
3939

40+
/*------------------------------------------------------------------------------*/
41+
/* RAW CLICK EXAMPLE */
42+
/*------------------------------------------------------------------------------*/
43+
Serial.println(my_btn.readRawClick() ? "ON" : "OFF");
44+
4045
/*------------------------------------------------------------------------------*/
4146
/* ON CLICK (RISING EDGE) EXAMPLE */
4247
/*------------------------------------------------------------------------------*/

library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=MyButton
2-
version=2.0.1
2+
version=2.0.2
33
author=Radhi
44
maintainer=Radhi <radhisghaier33@gmail.com>
55
sentence=Making buttons easy and fun to work with (normal, and counting buttons)

src/MyButton.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,13 @@ MyButton :: MyButton(uint8_t pin, uint8_t off_state_, uint8_t debounce_t){
6363
}
6464
}
6565

66+
/*
67+
* Returns whether the button was pressed or not (NO DEBOUNCING)
68+
*/
69+
bool MyButton :: readRawClick(){
70+
return digitalRead(button_pin) == (1 - off_state);
71+
}
72+
6673
/*
6774
* Returns whether the button was pressed or not with the debounce time (FALLING EDGE)
6875
*/

src/MyButton.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@
7878
MyButton(uint8_t pin, uint8_t off_state_, uint8_t debounce_t);
7979

8080
/* Functions */
81+
bool readRaw();
8182
bool readRisingClick();
8283
bool readFallingClick();
8384
uint32_t readTimedPress(uint8_t unit);

0 commit comments

Comments
 (0)