Skip to content

Instantly share code, notes, and snippets.

@electronut
Created October 29, 2017 08:17
Show Gist options
  • Save electronut/189f4ac4937b9723b9361ab7fe13c01a to your computer and use it in GitHub Desktop.
Save electronut/189f4ac4937b9723b9361ab7fe13c01a to your computer and use it in GitHub Desktop.
stm32-returns-4.c
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];
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment