40 uint8_t s_ssd1306_invertByte = 0x00000000;
42 extern lcduint_t ssd1306_cursorX;
43 extern lcduint_t ssd1306_cursorY;
45 #ifdef CONFIG_SSD1306_UNICODE_ENABLE 46 extern uint8_t g_ssd1306_unicode;
51 fill_Data ^= s_ssd1306_invertByte;
81 uint8_t text_index = 0;
82 uint8_t page_offset = 0;
98 if (page_offset == s_fixedFont.
pages)
114 const uint8_t * glyph_ptr;
115 #ifdef CONFIG_SSD1306_UNICODE_ENABLE 116 if (g_ssd1306_unicode)
121 unicode = ssd1306_unicode16FromUtf8(ch[j]);
124 glyph_ptr = ssd1306_getU16CharGlyph( unicode );
129 glyph_ptr = ssd1306_getCharGlyph( ch[j] );
133 glyph_ptr += page_offset * s_fixedFont.
h.
width;
134 for( i=s_fixedFont.
h.
width; i>0; i--)
137 if ( style == STYLE_NORMAL )
139 data = pgm_read_byte(glyph_ptr);
141 else if ( style == STYLE_BOLD )
143 uint8_t temp = pgm_read_byte(glyph_ptr);
149 uint8_t temp = pgm_read_byte(glyph_ptr + 1);
150 data = (temp & 0xF0) | ldata;
151 ldata = (temp & 0x0F);
165 uint8_t text_index = 0;
166 uint8_t page_offset = 0;
184 if (page_offset == (s_fixedFont.
pages << 1))
206 offset = (c * s_fixedFont.
pages + (page_offset >> 1)) * s_fixedFont.
h.
width;
207 for( i=s_fixedFont.
h.
width; i>0; i--)
210 if ( style == STYLE_NORMAL )
214 else if ( style == STYLE_BOLD )
216 uint8_t temp = pgm_read_byte(&s_fixedFont.
primary_table[offset]);
222 uint8_t temp = pgm_read_byte(&s_fixedFont.
primary_table[offset + 1]);
223 data = (temp & 0xF0) | ldata;
224 ldata = (temp & 0x0F);
226 if (page_offset & 1) data >>= 4;
227 data = ((data & 0x01) ? 0x03: 0x00) |
228 ((data & 0x02) ? 0x0C: 0x00) |
229 ((data & 0x04) ? 0x30: 0x00) |
230 ((data & 0x08) ? 0xC0: 0x00);
235 x += (s_fixedFont.
h.
width << 1);
246 uint8_t text_index = 0;
247 uint8_t page_offset = 0;
263 if (page_offset == (s_fixedFont.
pages << factor))
279 const uint8_t *glyph_ptr;
280 #ifdef CONFIG_SSD1306_UNICODE_ENABLE 281 if (g_ssd1306_unicode)
286 unicode = ssd1306_unicode16FromUtf8(ch[j]);
289 glyph_ptr = ssd1306_getU16CharGlyph( unicode );
294 glyph_ptr = ssd1306_getCharGlyph( ch[j] );
298 glyph_ptr += (page_offset >> factor) * s_fixedFont.
h.
width;
299 for( i=s_fixedFont.
h.
width; i>0; i--)
302 if ( style == STYLE_NORMAL )
304 data = pgm_read_byte(glyph_ptr);
306 else if ( style == STYLE_BOLD )
308 uint8_t temp = pgm_read_byte(glyph_ptr);
314 uint8_t temp = pgm_read_byte(glyph_ptr+1);
315 data = (temp & 0xF0) | ldata;
316 ldata = (temp & 0x0F);
321 uint8_t mask = ~((0xFF) << (1<<factor));
326 data >>= ((page_offset & ((1<<factor) - 1))<<(3-factor));
327 for (uint8_t idx = 0; idx < 1<<(3-factor); idx++)
329 accum |= (((data>>idx) & 0x01) ? (mask<<(idx<<factor)) : 0);
333 for (uint8_t z=(1<<factor); z>0; z--)
339 x += (s_fixedFont.
h.
width << factor);
355 ssd1306_cursorY += s_fixedFont.
h.
height;
366 const uint8_t *glyph_ptr;
367 #ifdef CONFIG_SSD1306_UNICODE_ENABLE 368 if (g_ssd1306_unicode)
370 uint16_t unicode = ssd1306_unicode16FromUtf8(ch);
372 glyph_ptr = ssd1306_getU16CharGlyph( unicode );
377 glyph_ptr = ssd1306_getCharGlyph( ch );
380 ssd1306_cursorY >> 3,
384 ssd1306_cursorX += s_fixedFont.
h.
width;
406 uint8_t c = ch[j] - 32;
420 if ( style == STYLE_NORMAL )
422 data = pgm_read_byte(&s_font6x8[c*6+i]);
424 else if ( style == STYLE_BOLD )
426 uint8_t temp = pgm_read_byte(&s_font6x8[c*6+i]);
432 uint8_t temp = pgm_read_byte(&s_font6x8[c*6+i + 1]);
433 data = (temp & 0xF0) | ldata;
434 ldata = (temp & 0x0F);
448 uint8_t text_index = 0;
489 if ( style == STYLE_NORMAL )
491 data = pgm_read_byte(&s_font6x8[c*6+i]);
493 else if ( style == STYLE_BOLD )
495 uint8_t temp = pgm_read_byte(&s_font6x8[c*6+i]);
501 uint8_t temp = pgm_read_byte(&s_font6x8[c*6+i + 1]);
502 data = (temp & 0xF0) | ldata;
503 ldata = (temp & 0x0F);
506 data = ((data & 0x01) ? 0x03: 0x00) |
507 ((data & 0x02) ? 0x0C: 0x00) |
508 ((data & 0x04) ? 0x30: 0x00) |
509 ((data & 0x08) ? 0xC0: 0x00);
527 uint8_t text_end_pos = len * 6 + left;
528 if (text_end_pos <= right)
549 void ssd1306_putPixel_delayed(uint8_t x, uint8_t y, uint8_t complete)
551 static uint8_t lx = 0, ly = 0xFF;
552 static uint8_t pixels = 0;
553 if ((lx != x) || ((ly & 0xF8) != (y & 0xF8)) || (complete))
564 pixels |= (1 << (y & 0x07));
571 lcduint_t dx = x1 > x2 ? (x1 - x2): (x2 - x1);
572 lcduint_t dy = y1 > y2 ? (y1 - y2): (y2 - y1);
587 x1 < x2 ? x1++: x1--;
589 ssd1306_putPixel_delayed( x1, y1, 0 );
591 ssd1306_putPixel_delayed( 0, 0, 1 );
606 if (y1 < y2) y1++;
else y1--;
616 for (uint8_t x = x1; x <= x2; x++)
625 uint8_t topPage = y1 >> 3;
626 uint8_t bottomPage = y2 >> 3;
627 uint8_t height = y2-y1;
630 if (topPage == bottomPage)
637 for ( y = (topPage + 1); y <= (bottomPage - 1); y++)
659 for(j=(h >> 3); j>0; j--)
672 for(j=(h >> 3); j>0; j--)
689 for(j=(h >> 3); j>0; j--)
703 lcduint_t origin_width = w;
704 uint8_t offset = y & 0x07;
705 uint8_t complexFlag = 0;
706 uint8_t mainFlag = 1;
710 if (y + (lcdint_t)h <= 0)
return;
712 if (x + (lcdint_t)w <= 0)
return;
727 max_pages = (
lcduint_t)(h + 15 - offset) >> 3;
736 pages = ((y + h - 1) >> 3) - (y >> 3) + 1;
739 for(j=0; j < pages; j++)
741 if ( j == max_pages - 1 ) mainFlag = !offset;
742 for( i=w; i > 0; i--)
745 if ( mainFlag ) data |= (pgm_read_byte(buf) << offset);
746 if ( complexFlag ) data |= (pgm_read_byte(buf - origin_width) >> (8 - offset));
750 buf += origin_width - w;
751 complexFlag = offset;
762 for(j=(h >> 3); j>0; j--)
788 uint8_t offsety = sprite->
y & 0x7;
792 for (uint8_t i=0; i < sprite->
w; i++)
801 for (uint8_t i=0; i < sprite->
w; i++)
807 sprite->
lx = sprite->
x;
808 sprite->
ly = sprite->
y;
814 uint8_t posy = sprite->
y >> 3;
815 uint8_t offsety = sprite->
y & 0x7;
817 for (uint8_t i=sprite->
w; i > 0; i--)
825 for (uint8_t i=sprite->
w; i > 0; i--)
836 uint8_t y1 = sprite->
ly >> 3;
837 uint8_t y2 = (sprite->
ly + 7) >> 3;
838 if (sprite->
ly < sprite->
y)
839 y2 =
min(y2, (uint8_t)((sprite->
y >> 3) - 1));
840 else if (sprite->
y + 8 > sprite->
ly)
841 y1 =
max(y1, (sprite->
ly + 7) >> 3);
842 for(uint8_t y = y1; y <= y2; y++)
845 for(uint8_t x = sprite->
w; x > 0; x--)
851 if (sprite->
lx != sprite->
x)
853 uint8_t x1 = sprite->
lx;
854 uint8_t x2 = sprite->
lx + sprite->
w - 1;
855 if (sprite->
x < sprite->
lx)
856 x1 =
max(x1, sprite->
x + sprite->
w);
858 x2 =
min((uint8_t)(sprite->
x - 1), x2);
859 for(uint8_t y = sprite->
ly >> 3; y <= (sprite->
ly + 7) >> 3; y++)
862 for(uint8_t x = x2 - x1 + 1; x > 0; x--)
873 return (
SPRITE){x,y,w,x,y,data,NULL};
883 s_ssd1306_invertByte = 0xFF;
888 s_ssd1306_invertByte = 0x00;
893 s_font6x8 = progmemFont + 4;
void ssd1306_drawBuffer(uint8_t x, uint8_t y, uint8_t w, uint8_t h, const uint8_t *buf)
uint8_t ssd1306_charF6x8(uint8_t x, uint8_t y, const char ch[], EFontStyle style)
void ssd1306_putPixels(uint8_t x, uint8_t y, uint8_t pixels)
void ssd1306_positiveMode()
const uint8_t * data
Pointer to PROGMEM data, representing sprite image.
SPRITE ssd1306_createSprite(uint8_t x, uint8_t y, uint8_t w, const uint8_t *data)
const uint8_t * primary_table
font chars bits
uint8_t ssd1306_printFixed2x(uint8_t xpos, uint8_t y, const char ch[], EFontStyle style)
void ssd1306_drawLine(uint8_t x1, uint8_t y1, uint8_t x2, uint8_t y2)
uint8_t ssd1306_printFixed(uint8_t xpos, uint8_t y, const char *ch, EFontStyle style)
void ssd1306_drawSprite(SPRITE *sprite)
void ssd1306_drawRect(uint8_t x1, uint8_t y1, uint8_t x2, uint8_t y2)
void(* set_block)(lcduint_t x, lcduint_t y, lcduint_t w)
Sets block in RAM of lcd display controller to write data to.
void ssd1306_fillScreen(uint8_t fill_Data)
void ssd1306_eraseTrace(SPRITE *sprite)
void(* send_pixels_buffer1)(const uint8_t *buffer, uint16_t len)
void ssd1306_drawBitmap(uint8_t x, uint8_t y, uint8_t w, uint8_t h, const uint8_t *buf)
const PROGMEM uint8_t ssd1306xled_font6x8[]
void(* send_pixels1)(uint8_t data)
void gfx_drawMonoBitmap(lcdint_t x, lcdint_t y, lcduint_t w, lcduint_t h, const uint8_t *buf)
ssd1306_lcd_t ssd1306_lcd
size_t ssd1306_print(const char ch[])
Prints null-terminated string to display at current cursor position.
uint8_t ssd1306_charF12x16(uint8_t xpos, uint8_t y, const char ch[], EFontStyle style)
void ssd1306_eraseSprite(SPRITE *sprite)
void ssd1306_drawVLine(uint8_t x1, uint8_t y1, uint8_t y2)
ssd1306_interface_t ssd1306_intf
uint8_t y
draw position Y on the screen
void ssd1306_drawSpriteEx(uint8_t x, uint8_t y, uint8_t w, const uint8_t *sprite)
SFixedFontInfo s_fixedFont
SFontHeaderRecord h
record, containing information on font
uint8_t x
draw position X on the screen
uint8_t ssd1306_printFixedN(uint8_t xpos, uint8_t y, const char ch[], EFontStyle style, uint8_t factor)
void ssd1306_drawHLine(uint8_t x1, uint8_t y1, uint8_t x2)
#define SSD1306_MORE_CHARS_REQUIRED
uint8_t lx
last draw position X on the screen
void ssd1306_clearBlock(uint8_t x, uint8_t y, uint8_t w, uint8_t h)
void ssd1306_setFont6x8(const uint8_t *progmemFont)
uint8_t ssd1306_charF6x8_eol(uint8_t left, uint8_t y, const char ch[], EFontStyle style, uint8_t right)
void ssd1306_clearScreen()
void ssd1306_replaceSprite(SPRITE *sprite, const uint8_t *data)
void ssd1306_drawBufferFast(lcdint_t x, lcdint_t y, lcduint_t w, lcduint_t h, const uint8_t *buf)
uint8_t pages
height in pages (each page height is 8-pixels)
#define ssd1306_swap_data(a, b, type)
uint8_t ly
last draw position Y on the screen
void ssd1306_negativeMode()
void ssd1306_putPixel(uint8_t x, uint8_t y)
size_t ssd1306_write(uint8_t ch)
Prints single character to display at current cursor position.