Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
// 有名なビット反転のコード
uint8_t revbits8(uint8_t v) {
v = ((v >> 1) & 0x55) | ((v & 0x55) << 1);
v = ((v >> 2) & 0x33) | ((v & 0x33) << 2);
v = ((v >> 4) & 0x0F) | ((v & 0x0F) << 4);
return v;
}
void screen_render(uint8_t screen[][4]) {
// ここに転送の初期化処理が入る
for (uint8_t row = 0; row < 4; ++row) {
for (uint8_t col = 0; col < 128; ++col) {
uint8_t bits = screen[127 - col][row];
i2c_master_write(revbits8(bits));
}
}
// ここに転送の終了処理が入る
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment