28 void ssd1306_setRgbColor16(uint8_t r, uint8_t g, uint8_t b)
35 ssd1306_lcd.set_block(x, y, w);
41 ssd1306_intf.send( *data );
44 data += pitch - (w << 1);
51 ssd1306_drawBufferPitch16(x, y, w, h, w<<1, data);
56 ssd1306_drawBufferPitch16( x, y, w, h, pitch, data );
61 ssd1306_lcd.set_block(x, y, 0);
62 ssd1306_lcd.send_pixels16( color );
68 ssd1306_lcd.set_block(xpos, ypos, w);
69 uint32_t count = (w) * (h);
72 ssd1306_lcd.send_pixels16( (pgm_read_byte( &bitmap[0] ) << 8) | pgm_read_byte( &bitmap[1] ) );
78 void ssd1306_clearBlock16(uint8_t x, uint8_t y, uint8_t w, uint8_t h)
80 ssd1306_lcd.set_block(x, y, w);
81 uint32_t count = w * h;
84 ssd1306_lcd.send_pixels16( 0x0000 );
95 void ssd1306_printChar16(uint8_t c)
97 uint16_t unicode = ssd1306_unicode16FromUtf8(c);
100 ssd1306_getCharBitmap(unicode, &char_info);
101 ssd1306_drawMonoBitmap16(ssd1306_cursorX,
108 size_t ssd1306_write16(uint8_t ch)
115 else if ( (ssd1306_cursorX > ssd1306_lcd.width - m_font->getHeader().width) || (ch ==
'\n') )
118 ssd1306_cursorY += m_font->getHeader().height;
119 if ( ssd1306_cursorY > ssd1306_lcd.height - m_font->getHeader().height )
123 ssd1306_clearBlock16(0, ssd1306_cursorY, ssd1306_lcd.width, m_font->getHeader().height);
129 uint16_t unicode = m_font->unicode16FromUtf8(ch);
132 m_font->getCharBitmap(unicode, &char_info);
133 ssd1306_drawMonoBitmap16( ssd1306_cursorX,
142 size_t ssd1306_print16(
const char ch[])
147 n += ssd1306_write16(*ch);
157 return ssd1306_print16(ch);
170 this->m_intf.startBlock(x, y, 0);
171 this->m_intf.send(this->m_color >> 8);
172 this->m_intf.send(this->m_color & 0xFF);
173 this->m_intf.endBlock();
178 this->m_intf.startBlock(x1, y1, 0);
181 this->m_intf.send(this->m_color >> 8);
182 this->m_intf.send(this->m_color & 0xFF);
185 this->m_intf.endBlock();
190 this->m_intf.startBlock(x1, y1, 1);
193 this->m_intf.send(this->m_color >> 8);
194 this->m_intf.send(this->m_color & 0xFF);
197 this->m_intf.endBlock();
210 this->m_intf.startBlock(x1, y1, x2 - x1 + 1);
211 uint16_t count = (x2 - x1 + 1) * (y2 - y1 + 1);
214 this->m_intf.send(this->m_color >> 8);
215 this->m_intf.send(this->m_color & 0xFF);
217 this->m_intf.endBlock();
222 this->m_intf.startBlock(0, 0, 0);
223 uint32_t count = (uint32_t)this->m_w * (uint32_t)this->m_h;
226 this->m_intf.send(color >> 8);
227 this->m_intf.send(color & 0xFF);
229 this->m_intf.endBlock();
247 uint16_t blackColor = this->m_bgColor;
248 uint16_t color = this->m_color;
249 this->m_intf.startBlock(xpos, ypos, w);
255 uint8_t data = pgm_read_byte(bitmap);
258 this->m_intf.send(color >> 8);
259 this->m_intf.send(color & 0xFF);
263 this->m_intf.send(blackColor >> 8);
264 this->m_intf.send(blackColor & 0xFF);
278 this->m_intf.endBlock();
290 this->m_intf.startBlock(x, y, w);
291 uint32_t count = (w) * (h);
295 this->m_intf.send(color >> 8);
296 this->m_intf.send(color & 0xFF);
299 this->m_intf.endBlock();
305 this->m_intf.startBlock(x, y, w);
306 uint32_t count = (w) * (h);
309 this->m_intf.send(pgm_read_byte(&bitmap[0]));
310 this->m_intf.send(pgm_read_byte(&bitmap[1]));
313 this->m_intf.endBlock();
320 uint16_t blackColor = this->m_bgColor;
321 uint16_t color = this->m_color;
322 this->m_intf.startBlock(xpos, ypos, w);
328 uint8_t data = *buffer;
331 this->m_intf.send(color >> 8);
332 this->m_intf.send(color & 0xFF);
336 this->m_intf.send(blackColor >> 8);
337 this->m_intf.send(blackColor & 0xFF);
351 this->m_intf.endBlock();
357 this->drawBuffer1(x, y, w, h, buf);
369 this->m_intf.startBlock(x, y, w);
370 uint32_t count = (w) * (h);
374 this->m_intf.send(color >> 8);
375 this->m_intf.send(color & 0xFF);
378 this->m_intf.endBlock();
384 this->m_intf.startBlock(x, y, w);
385 uint32_t count = (w) * (h);
388 this->m_intf.send(buffer[0]);
389 this->m_intf.send(buffer[1]);
392 this->m_intf.endBlock();
397 uint16_t unicode = this->m_font->unicode16FromUtf8(c);
401 this->m_font->getCharBitmap(unicode, &char_info);
402 uint8_t mode = this->m_textMode;
403 for ( uint8_t i = 0; i < (this->m_fontStyle == STYLE_BOLD ? 2 : 1); i++ )
405 this->drawBitmap1(this->m_cursorX + i, this->m_cursorY, char_info.
width, char_info.
height, char_info.
glyph);
408 this->m_textMode = mode;
409 if ( char_info.
height < (
lcdint_t)this->m_font->getHeader().height )
411 this->invertColors();
412 this->fillRect(this->m_cursorX, this->m_cursorY + char_info.
height, this->m_cursorX + char_info.
width - 1,
413 this->m_cursorY + (
lcdint_t)this->m_font->getHeader().height - 1);
414 this->invertColors();
419 this->invertColors();
420 this->fillRect(this->m_cursorX - char_info.
spacing, this->m_cursorY, this->m_cursorX - 1,
421 this->m_cursorY + (
lcdint_t)this->m_font->getHeader().height - 1);
422 this->invertColors();
425 (this->m_cursorX > ((
lcdint_t)this->m_w - (
lcdint_t)this->m_font->getHeader().width))) ||
427 (this->m_cursorX > ((
lcdint_t)this->m_w - (
lcdint_t)this->m_font->getHeader().width))) )
429 this->m_cursorY += (
lcdint_t)this->m_font->getHeader().height;
431 if ( (this->m_textMode & CANVAS_TEXT_WRAP_LOCAL) &&
432 (this->m_cursorY > ((
lcdint_t)this->m_h - (
lcdint_t)this->m_font->getHeader().height)) )
444 this->m_cursorY += (
lcdint_t)this->m_font->getHeader().height;
447 else if ( c ==
'\r' )
462 this->m_cursorX = xpos;
475 uint8_t text_index = 0;
476 uint8_t page_offset = 0;
481 if ( (x > this->m_w - (this->m_font->getHeader().width << factor)) || (ch[j] ==
'\0') )
485 if ( y >= this->m_h )
490 if ( page_offset == (this->m_font->getPages() << factor) )
507 unicode = this->m_font->unicode16FromUtf8(ch[j]);
511 this->m_font->getCharBitmap(unicode, &char_info);
513 if ( char_info.
height > (page_offset >> factor) * 8 )
515 char_info.
glyph += (page_offset >> factor) * char_info.
width;
516 for ( i = char_info.
width; i > 0; i-- )
519 if ( style == STYLE_NORMAL )
521 data = pgm_read_byte(char_info.
glyph);
523 else if ( style == STYLE_BOLD )
525 uint8_t temp = pgm_read_byte(char_info.
glyph);
531 uint8_t temp = pgm_read_byte(char_info.
glyph + 1);
532 data = (temp & 0xF0) | ldata;
533 ldata = (temp & 0x0F);
538 uint8_t mask = ~((0xFF) << (1 << factor));
543 data >>= ((page_offset & ((1 << factor) - 1)) << (3 - factor));
544 for ( uint8_t idx = 0; idx < 1 << (3 - factor); idx++ )
546 accum |= (((data >> idx) & 0x01) ? (mask << (idx << factor)) : 0);
550 this->m_intf.startBlock(x, y, (1 << factor));
551 for ( uint8_t b = 0; b < 8; b++ )
553 uint16_t color = (data & (1 << b)) ? this->m_color : this->m_bgColor;
554 for ( uint8_t z = (1 << factor); z > 0; z-- )
556 this->m_intf.send(color >> 8);
557 this->m_intf.send(color & 0xFF);
560 this->m_intf.endBlock();
568 x += (char_info.
width << factor);
570 this->m_intf.startBlock(x, y, (char_info.
spacing << factor));
571 for ( uint8_t b = 0; b < 8; b++ )
573 uint16_t color = this->m_bgColor;
574 for ( i = 0; i < (char_info.
spacing << factor); i++ )
576 this->m_intf.send(color >> 8);
577 this->m_intf.send(color & 0xFF);
580 x += (char_info.
spacing << factor);
581 this->m_intf.endBlock();
uint8_t printChar(uint8_t c)
uint8_t height
char height in pixels
#define RGB_COLOR16(r, g, b)
void drawVLine(lcdint_t x1, lcdint_t y1, lcdint_t y2)
void drawHLine(lcdint_t x1, lcdint_t y1, lcdint_t x2)
size_t write(uint8_t c) __attribute__((noinline))
#define SSD1306_MORE_CHARS_REQUIRED
void drawBitmap8(lcdint_t x, lcdint_t y, lcduint_t w, lcduint_t h, const uint8_t *bitmap)
Draws 8-bit color bitmap in color buffer. Draws 8-bit color bitmap in color buffer.
void printFixedN(lcdint_t xpos, lcdint_t y, const char *ch, EFontStyle style, uint8_t factor) __attribute__((noinline))
void drawBuffer1Fast(lcdint_t x, lcdint_t y, lcduint_t w, lcduint_t h, const uint8_t *buffer)
uint8_t width
char width in pixels
const uint8_t * glyph
char data, located in progmem.
void fillRect(lcdint_t x1, lcdint_t y1, lcdint_t x2, lcdint_t y2) __attribute__((noinline))
void drawBuffer16(lcdint_t xpos, lcdint_t ypos, lcduint_t w, lcduint_t h, const uint8_t *buffer) __attribute__((noinline))
void drawBuffer8(lcdint_t x, lcdint_t y, lcduint_t w, lcduint_t h, const uint8_t *buffer)
void drawBuffer1(lcdint_t x, lcdint_t y, lcduint_t w, lcduint_t h, const uint8_t *buffer) __attribute__((noinline))
void printFixed(lcdint_t xpos, lcdint_t y, const char *ch, EFontStyle style=STYLE_NORMAL) __attribute__((noinline))
void putPixel(lcdint_t x, lcdint_t y) __attribute__((noinline))
uint8_t spacing
additional spaces after char in pixels
void drawXBitmap(lcdint_t x, lcdint_t y, lcduint_t w, lcduint_t h, const uint8_t *bitmap)
void drawBitmap1(lcdint_t x, lcdint_t y, lcduint_t w, lcduint_t h, const uint8_t *bitmap) __attribute__((noinline))
Draws monochrome bitmap in color buffer using color, specified via setColor() method Draws monochrome...
void drawBuffer4(lcdint_t x, lcdint_t y, lcduint_t w, lcduint_t h, const uint8_t *buffer) __attribute__((noinline))
void drawBitmap16(lcdint_t xpos, lcdint_t ypos, lcduint_t w, lcduint_t h, const uint8_t *bitmap)
void drawBitmap4(lcdint_t x, lcdint_t y, lcduint_t w, lcduint_t h, const uint8_t *bitmap) __attribute__((noinline))
Draws 4-bit gray-color bitmap in color buffer. Draws 4-bit gray-color bitmap in color buffer...
#define ssd1306_swap_data(a, b, type)
void fill(uint16_t color)