SSD1306 OLED display driver  1.4.6
This library is developed to control SSD1306/SSD1331 RGB i2c/spi OLED displays and spi PCD8544 LED display
ssd1306.c
1 /*
2  MIT License
3 
4  Copyright (c) 2016-2018, Alexey Dynda
5 
6  Permission is hereby granted, free of charge, to any person obtaining a copy
7  of this software and associated documentation files (the "Software"), to deal
8  in the Software without restriction, including without limitation the rights
9  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10  copies of the Software, and to permit persons to whom the Software is
11  furnished to do so, subject to the following conditions:
12 
13  The above copyright notice and this permission notice shall be included in all
14  copies or substantial portions of the Software.
15 
16  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22  SOFTWARE.
23 */
24 
25 #include "font6x8.h"
26 #include "ssd1306.h"
27 #include "lcd/lcd_common.h"
28 #include "i2c/ssd1306_i2c.h"
29 #include "spi/ssd1306_spi.h"
30 #include "intf/ssd1306_interface.h"
31 #include <stdlib.h>
32 
33 // TODO: remove
34 #include "lcd/ssd1306_commands.h"
35 
36 #define swap_data(a, b) { uint8_t t = a; a = b; b = t; }
37 
41 static uint8_t s_invertByte = 0x00000000;
42 const uint8_t *s_font6x8 = &ssd1306xled_font6x8[4];
43 SFixedFontInfo s_fixedFont = { 0 };
44 
46 {
47  return s_displayHeight;
48 }
49 
51 {
52  return s_displayWidth;
53 }
54 
55 void ssd1306_fillScreen(uint8_t fill_Data)
56 {
57  fill_Data ^= s_invertByte;
58  ssd1306_setRamBlock(0, 0, 0);
60  for(uint8_t m=(s_displayHeight >> 3); m>0; m--)
61  {
62  for(uint8_t n=s_displayWidth; n>0; n--)
63  {
64  ssd1306_sendPixels(fill_Data);
65  }
67  }
69 }
70 
72 {
73  ssd1306_setRamBlock(0, 0, 0);
75  for(uint8_t m=(s_displayHeight >> 3); m>0; m--)
76  {
77  for(uint8_t n=s_displayWidth; n>0; n--)
78  {
79  ssd1306_sendPixels( s_invertByte );
80  }
82  }
84 }
85 
86 
88 {
89  ssd1306_sendCommand(SSD1306_DISPLAYOFF);
90 }
91 
92 
94 {
95  ssd1306_sendCommand(SSD1306_DISPLAYON);
96 }
97 
98 void ssd1306_setContrast(uint8_t contrast)
99 {
101  ssd1306_sendByte(SSD1306_SETCONTRAST);
102  ssd1306_sendByte(contrast);
104 }
105 
106 uint8_t ssd1306_printFixed(uint8_t xpos, uint8_t y, const char ch[], EFontStyle style)
107 {
108  uint8_t i, j=0;
109  uint8_t text_index = 0;
110  uint8_t page_offset = 0;
111  uint8_t x = xpos;
112  y >>= 3;
113  ssd1306_setRamBlock(xpos, y, s_displayWidth - xpos);
115  for(;;)
116  {
117  if( (x > s_displayWidth - s_fixedFont.width) || (ch[j] == '\0') )
118  {
119  x = xpos;
120  y++;
121  if (y >= (s_displayHeight >> 3))
122  {
123  break;
124  }
125  page_offset++;
126  if (page_offset == s_fixedFont.pages)
127  {
128  text_index = j;
129  page_offset = 0;
130  if (ch[j] == '\0')
131  {
132  break;
133  }
134  }
135  else
136  {
137  j = text_index;
138  }
140  ssd1306_setRamBlock(xpos, y, s_displayWidth - xpos);
142  }
143  uint8_t c = ch[j];
144  if ( c >= s_fixedFont.ascii_offset )
145  {
146  c -= s_fixedFont.ascii_offset;
147  }
148  uint8_t ldata = 0;
149  uint16_t offset = (c * s_fixedFont.pages + page_offset) * s_fixedFont.width;
150  for( i=s_fixedFont.width; i>0; i--)
151  {
152  uint8_t data;
153  if ( style == STYLE_NORMAL )
154  {
155  data = pgm_read_byte(&s_fixedFont.data[offset]);
156  }
157  else if ( style == STYLE_BOLD )
158  {
159  uint8_t temp = pgm_read_byte(&s_fixedFont.data[offset]);
160  data = temp | ldata;
161  ldata = temp;
162  }
163  else
164  {
165  uint8_t temp = pgm_read_byte(&s_fixedFont.data[offset + 1]);
166  data = (temp & 0xF0) | ldata;
167  ldata = (temp & 0x0F);
168  }
169  ssd1306_sendPixels(data^s_invertByte);
170  offset++;
171  }
172  x += s_fixedFont.width;
173  j++;
174  }
176  return j;
177 }
178 
179 uint8_t ssd1306_printFixed2x(uint8_t xpos, uint8_t y, const char ch[], EFontStyle style)
180 {
181  uint8_t i, j=0;
182  uint8_t text_index = 0;
183  uint8_t page_offset = 0;
184  uint8_t x = xpos;
185  y >>= 3;
186  ssd1306_setRamBlock(xpos, y, s_displayWidth - xpos);
188  for(;;)
189  {
190  if( (x > s_displayWidth - (s_fixedFont.width << 1)) || (ch[j] == '\0') )
191  {
192  x = xpos;
193  y++;
194  if (y >= (s_displayHeight >> 3))
195  {
196  break;
197  }
198  page_offset++;
199  if (page_offset == (s_fixedFont.pages << 1))
200  {
201  text_index = j;
202  page_offset = 0;
203  if (ch[j] == '\0')
204  {
205  break;
206  }
207  }
208  else
209  {
210  j = text_index;
211  }
213  ssd1306_setRamBlock(xpos, y, s_displayWidth - xpos);
215  }
216  uint8_t c = ch[j];
217  if ( c >= s_fixedFont.ascii_offset )
218  {
219  c -= s_fixedFont.ascii_offset;
220  }
221  uint8_t ldata = 0;
222  uint16_t offset = (c * s_fixedFont.pages + (page_offset >> 1)) * s_fixedFont.width;
223  for( i=s_fixedFont.width; i>0; i--)
224  {
225  uint8_t data;
226  if ( style == STYLE_NORMAL )
227  {
228  data = pgm_read_byte(&s_fixedFont.data[offset]);
229  }
230  else if ( style == STYLE_BOLD )
231  {
232  uint8_t temp = pgm_read_byte(&s_fixedFont.data[offset]);
233  data = temp | ldata;
234  ldata = temp;
235  }
236  else
237  {
238  uint8_t temp = pgm_read_byte(&s_fixedFont.data[offset + 1]);
239  data = (temp & 0xF0) | ldata;
240  ldata = (temp & 0x0F);
241  }
242  if (page_offset & 1) data >>= 4;
243  data = ((data & 0x01) ? 0x03: 0x00) |
244  ((data & 0x02) ? 0x0C: 0x00) |
245  ((data & 0x04) ? 0x30: 0x00) |
246  ((data & 0x08) ? 0xC0: 0x00);
247  ssd1306_sendPixels(data^s_invertByte);
248  ssd1306_sendPixels(data^s_invertByte);
249  offset++;
250  }
251  x += (s_fixedFont.width << 1);
252  j++;
253  }
255  return j;
256 }
257 
258 
259 uint8_t ssd1306_printFixedN(uint8_t xpos, uint8_t y, const char ch[], EFontStyle style, uint8_t factor)
260 {
261  uint8_t i, j=0;
262  uint8_t text_index = 0;
263  uint8_t page_offset = 0;
264  uint8_t x = xpos;
265  y >>= 3;
266  ssd1306_setRamBlock(xpos, y, s_displayWidth - xpos);
268  for(;;)
269  {
270  if( (x > s_displayWidth - (s_fixedFont.width << factor)) || (ch[j] == '\0') )
271  {
272  x = xpos;
273  y++;
274  if (y >= (s_displayHeight >> 3))
275  {
276  break;
277  }
278  page_offset++;
279  if (page_offset == (s_fixedFont.pages << factor))
280  {
281  text_index = j;
282  page_offset = 0;
283  if (ch[j] == '\0')
284  {
285  break;
286  }
287  }
288  else
289  {
290  j = text_index;
291  }
293  ssd1306_setRamBlock(xpos, y, s_displayWidth - xpos);
295  }
296  uint8_t c = ch[j];
297  if ( c >= s_fixedFont.ascii_offset )
298  {
299  c -= s_fixedFont.ascii_offset;
300  }
301  uint8_t ldata = 0;
302  uint16_t offset = (c * s_fixedFont.pages + (page_offset >> factor)) * s_fixedFont.width;
303  for( i=s_fixedFont.width; i>0; i--)
304  {
305  uint8_t data;
306  if ( style == STYLE_NORMAL )
307  {
308  data = pgm_read_byte(&s_fixedFont.data[offset]);
309  }
310  else if ( style == STYLE_BOLD )
311  {
312  uint8_t temp = pgm_read_byte(&s_fixedFont.data[offset]);
313  data = temp | ldata;
314  ldata = temp;
315  }
316  else
317  {
318  uint8_t temp = pgm_read_byte(&s_fixedFont.data[offset + 1]);
319  data = (temp & 0xF0) | ldata;
320  ldata = (temp & 0x0F);
321  }
322  if ( factor > 0 )
323  {
324  // N=0 -> right shift is always 0
325  // N=1 -> right shift goes through 0, 4
326  // N=2 -> right shift goes through 0, 2, 4, 6
327  // N=3 -> right shift goes through 0, 1, 2, 3, 4, 5, 6, 7
328  data >>= ((page_offset & ((1<<factor) - 1))<<(3-factor));
329  uint8_t accum = 0;
330  uint8_t mask = ~((0xFF) << (1<<factor));
331  for (uint8_t idx = 0; idx < 1<<(3-factor); idx++)
332  {
333  accum |= (((data>>idx) & 0x01) ? (mask<<(idx<<factor)) : 0);
334  }
335  data = accum;
336  }
337  for (uint8_t z=(1<<factor); z>0; z--)
338  {
339  ssd1306_sendPixels(data^s_invertByte);
340  }
341  offset++;
342  }
343  x += (s_fixedFont.width << factor);
344  j++;
345  }
347  return j;
348 }
349 
350 
351 uint8_t ssd1306_charF6x8(uint8_t x, uint8_t y, const char ch[], EFontStyle style)
352 {
353  uint8_t i, j=0;
356  while(ch[j] != '\0')
357  {
358  uint8_t c = ch[j] - 32;
359  if ( c > 224 )
360  {
361  c = 0;
362  }
363  if(x > s_displayWidth - 6)
364  {
365  x=0;
366  y++;
367  }
368  uint8_t ldata = 0;
369  for(i=0;i<6;i++)
370  {
371  uint8_t data;
372  if ( style == STYLE_NORMAL )
373  {
374  data = pgm_read_byte(&s_font6x8[c*6+i]);
375  }
376  else if ( style == STYLE_BOLD )
377  {
378  uint8_t temp = pgm_read_byte(&s_font6x8[c*6+i]);
379  data = temp | ldata;
380  ldata = temp;
381  }
382  else
383  {
384  uint8_t temp = pgm_read_byte(&s_font6x8[c*6+i + 1]);
385  data = (temp & 0xF0) | ldata;
386  ldata = (temp & 0x0F);
387  }
388  ssd1306_sendPixels(data^s_invertByte);
389  }
390  x += 6;
391  j++;
392  }
394  return j;
395 }
396 
397 uint8_t ssd1306_charF12x16(uint8_t xpos, uint8_t y, const char ch[], EFontStyle style)
398 {
399  uint8_t i, j=0;
400  uint8_t text_index = 0;
401  uint8_t odd = 0;
402  uint8_t x = xpos;
403  ssd1306_setRamBlock(xpos, y, s_displayWidth - xpos);
405  for(;;)
406  {
407  if( (x > s_displayWidth-12) || (ch[j] == '\0') )
408  {
409  x = xpos;
410  y++;
411  if (y >= (s_displayHeight >> 3))
412  {
413  break;
414  }
415  if (odd)
416  {
417  text_index = j;
418  if (ch[j] == '\0')
419  {
420  break;
421  }
422  }
423  else
424  {
425  j = text_index;
426  }
427  odd = !odd;
429  ssd1306_setRamBlock(xpos, y, s_displayWidth - xpos);
431  }
432  uint8_t c = ch[j] - 32;
433  if ( c > 224 )
434  {
435  c = 0;
436  }
437  uint8_t ldata = 0;
438  for(i=0;i<6;i++)
439  {
440  uint8_t data;
441  if ( style == STYLE_NORMAL )
442  {
443  data = pgm_read_byte(&s_font6x8[c*6+i]);
444  }
445  else if ( style == STYLE_BOLD )
446  {
447  uint8_t temp = pgm_read_byte(&s_font6x8[c*6+i]);
448  data = temp | ldata;
449  ldata = temp;
450  }
451  else
452  {
453  uint8_t temp = pgm_read_byte(&s_font6x8[c*6+i + 1]);
454  data = (temp & 0xF0) | ldata;
455  ldata = (temp & 0x0F);
456  }
457  if (odd) data >>= 4;
458  data = ((data & 0x01) ? 0x03: 0x00) |
459  ((data & 0x02) ? 0x0C: 0x00) |
460  ((data & 0x04) ? 0x30: 0x00) |
461  ((data & 0x08) ? 0xC0: 0x00);
462  ssd1306_sendPixels(data^s_invertByte);
463  ssd1306_sendPixels(data^s_invertByte);
464  }
465  x += 12;
466  j++;
467  }
469  return j;
470 }
471 
472 uint8_t ssd1306_charF6x8_eol(uint8_t left,
473  uint8_t y,
474  const char ch[],
475  EFontStyle style,
476  uint8_t right)
477 {
478  uint8_t len = ssd1306_charF6x8(left, y, ch, style);
479  uint8_t text_end_pos = len * 6 + left;
480  if (text_end_pos <= right)
481  {
482  ssd1306_clearBlock(text_end_pos, y, right - text_end_pos + 1, 8);
483  }
484  return len;
485 }
486 
487 void ssd1306_setFixedFont(const uint8_t * progmemFont)
488 {
489  s_fixedFont.width = pgm_read_byte(&progmemFont[1]);
490  s_fixedFont.pages = (pgm_read_byte(&progmemFont[2]) + 7) >> 3;
491  s_fixedFont.ascii_offset = pgm_read_byte(&progmemFont[3]);
492  s_fixedFont.data = progmemFont + 4;
493 }
494 
495 void ssd1306_setFont6x8(const uint8_t * progmemFont)
496 {
497  s_font6x8 = progmemFont + 4;
498 }
499 
500 void ssd1306_putPixel(uint8_t x, uint8_t y)
501 {
502  ssd1306_setRamBlock(x, y >> 3, 1);
504  ssd1306_sendPixels((1 << (y & 0x07))^s_invertByte);
506 }
507 
508 void ssd1306_putPixels(uint8_t x, uint8_t y, uint8_t pixels)
509 {
510  ssd1306_setRamBlock(x, y >> 3, 1);
512  ssd1306_sendPixels(pixels^s_invertByte);
514 }
515 
516 void ssd1306_putPixel_delayed(uint8_t x, uint8_t y, uint8_t complete)
517 {
518  static uint8_t lx = 0, ly = 0xFF;
519  static uint8_t pixels = 0;
520  if ((lx != x) || ((ly & 0xF8) != (y & 0xF8)) || (complete))
521  {
522  if (ly != 0xFF)
523  {
524  ssd1306_putPixels( lx, ly, pixels );
525  }
526  pixels = 0;
527  ly = 0xFF;
528  }
529  if ( !complete )
530  {
531  pixels |= (1 << (y & 0x07));
532  lx = x; ly = y;
533  }
534 }
535 
536 void ssd1306_drawLine(uint8_t x1, uint8_t y1, uint8_t x2, uint8_t y2)
537 {
538  uint8_t dx = x1 > x2 ? (x1 - x2): (x2 - x1);
539  uint8_t dy = y1 > y2 ? (y1 - y2): (y2 - y1);
540  uint8_t err = 0;
541  if (dy > dx)
542  {
543  if (y1 > y2)
544  {
545  swap_data(x1, x2);
546  swap_data(y1, y2);
547  }
548  for(; y1<=y2; y1++)
549  {
550  err += dx;
551  if (err >= dy)
552  {
553  err -= dy;
554  x1 < x2 ? x1++: x1--;
555  }
556  ssd1306_putPixel_delayed( x1, y1, 0 );
557  }
558  ssd1306_putPixel_delayed( 0, 0, 1 );
559  }
560  else
561  {
562  if (x1 > x2)
563  {
564  swap_data(x1, x2);
565  swap_data(y1, y2);
566  }
567 
568  for(; x1<=x2; x1++)
569  {
570  err += dy;
571  if (err >= dx)
572  {
573  err -= dx;
574  if (y1 < y2) y1++; else y1--;
575  }
576  ssd1306_putPixel( x1, y1 );
577  }
578  }
579 }
580 
581 void ssd1306_drawHLine(uint8_t x1, uint8_t y1, uint8_t x2)
582 {
583  ssd1306_setRamBlock(x1, y1 >> 3, x2 - x1 + 1);
585  for (uint8_t x = x1; x <= x2; x++)
586  {
587  ssd1306_sendPixels((1 << (y1 & 0x07))^s_invertByte);
588  }
590 }
591 
592 void ssd1306_drawVLine(uint8_t x1, uint8_t y1, uint8_t y2)
593 {
594  uint8_t topPage = y1 >> 3;
595  uint8_t bottomPage = y2 >> 3;
596  uint8_t height = y2-y1;
597  ssd1306_setRamBlock(x1, topPage, 1);
599  if (topPage == bottomPage)
600  {
601  ssd1306_sendPixels( ((0xFF >> (0x07 - height)) << (y1 & 0x07))^s_invertByte );
603  return;
604  }
605  ssd1306_sendPixels( (0xFF << (y1 & 0x07))^s_invertByte );
606  uint8_t y;
607  for ( y = (topPage + 1); y <= (bottomPage - 1); y++)
608  {
610  ssd1306_sendPixels( 0xFF^s_invertByte );
611  }
613  ssd1306_sendPixels( (0xFF >> (0x07 - (y2 & 0x07)))^s_invertByte );
615 }
616 
617 void ssd1306_drawRect(uint8_t x1, uint8_t y1, uint8_t x2, uint8_t y2)
618 {
619  ssd1306_drawHLine(x1+1, y1, x2-1);
620  ssd1306_drawHLine(x1+1, y2, x2-1);
621  ssd1306_drawVLine(x1, y1, y2);
622  ssd1306_drawVLine(x2, y1, y2);
623 }
624 
625 void ssd1306_drawBuffer(uint8_t x, uint8_t y, uint8_t w, uint8_t h, const uint8_t *buf)
626 {
627  uint8_t i, j;
628  ssd1306_setRamBlock(x, y, w);
630  for(j=(h >> 3); j>0; j--)
631  {
632  for(i=w;i>0;i--)
633  {
634  ssd1306_sendPixels(s_invertByte^*buf++);
635  }
637  }
639 }
640 
641 void ssd1306_drawBitmap(uint8_t x, uint8_t y, uint8_t w, uint8_t h, const uint8_t *buf)
642 {
643  uint8_t i, j;
644  uint8_t remainder = (s_displayWidth - x) < w ? (w + x - s_displayWidth): 0;
645  w -= remainder;
646  ssd1306_setRamBlock(x, y, w);
648  for(j=(h >> 3); j>0; j--)
649  {
650  for(i=w;i>0;i--)
651  {
652  ssd1306_sendPixels(s_invertByte^pgm_read_byte(buf++));
653  }
654  buf += remainder;
656  }
658 }
659 
660 
661 void ssd1306_clearBlock(uint8_t x, uint8_t y, uint8_t w, uint8_t h)
662 {
663  uint8_t i, j;
664  ssd1306_setRamBlock(x, y, w);
666  for(j=(h >> 3); j>0; j--)
667  {
668  for(i=w;i>0;i--)
669  {
670  ssd1306_sendPixels(s_invertByte);
671  }
673  }
675 }
676 
677 
678 void ssd1306_drawSpriteEx(uint8_t x, uint8_t y, uint8_t w, const uint8_t *sprite)
679 {
680  uint8_t i;
681  ssd1306_setRamBlock(x,y,w);
683  for(i=0;i<w;i++)
684  {
685  ssd1306_sendPixels(s_invertByte^pgm_read_byte(&sprite[i]));
686  }
688 }
689 
690 
692 {
693  uint8_t offsety = sprite->y & 0x7;
694  if (sprite->y < s_displayHeight)
695  {
696  ssd1306_setRamBlock(sprite->x, sprite->y >> 3, sprite->w);
698  for (uint8_t i=0; i < sprite->w; i++)
699  {
700  ssd1306_sendPixels( s_invertByte^(pgm_read_byte( &sprite->data[i] ) << offsety) );
701  }
703  }
704  if (offsety && (sprite->y + 8 < s_displayHeight))
705  {
706  ssd1306_setRamBlock(sprite->x, (sprite->y >> 3) + 1, sprite->w);
708  for (uint8_t i=0; i < sprite->w; i++)
709  {
710  ssd1306_sendPixels( s_invertByte^(pgm_read_byte( &sprite->data[i] ) >> (8 - offsety)) );
711  }
713  }
714  sprite->lx = sprite->x;
715  sprite->ly = sprite->y;
716 }
717 
718 
720 {
721  uint8_t posy = sprite->y >> 3;
722  uint8_t offsety = sprite->y & 0x7;
723  ssd1306_setRamBlock(sprite->x, posy, sprite->w);
725  for (uint8_t i=sprite->w; i > 0; i--)
726  {
727  ssd1306_sendPixels( s_invertByte );
728  }
730  if (offsety)
731  {
732  ssd1306_setRamBlock(sprite->x, posy + 1, sprite->w);
734  for (uint8_t i=sprite->w; i > 0; i--)
735  {
736  ssd1306_sendPixels( s_invertByte );
737  }
738  }
740 }
741 
742 
744 {
745  uint8_t y1 = sprite->ly >> 3;
746  uint8_t y2 = (sprite->ly + 7) >> 3;
747  if (sprite->ly < sprite->y)
748  y2 = min(y2, (uint8_t)((sprite->y >> 3) - 1));
749  else if (sprite->y + 8 > sprite->ly)
750  y1 = max(y1, (sprite->ly + 7) >> 3);
751  for(uint8_t y = y1; y <= y2; y++)
752  {
753  ssd1306_setRamBlock(sprite->lx, y, sprite->w);
755  for(uint8_t x = sprite->w; x > 0; x--)
756  {
757  ssd1306_sendPixels( s_invertByte );
758  }
760  }
761  if (sprite->lx != sprite->x)
762  {
763  uint8_t x1 = sprite->lx;
764  uint8_t x2 = sprite->lx + sprite->w - 1;
765  if (sprite->x < sprite->lx)
766  x1 = max(x1, sprite->x + sprite->w);
767  else
768  x2 = min((uint8_t)(sprite->x - 1), x2);
769  for(uint8_t y = sprite->ly >> 3; y <= (sprite->ly + 7) >> 3; y++)
770  {
771  ssd1306_setRamBlock(x1, y, x2 - x1 + 1 );
773  for(uint8_t x = x2 - x1 + 1; x > 0; x--)
774  {
775  ssd1306_sendPixels( s_invertByte );
776  }
778  }
779  }
780 }
781 
782 SPRITE ssd1306_createSprite(uint8_t x, uint8_t y, uint8_t w, const uint8_t *data)
783 {
784  return (SPRITE){x,y,w,x,y,data,NULL};
785 }
786 
787 void ssd1306_replaceSprite(SPRITE *sprite, const uint8_t *data)
788 {
789  sprite->data = data;
790 }
791 
793 {
795  {
796  ssd1306_sendCommand(SSD1306_INVERTDISPLAY);
797  }
798 }
799 
801 {
803  {
804  ssd1306_sendCommand(SSD1306_NORMALDISPLAY);
805  }
806 }
807 
809 {
810  s_invertByte = 0xFF;
811 }
812 
814 {
815  s_invertByte = 0x00;
816 }
uint8_t ssd1306_printFixed2x(uint8_t xpos, uint8_t y, const char ch[], EFontStyle style)
Definition: ssd1306.c:179
void ssd1306_drawBitmap(uint8_t x, uint8_t y, uint8_t w, uint8_t h, const uint8_t *buf)
Definition: ssd1306.c:641
void ssd1306_negativeMode()
Definition: ssd1306.c:808
void ssd1306_setContrast(uint8_t contrast)
Definition: ssd1306.c:98
const uint8_t * data
Pointer to PROGMEM data, representing sprite image.
void(* ssd1306_sendByte)(uint8_t data)
uint8_t ssd1306_printFixedN(uint8_t xpos, uint8_t y, const char ch[], EFontStyle style, uint8_t factor)
Definition: ssd1306.c:259
void ssd1306_displayOff()
Definition: ssd1306.c:87
void(* ssd1306_dataStart)()
void(* ssd1306_endTransmission)()
uint8_t ssd1306_displayHeight()
Definition: ssd1306.c:45
void ssd1306_replaceSprite(SPRITE *sprite, const uint8_t *data)
Definition: ssd1306.c:787
void ssd1306_drawHLine(uint8_t x1, uint8_t y1, uint8_t x2)
Definition: ssd1306.c:581
void(* ssd1306_nextRamPage)()
void ssd1306_displayOn()
Definition: ssd1306.c:93
void ssd1306_drawVLine(uint8_t x1, uint8_t y1, uint8_t y2)
Definition: ssd1306.c:592
void ssd1306_positiveMode()
Definition: ssd1306.c:813
const PROGMEM uint8_t ssd1306xled_font6x8[]
Definition: font6x8.c:18
uint8_t ascii_offset
ascii offset
void ssd1306_putPixels(uint8_t x, uint8_t y, uint8_t pixels)
Definition: ssd1306.c:508
SPRITE ssd1306_createSprite(uint8_t x, uint8_t y, uint8_t w, const uint8_t *data)
Definition: ssd1306.c:782
void ssd1306_drawLine(uint8_t x1, uint8_t y1, uint8_t x2, uint8_t y2)
Definition: ssd1306.c:536
void ssd1306_drawSpriteEx(uint8_t x, uint8_t y, uint8_t w, const uint8_t *sprite)
Definition: ssd1306.c:678
void ssd1306_sendCommand(uint8_t command)
void ssd1306_fillScreen(uint8_t fill_Data)
Definition: ssd1306.c:55
void ssd1306_drawRect(uint8_t x1, uint8_t y1, uint8_t x2, uint8_t y2)
Definition: ssd1306.c:617
void ssd1306_clearScreen()
Definition: ssd1306.c:71
#define max(a, b)
uint8_t y
draw position Y on the screen
#define min(a, b)
void ssd1306_clearBlock(uint8_t x, uint8_t y, uint8_t w, uint8_t h)
Definition: ssd1306.c:661
void ssd1306_setFixedFont(const uint8_t *progmemFont)
Definition: ssd1306.c:487
uint8_t width
width in pixels
uint8_t ssd1306_charF6x8_eol(uint8_t left, uint8_t y, const char ch[], EFontStyle style, uint8_t right)
Definition: ssd1306.c:472
void ssd1306_invertMode()
Definition: ssd1306.c:792
uint8_t x
draw position X on the screen
void ssd1306_setFont6x8(const uint8_t *progmemFont)
Definition: ssd1306.c:495
uint8_t ssd1306_displayWidth()
Definition: ssd1306.c:50
void ssd1306_drawSprite(SPRITE *sprite)
Definition: ssd1306.c:691
void ssd1306_eraseTrace(SPRITE *sprite)
Definition: ssd1306.c:743
void ssd1306_drawBuffer(uint8_t x, uint8_t y, uint8_t w, uint8_t h, const uint8_t *buf)
Definition: ssd1306.c:625
void ssd1306_eraseSprite(SPRITE *sprite)
Definition: ssd1306.c:719
void(* ssd1306_commandStart)()
uint8_t g_lcd_type
Definition: ssd1306.c:40
uint8_t s_displayHeight
Definition: ssd1306.c:38
void ssd1306_normalMode()
Definition: ssd1306.c:800
uint8_t w
sprite width
uint8_t ssd1306_charF12x16(uint8_t xpos, uint8_t y, const char ch[], EFontStyle style)
Definition: ssd1306.c:397
void(* ssd1306_setRamBlock)(uint8_t x, uint8_t y, uint8_t w)
void ssd1306_putPixel(uint8_t x, uint8_t y)
Definition: ssd1306.c:500
uint8_t lx
last draw position X on the screen
uint8_t ssd1306_printFixed(uint8_t xpos, uint8_t y, const char ch[], EFontStyle style)
Definition: ssd1306.c:106
const uint8_t * data
font chars bits
void(* ssd1306_sendPixels)(uint8_t data)
EFontStyle
uint8_t pages
height in pages
uint8_t s_displayWidth
Definition: ssd1306.c:39
uint8_t ssd1306_charF6x8(uint8_t x, uint8_t y, const char ch[], EFontStyle style)
Definition: ssd1306.c:351
uint8_t ly
last draw position Y on the screen