1 #ifndef __ScreenBuffer_h__
2 #define __ScreenBuffer_h__
10 template<
typename Colour, Colour BLACK, Colour WHITE>
14 const uint16_t height;
23 inline void swap(
int& a,
int& b) {
int t = a; a = b; b = t; };
27 width(w), height(h), pixels(NULL),
28 cursor_x(0), cursor_y(0), textsize(1),
29 textcolor(
WHITE), textbgcolor(
WHITE), wrap(true) {}
46 void fade(uint16_t steps);
48 cursor_x = cursor_y = 0;
51 void clear(
int x,
int y,
int width,
int height){
57 unsigned int len = strnlen(str, 256);
58 for(
unsigned int i=0; i<len; ++i)
70 void print(
int x,
int y,
const char* text){
95 for(
int i=y; i<y+h; i++)
112 int steep =
abs(y1 - y0) >
abs(x1 - x0);
130 for (; x0<=x1; x0++) {
149 textsize = (s > 0) ? s : 1;
155 textcolor = textbgcolor = c;
168 invert(0, 0, width, height);
172 for(
int i=x; i<x+w; ++i)
173 for(
int j=y; j<y+h; ++j)
179 cursor_y += textsize*8;
181 }
else if (c ==
'\r') {
184 drawChar(cursor_x, cursor_y, c, textcolor, textbgcolor, textsize);
185 cursor_x += textsize*6;
186 if(wrap && (cursor_x > (width - textsize*6))){
187 cursor_y += textsize*8;
248 void drawChar(uint16_t x, uint16_t y,
unsigned char ch,
250 extern const unsigned char font[];
258 for(int8_t i=0; i<6; i++ ) {
263 line = font[(ch*5)+i];
264 for (int8_t j = 0; j<8; j++) {
271 }
else if (bg != c) {
286 extern const unsigned char font[];
293 for (int8_t i=0; i<6; i++ ) {
298 line = font[(ch*5)+i];
300 for (int8_t j = 7; j>=0; j--) {
308 }
else if (bg != c) {
void print(const char *str)
void setPixel(unsigned int x, unsigned int y, Colour c)
Colour getPixel(unsigned int x, unsigned int y)
void invertPixel(unsigned int x, unsigned int y)
void setTextColour(Colour c)
void fade(uint16_t steps)
void fillRectangle(int x, int y, int w, int h, Colour c)
void invert(int x, int y, int w, int h)
void drawLine(int x0, int y0, int x1, int y1, Colour c)
void setTextSize(uint8_t s)
void print(int x, int y, const char *text)
void drawChar(uint16_t x, uint16_t y, unsigned char ch, Colour c, Colour bg, uint8_t size)
void fillCircle(uint16_t x, uint16_t y, uint16_t r, Colour c)
void setTextColour(Colour c, Colour b)
void drawHorizontalLine(int x, int y, int length, Colour c)
void setCursor(uint16_t x, uint16_t y)
void drawRectangle(int x, int y, int w, int h, Colour c)
ScreenBuffer(uint16_t w, uint16_t h)
void drawVerticalLine(int x, int y, int length, Colour c)
void setBuffer(uint8_t *buffer)
void drawCircle(uint16_t x, uint16_t y, uint16_t r, Colour c)
void clear(int x, int y, int width, int height)
void drawRotatedChar(uint16_t x, uint16_t y, unsigned char ch, Colour c, Colour bg, uint8_t size)
char * msg_itoa(int val, int base)
char * msg_ftoa(float val, int base)