28 extern const uint8_t *s_font6x8;
31 #define YADDR(y) (static_cast<uint16_t>((y) >> 3) << m_p) 32 #define BADDR(b) ((b) << m_p) 36 if ((x>=m_w) || (y>=m_h))
return;
39 m_bytes[YADDR(y) + x] &= ((1 << (y & 0x7))^m_invertByte);
43 m_bytes[YADDR(y) + x] |= (1 << (y & 0x7));
49 if (y1 >= m_h)
return;
51 if (x1 >= m_w)
return;
52 if (x2 >= m_w) x2 = m_w - 1;
53 for(uint8_t x = x1; x<=x2; x++)
54 m_bytes[YADDR(y1) + x] |= (1 << (y1 & 0x7));
59 if (x1 >= m_w)
return;
61 if (y1 >= m_h)
return;
62 if (y2 >= m_h) y2 = m_h - 1;
63 for(uint8_t y = y1; y<=y2; y++)
64 m_bytes[YADDR(y) + x1] |= (1 << (y & 0x7));
78 templ ^= m_invertByte;
79 if ((x1 < x2) && (x1 >= m_w))
return;
80 if ((y1 < y2) && (y1 >= m_h))
return;
83 if (x2 >= m_w) x2 = m_w -1;
84 if (y2 >= m_h) y2 = m_h -1;
85 uint8_t bank1 = (y1 >> 3);
86 uint8_t bank2 = (y2 >> 3);
87 for (uint8_t bank = bank1; bank<=bank2; bank++)
92 mask = (mask >> ((y1 & 7) + 7 - (y2 & 7))) << (y1 & 7);
94 else if (bank1 == bank)
96 mask = (mask << (y1 & 7));
98 else if (bank2 == bank)
100 mask = (mask >> (7 - (y2 & 7)));
102 for (uint8_t x=x1; x<=x2; x++)
104 m_bytes[BADDR(bank) + x] &= ~mask;
105 m_bytes[BADDR(bank) + x] |= (templ & mask);
113 for(uint16_t i=0; i< static_cast<uint16_t>(m_w) * (m_h >> 3); i++)
115 m_bytes[i] = m_invertByte;
122 uint8_t i, j, topMask, bottomMask;
125 topMask = (0xFF >> (8 - (y & 0x7)));
126 bottomMask = (0xFF << (y & 0x7));
129 uint8_t c = ch[j] - 32;
135 if ( style == STYLE_NORMAL )
137 data = pgm_read_byte(&s_font6x8[c*6+i]);
139 else if ( style == STYLE_BOLD )
141 data = pgm_read_byte(&s_font6x8[c*6+i]);
142 uint8_t temp = data | ldata;
148 data = pgm_read_byte(&s_font6x8[c*6+i + 1]);
149 uint8_t temp = (data & 0xF0) | ldata;
150 ldata = (data & 0x0F);
153 m_bytes[YADDR(y) + x] &= topMask;
154 m_bytes[YADDR(y) + x] |= (data << (y & 0x7));
157 m_bytes[YADDR(y) + m_w + x] &= bottomMask;
158 m_bytes[YADDR(y) + m_w + x] |= (data >> (8 - (y & 0x7)));
169 uint8_t text_index = 0;
172 uint8_t topMask, bottomMask;
173 if ( y >= m_h )
return;
174 topMask = (0xFF >> (8 - (y & 0x7)));
175 bottomMask = (0xFF << (y & 0x7));
178 if( ( x > m_w - 12 ) || ( ch[j] ==
'\0' ) )
200 uint8_t c = ch[j] - 32;
205 if ( style == STYLE_NORMAL )
207 data = pgm_read_byte(&s_font6x8[c*6+i]);
209 else if ( style == STYLE_BOLD )
211 data = pgm_read_byte(&s_font6x8[c*6+i]);
212 uint8_t temp = data | ldata;
218 data = pgm_read_byte(&s_font6x8[c*6+i + 1]);
219 uint8_t temp = (data & 0xF0) | ldata;
220 ldata = (data & 0x0F);
224 data = ((data & 0x01) ? 0x03: 0x00) |
225 ((data & 0x02) ? 0x0C: 0x00) |
226 ((data & 0x04) ? 0x30: 0x00) |
227 ((data & 0x08) ? 0xC0: 0x00);
229 for (uint8_t n=2; n>0; n--)
231 m_bytes[YADDR(y) + x] &= topMask;
232 m_bytes[YADDR(y) + x] |= (data << (y & 0x7));
235 m_bytes[YADDR(y) + m_w + x] &= bottomMask;
236 m_bytes[YADDR(y) + m_w + x] |= (data >> (8 - (y & 0x7)));
248 uint8_t text_index = 0;
249 uint8_t page_offset = 0;
251 uint8_t topMask, bottomMask;
252 if ( y >= m_h )
return;
253 topMask = (0xFF >> (8 - (y & 0x7)));
254 bottomMask = (0xFF << (y & 0x7));
257 if( ( x > m_w - s_fixedFont.
width ) || ( ch[j] ==
'\0' ) )
266 if (page_offset == s_fixedFont.
pages)
280 uint8_t c = ch[j] - 32;
286 uint16_t offset = (c * s_fixedFont.
pages + page_offset) * s_fixedFont.
width;
287 for( i=0; i<s_fixedFont.
width; i++)
290 if ( style == STYLE_NORMAL )
292 data = pgm_read_byte(&s_fixedFont.
data[offset]);
294 else if ( style == STYLE_BOLD )
296 data = pgm_read_byte(&s_fixedFont.
data[offset]);
297 uint8_t temp = data | ldata;
303 data = pgm_read_byte(&s_fixedFont.
data[offset + 1]);
304 uint8_t temp = (data & 0xF0) | ldata;
305 ldata = (data & 0x0F);
308 m_bytes[YADDR(y) + x] &= topMask;
309 m_bytes[YADDR(y) + x] |= (data << (y & 0x7));
312 m_bytes[YADDR(y) + m_w + x] &= bottomMask;
313 m_bytes[YADDR(y) + m_w + x] |= (data >> (8 - (y & 0x7)));
325 uint8_t text_index = 0;
326 uint8_t page_offset = 0;
328 uint8_t topMask, bottomMask;
329 if ( y >= m_h )
return;
330 topMask = (0xFF >> (8 - (y & 0x7)));
331 bottomMask = (0xFF << (y & 0x7));
334 if( ( x > m_w - (s_fixedFont.
width<<1) ) || ( ch[j] ==
'\0' ) )
343 if (page_offset == (s_fixedFont.
pages<<1))
357 uint8_t c = ch[j] - 32;
363 uint16_t offset = (c * s_fixedFont.
pages + (page_offset >> 1)) * s_fixedFont.
width;
364 for( i=0; i<s_fixedFont.
width; i++)
367 if ( style == STYLE_NORMAL )
369 data = pgm_read_byte(&s_fixedFont.
data[offset]);
371 else if ( style == STYLE_BOLD )
373 data = pgm_read_byte(&s_fixedFont.
data[offset]);
374 uint8_t temp = data | ldata;
380 data = pgm_read_byte(&s_fixedFont.
data[offset + 1]);
381 uint8_t temp = (data & 0xF0) | ldata;
382 ldata = (data & 0x0F);
385 if (page_offset & 1) data >>= 4;
386 data = ((data & 0x01) ? 0x03: 0x00) |
387 ((data & 0x02) ? 0x0C: 0x00) |
388 ((data & 0x04) ? 0x30: 0x00) |
389 ((data & 0x08) ? 0xC0: 0x00);
391 for (uint8_t n=2; n>0; n--)
393 m_bytes[YADDR(y) + x] &= topMask;
394 m_bytes[YADDR(y) + x] |= (data << (y & 0x7));
397 m_bytes[YADDR(y) + m_w + x] &= bottomMask;
398 m_bytes[YADDR(y) + m_w + x] |= (data >> (8 - (y & 0x7)));
413 if (x >= m_w) { x++;
continue; }
414 uint8_t d = pgm_read_byte(&sprite[i]);
416 m_bytes[YADDR(y) + x] |= (d << (y & 0x7));
417 if ((uint8_t)(y + 8) < m_h)
418 m_bytes[YADDR((uint8_t)(y + 8)) + x] |= (d >> (8 - (y & 0x7)));
431 uint8_t scrX = startX + x;
432 if (scrX >= m_w)
continue;
433 uint8_t d = pgm_read_byte(&buf[x + static_cast<uint16_t>(y>>3) * w]);
434 uint8_t scrY = y + startY;
437 m_bytes[YADDR(scrY) + scrX] |= (d << (scrY & 0x7));
440 m_bytes[YADDR(scrY) + scrX] |= (d >> (8 - (scrY & 0x7)));
451 if (x>=m_w) { x++;
continue; }
452 uint8_t d = sprite[i];
453 if (uint8_t(y) < m_h)
454 m_bytes[YADDR(y) + x] |= (d << (y & 0x7));
455 if ((uint8_t)(y+8) < m_h)
456 m_bytes[YADDR((uint8_t)(y + 8)) + x] |= (d >> (8 - (y & 0x7)));
464 for(i = 0; i < sprite->
w; i++)
466 if ((sprite->
x + i) >= m_w) {
continue; }
467 uint8_t d = pgm_read_byte(&sprite->
data[i]);
469 m_bytes[YADDR(sprite->
y) + sprite->
x + i] |= (d << (sprite->
y & 0x7));
470 if (uint8_t(sprite->
y + 8) < m_h)
471 m_bytes[YADDR(uint8_t(sprite->
y + 8)) + sprite->
x + i] |= (d >> (8 - (sprite->
y & 0x7)));
482 for(uint16_t i=0; i< static_cast<uint16_t>(m_w) * (m_h >> 3); i++)
483 m_bytes[i] = ~m_bytes[i];
488 for (uint8_t y=0; y<(m_h>>3); y++)
489 for (uint8_t x=0; x<m_w>>1; x++)
491 uint8_t temp = m_bytes[YADDR(y) + x];
492 m_bytes[YADDR(y) + x] = m_bytes[YADDR(y) + m_w - x -1];
493 m_bytes[YADDR(y) + m_w - x -1] = temp;
void charF6x8(uint8_t x, uint8_t y, const char ch[], EFontStyle style=STYLE_NORMAL)
void charF12x16(uint8_t x, uint8_t y, const char ch[], EFontStyle style=STYLE_NORMAL)
void fillRect(uint8_t x1, uint8_t y1, uint8_t x2, uint8_t y2, uint8_t templ)
const uint8_t * data
Pointer to PROGMEM data, representing sprite image.
void drawSpritePgm(uint8_t x, uint8_t y, const uint8_t sprite[])
void drawSprite(uint8_t x, uint8_t y, const uint8_t sprite[])
void printFixed(uint8_t xpos, uint8_t y, const char ch[], EFontStyle style=STYLE_NORMAL)
void setPos(uint8_t x, uint8_t y)
void drawVLine(uint8_t x1, uint8_t y1, uint8_t y2)
uint8_t y
draw position Y on the screen
void drawRect(uint8_t x1, uint8_t y1, uint8_t x2, uint8_t y2)
uint8_t width
width in pixels
uint8_t x
draw position X on the screen
void ssd1306_drawSprite(SPRITE *sprite)
void ssd1306_eraseTrace(SPRITE *sprite)
void ssd1306_drawBuffer(uint8_t x, uint8_t y, uint8_t w, uint8_t h, const uint8_t *buf)
void ssd1306_eraseSprite(SPRITE *sprite)
void blt(uint8_t x, uint8_t y)
void putPixel(uint8_t x, uint8_t y)
void drawBitmap(uint8_t x, uint8_t y, uint8_t w, uint8_t h, const uint8_t *buf)
const uint8_t * data
font chars bits
uint8_t pages
height in pages
void drawHLine(uint8_t x1, uint8_t y1, uint8_t x2)
void printFixed2x(uint8_t xpos, uint8_t y, const char ch[], EFontStyle style=STYLE_NORMAL)