Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# BitPP (or Bit++)
This library provides namespace BitPP with four classes Input, Output and their
inverted counterparts InputInv, OutputInv. With following interface.
Output {
void on();
void off();
void toggle();
}
Input {
bool get();
}
## Example
#include <bitpp.h>
using namespace BitPP;
Output<PORTB_ADDR, 0> led1; // define LED on PB0
OutputInv<PORTB_ADDR, 1> led2; // define inverted LED on PB1
Input<PIND_ADDR, 1> button; // define button on PD1
void setup()
{
Output<DDRB_ADDR, 0> ledDDR;
ledDDR.on();
// it is probably still easier to just use DDRB |= 1;
}
int main(void)
{
setup();
led1.on();
led2.off();
while(1) {
if(button.get()) {
led2.on();
} else {
led2.off();
}
}
}