avr-firmwares/drivers/framebuffer.c

34 lines
723 B
C
Raw Normal View History

#define DONT_DECLARE_FRAMEBUFFER 1
#include "framebuffer.h"
FRAMEBUFFER;
2018-10-03 09:16:54 +02:00
#if FB_DEPTH==1
void fb_fill(uint8_t c) {
memset(framebuffer, c, sizeof(framebuffer[0][0]) * FB_HEIGHT * FB_WIDTH_BYTES);
}
void fb_shift(uint16_t newcol) {
int x, y;
uint8_t transfer = 0, tmp = 0;
for (y = 0; y < FB_HEIGHT; y++) {
for (x = FB_WIDTH_BYTES - 1; x >= 0; x--) {
tmp = transfer;
transfer = (framebuffer[y][x] & 1);
framebuffer[y][x] = (framebuffer[y][x] >> 1) | (tmp << 7);
}
transfer = 0;
FB_SET(FB_WIDTH - 1, y, newcol & 1);
newcol = newcol >> 1;
}
}
#elif FB_DEPTH==8
void fb_fill(uint8_t c) {
memset(framebuffer, c, sizeof(framebuffer[0][0]) * FB_HEIGHT * FB_WIDTH);
}
#endif