53 if ( m_lastRow != y || newColumn != m_lastColumn )
56 m_lastColumn = newColumn;
57 m_lastByte = this->m_bgColor | (this->m_bgColor << 4);
60 m_lastByte &= 0xF0 >> (4 * (x & 1));
62 m_lastByte |= (this->m_color & 0x0F) << (4 * (x & 1));
63 this->m_intf.startBlock(x, y, 0);
64 this->m_intf.send(m_lastByte);
65 this->m_intf.endBlock();
71 this->m_intf.startBlock(x1, y1, 0);
74 data |= (this->m_color & 0x0F) << (4 * (x1 & 1));
77 this->m_intf.send(data);
84 this->m_intf.send(data);
86 this->m_intf.endBlock();
91 this->m_intf.startBlock(x1, y1, 1);
94 this->m_intf.send((this->m_color & 0x0F) << (4 * (x1 & 1)));
97 this->m_intf.endBlock();
120 const uint8_t c = this->m_color & 0x0F;
121 const uint8_t full = (uint8_t)((c << 4) | c);
122 const uint8_t left_byte = (x1 & 1) ? (uint8_t)(c << 4) : full;
123 const uint8_t right_byte = ((x2 & 1) == 0) ? c : full;
124 const lcdint_t pair_start = x1 >> 1;
126 this->m_intf.startBlock(x1, y1, x2 - x1 + 1);
127 for (
lcdint_t row = y1; row <= y2; row++ )
129 if ( pair_start == pair_end )
133 if ( x1 & 1 ) both &= 0xF0;
134 if ( (x2 & 1) == 0 ) both &= 0x0F;
135 this->m_intf.send(both);
138 this->m_intf.send(left_byte);
139 for (
lcdint_t k = pair_start + 1; k < pair_end; k++ )
141 this->m_intf.send(full);
143 this->m_intf.send(right_byte);
145 this->m_intf.endBlock();
150 this->m_intf.startBlock(0, 0, 0);
151 uint32_t count = (uint32_t)this->m_w * (uint32_t)this->m_h / 2;
154 this->m_intf.send(color);
157 this->m_intf.endBlock();
175 uint8_t blackColor = this->m_bgColor | (this->m_bgColor << 4);
176 uint8_t color = this->m_color | (this->m_color << 4);
177 this->m_intf.startBlock(xpos, ypos, w);
182 for ( wx = xpos; wx < xpos + (
lcdint_t)w; wx++ )
184 uint8_t data = pgm_read_byte(bitmap);
185 uint8_t mask = (wx & 0x01) ? 0xF0 : 0x0F;
187 pixels |= color & mask;
189 pixels |= blackColor & mask;
193 this->m_intf.send(pixels);
199 this->m_intf.send(pixels);
211 this->m_intf.endBlock();
217 this->m_intf.startBlock(x, y, w);
218 for (
lcdint_t _y = y; _y < y + h; _y++ )
221 for (
lcdint_t _x = x; _x < x + w; _x++ )
223 uint8_t bmp = pgm_read_byte(bitmap);
228 data |= bmp << (4 * (_x & 1));
235 this->m_intf.send(data);
241 this->m_intf.send(data);
244 this->m_intf.endBlock();
250 this->m_intf.startBlock(x, y, w);
251 uint32_t count = (w) * (h);
254 uint8_t data1 = pgm_read_byte(bitmap++);
255 uint8_t data2 = pgm_read_byte(bitmap++);
259 this->m_intf.endBlock();
272 uint8_t blackColor = this->m_bgColor | (this->m_bgColor << 4);
273 uint8_t color = this->m_color | (this->m_color << 4);
274 this->m_intf.startBlock(xpos, ypos, w);
281 uint8_t data = *buffer;
282 uint8_t mask = (wx & 0x01) ? 0xF0 : 0x0F;
284 pixels |= color & mask;
286 pixels |= blackColor & mask;
287 if ( (wx & 0x01) == 0x00 )
289 this->m_intf.send(pixels);
304 this->m_intf.endBlock();
310 this->drawBuffer1(x, y, w, h, buf);
316 this->m_intf.startBlock(x, y, w);
317 for (
lcdint_t _y = y; _y < y + h; _y++ )
320 for (
lcdint_t _x = x; _x < x + w; _x++ )
322 uint8_t bmp = *buffer;
327 data |= bmp << (4 * (_x & 1));
334 this->m_intf.send(data);
340 this->m_intf.send(data);
343 this->m_intf.endBlock();
349 this->m_intf.startBlock(x, y, w);
350 uint32_t count = (w) * (h);
353 uint8_t data1 = *buffer;
355 uint8_t data2 = *buffer;
360 this->m_intf.endBlock();
371 uint16_t unicode = this->m_font->unicode16FromUtf8(c);
375 this->m_font->getCharBitmap(unicode, &char_info);
376 uint8_t mode = this->m_textMode;
377 for ( uint8_t i = 0; i < (this->m_fontStyle == STYLE_BOLD ? 2 : 1); i++ )
379 this->drawBitmap1(this->m_cursorX + i, this->m_cursorY, char_info.
width, char_info.
height, char_info.
glyph);
382 this->m_textMode = mode;
385 (this->m_cursorX > ((
lcdint_t)this->m_w - (
lcdint_t)this->m_font->getHeader().width))) ||
387 (this->m_cursorX > ((
lcdint_t)this->m_w - (
lcdint_t)this->m_font->getHeader().width))) )
389 this->m_cursorY += (
lcdint_t)this->m_font->getHeader().height;
391 if ( (this->m_textMode & CANVAS_TEXT_WRAP_LOCAL) &&
392 (this->m_cursorY > ((
lcdint_t)this->m_h - (
lcdint_t)this->m_font->getHeader().height)) )
404 this->m_cursorY += (
lcdint_t)this->m_font->getHeader().height;
407 else if ( c ==
'\r' )
422 this->m_cursorX = xpos;
void fill(uint16_t color)
Fill screen content with specified color.
void drawHLine(lcdint_t x1, lcdint_t y1, lcdint_t x2)
Draws horizontal or vertical line.
uint8_t height
char height in pixels
uint8_t lcduint_t
internal int type, used by the library.
void drawXBitmap(lcdint_t x, lcdint_t y, lcduint_t w, lcduint_t h, const uint8_t *bitmap)
Draws bitmap, located in Flash, on the display The bitmap should be in XBMP format.
Structure describes single char information.
void putPixel(lcdint_t x, lcdint_t y) __attribute__((noinline))
Draws pixel on specified position.
void drawVLine(lcdint_t x1, lcdint_t y1, lcdint_t y2)
Draws horizontal or vertical line.
If the flag is specified, text cursor is moved to new line when end of canvas is reached.
void drawBuffer4(lcdint_t x, lcdint_t y, lcduint_t w, lcduint_t h, const uint8_t *buffer) __attribute__((noinline))
Draws 4-bit bitmap, located in RAM, on the display Each byte represents two pixels in 4-4 format: ref...
This flag make bitmaps transparent (Black color)
int8_t lcdint_t
internal int type, used by the library.
SSD1306 HAL IO communication functions.
#define SSD1306_MORE_CHARS_REQUIRED
Flag means that more chars are required to decode utf-8.
void printFixed(lcdint_t xpos, lcdint_t y, const char *ch, EFontStyle style=STYLE_NORMAL) __attribute__((noinline))
Print text at specified position to canvas.
void drawBuffer8(lcdint_t x, lcdint_t y, lcduint_t w, lcduint_t h, const uint8_t *buffer)
Draws 8-bit bitmap, located in RAM, on the display Each byte represents one pixel in 2-2-3 format: re...
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.
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.
uint8_t printChar(uint8_t c)
Draws single character to canvas.
void drawBuffer16(lcdint_t xpos, lcdint_t ypos, lcduint_t w, lcduint_t h, const uint8_t *buffer) __attribute__((noinline))
Draws 16-bit bitmap, located in RAM, on the display Each pixel occupies 2 bytes (5-6-5 format): refer...
size_t write(uint8_t c) __attribute__((noinline))
Writes single character to canvas.
void clear()
Clears canvas.
void drawBitmap16(lcdint_t xpos, lcdint_t ypos, lcduint_t w, lcduint_t h, const uint8_t *bitmap)
Draw 16-bit color bitmap, located in Flash, directly to OLED display GDRAM.
If the flag is specified, text cursor is moved to new line when end of screen is reached.
uint8_t width
char width in pixels
#define RGB8_TO_GRAY4(rgb)
Macro to convert 8-bit RGB to 4-bit monochrome format.
void drawBuffer1Fast(lcdint_t x, lcdint_t y, lcduint_t w, lcduint_t h, const uint8_t *buffer)
Implements the same behavior as drawBuffer1, but much faster.
void fillRect(lcdint_t x1, lcdint_t y1, lcdint_t x2, lcdint_t y2) __attribute__((noinline))
Fills rectangle area.
const uint8_t * glyph
char data, located in progmem.
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 drawBuffer1(lcdint_t x, lcdint_t y, lcduint_t w, lcduint_t h, const uint8_t *buffer) __attribute__((noinline))
Draws bitmap, located in RAM, on the display Each byte represents 8 vertical pixels.
uint8_t spacing
additional spaces after char in pixels
EFontStyle
Supported font styles.
#define ssd1306_swap_data(a, b, type)
swaps content of a and b variables of type type