Skip to content

Instantly share code, notes, and snippets.

@electronut
Created October 29, 2017 08:17

Revisions

  1. Mahesh Venkitachalam created this gist Oct 29, 2017.
    34 changes: 34 additions & 0 deletions stm32-returns-4.c
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,34 @@
    struct BitBuf88
    {
    // constr
    BitBuf88() {
    clearAll();
    }
    // destr
    virtual ~BitBuf88() {}

    // set (i, j)
    void set(uint8_t i, uint8_t j) {
    _vals[i] |= (1 << j);
    }

    // clear (i, j)
    void clr(uint8_t i, uint8_t j) {
    _vals[i] &= ~(1 << j);
    }

    // get (i, j)
    bool get(uint8_t i, uint8_t j) {
    return _vals[i] & (1 << j) ? true : false;
    }

    // clear all bits
    void clearAll() {
    for(uint8_t i = 0; i < 8; i++) {
    _vals[i] = 0;
    }
    }

    // vals[i] represents digit (column) and bits vals[i][0:7] the rows
    uint8_t _vals[8];
    };