LibDriver SSD1309
Loading...
Searching...
No Matches
driver_ssd1309.c
Go to the documentation of this file.
1
36
37#include "driver_ssd1309.h"
38#include "driver_ssd1309_font.h"
39
43#define CHIP_NAME "Solomon Systech SSD1309"
44#define MANUFACTURER_NAME "Solomon Systech"
45#define SUPPLY_VOLTAGE_MIN 1.65f
46#define SUPPLY_VOLTAGE_MAX 3.3f
47#define MAX_CURRENT 0.58f
48#define TEMPERATURE_MIN -40.0f
49#define TEMPERATURE_MAX 85.0f
50#define DRIVER_VERSION 1000
51
55#define SSD1309_CMD 0
56#define SSD1309_DATA 1
57
61#define SSD1309_CMD_LOWER_COLUMN_START_ADDRESS 0x00
62#define SSD1309_CMD_HIGHER_COLUMN_START_ADDRESS 0x10
63#define SSD1309_CMD_MEMORY_ADDRESSING_MODE 0x20
64#define SSD1309_CMD_SET_COLUMN_ADDRESS 0x21
65#define SSD1309_CMD_SET_PAGE_ADDRESS 0x22
66#define SSD1309_CMD_RIGHT_HORIZONTAL_SCROLL 0x26
67#define SSD1309_CMD_LEFT_HORIZONTAL_SCROLL 0x27
68#define SSD1309_CMD_VERTICAL_RIGHT_HORIZONTAL_SCROLL 0x29
69#define SSD1309_CMD_VERTICAL_LEFT_HORIZONTAL_SCROLL 0x2A
70#define SSD1309_CMD_RIGHT_HORIZONTAL_SCROLL_ONE_COL 0x2C
71#define SSD1309_CMD_LEFT_HORIZONTAL_SCROLL_ONE_COL 0x2D
72#define SSD1309_CMD_DEACTIVATE_SCROLL 0x2E
73#define SSD1309_CMD_ACTIVATE_SCROLL 0x2F
74#define SSD1309_CMD_DISPLAY_START_LINE 0x40
75#define SSD1309_CMD_CONTRAST_CONTROL 0x81
76#define SSD1309_CMD_COLUMN_0_MAPPED_TO_SEG0 0xA0
77#define SSD1309_CMD_COLUMN_127_MAPPED_TO_SEG0 0xA1
78#define SSD1309_CMD_VERTICAL_SCROLL_AREA 0xA3
79#define SSD1309_CMD_ENTIRE_DISPLAY_OFF 0xA4
80#define SSD1309_CMD_ENTIRE_DISPLAY_ON 0xA5
81#define SSD1309_CMD_NORMAL_DISPLAY 0xA6
82#define SSD1309_CMD_INVERSE_DISPLAY 0xA7
83#define SSD1309_CMD_MULTIPLEX_RATIO 0xA8
84#define SSD1309_CMD_DISPLAY_OFF 0xAE
85#define SSD1309_CMD_DISPLAY_ON 0xAF
86#define SSD1309_CMD_PAGE_ADDR 0xB0
87#define SSD1309_CMD_SCAN_DIRECTION_COM0_START 0xC0
88#define SSD1309_CMD_SCAN_DIRECTION_COMN_1_START 0xC8
89#define SSD1309_CMD_DISPLAY_OFFSET 0xD3
90#define SSD1309_CMD_DISPLAY_CLOCK_DIVIDE 0xD5
91#define SSD1309_CMD_PRE_CHARGE_PERIOD 0xD9
92#define SSD1309_CMD_COM_PINS_CONF 0xDA
93#define SSD1309_CMD_COMH_DESLECT_LEVEL 0xDB
94#define SSD1309_CMD_GPIO 0xDC
95#define SSD1309_CMD_LOCK 0xFD
96
107static uint8_t a_ssd1309_write_byte(ssd1309_handle_t *handle, uint8_t data, uint8_t cmd)
108{
109 uint8_t res;
110
111 if (handle->iic_spi == SSD1309_INTERFACE_IIC) /* if iic */
112 {
113 if (cmd != 0) /* if data */
114 {
115 if (handle->iic_write(handle->iic_addr, 0x40, &data, 1) != 0) /* write data */
116 {
117 return 1; /* return error */
118 }
119 else
120 {
121 return 0; /* success return 0 */
122 }
123 }
124 else
125 {
126 if (handle->iic_write(handle->iic_addr, 0x00, &data, 1) != 0) /* write command */
127 {
128 return 1; /* return error */
129 }
130 else
131 {
132 return 0; /* success return 0 */
133 }
134 }
135 }
136 else if (handle->iic_spi == SSD1309_INTERFACE_SPI) /* if spi */
137 {
138 res = handle->spi_cmd_data_gpio_write(cmd); /* write data command */
139 if (res != 0) /* check error */
140 {
141 return 1; /* return error */
142 }
143
144 if (handle->spi_write_cmd(&data, 1) != 0) /* write command */
145 {
146 return 1; /* return error */
147 }
148 else
149 {
150 return 0; /* success return 0 */
151 }
152 }
153 else
154 {
155 return 1; /* return error */
156 }
157}
158
170static uint8_t a_ssd1309_multiple_write_byte(ssd1309_handle_t *handle, uint8_t *data, uint8_t len, uint8_t cmd)
171{
172 uint8_t res;
173
174 if (handle->iic_spi == SSD1309_INTERFACE_IIC) /* if iic */
175 {
176 if (cmd != 0) /* if data */
177 {
178 if (handle->iic_write(handle->iic_addr, 0x40, data, len) != 0) /* write data */
179 {
180 return 1; /* return error */
181 }
182 else
183 {
184 return 0; /* success return 0 */
185 }
186 }
187 else
188 {
189 if (handle->iic_write(handle->iic_addr, 0x00, data, len) != 0) /* write command */
190 {
191 return 1; /* return error */
192 }
193 else
194 {
195 return 0; /* success return 0 */
196 }
197 }
198 }
199 else if (handle->iic_spi == SSD1309_INTERFACE_SPI) /* if spi */
200 {
201 res = handle->spi_cmd_data_gpio_write(cmd); /* write data command */
202 if (res != 0) /* check error */
203 {
204 return 1; /* return error */
205 }
206
207 if (handle->spi_write_cmd(data, len) != 0) /* write command */
208 {
209 return 1; /* return error */
210 }
211 else
212 {
213 return 0; /* success return 0 */
214 }
215 }
216 else
217 {
218 return 1; /* return error */
219 }
220}
221
233static uint8_t a_ssd1309_gram_draw_point(ssd1309_handle_t *handle, uint8_t x, uint8_t y, uint8_t data)
234{
235 uint8_t pos;
236 uint8_t bx;
237 uint8_t temp = 0;
238
239 pos = y / 8; /* get y page */
240 bx = y % 8; /* get y point */
241 temp = 1 << bx; /* set data */
242 if (data != 0) /* if 1 */
243 {
244 handle->gram[x][pos] |= temp; /* set 1 */
245 }
246 else
247 {
248 handle->gram[x][pos] &= ~temp; /* set 0 */
249 }
250
251 return 0; /* success return 0 */
252}
253
267static uint8_t a_ssd1309_gram_show_char(ssd1309_handle_t *handle, uint8_t x, uint8_t y, uint8_t chr, uint8_t size, uint8_t mode)
268{
269 uint8_t temp, t, t1;
270 uint8_t y0 = y;
271 uint8_t csize = (size / 8 + ((size % 8) ? 1 : 0)) * (size / 2); /* get size */
272
273 chr = chr - ' '; /* get index */
274 for (t = 0; t < csize; t++) /* write size */
275 {
276 if (size == 12) /* if size 12 */
277 {
278 temp = gsc_ssd1309_ascii_1206[chr][t]; /* get ascii 1206 */
279 }
280 else if (size == 16) /* if size 16 */
281 {
282 temp = gsc_ssd1309_ascii_1608[chr][t]; /* get ascii 1608 */
283 }
284 else if(size == 24) /* if size 24 */
285 {
286 temp = gsc_ssd1309_ascii_2412[chr][t]; /* get ascii 2412 */
287 }
288 else
289 {
290 return 1; /* return error */
291 }
292 for (t1 = 0; t1 < 8; t1++) /* write one line */
293 {
294 if ((temp & 0x80) != 0) /* if 1 */
295 {
296 if (a_ssd1309_gram_draw_point(handle, x, y, mode) != 0) /* draw point */
297 {
298 return 1; /* return error */
299 }
300 }
301 else
302 {
303 if (a_ssd1309_gram_draw_point(handle, x, y, !mode) != 0) /* draw point */
304 {
305 return 1; /* return error */
306 }
307 }
308 temp <<= 1; /* left shift 1 */
309 y++;
310 if ((y - y0) == size) /* reset size */
311 {
312 y = y0; /* set y */
313 x++; /* x++ */
314
315 break; /* break */
316 }
317 }
318 }
319
320 return 0; /* success return 0 */
321}
322
334{
335 uint8_t i;
336 uint8_t n;
337
338 if (handle == NULL) /* check handle */
339 {
340 return 2; /* return error */
341 }
342 if (handle->inited != 1) /* check handle initialization */
343 {
344 return 3; /* return error */
345 }
346
347 for (i = 0; i < 8; i++) /* write 8 page */
348 {
349 if (a_ssd1309_write_byte(handle, SSD1309_CMD_PAGE_ADDR + i, SSD1309_CMD) != 0) /* set page */
350 {
351 handle->debug_print("ssd1309: write byte failed.\n"); /* write byte failed */
352
353 return 1; /* return error */
354 }
355 if (a_ssd1309_write_byte(handle, SSD1309_CMD_LOWER_COLUMN_START_ADDRESS, SSD1309_CMD) != 0) /* set lower column 0 */
356 {
357 handle->debug_print("ssd1309: write byte failed.\n"); /* write byte failed */
358
359 return 1; /* return error */
360 }
361 if (a_ssd1309_write_byte(handle, SSD1309_CMD_HIGHER_COLUMN_START_ADDRESS, SSD1309_CMD) != 0) /* set higher column 0 */
362 {
363 handle->debug_print("ssd1309: write byte failed.\n"); /* write byte failed */
364
365 return 1; /* return error */
366 }
367 for (n = 0; n < 128; n++) /* write 128 */
368 {
369 handle->gram[n][i] = 0x00; /* set black */
370 if (a_ssd1309_write_byte(handle, handle->gram[n][i], SSD1309_DATA) != 0) /* write data */
371 {
372 handle->debug_print("ssd1309: write byte failed.\n"); /* write byte failed */
373
374 return 1; /* return error */
375 }
376 }
377 }
378
379 return 0; /* success return 0 */
380}
381
393{
394 uint8_t i;
395 uint8_t n;
396
397 if (handle == NULL) /* check handle */
398 {
399 return 2; /* return error */
400 }
401 if (handle->inited != 1) /* check handle initialization */
402 {
403 return 3; /* return error */
404 }
405
406 for (i = 0; i < 8; i++) /* write 8 page */
407 {
408 if (a_ssd1309_write_byte(handle, SSD1309_CMD_PAGE_ADDR + i, SSD1309_CMD) != 0) /* set page */
409 {
410 handle->debug_print("ssd1309: write byte failed.\n"); /* write byte failed */
411
412 return 1; /* return error */
413 }
414 if (a_ssd1309_write_byte(handle, SSD1309_CMD_LOWER_COLUMN_START_ADDRESS, SSD1309_CMD) != 0) /* set lower column 0 */
415 {
416 handle->debug_print("ssd1309: write byte failed.\n"); /* write byte failed */
417
418 return 1; /* return error */
419 }
420 if (a_ssd1309_write_byte(handle, SSD1309_CMD_HIGHER_COLUMN_START_ADDRESS, SSD1309_CMD) != 0) /* set higher column 0 */
421 {
422 handle->debug_print("ssd1309: write byte failed.\n"); /* write byte failed */
423
424 return 1; /* return error */
425 }
426 for (n = 0; n < 128; n++) /* write 128 */
427 {
428 if (a_ssd1309_write_byte(handle, handle->gram[n][i], SSD1309_DATA) != 0) /* write data */
429 {
430 handle->debug_print("ssd1309: write byte failed.\n"); /* write byte failed */
431
432 return 1; /* return error */
433 }
434 }
435 }
436
437 return 0; /* success return 0 */
438}
439
454uint8_t ssd1309_write_point(ssd1309_handle_t *handle, uint8_t x, uint8_t y, uint8_t data)
455{
456 uint8_t pos;
457 uint8_t bx;
458 uint8_t temp = 0;
459
460 if (handle == NULL) /* check handle */
461 {
462 return 2; /* return error */
463 }
464 if (handle->inited != 1) /* check handle initialization */
465 {
466 return 3; /* return error */
467 }
468 if ((x > 127) || (y > 63)) /* check x, y */
469 {
470 handle->debug_print("ssd1309: x or y is invalid.\n"); /* x or y is invalid */
471
472 return 4; /* return error */
473 }
474
475 pos = y / 8; /* get y page */
476 bx = y % 8; /* get y point */
477 temp = 1 << bx; /* set data */
478 if (data != 0) /* check the data */
479 {
480 handle->gram[x][pos] |= temp; /* set 1 */
481 }
482 else
483 {
484 handle->gram[x][pos] &= ~temp; /* set 0 */
485 }
486 if (a_ssd1309_write_byte(handle, SSD1309_CMD_PAGE_ADDR + pos, SSD1309_CMD) != 0) /* write page addr */
487 {
488 handle->debug_print("ssd1309: write byte failed.\n"); /* write byte failed */
489
490 return 1; /* return error */
491 }
492 if (a_ssd1309_write_byte(handle, SSD1309_CMD_LOWER_COLUMN_START_ADDRESS|(x&0x0F), SSD1309_CMD) != 0) /* write lower column */
493 {
494 handle->debug_print("ssd1309: write byte failed.\n"); /* write byte failed */
495
496 return 1; /* return error */
497 }
498 if (a_ssd1309_write_byte(handle, SSD1309_CMD_HIGHER_COLUMN_START_ADDRESS|((x>4)&0x0F), SSD1309_CMD) != 0) /* write higher column */
499 {
500 handle->debug_print("ssd1309: write byte failed.\n"); /* write byte failed */
501
502 return 1; /* return error */
503 }
504 if (a_ssd1309_write_byte(handle, handle->gram[x][pos], SSD1309_DATA) != 0) /* write data */
505 {
506 handle->debug_print("ssd1309: write byte failed.\n"); /* write byte failed */
507
508 return 1; /* return error */
509 }
510 else
511 {
512 return 0; /* success return 0 */
513 }
514}
515
530uint8_t ssd1309_read_point(ssd1309_handle_t *handle, uint8_t x, uint8_t y, uint8_t *data)
531{
532 uint8_t pos;
533 uint8_t bx;
534 uint8_t temp = 0;
535
536 if (handle == NULL) /* check handle */
537 {
538 return 2; /* return error */
539 }
540 if (handle->inited != 1) /* check handle initialization */
541 {
542 return 3; /* return error */
543 }
544 if ((x > 127) || (y > 63)) /* check x, y */
545 {
546 handle->debug_print("ssd1309: x or y is invalid.\n"); /* x or y is invalid */
547
548 return 4; /* return error */
549 }
550
551 pos = y / 8; /* get y page */
552 bx = y % 8; /* get y point */
553 temp = 1 << bx; /* set data */
554 if ((handle->gram[x][pos] & temp) != 0) /* get data */
555 {
556 *data = 1; /* set 1 */
557 }
558 else
559 {
560 *data = 0; /* set 0 */
561 }
562
563 return 0; /* success return 0 */
564}
565
580uint8_t ssd1309_gram_write_point(ssd1309_handle_t *handle, uint8_t x, uint8_t y, uint8_t data)
581{
582 uint8_t pos;
583 uint8_t bx;
584 uint8_t temp = 0;
585
586 if (handle == NULL) /* check handle */
587 {
588 return 2; /* return error */
589 }
590 if (handle->inited != 1) /* check handle initialization */
591 {
592 return 3; /* return error */
593 }
594 if ((x > 127) || (y > 63)) /* check x, y */
595 {
596 handle->debug_print("ssd1309: x or y is invalid.\n"); /* x or y is invalid */
597
598 return 4; /* return error */
599 }
600
601 pos = y / 8; /* get y page */
602 bx = y % 8; /* get y point */
603 temp = 1 << bx; /* set data */
604 if (data != 0) /* if 1 */
605 {
606 handle->gram[x][pos] |= temp; /* set 1 */
607 }
608 else
609 {
610 handle->gram[x][pos] &= ~temp; /* set 0 */
611 }
612
613 return 0; /* success return 0 */
614}
615
630uint8_t ssd1309_gram_read_point(ssd1309_handle_t *handle, uint8_t x, uint8_t y, uint8_t *data)
631{
632 uint8_t pos;
633 uint8_t bx;
634 uint8_t temp = 0;
635
636 if (handle == NULL) /* check handle */
637 {
638 return 2; /* return error */
639 }
640 if (handle->inited != 1) /* check handle initialization */
641 {
642 return 3; /* return error */
643 }
644 if ((x > 127) || (y > 63)) /* check x, y */
645 {
646 handle->debug_print("ssd1309: x or y is invalid.\n"); /* x or y is invalid */
647
648 return 4; /* return error */
649 }
650
651 pos = y / 8; /* get y page */
652 bx = y % 8; /* get y point */
653 temp = 1 << bx; /* set data */
654 if ((handle->gram[x][pos] & temp) != 0) /* get data */
655 {
656 *data = 1; /* set 1 */
657 }
658 else
659 {
660 *data = 0; /* set 0 */
661 }
662
663 return 0; /* success return 0 */
664}
665
683uint8_t ssd1309_gram_write_string(ssd1309_handle_t *handle, uint8_t x, uint8_t y, char *str, uint16_t len, uint8_t color, ssd1309_font_t font)
684{
685 if (handle == NULL) /* check handle */
686 {
687 return 2; /* return error */
688 }
689 if (handle->inited != 1) /* check handle initialization */
690 {
691 return 3; /* return error */
692 }
693 if((x > 127) || (y > 63)) /* check x, y */
694 {
695 handle->debug_print("ssd1309: x or y is invalid.\n"); /* x or y is invalid */
696
697 return 4; /* return error */
698 }
699
700 while ((len != 0) && (*str <= '~') && (*str >= ' ')) /* write all string */
701 {
702 if (x > (127 - (font / 2))) /* check x point */
703 {
704 x = 0; /* set x */
705 y += (uint8_t)font; /* set next row */
706 }
707 if (y > (63 - font)) /* check y pont */
708 {
709 y = x = 0; /* reset to 0,0 */
710 }
711 if (a_ssd1309_gram_show_char(handle, x, y, *str, font, color) != 0) /* show a char */
712 {
713 return 1; /* return error */
714 }
715 x += (uint8_t)(font / 2); /* x + font/2 */
716 str++; /* str address++ */
717 len--; /* str length-- */
718 }
719
720 return 0; /* success return 0 */
721}
722
741uint8_t ssd1309_gram_fill_rect(ssd1309_handle_t *handle, uint8_t left, uint8_t top, uint8_t right, uint8_t bottom, uint8_t color)
742{
743 uint8_t x, y;
744
745 if (handle == NULL) /* check handle */
746 {
747 return 2; /* return error */
748 }
749 if (handle->inited != 1) /* check handle initialization */
750 {
751 return 3; /* return error */
752 }
753 if ((left > 127) || (top > 63)) /* check left top */
754 {
755 handle->debug_print("ssd1309: left or top is invalid.\n"); /* left or top is invalid */
756
757 return 4; /* return error */
758 }
759 if ((right > 127) || (bottom > 63)) /* check right bottom */
760 {
761 handle->debug_print("ssd1309: right or bottom is invalid.\n"); /* right or bottom is invalid */
762
763 return 5; /* return error */
764 }
765 if ((left > right) || (top > bottom)) /* check left right top bottom */
766 {
767 handle->debug_print("ssd1309: left > right or top > bottom.\n"); /* left > right or top > bottom */
768
769 return 6; /* return error */
770 }
771
772 for (x = left; x <= right; x++) /* write x */
773 {
774 for (y = top; y <= bottom; y++) /* write y */
775 {
776 if (a_ssd1309_gram_draw_point(handle, x, y, color) != 0) /* draw point */
777 {
778 return 1; /* return error */
779 }
780 }
781 }
782
783 return 0; /* return error */
784}
785
804uint8_t ssd1309_gram_draw_picture(ssd1309_handle_t *handle, uint8_t left, uint8_t top, uint8_t right, uint8_t bottom, uint8_t *img)
805{
806 uint8_t x, y;
807
808 if (handle == NULL) /* check handle */
809 {
810 return 2; /* return error */
811 }
812 if (handle->inited != 1) /* check handle initialization */
813 {
814 return 3; /* return error */
815 }
816 if ((left > 127) || (top > 63)) /* check left top */
817 {
818 handle->debug_print("ssd1309: left or top is invalid.\n"); /* left or top is invalid */
819
820 return 4; /* return error */
821 }
822 if ((right > 127) || (bottom > 63)) /* check right bottom */
823 {
824 handle->debug_print("ssd1309: right or bottom is invalid.\n"); /* right or bottom is invalid */
825
826 return 5; /* return error */
827 }
828 if ((left > right) || (top > bottom)) /* check left right top bottom */
829 {
830 handle->debug_print("ssd1309: left > right or top > bottom.\n"); /* left > right or top > bottom */
831
832 return 6; /* return error */
833 }
834
835 for (x = left; x <= right; x++) /* write x */
836 {
837 for (y = top; y <= bottom; y++) /* write y */
838 {
839 if (a_ssd1309_gram_draw_point(handle, x, y, *img) != 0) /* draw point */
840 {
841 return 1; /* return error */
842 }
843 img++; /* img++ */
844 }
845 }
846
847 return 0; /* succeed return 0 */
848}
849
864{
865 if (handle == NULL) /* check handle */
866 {
867 return 2; /* return error */
868 }
869 if (handle->debug_print == NULL) /* check debug_print */
870 {
871 return 3; /* return error */
872 }
873 if (handle->iic_init == NULL) /* check iic_init */
874 {
875 handle->debug_print("ssd1309: iic_init is null.\n"); /* iic_init is null */
876
877 return 3; /* return error */
878 }
879 if (handle->iic_deinit == NULL) /* check iic_deinit */
880 {
881 handle->debug_print("ssd1309: iic_deinit is null.\n"); /* iic_deinit is null */
882
883 return 3; /* return error */
884 }
885 if (handle->iic_write == NULL) /* check iic_write */
886 {
887 handle->debug_print("ssd1309: iic_write is null.\n"); /* iic_write is null */
888
889 return 3; /* return error */
890 }
891 if (handle->spi_init == NULL) /* check spi_init */
892 {
893 handle->debug_print("ssd1309: spi_init is null.\n"); /* spi_init is null */
894
895 return 3; /* return error */
896 }
897 if (handle->spi_deinit == NULL) /* check spi_deinit */
898 {
899 handle->debug_print("ssd1309: spi_deinit is null.\n"); /* spi_deinit is null */
900
901 return 3; /* return error */
902 }
903 if (handle->spi_write_cmd == NULL) /* check spi_write_cmd */
904 {
905 handle->debug_print("ssd1309: spi_write_cmd is null.\n"); /* spi_write_cmd is null */
906
907 return 3; /* return error */
908 }
909 if (handle->delay_ms == NULL) /* check delay_ms */
910 {
911 handle->debug_print("ssd1309: delay_ms is null.\n"); /* delay_ms is null */
912
913 return 3; /* return error */
914 }
915 if (handle->spi_cmd_data_gpio_init == NULL) /* check spi_cmd_data_gpio_init */
916 {
917 handle->debug_print("ssd1309: spi_cmd_data_gpio_init is null.\n"); /* spi_cmd_data_gpio_init is null */
918
919 return 3; /* return error */
920 }
921 if (handle->spi_cmd_data_gpio_deinit == NULL) /* check spi_cmd_data_gpio_deinit */
922 {
923 handle->debug_print("ssd1309: spi_cmd_data_gpio_deinit is null.\n"); /* spi_cmd_data_gpio_deinit is null */
924
925 return 3; /* return error */
926 }
927 if (handle->spi_cmd_data_gpio_write == NULL) /* check spi_cmd_data_gpio_write */
928 {
929 handle->debug_print("ssd1309: spi_cmd_data_gpio_write is null.\n"); /* spi_cmd_data_gpio_write is null */
930
931 return 3; /* return error */
932 }
933 if (handle->reset_gpio_init == NULL) /* check reset_gpio_init */
934 {
935 handle->debug_print("ssd1309: reset_gpio_init is null.\n"); /* reset_gpio_init is null */
936
937 return 3; /* return error */
938 }
939 if (handle->reset_gpio_deinit == NULL) /* check reset_gpio_deinit */
940 {
941 handle->debug_print("ssd1309: reset_gpio_deinit is null.\n"); /* reset_gpio_deinit is null */
942
943 return 3; /* return error */
944 }
945 if(handle->reset_gpio_write == NULL) /* check reset_gpio_write */
946 {
947 handle->debug_print("ssd1309: reset_gpio_write is null.\n"); /* reset_gpio_write is null */
948
949 return 3; /* return error */
950 }
951
952 if (handle->spi_cmd_data_gpio_init() != 0) /* check spi_cmd_data_gpio_init */
953 {
954 handle->debug_print("ssd1309: spi cmd data gpio init failed.\n"); /* spi cmd data gpio init failed */
955
956 return 5; /* return error */
957 }
958 if (handle->reset_gpio_init() != 0) /* reset gpio init */
959 {
960 handle->debug_print("ssd1309: reset gpio init failed.\n"); /* reset gpio init failed */
961 (void)handle->spi_cmd_data_gpio_deinit(); /* spi_cmd_data_gpio_deinit */
962
963 return 4; /* return error */
964 }
965 if (handle->reset_gpio_write(0) != 0) /* write 0 */
966 {
967 handle->debug_print("ssd1309: reset gpio write failed.\n"); /* reset gpio write failed */
968 (void)handle->spi_cmd_data_gpio_deinit(); /* spi_cmd_data_gpio_deinit */
969 (void)handle->reset_gpio_deinit(); /* reset_gpio_deinit */
970
971 return 4; /* return error */
972 }
973 handle->delay_ms(100); /* delay 100 ms */
974 if (handle->reset_gpio_write(1) != 0) /* write 1 */
975 {
976 handle->debug_print("ssd1309: reset gpio write failed.\n"); /* reset gpio write failed */
977 (void)handle->spi_cmd_data_gpio_deinit(); /* spi_cmd_data_gpio_deinit */
978 (void)handle->reset_gpio_deinit(); /* reset_gpio_deinit */
979
980 return 4; /* return error */
981 }
982 if (handle->iic_spi == SSD1309_INTERFACE_IIC) /* if iic interface */
983 {
984 if (handle->iic_init() != 0) /* iic init */
985 {
986 handle->debug_print("ssd1309: iic init failed.\n"); /* iic init failed */
987 (void)handle->spi_cmd_data_gpio_deinit(); /* spi_cmd_data_gpio_deinit */
988 (void)handle->reset_gpio_deinit(); /* reset_gpio_deinit */
989
990 return 1; /* return error */
991 }
992 }
993 else if (handle->iic_spi == SSD1309_INTERFACE_SPI) /* if spi interface */
994 {
995 if (handle->spi_init() != 0) /* spi init */
996 {
997 handle->debug_print("ssd1309: spi init failed.\n"); /* spi init failed */
998 (void)handle->spi_cmd_data_gpio_deinit(); /* spi_cmd_data_gpio_deinit */
999 (void)handle->reset_gpio_deinit(); /* reset_gpio_deinit */
1000
1001 return 1; /* return error */
1002 }
1003 }
1004 else
1005 {
1006 handle->debug_print("ssd1309: interface is invalid.\n"); /* interface is invalid */
1007 (void)handle->spi_cmd_data_gpio_deinit(); /* spi_cmd_data_gpio_deinit */
1008 (void)handle->reset_gpio_deinit(); /* reset_gpio_deinit */
1009
1010 return 6; /* return error */
1011 }
1012 handle->inited = 1; /* flag inited */
1013
1014 return 0; /* success return 0 */
1015}
1016
1032{
1033 if (handle == NULL) /* check handle */
1034 {
1035 return 2; /* return error */
1036 }
1037 if (handle->inited != 1) /* check handle initialization */
1038 {
1039 return 3; /* return error */
1040 }
1041
1042 if (a_ssd1309_write_byte(handle, SSD1309_CMD_DISPLAY_OFF, SSD1309_CMD) != 0) /* write display off */
1043 {
1044 handle->debug_print("ssd1309: write command failed.\n"); /* write command failed */
1045
1046 return 4; /* return error */
1047 }
1048 if (handle->reset_gpio_deinit() != 0) /* reset gpio deinit */
1049 {
1050 handle->debug_print("ssd1309: reset gpio deinit failed.\n"); /* reset gpio deinit failed */
1051
1052 return 5; /* return error */
1053 }
1054 if (handle->spi_cmd_data_gpio_deinit() != 0) /* spi cmd data gpio deinit */
1055 {
1056 handle->debug_print("ssd1309: spi cmd data gpio deinit failed.\n"); /* spi cmd data gpio deinit failed */
1057
1058 return 6; /* return error */
1059 }
1060 if (handle->iic_spi == SSD1309_INTERFACE_IIC) /* if iic interface */
1061 {
1062 if (handle->iic_deinit() != 0) /* iic deinit */
1063 {
1064 handle->debug_print("ssd1309: iic deinit failed.\n"); /* iic deinit failed */
1065
1066 return 1; /* return error */
1067 }
1068 }
1069 else if (handle->iic_spi == SSD1309_INTERFACE_SPI) /* if spi interface */
1070 {
1071 if (handle->spi_deinit() != 0) /* spi deinit */
1072 {
1073 handle->debug_print("ssd1309: spi deinit failed.\n"); /* spi deinit failed */
1074
1075 return 1; /* return error */
1076 }
1077 }
1078 else
1079 {
1080 handle->debug_print("ssd1309: interface is invalid.\n"); /* interface is invalid */
1081
1082 return 7; /* return error */
1083 }
1084 handle->inited = 0; /* flag close */
1085
1086 return 0; /* success return 0 */
1087}
1088
1099{
1100 if (handle == NULL) /* check handle */
1101 {
1102 return 2; /* return error */
1103 }
1104
1105 handle->iic_spi = (uint8_t)interface; /* set interface */
1106
1107 return 0; /* success return 0 */
1108}
1109
1120{
1121 if (handle == NULL) /* check handle */
1122 {
1123 return 2; /* return error */
1124 }
1125
1126 *interface = (ssd1309_interface_t)(handle->iic_spi); /* get interface */
1127
1128 return 0; /* success return 0 */
1129}
1130
1141{
1142 if (handle == NULL) /* check handle */
1143 {
1144 return 2; /* return error */
1145 }
1146
1147 handle->iic_addr = (uint8_t)addr_pin; /* set addr pin */
1148
1149 return 0; /* success return 0 */
1150}
1151
1162{
1163 if (handle == NULL) /* check handle */
1164 {
1165 return 2; /* return error */
1166 }
1167
1168 *addr_pin = (ssd1309_address_t)(handle->iic_addr); /* set address */
1169
1170 return 0; /* success return 0 */
1171}
1172
1186{
1187 if (handle == NULL) /* check handle */
1188 {
1189 return 2; /* return error */
1190 }
1191 if (handle->inited != 1) /* check handle initialization */
1192 {
1193 return 3; /* return error */
1194 }
1195 if (addr > 0x0F) /* check addr */
1196 {
1197 handle->debug_print("ssd1309: addr is invalid.\n"); /* addr is invalid */
1198
1199 return 4; /* return error */
1200 }
1201
1202 return a_ssd1309_write_byte(handle, SSD1309_CMD_LOWER_COLUMN_START_ADDRESS | (addr & 0x0F), SSD1309_CMD); /* write command */
1203}
1204
1218{
1219 if (handle == NULL) /* check handle */
1220 {
1221 return 2; /* return error */
1222 }
1223 if (handle->inited != 1) /* check handle initialization */
1224 {
1225 return 3; /* return error */
1226 }
1227 if (addr > 0x0F) /* check addr */
1228 {
1229 handle->debug_print("ssd1309: addr is invalid.\n"); /* addr is invalid */
1230
1231 return 4; /* return error */
1232 }
1233
1234 return a_ssd1309_write_byte(handle, SSD1309_CMD_HIGHER_COLUMN_START_ADDRESS | (addr & 0x0F), SSD1309_CMD); /* write command */
1235}
1236
1249{
1250 uint8_t buf[2];
1251
1252 if (handle == NULL) /* check handle */
1253 {
1254 return 2; /* return error */
1255 }
1256 if (handle->inited != 1) /* check handle initialization */
1257 {
1258 return 3; /* return error */
1259 }
1260
1261 buf[0] = SSD1309_CMD_MEMORY_ADDRESSING_MODE; /* set command mode */
1262 buf[1] = mode; /* set mode */
1263
1264 return a_ssd1309_multiple_write_byte(handle, (uint8_t *)buf, 2, SSD1309_CMD); /* write command */
1265}
1266
1281uint8_t ssd1309_set_column_address_range(ssd1309_handle_t *handle, uint8_t start_addr, uint8_t end_addr)
1282{
1283 uint8_t buf[3];
1284
1285 if (handle == NULL) /* check handle */
1286 {
1287 return 2; /* return error */
1288 }
1289 if (handle->inited != 1) /* check handle initialization */
1290 {
1291 return 3; /* return error */
1292 }
1293 if (start_addr > 0x7F) /* check start addr */
1294 {
1295 handle->debug_print("ssd1309: start addr is invalid.\n"); /* start addr is invalid */
1296
1297 return 4; /* return error */
1298 }
1299 if (end_addr > 0x7F) /* check end addr */
1300 {
1301 handle->debug_print("ssd1309: end addr is invalid.\n"); /* end addr is invalid */
1302
1303 return 5; /* return error */
1304 }
1305
1306 buf[0] = SSD1309_CMD_SET_COLUMN_ADDRESS; /* set command */
1307 buf[1] = start_addr & 0x7F; /* set start address */
1308 buf[2] = end_addr & 0x7F; /* set end address */
1309
1310 return a_ssd1309_multiple_write_byte(handle, (uint8_t *)buf, 3, SSD1309_CMD); /* write command */
1311}
1312
1327uint8_t ssd1309_set_page_address_range(ssd1309_handle_t *handle, uint8_t start_addr, uint8_t end_addr)
1328{
1329 uint8_t buf[3];
1330
1331 if (handle == NULL) /* check handle */
1332 {
1333 return 2; /* return error */
1334 }
1335 if (handle->inited != 1) /* check handle initialization */
1336 {
1337 return 3; /* return error */
1338 }
1339 if (start_addr > 0x07) /* check start addr */
1340 {
1341 handle->debug_print("ssd1309: start addr is invalid.\n"); /* start addr is invalid */
1342
1343 return 4; /* return error */
1344 }
1345 if (end_addr > 0x07) /* check end addr */
1346 {
1347 handle->debug_print("ssd1309: end addr is invalid.\n"); /* end_addr is invalid */
1348
1349 return 5; /* return error */
1350 }
1351
1352 buf[0] = SSD1309_CMD_SET_PAGE_ADDRESS; /* set command */
1353 buf[1] = start_addr & 0x07; /* set start address */
1354 buf[2] = end_addr & 0x07; /* set end address */
1355
1356 return a_ssd1309_multiple_write_byte(handle, (uint8_t *)buf, 3, SSD1309_CMD); /* write command */
1357}
1358
1381uint8_t ssd1309_set_right_horizontal_scroll(ssd1309_handle_t *handle, uint8_t start_page_addr,
1382 uint8_t end_page_addr, ssd1309_scroll_frame_t frames,
1383 uint8_t start_column_addr, uint8_t end_column_addr)
1384{
1385 uint8_t buf[8];
1386
1387 if (handle == NULL) /* check handle */
1388 {
1389 return 2; /* return error */
1390 }
1391 if (handle->inited != 1) /* check handle initialization */
1392 {
1393 return 3; /* return error */
1394 }
1395 if (start_page_addr > 0x07) /* check start_page_addr */
1396 {
1397 handle->debug_print("ssd1309: start page addr is invalid.\n"); /* start page addr is invalid */
1398
1399 return 4; /* return error */
1400 }
1401 if (end_page_addr > 0x07) /* check end_page_addr */
1402 {
1403 handle->debug_print("ssd1309: end page addr is invalid.\n"); /* end page addr is invalid */
1404
1405 return 5; /* return error */
1406 }
1407 if (start_column_addr > 0x7F) /* check start column addr */
1408 {
1409 handle->debug_print("ssd1309: start column addr is invalid.\n"); /* start column addr is invalid */
1410
1411 return 6; /* return error */
1412 }
1413 if (end_column_addr > 0x7F) /* check end column addr */
1414 {
1415 handle->debug_print("ssd1309: end column addr is invalid.\n"); /* end column addr is invalid */
1416
1417 return 7; /* return error */
1418 }
1419
1420 buf[0] = SSD1309_CMD_RIGHT_HORIZONTAL_SCROLL; /* set command */
1421 buf[1] = 0x00; /* set null */
1422 buf[2] = start_page_addr & 0x07; /* set start page address */
1423 buf[3] = frames & 0x07; /* set frames */
1424 buf[4] = end_page_addr & 0x07; /* set end page address */
1425 buf[5] = 0x00; /* set null */
1426 buf[6] = start_column_addr; /* set start column addr */
1427 buf[7] = end_column_addr; /* set end column addr */
1428
1429 return a_ssd1309_multiple_write_byte(handle, (uint8_t *)buf, 8, SSD1309_CMD); /* write command */
1430}
1431
1454uint8_t ssd1309_set_left_horizontal_scroll(ssd1309_handle_t *handle, uint8_t start_page_addr,
1455 uint8_t end_page_addr, ssd1309_scroll_frame_t frames,
1456 uint8_t start_column_addr, uint8_t end_column_addr)
1457{
1458 uint8_t buf[8];
1459
1460 if (handle == NULL) /* check handle */
1461 {
1462 return 2; /* return error */
1463 }
1464 if (handle->inited != 1) /* check handle initialization */
1465 {
1466 return 3; /* return error */
1467 }
1468 if (start_page_addr > 0x07) /* check start_page_addr */
1469 {
1470 handle->debug_print("ssd1309: start page addr is invalid.\n"); /* start page addr is invalid */
1471
1472 return 4; /* return error */
1473 }
1474 if (end_page_addr > 0x07) /* check end_page_addr */
1475 {
1476 handle->debug_print("ssd1309: end page addr is invalid.\n"); /* end page addr is invalid */
1477
1478 return 5; /* return error */
1479 }
1480 if (start_column_addr > 0x7F) /* check start column addr */
1481 {
1482 handle->debug_print("ssd1309: start column addr is invalid.\n"); /* start column addr is invalid */
1483
1484 return 6; /* return error */
1485 }
1486 if (end_column_addr > 0x7F) /* check end column addr */
1487 {
1488 handle->debug_print("ssd1309: end column addr is invalid.\n"); /* end column addr is invalid */
1489
1490 return 7; /* return error */
1491 }
1492
1493 buf[0] = SSD1309_CMD_LEFT_HORIZONTAL_SCROLL; /* set command */
1494 buf[1] = 0x00; /* set null */
1495 buf[2] = start_page_addr & 0x07; /* set start page address */
1496 buf[3] = frames & 0x07; /* set frames */
1497 buf[4] = end_page_addr & 0x07; /* set end page address */
1498 buf[5] = 0x00; /* set null */
1499 buf[6] = start_column_addr; /* set start column addr */
1500 buf[7] = end_column_addr; /* set end column addr */
1501
1502 return a_ssd1309_multiple_write_byte(handle, (uint8_t *)buf, 8, SSD1309_CMD); /* write command */
1503}
1504
1532 uint8_t start_page_addr, uint8_t end_page_addr,
1533 uint8_t rows, ssd1309_scroll_frame_t frames,
1534 uint8_t start_column_addr, uint8_t end_column_addr)
1535{
1536 uint8_t buf[8];
1537
1538 if (handle == NULL) /* check handle */
1539 {
1540 return 2; /* return error */
1541 }
1542 if (handle->inited != 1) /* check handle initialization */
1543 {
1544 return 3; /* return error */
1545 }
1546 if (start_page_addr > 0x07) /* check start_page_addr */
1547 {
1548 handle->debug_print("ssd1309: start_page_addr is invalid.\n"); /* start_page_addr is invalid */
1549
1550 return 4; /* return error */
1551 }
1552 if (end_page_addr > 0x07) /* check end page addr */
1553 {
1554 handle->debug_print("ssd1309: end_page_addr is invalid.\n"); /* end_page_addr is invalid */
1555
1556 return 5; /* return error */
1557 }
1558 if (rows > 0x3F) /* check rows */
1559 {
1560 handle->debug_print("ssd1309: rows is invalid.\n"); /* rows is invalid */
1561
1562 return 6; /* return error */
1563 }
1564 if (start_column_addr > 0x7F) /* check start column addr */
1565 {
1566 handle->debug_print("ssd1309: start column addr is invalid.\n"); /* start column addr is invalid */
1567
1568 return 7; /* return error */
1569 }
1570 if (end_column_addr > 0x7F) /* check end column addr */
1571 {
1572 handle->debug_print("ssd1309: end column addr is invalid.\n"); /* end column addr is invalid */
1573
1574 return 8; /* return error */
1575 }
1576
1577 buf[0] = SSD1309_CMD_VERTICAL_RIGHT_HORIZONTAL_SCROLL; /* set command */
1578 buf[1] = horizontal_scroll & 0x01; /* set horizontal scroll */
1579 buf[2] = start_page_addr & 0x07; /* set start page addr */
1580 buf[3] = frames & 0x07; /* set frames */
1581 buf[4] = end_page_addr & 0x07; /* set end page addr */
1582 buf[5] = rows & 0x3F; /* set rows */
1583 buf[6] = start_column_addr & 0x7F; /* set start column addr */
1584 buf[7] = end_column_addr & 0x7F; /* set end column addr */
1585
1586 return a_ssd1309_multiple_write_byte(handle, (uint8_t *)buf, 8, SSD1309_CMD); /* write command */
1587}
1588
1616 uint8_t start_page_addr, uint8_t end_page_addr,
1617 uint8_t rows, ssd1309_scroll_frame_t frames,
1618 uint8_t start_column_addr, uint8_t end_column_addr)
1619{
1620 uint8_t buf[8];
1621
1622 if (handle == NULL) /* check handle */
1623 {
1624 return 2; /* return error */
1625 }
1626 if (handle->inited != 1) /* check handle initialization */
1627 {
1628 return 3; /* return error */
1629 }
1630 if (start_page_addr > 0x07) /* check start_page_addr */
1631 {
1632 handle->debug_print("ssd1309: start_page_addr is invalid.\n"); /* start_page_addr is invalid */
1633
1634 return 4; /* return error */
1635 }
1636 if (end_page_addr > 0x07) /* check end page addr */
1637 {
1638 handle->debug_print("ssd1309: end_page_addr is invalid.\n"); /* end_page_addr is invalid */
1639
1640 return 5; /* return error */
1641 }
1642 if (rows > 0x3F) /* check rows */
1643 {
1644 handle->debug_print("ssd1309: rows is invalid.\n"); /* rows is invalid */
1645
1646 return 6; /* return error */
1647 }
1648 if (start_column_addr > 0x7F) /* check start column addr */
1649 {
1650 handle->debug_print("ssd1309: start column addr is invalid.\n"); /* start column addr is invalid */
1651
1652 return 7; /* return error */
1653 }
1654 if (end_column_addr > 0x7F) /* check end column addr */
1655 {
1656 handle->debug_print("ssd1309: end column addr is invalid.\n"); /* end column addr is invalid */
1657
1658 return 8; /* return error */
1659 }
1660
1661 buf[0] = SSD1309_CMD_VERTICAL_LEFT_HORIZONTAL_SCROLL; /* set command */
1662 buf[1] = horizontal_scroll & 0x01; /* set horizontal scroll */
1663 buf[2] = start_page_addr & 0x07; /* set start page addr */
1664 buf[3] = frames & 0x07; /* set frames */
1665 buf[4] = end_page_addr & 0x07; /* set end page addr */
1666 buf[5] = rows & 0x3F; /* set rows */
1667 buf[6] = start_column_addr & 0x7F; /* set start column addr */
1668 buf[7] = end_column_addr & 0x7F; /* set end column addr */
1669
1670 return a_ssd1309_multiple_write_byte(handle, (uint8_t *)buf, 8, SSD1309_CMD); /* write command */
1671}
1672
1684{
1685 if (handle == NULL) /* check handle */
1686 {
1687 return 2; /* return error */
1688 }
1689 if (handle->inited != 1) /* check handle initialization */
1690 {
1691 return 3; /* return error */
1692 }
1693
1694 return a_ssd1309_write_byte(handle, SSD1309_CMD_DEACTIVATE_SCROLL, SSD1309_CMD); /* write command */
1695}
1696
1708{
1709 if (handle == NULL) /* check handle */
1710 {
1711 return 2; /* return error */
1712 }
1713 if (handle->inited != 1) /* check handle initialization */
1714 {
1715 return 3; /* return error */
1716 }
1717
1718 return a_ssd1309_write_byte(handle, SSD1309_CMD_ACTIVATE_SCROLL, SSD1309_CMD); /* write command */
1719}
1720
1734{
1735 if (handle == NULL) /* check handle */
1736 {
1737 return 2; /* return error */
1738 }
1739 if (handle->inited != 1) /* check handle initialization */
1740 {
1741 return 3; /* return error */
1742 }
1743 if (l > 0x3F) /* check line */
1744 {
1745 handle->debug_print("ssd1309: line is invalid.\n"); /* line is invalid */
1746
1747 return 4; /* return error */
1748 }
1749
1750 return a_ssd1309_write_byte(handle, SSD1309_CMD_DISPLAY_START_LINE | (l & 0x3F), SSD1309_CMD); /* write command */
1751}
1752
1764uint8_t ssd1309_set_contrast(ssd1309_handle_t *handle, uint8_t contrast)
1765{
1766 uint8_t buf[2];
1767
1768 if (handle == NULL) /* check handle */
1769 {
1770 return 2; /* return error */
1771 }
1772 if (handle->inited != 1) /* check handle initialization */
1773 {
1774 return 3; /* return error */
1775 }
1776
1777 buf[0] = SSD1309_CMD_CONTRAST_CONTROL; /* set command */
1778 buf[1] = contrast; /* set contrast */
1779
1780 return a_ssd1309_multiple_write_byte(handle, (uint8_t *)buf, 2, SSD1309_CMD); /* write command */
1781}
1782
1795{
1796 if (handle == NULL) /* check handle */
1797 {
1798 return 2; /* return error */
1799 }
1800 if (handle->inited != 1) /* check handle initialization */
1801 {
1802 return 3; /* return error */
1803 }
1804
1805 if (remap != 0) /* check remap */
1806 {
1807 return a_ssd1309_write_byte(handle, SSD1309_CMD_COLUMN_127_MAPPED_TO_SEG0, SSD1309_CMD); /* write remap */
1808 }
1809 else
1810 {
1811 return a_ssd1309_write_byte(handle, SSD1309_CMD_COLUMN_0_MAPPED_TO_SEG0, SSD1309_CMD); /* write remap */
1812 }
1813}
1814
1832uint8_t ssd1309_set_vertical_scroll_area(ssd1309_handle_t *handle, uint8_t start_row, uint8_t end_row)
1833{
1834 uint8_t buf[3];
1835
1836 if (handle == NULL) /* check handle */
1837 {
1838 return 2; /* return error */
1839 }
1840 if (handle->inited != 1) /* check handle initialization */
1841 {
1842 return 3; /* return error */
1843 }
1844 if (start_row > 0x3F) /* check start row */
1845 {
1846 handle->debug_print("ssd1309: start_row is invalid.\n"); /* start_row is invalid */
1847
1848 return 4; /* return error */
1849 }
1850 if (end_row > 0x7F) /* check end_row */
1851 {
1852 handle->debug_print("ssd1309: end_row is invalid.\n"); /* end_row is invalid */
1853
1854 return 5; /* return error */
1855 }
1856 if (end_row > start_row) /* check start_row and end_row */
1857 {
1858 handle->debug_print("ssd1309: end_row > start_row.\n"); /* end_row > start_row */
1859
1860 return 6; /* return error */
1861 }
1862
1863 buf[0] = SSD1309_CMD_VERTICAL_SCROLL_AREA; /* set command */
1864 buf[1] = start_row; /* set start row */
1865 buf[2] = end_row; /* set end row */
1866
1867 return a_ssd1309_multiple_write_byte(handle, (uint8_t *)buf, 3, SSD1309_CMD); /* write command */
1868}
1869
1882{
1883 if (handle == NULL) /* check handle */
1884 {
1885 return 2; /* return error */
1886 }
1887 if (handle->inited != 1) /* check handle initialization */
1888 {
1889 return 3; /* return error */
1890 }
1891
1892 if (enable != 0) /* if enable */
1893 {
1894 return a_ssd1309_write_byte(handle, SSD1309_CMD_ENTIRE_DISPLAY_ON, SSD1309_CMD); /* write command */
1895 }
1896 else
1897 {
1898 return a_ssd1309_write_byte(handle, SSD1309_CMD_ENTIRE_DISPLAY_OFF, SSD1309_CMD); /* write command */
1899 }
1900}
1901
1914{
1915 if (handle == NULL) /* check handle */
1916 {
1917 return 2; /* return error */
1918 }
1919 if (handle->inited != 1) /* check handle initialization */
1920 {
1921 return 3; /* return error */
1922 }
1923
1924 if (mode != 0) /* check mode */
1925 {
1926 return a_ssd1309_write_byte(handle, SSD1309_CMD_INVERSE_DISPLAY, SSD1309_CMD); /* write command */
1927 }
1928 else
1929 {
1930 return a_ssd1309_write_byte(handle, SSD1309_CMD_NORMAL_DISPLAY, SSD1309_CMD); /* write command */
1931 }
1932}
1933
1947uint8_t ssd1309_set_multiplex_ratio(ssd1309_handle_t *handle, uint8_t multiplex)
1948{
1949 uint8_t buf[2];
1950
1951 if (handle == NULL) /* check handle */
1952 {
1953 return 2; /* return error */
1954 }
1955 if (handle->inited != 1) /* check handle initialization */
1956 {
1957 return 3; /* return error */
1958 }
1959 if (multiplex < 0x0F) /* check multiplex */
1960 {
1961 handle->debug_print("ssd1309: multiplex is too small.\n"); /* multiplex is too small */
1962
1963 return 4; /* return error */
1964 }
1965 if (multiplex > 0x3F) /* check multiplex */
1966 {
1967 handle->debug_print("ssd1309: multiplex is too large.\n"); /* multiplex is too large */
1968
1969 return 5; /* return error */
1970 }
1971
1972 buf[0] = SSD1309_CMD_MULTIPLEX_RATIO; /* set command */
1973 buf[1] = multiplex; /* set multiplex */
1974
1975 return a_ssd1309_multiple_write_byte(handle, (uint8_t *)buf, 2, SSD1309_CMD); /* write command */
1976}
1977
1990{
1991 if (handle == NULL) /* check handle */
1992 {
1993 return 2; /* return error */
1994 }
1995 if (handle->inited != 1) /* check handle initialization */
1996 {
1997 return 3; /* return error */
1998 }
1999
2000 if (on_off != 0) /* check on off */
2001 {
2002 return a_ssd1309_write_byte(handle, SSD1309_CMD_DISPLAY_ON, SSD1309_CMD); /* write command */
2003 }
2004 else
2005 {
2006 return a_ssd1309_write_byte(handle, SSD1309_CMD_DISPLAY_OFF, SSD1309_CMD); /* write command */
2007 }
2008}
2009
2022uint8_t ssd1309_set_page_address(ssd1309_handle_t *handle, uint8_t addr)
2023{
2024 if (handle == NULL) /* check handle */
2025 {
2026 return 2; /* return error */
2027 }
2028 if (handle->inited != 1) /* check handle initialization */
2029 {
2030 return 3; /* return error */
2031 }
2032 if (addr > 0x07) /* check addr */
2033 {
2034 handle->debug_print("ssd1309: addr is invalid.\n"); /* addr is invalid */
2035
2036 return 4; /* return error */
2037 }
2038
2039 return a_ssd1309_write_byte(handle, SSD1309_CMD_PAGE_ADDR | (addr & 0x07), SSD1309_CMD); /* write command */
2040}
2041
2054{
2055 if (handle == NULL) /* check handle */
2056 {
2057 return 2; /* return error */
2058 }
2059 if (handle->inited != 1) /* check handle initialization */
2060 {
2061 return 3; /* return error */
2062 }
2063
2064 if (dir != 0) /* choose dir */
2065 {
2066 return a_ssd1309_write_byte(handle, SSD1309_CMD_SCAN_DIRECTION_COMN_1_START, SSD1309_CMD); /* write command */
2067 }
2068 else
2069 {
2070 return a_ssd1309_write_byte(handle, SSD1309_CMD_SCAN_DIRECTION_COM0_START, SSD1309_CMD); /* write command */
2071 }
2072}
2073
2086uint8_t ssd1309_set_display_offset(ssd1309_handle_t *handle, uint8_t offset)
2087{
2088 uint8_t buf[2];
2089
2090 if (handle == NULL) /* check handle */
2091 {
2092 return 2; /* return error */
2093 }
2094 if (handle->inited != 1) /* check handle initialization */
2095 {
2096 return 3; /* return error */
2097 }
2098 if (offset > 0x3F) /* check offset */
2099 {
2100 handle->debug_print("ssd1309: offset is invalid.\n"); /* offset is invalid */
2101
2102 return 4; /* return error */
2103 }
2104
2105 buf[0] = SSD1309_CMD_DISPLAY_OFFSET ; /* set command */
2106 buf[1] = offset; /* set offset */
2107
2108 return a_ssd1309_multiple_write_byte(handle, (uint8_t *)buf, 2, SSD1309_CMD); /* write command */
2109}
2110
2126uint8_t ssd1309_set_display_clock(ssd1309_handle_t *handle, uint8_t oscillator_frequency, uint8_t clock_divide)
2127{
2128 uint8_t buf[2];
2129
2130 if (handle == NULL) /* check handle */
2131 {
2132 return 2; /* return error */
2133 }
2134 if (handle->inited != 1) /* check handle initialization */
2135 {
2136 return 3; /* return error */
2137 }
2138 if (oscillator_frequency> 0x0F) /* check oscillator_frequency */
2139 {
2140 handle->debug_print("ssd1309: oscillator frequency is invalid.\n"); /* oscillator frequency is invalid */
2141
2142 return 4; /* return error */
2143 }
2144 if (clock_divide> 0x0F) /* check clock_divide */
2145 {
2146 handle->debug_print("ssd1309: clock divide is invalid.\n"); /* clock divide is invalid */
2147
2148 return 5; /* return error */
2149 }
2150
2151 buf[0] = SSD1309_CMD_DISPLAY_CLOCK_DIVIDE; /* set command */
2152 buf[1] = (oscillator_frequency << 4) | clock_divide; /* set oscillator frequency and clock divide */
2153
2154 return a_ssd1309_multiple_write_byte(handle, (uint8_t *)buf, 2, SSD1309_CMD); /* write command */
2155}
2156
2172uint8_t ssd1309_set_precharge_period(ssd1309_handle_t *handle, uint8_t phase1_period, uint8_t phase2_period)
2173{
2174 uint8_t buf[2];
2175
2176 if (handle == NULL) /* check handle */
2177 {
2178 return 2; /* return error */
2179 }
2180 if (handle->inited != 1) /* check handle initialization */
2181 {
2182 return 3; /* return error */
2183 }
2184 if (phase1_period> 0x0F) /* check phase1 period */
2185 {
2186 handle->debug_print("ssd1309: phase1 period is invalid.\n"); /* phase1 period is invalid */
2187
2188 return 4; /* return error */
2189 }
2190 if (phase2_period> 0x0F) /* check phase2 period */
2191 {
2192 handle->debug_print("ssd1309: phase2 period is invalid.\n"); /* phase2 period is invalid */
2193
2194 return 5; /* return error */
2195 }
2196
2197 buf[0] = SSD1309_CMD_PRE_CHARGE_PERIOD; /* set command */
2198 buf[1] = (phase2_period << 4) | phase1_period; /* set period */
2199
2200 return a_ssd1309_multiple_write_byte(handle, (uint8_t *)buf, 2, SSD1309_CMD); /* write command */
2201}
2202
2216{
2217 uint8_t buf[2];
2218
2219 if (handle == NULL) /* check handle */
2220 {
2221 return 2; /* return error */
2222 }
2223 if (handle->inited != 1) /* check handle initialization */
2224 {
2225 return 3; /* return error */
2226 }
2227
2228 buf[0] = SSD1309_CMD_COM_PINS_CONF; /* set command */
2229 buf[1] = (uint8_t)((conf << 4) | (remap << 5) | 0x02); /* set com pins */
2230
2231 return a_ssd1309_multiple_write_byte(handle, (uint8_t *)buf, 2, SSD1309_CMD); /* write command */
2232}
2233
2246{
2247 uint8_t buf[2];
2248
2249 if (handle == NULL) /* check handle */
2250 {
2251 return 2; /* return error */
2252 }
2253 if (handle->inited != 1) /* check handle initialization */
2254 {
2255 return 3; /* return error */
2256 }
2257
2258 buf[0] = SSD1309_CMD_COMH_DESLECT_LEVEL; /* set command */
2259 buf[1] = (uint8_t)(level << 2); /* set level */
2260
2261 return a_ssd1309_multiple_write_byte(handle, (uint8_t *)buf, 2, SSD1309_CMD); /* write command */
2262}
2263
2286 uint8_t end_page_addr, uint8_t start_column_addr,
2287 uint8_t end_column_addr)
2288{
2289 uint8_t buf[8];
2290
2291 if (handle == NULL) /* check handle */
2292 {
2293 return 2; /* return error */
2294 }
2295 if (handle->inited != 1) /* check handle initialization */
2296 {
2297 return 3; /* return error */
2298 }
2299 if (start_page_addr > 0x07) /* check start_page_addr */
2300 {
2301 handle->debug_print("ssd1309: start page addr is invalid.\n"); /* start page addr is invalid */
2302
2303 return 4; /* return error */
2304 }
2305 if (end_page_addr > 0x07) /* check end_page_addr */
2306 {
2307 handle->debug_print("ssd1309: end page addr is invalid.\n"); /* end page addr is invalid */
2308
2309 return 5; /* return error */
2310 }
2311 if (start_column_addr > 0x7F) /* check start column addr */
2312 {
2313 handle->debug_print("ssd1309: start column addr is invalid.\n"); /* start column addr is invalid */
2314
2315 return 6; /* return error */
2316 }
2317 if (end_column_addr > 0x7F) /* check end column addr */
2318 {
2319 handle->debug_print("ssd1309: end column addr is invalid.\n"); /* end column addr is invalid */
2320
2321 return 7; /* return error */
2322 }
2323
2324 buf[0] = SSD1309_CMD_RIGHT_HORIZONTAL_SCROLL_ONE_COL; /* set command */
2325 buf[1] = 0x00; /* set null */
2326 buf[2] = start_page_addr & 0x07; /* set start page address */
2327 buf[3] = 0x00; /* set 0x00 */
2328 buf[4] = end_page_addr & 0x07; /* set end page address */
2329 buf[5] = 0x00; /* set null */
2330 buf[6] = start_column_addr; /* set start column addr */
2331 buf[7] = end_column_addr; /* set end column addr */
2332
2333 return a_ssd1309_multiple_write_byte(handle, (uint8_t *)buf, 8, SSD1309_CMD); /* write command */
2334}
2335
2357uint8_t ssd1309_set_left_horizontal_scroll_one_column(ssd1309_handle_t *handle, uint8_t start_page_addr,
2358 uint8_t end_page_addr, uint8_t start_column_addr,
2359 uint8_t end_column_addr)
2360{
2361 uint8_t buf[8];
2362
2363 if (handle == NULL) /* check handle */
2364 {
2365 return 2; /* return error */
2366 }
2367 if (handle->inited != 1) /* check handle initialization */
2368 {
2369 return 3; /* return error */
2370 }
2371 if (start_page_addr > 0x07) /* check start_page_addr */
2372 {
2373 handle->debug_print("ssd1309: start page addr is invalid.\n"); /* start page addr is invalid */
2374
2375 return 4; /* return error */
2376 }
2377 if (end_page_addr > 0x07) /* check end_page_addr */
2378 {
2379 handle->debug_print("ssd1309: end page addr is invalid.\n"); /* end page addr is invalid */
2380
2381 return 5; /* return error */
2382 }
2383 if (start_column_addr > 0x7F) /* check start column addr */
2384 {
2385 handle->debug_print("ssd1309: start column addr is invalid.\n"); /* start column addr is invalid */
2386
2387 return 6; /* return error */
2388 }
2389 if (end_column_addr > 0x7F) /* check end column addr */
2390 {
2391 handle->debug_print("ssd1309: end column addr is invalid.\n"); /* end column addr is invalid */
2392
2393 return 7; /* return error */
2394 }
2395
2396 buf[0] = SSD1309_CMD_LEFT_HORIZONTAL_SCROLL_ONE_COL; /* set command */
2397 buf[1] = 0x00; /* set null */
2398 buf[2] = start_page_addr & 0x07; /* set start page address */
2399 buf[3] = 0x00; /* set 0x00 */
2400 buf[4] = end_page_addr & 0x07; /* set end page address */
2401 buf[5] = 0x00; /* set null */
2402 buf[6] = start_column_addr; /* set start column addr */
2403 buf[7] = end_column_addr; /* set end column addr */
2404
2405 return a_ssd1309_multiple_write_byte(handle, (uint8_t *)buf, 8, SSD1309_CMD); /* write command */
2406}
2407
2420{
2421 uint8_t buf[2];
2422
2423 if (handle == NULL) /* check handle */
2424 {
2425 return 2; /* return error */
2426 }
2427 if (handle->inited != 1) /* check handle initialization */
2428 {
2429 return 3; /* return error */
2430 }
2431
2432 buf[0] = SSD1309_CMD_GPIO; /* set command */
2433 buf[1] = gpio; /* set gpio */
2434
2435 return a_ssd1309_multiple_write_byte(handle, (uint8_t *)buf, 2, SSD1309_CMD); /* write command */
2436}
2437
2450{
2451 uint8_t buf[2];
2452
2453 if (handle == NULL) /* check handle */
2454 {
2455 return 2; /* return error */
2456 }
2457 if (handle->inited != 1) /* check handle initialization */
2458 {
2459 return 3; /* return error */
2460 }
2461
2462 buf[0] = SSD1309_CMD_LOCK; /* set command */
2463 buf[1] = enable; /* set bool */
2464
2465 return a_ssd1309_multiple_write_byte(handle, (uint8_t *)buf, 2, SSD1309_CMD); /* write command */
2466}
2467
2480uint8_t ssd1309_write_cmd(ssd1309_handle_t *handle, uint8_t *buf, uint8_t len)
2481{
2482 if (handle == NULL) /* check handle */
2483 {
2484 return 2; /* return error */
2485 }
2486 if (handle->inited != 1) /* check handle initialization */
2487 {
2488 return 3; /* return error */
2489 }
2490
2491 return a_ssd1309_multiple_write_byte(handle, (uint8_t *)buf, len, SSD1309_CMD); /* write command */
2492}
2493
2506uint8_t ssd1309_write_data(ssd1309_handle_t *handle, uint8_t *buf, uint8_t len)
2507{
2508 if (handle == NULL) /* check handle */
2509 {
2510 return 2; /* return error */
2511 }
2512 if (handle->inited != 1) /* check handle initialization */
2513 {
2514 return 3; /* return error */
2515 }
2516
2517 return a_ssd1309_multiple_write_byte(handle, (uint8_t *)buf, len, SSD1309_DATA); /* write data */
2518}
2519
2529{
2530 if (info == NULL) /* check handle */
2531 {
2532 return 2; /* return error */
2533 }
2534
2535 memset(info, 0, sizeof(ssd1309_info_t)); /* initialize ssd1309 info structure */
2536 strncpy(info->chip_name, CHIP_NAME, 32); /* copy chip name */
2537 strncpy(info->manufacturer_name, MANUFACTURER_NAME, 32); /* copy manufacturer name */
2538 strncpy(info->interface, "IIC SPI", 8); /* copy interface name */
2539 info->supply_voltage_min_v = SUPPLY_VOLTAGE_MIN; /* set minimal supply voltage */
2540 info->supply_voltage_max_v = SUPPLY_VOLTAGE_MAX; /* set maximum supply voltage */
2541 info->max_current_ma = MAX_CURRENT; /* set maximum current */
2542 info->temperature_max = TEMPERATURE_MAX; /* set minimal temperature */
2543 info->temperature_min = TEMPERATURE_MIN; /* set maximum temperature */
2544 info->driver_version = DRIVER_VERSION; /* set driver version */
2545
2546 return 0; /* success return 0 */
2547}
#define SSD1309_CMD_SCAN_DIRECTION_COMN_1_START
#define SSD1309_CMD_VERTICAL_LEFT_HORIZONTAL_SCROLL
#define SSD1309_CMD_CONTRAST_CONTROL
#define SSD1309_CMD_HIGHER_COLUMN_START_ADDRESS
#define SSD1309_CMD_SET_COLUMN_ADDRESS
#define SSD1309_CMD_SET_PAGE_ADDRESS
#define SSD1309_CMD_ACTIVATE_SCROLL
#define MAX_CURRENT
#define SSD1309_CMD_LOWER_COLUMN_START_ADDRESS
chip command definition
#define SSD1309_CMD_LEFT_HORIZONTAL_SCROLL_ONE_COL
#define SSD1309_CMD_ENTIRE_DISPLAY_OFF
#define SSD1309_CMD_DISPLAY_OFFSET
#define SSD1309_CMD_MEMORY_ADDRESSING_MODE
#define SSD1309_CMD_LEFT_HORIZONTAL_SCROLL
#define SSD1309_CMD_DEACTIVATE_SCROLL
#define SSD1309_CMD_NORMAL_DISPLAY
#define SSD1309_CMD_PAGE_ADDR
#define SUPPLY_VOLTAGE_MAX
#define SSD1309_CMD_INVERSE_DISPLAY
#define SSD1309_CMD_COLUMN_0_MAPPED_TO_SEG0
#define SSD1309_CMD_LOCK
#define SSD1309_CMD_COM_PINS_CONF
#define SSD1309_CMD_COMH_DESLECT_LEVEL
#define SSD1309_CMD_VERTICAL_RIGHT_HORIZONTAL_SCROLL
#define SSD1309_CMD_ENTIRE_DISPLAY_ON
#define TEMPERATURE_MAX
#define SSD1309_CMD_RIGHT_HORIZONTAL_SCROLL
#define SSD1309_CMD_COLUMN_127_MAPPED_TO_SEG0
#define SSD1309_CMD_VERTICAL_SCROLL_AREA
#define MANUFACTURER_NAME
#define TEMPERATURE_MIN
#define SUPPLY_VOLTAGE_MIN
#define SSD1309_CMD_PRE_CHARGE_PERIOD
#define SSD1309_CMD_GPIO
#define CHIP_NAME
chip information definition
#define SSD1309_CMD_DISPLAY_START_LINE
#define SSD1309_CMD_MULTIPLEX_RATIO
#define SSD1309_CMD_DISPLAY_ON
#define SSD1309_CMD_SCAN_DIRECTION_COM0_START
#define SSD1309_CMD
chip command data definition
#define DRIVER_VERSION
#define SSD1309_CMD_DISPLAY_OFF
#define SSD1309_CMD_DISPLAY_CLOCK_DIVIDE
#define SSD1309_DATA
#define SSD1309_CMD_RIGHT_HORIZONTAL_SCROLL_ONE_COL
driver ssd1309 header file
driver ssd1309 font header file
ssd1309_bool_t
ssd1309 bool enumeration definition
uint8_t ssd1309_set_page_address(ssd1309_handle_t *handle, uint8_t addr)
set the page address
uint8_t ssd1309_set_vertical_left_horizontal_scroll(ssd1309_handle_t *handle, ssd1309_bool_t horizontal_scroll, uint8_t start_page_addr, uint8_t end_page_addr, uint8_t rows, ssd1309_scroll_frame_t frames, uint8_t start_column_addr, uint8_t end_column_addr)
set the vertical left horizontal scroll
uint8_t ssd1309_set_right_horizontal_scroll(ssd1309_handle_t *handle, uint8_t start_page_addr, uint8_t end_page_addr, ssd1309_scroll_frame_t frames, uint8_t start_column_addr, uint8_t end_column_addr)
set the right horizontal scroll
uint8_t ssd1309_read_point(ssd1309_handle_t *handle, uint8_t x, uint8_t y, uint8_t *data)
read a point
uint8_t ssd1309_set_mcu_interface_lock(ssd1309_handle_t *handle, ssd1309_bool_t enable)
enable or disable mcu interface lock
uint8_t ssd1309_deactivate_scroll(ssd1309_handle_t *handle)
deactivate the scroll
uint8_t ssd1309_set_column_address_range(ssd1309_handle_t *handle, uint8_t start_addr, uint8_t end_addr)
set the column address range
ssd1309_interface_t
ssd1309 interface enumeration definition
uint8_t ssd1309_deinit(ssd1309_handle_t *handle)
close the chip
uint8_t ssd1309_get_addr_pin(ssd1309_handle_t *handle, ssd1309_address_t *addr_pin)
get the chip iic address
uint8_t ssd1309_gram_write_string(ssd1309_handle_t *handle, uint8_t x, uint8_t y, char *str, uint16_t len, uint8_t color, ssd1309_font_t font)
draw a string in the gram
uint8_t ssd1309_set_display_clock(ssd1309_handle_t *handle, uint8_t oscillator_frequency, uint8_t clock_divide)
set the display clock
uint8_t ssd1309_set_left_horizontal_scroll(ssd1309_handle_t *handle, uint8_t start_page_addr, uint8_t end_page_addr, ssd1309_scroll_frame_t frames, uint8_t start_column_addr, uint8_t end_column_addr)
set the left horizontal scroll
uint8_t ssd1309_info(ssd1309_info_t *info)
get chip's information
uint8_t ssd1309_set_high_column_start_address(ssd1309_handle_t *handle, uint8_t addr)
set the high column start address
uint8_t ssd1309_set_display(ssd1309_handle_t *handle, ssd1309_display_t on_off)
enable or disable the display
uint8_t ssd1309_set_addr_pin(ssd1309_handle_t *handle, ssd1309_address_t addr_pin)
set the chip iic address
uint8_t ssd1309_gram_write_point(ssd1309_handle_t *handle, uint8_t x, uint8_t y, uint8_t data)
write a point in the gram
uint8_t ssd1309_init(ssd1309_handle_t *handle)
initialize the chip
ssd1309_memory_addressing_mode_t
ssd1309 memory addressing mode enumeration definition
ssd1309_display_mode_t
ssd1309 display mode enumeration definition
struct ssd1309_info_s ssd1309_info_t
ssd1309 information structure definition
ssd1309_segment_column_remap_t
ssd1309 segment column remap enumeration definition
ssd1309_pin_conf_t
ssd1309 pin conf enumeration definition
uint8_t ssd1309_set_memory_addressing_mode(ssd1309_handle_t *handle, ssd1309_memory_addressing_mode_t mode)
set the memory addressing mode
struct ssd1309_handle_s ssd1309_handle_t
ssd1309 handle structure definition
uint8_t ssd1309_set_gpio(ssd1309_handle_t *handle, ssd1309_gpio_t gpio)
set gpio
uint8_t ssd1309_set_display_offset(ssd1309_handle_t *handle, uint8_t offset)
set the display offset
uint8_t ssd1309_set_right_horizontal_scroll_one_column(ssd1309_handle_t *handle, uint8_t start_page_addr, uint8_t end_page_addr, uint8_t start_column_addr, uint8_t end_column_addr)
set right horizontal scroll one column
uint8_t ssd1309_set_vertical_scroll_area(ssd1309_handle_t *handle, uint8_t start_row, uint8_t end_row)
set the vertical scroll area
uint8_t ssd1309_write_point(ssd1309_handle_t *handle, uint8_t x, uint8_t y, uint8_t data)
write a point
ssd1309_scan_direction_t
ssd1309 scan direction enumeration definition
uint8_t ssd1309_set_left_horizontal_scroll_one_column(ssd1309_handle_t *handle, uint8_t start_page_addr, uint8_t end_page_addr, uint8_t start_column_addr, uint8_t end_column_addr)
set left horizontal scroll one column
uint8_t ssd1309_set_interface(ssd1309_handle_t *handle, ssd1309_interface_t interface)
set the chip interface
uint8_t ssd1309_set_entire_display(ssd1309_handle_t *handle, ssd1309_entire_display_t enable)
enable or disable the entire display
ssd1309_display_t
ssd1309 display enumeration definition
uint8_t ssd1309_gram_draw_picture(ssd1309_handle_t *handle, uint8_t left, uint8_t top, uint8_t right, uint8_t bottom, uint8_t *img)
draw a picture in the gram
uint8_t ssd1309_activate_scroll(ssd1309_handle_t *handle)
activate the scroll
uint8_t ssd1309_set_scan_direction(ssd1309_handle_t *handle, ssd1309_scan_direction_t dir)
set the scan direction
uint8_t ssd1309_set_display_start_line(ssd1309_handle_t *handle, uint8_t l)
set the display start line
uint8_t ssd1309_set_deselect_level(ssd1309_handle_t *handle, ssd1309_deselect_level_t level)
set the deselect level
uint8_t ssd1309_set_low_column_start_address(ssd1309_handle_t *handle, uint8_t addr)
set the low column start address
ssd1309_address_t
ssd1309 address pin enumeration definition
uint8_t ssd1309_set_page_address_range(ssd1309_handle_t *handle, uint8_t start_addr, uint8_t end_addr)
set the page address range
uint8_t ssd1309_set_display_mode(ssd1309_handle_t *handle, ssd1309_display_mode_t mode)
set the display mode
uint8_t ssd1309_set_multiplex_ratio(ssd1309_handle_t *handle, uint8_t multiplex)
set the multiplex ratio
uint8_t ssd1309_gram_read_point(ssd1309_handle_t *handle, uint8_t x, uint8_t y, uint8_t *data)
read a point from the gram
uint8_t ssd1309_set_vertical_right_horizontal_scroll(ssd1309_handle_t *handle, ssd1309_bool_t horizontal_scroll, uint8_t start_page_addr, uint8_t end_page_addr, uint8_t rows, ssd1309_scroll_frame_t frames, uint8_t start_column_addr, uint8_t end_column_addr)
set the vertical right horizontal scroll
ssd1309_deselect_level_t
ssd1309 deselect level enumeration definition
ssd1309_entire_display_t
ssd1309 entire display enumeration definition
ssd1309_left_right_remap_t
ssd1309 left right remap enumeration definition
uint8_t ssd1309_set_contrast(ssd1309_handle_t *handle, uint8_t contrast)
set the display contrast
uint8_t ssd1309_set_com_pins_hardware_conf(ssd1309_handle_t *handle, ssd1309_pin_conf_t conf, ssd1309_left_right_remap_t remap)
set the hardware com pins
ssd1309_gpio_t
ssd1309 gpio enumeration definition
uint8_t ssd1309_gram_fill_rect(ssd1309_handle_t *handle, uint8_t left, uint8_t top, uint8_t right, uint8_t bottom, uint8_t color)
fill a rectangle in the gram
ssd1309_scroll_frame_t
ssd1309 scroll frame enumeration definition
uint8_t ssd1309_clear(ssd1309_handle_t *handle)
clear the screen
uint8_t ssd1309_get_interface(ssd1309_handle_t *handle, ssd1309_interface_t *interface)
get the chip interface
uint8_t ssd1309_set_precharge_period(ssd1309_handle_t *handle, uint8_t phase1_period, uint8_t phase2_period)
set the pre charge period
uint8_t ssd1309_gram_update(ssd1309_handle_t *handle)
update the gram data
uint8_t ssd1309_set_segment_remap(ssd1309_handle_t *handle, ssd1309_segment_column_remap_t remap)
set the segment remap
ssd1309_font_t
ssd1309 font enumeration definition
@ SSD1309_INTERFACE_SPI
@ SSD1309_INTERFACE_IIC
uint8_t ssd1309_write_cmd(ssd1309_handle_t *handle, uint8_t *buf, uint8_t len)
write the register command
uint8_t ssd1309_write_data(ssd1309_handle_t *handle, uint8_t *buf, uint8_t len)
write the register data
uint8_t(* spi_init)(void)
void(* delay_ms)(uint32_t ms)
uint8_t(* spi_cmd_data_gpio_deinit)(void)
uint8_t(* reset_gpio_deinit)(void)
void(* debug_print)(const char *const fmt,...)
uint8_t(* iic_init)(void)
uint8_t(* spi_deinit)(void)
uint8_t(* reset_gpio_init)(void)
uint8_t(* spi_cmd_data_gpio_init)(void)
uint8_t gram[128][8]
uint8_t(* spi_write_cmd)(uint8_t *buf, uint16_t len)
uint8_t(* iic_write)(uint8_t addr, uint8_t reg, uint8_t *buf, uint16_t len)
uint8_t(* spi_cmd_data_gpio_write)(uint8_t value)
uint8_t(* reset_gpio_write)(uint8_t value)
uint8_t(* iic_deinit)(void)
uint32_t driver_version
char manufacturer_name[32]