Skip to content

Instantly share code, notes, and snippets.

/progmem.c Secret

Created January 22, 2016 18:31
Show Gist options
  • Save anonymous/ab0351022bb99f67d803 to your computer and use it in GitHub Desktop.
Save anonymous/ab0351022bb99f67d803 to your computer and use it in GitHub Desktop.
void draw_character(font_t* font, uint8_t x, uint8_t y, char chr) {
for (uint8_t cy=0; cy < 8; cy++) {
for (uint8_t cx=0; cx < 8; cx++) {
uint8_t d = (y + cy) % 8;
uint8_t* b = &gfx_buffer[((y + cy) / 8 * 128) + x + cx];
uint8_t** flash_data = pgm_read_word(&font->data);
uint8_t* chr_data = pgm_read_word(&flash_data[chr]);
if (pgm_read_byte(&chr_data[7 - cy]) & (0x01 << cx)) {
*b |= 0x80 >> d;
} else {
*b &= ~(0x80 >> d);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment