Skip to content
Snippets Groups Projects
README.md 916 B
Newer Older
Isabella Skořepová's avatar
Isabella Skořepová committed
# 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();
            }
        }
    }