Skip to content

Commit df7caab

Browse files
authored
Update README.md
1 parent 36e957f commit df7caab

File tree

1 file changed

+20
-16
lines changed

1 file changed

+20
-16
lines changed

README.md

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,18 @@
11
## Bugtton
2-
Fast button debounce library for ATmega328P, uses registers.
3-
4-
### Why another button library?
5-
I've tried plenty of different button libraries with ATmega328P, but most of them lacked something, or were too bulky for my own use.
6-
7-
### Fast
8-
It uses registers, and it's fast. 1000 cycles with various button amounts gave following:
9-
10-
* Unpressed buttons 0.003 ms per cycle regardless button count.
11-
* Pressed buttons 0.010 - 0.085 ms per cycle with 1-18 buttons.
2+
Fast button debounce library for ATmega328P. Uses registers instead of digitalRead.
123

134
### Usage In nutshell
5+
Compact to use.
146
```
157
#include <Bugtton.h>
16-
17-
const uint8_t buttonCount = 5;
18-
const uint8_t buttonPins[buttonCount] = {2,3,4,5,6};
19-
Bugtton buttons(buttonCount, buttonPins, INPUT_PULLUP, 25);
20-
-
8+
Bugtton buttons(5, {2,3,4,5,6}, INPUT_PULLUP, 25);
9+
--
2110
void loop() {
2211
buttons.update();
2312
2413
if (buttons.fell(0)) //B0 down and debounced
2514
if (buttons.heldUntil(1,3000)) //B1 has been pressed 3 seconds
26-
-
15+
--
2716
```
2817

2918
### Usable functions
@@ -40,3 +29,18 @@ Function|Notes
4029
**`bool held(button_i)`**<br>|*Is button_i pressed?*
4130
**`bool heldUntil(button_i, time)`**<br>|*Returns true ONCE when button_i have been pressed x time.*
4231
**`bool upUntil(button_i, time)`**<br>|*Returns true ONCE when button_i have been unpressed x time.*
32+
33+
I use long press functionality alot in my codes, so I wanted to add suitable functions for it. Feel free to suggest new ideas.
34+
35+
### Why this library was made
36+
Idea was to make fast button library when nothing is pressed so it would affect to the cycle time as little as possible.
37+
38+
**Times per one cycle**
39+
Button amount|unpressed|pressed
40+
-|-|-
41+
1|0.003 ms|0.010 ms
42+
2|0.003 ms|0.014 ms
43+
3|0.003 ms|0.018 ms
44+
5|0.003 ms|0.027 ms
45+
10|0.003 ms|0.049 ms
46+
18|0.003 ms|0.085 ms

0 commit comments

Comments
 (0)