avr-firmwares/drivers/framebuffer.h

33 lines
869 B
C

#include <stdint.h>
#include <string.h>
#define CEILDIV(x, y) (((x)+((y)-1))/(y))
#if FB_DEPTH==1
#define FB_WIDTH_BYTES CEILDIV(FB_WIDTH, 8)
#define FRAMEBUFFER uint8_t framebuffer[FB_HEIGHT][FB_WIDTH_BYTES];
#define FB_SET(w,h,c) if (c) { \
framebuffer[h][(w)>>3] |= (1 << ((w) & 7)); \
} else { \
framebuffer[h][(w)>>3] &= ~(1 << ((w) & 7)); \
}
#elif FB_DEPTH==8
#define FRAMEBUFFER uint8_t framebuffer][FB_HEIGHT][FB_WIDTH];
#define FB_SET(w,h,c) framebuffer[h][w] = c
#endif
#ifndef DONT_DECLARE_FRAMEBUFFER
extern FRAMEBUFFER
#endif
void fb_fill(uint8_t c);
void fb_shift();
void fb_hline(uint8_t y, uint8_t x1, uint8_t x2, uint8_t c);
void fb_vline(uint8_t x, uint8_t y1, uint8_t y2, uint8_t c);
void fb_box(uint8_t ax, uint8_t ay, uint8_t bx, uint8_t by, uint8_t c);
void fb_area(uint8_t ax, uint8_t ay, uint8_t bx, uint8_t by, uint8_t c);