]> git.donarmstrong.com Git - qmk_firmware.git/blob - drivers/avr/ssd1306.h
Usbasploader bootloader option addition (#6304)
[qmk_firmware.git] / drivers / avr / ssd1306.h
1 #ifndef SSD1306_H
2 #define SSD1306_H
3
4 #include <stdbool.h>
5 #include <stdio.h>
6 #include "pincontrol.h"
7 #include "config.h"
8
9 enum ssd1306_cmds {
10   DisplayOff = 0xAE,
11   DisplayOn = 0xAF,
12
13   SetContrast = 0x81,
14   DisplayAllOnResume = 0xA4,
15
16   DisplayAllOn = 0xA5,
17   NormalDisplay = 0xA6,
18   InvertDisplay = 0xA7,
19   SetDisplayOffset = 0xD3,
20   SetComPins = 0xda,
21   SetVComDetect = 0xdb,
22   SetDisplayClockDiv = 0xD5,
23   SetPreCharge = 0xd9,
24   SetMultiPlex = 0xa8,
25   SetLowColumn = 0x00,
26   SetHighColumn = 0x10,
27   SetStartLine = 0x40,
28
29   SetMemoryMode = 0x20,
30   ColumnAddr = 0x21,
31   PageAddr = 0x22,
32
33   ComScanInc = 0xc0,
34   ComScanDec = 0xc8,
35   SegRemap = 0xa0,
36   SetChargePump = 0x8d,
37   ExternalVcc = 0x01,
38   SwitchCapVcc = 0x02,
39
40   ActivateScroll = 0x2f,
41   DeActivateScroll = 0x2e,
42   SetVerticalScrollArea = 0xa3,
43   RightHorizontalScroll = 0x26,
44   LeftHorizontalScroll = 0x27,
45   VerticalAndRightHorizontalScroll = 0x29,
46   VerticalAndLeftHorizontalScroll = 0x2a,
47 };
48
49 // Controls the SSD1306 128x32 OLED display via i2c
50
51 #ifndef SSD1306_ADDRESS
52 #define SSD1306_ADDRESS 0x3C
53 #endif
54
55 #define DisplayHeight 32
56 #define DisplayWidth 128
57
58 #define FontHeight 8
59 #define FontWidth 6
60
61 #define MatrixRows (DisplayHeight / FontHeight)
62 #define MatrixCols (DisplayWidth / FontWidth)
63
64 struct CharacterMatrix {
65   uint8_t display[MatrixRows][MatrixCols];
66   uint8_t *cursor;
67   bool dirty;
68 };
69
70 struct CharacterMatrix display;
71
72 bool iota_gfx_init(void);
73 void iota_gfx_task(void);
74 bool iota_gfx_off(void);
75 bool iota_gfx_on(void);
76 void iota_gfx_flush(void);
77 void iota_gfx_write_char(uint8_t c);
78 void iota_gfx_write(const char *data);
79 void iota_gfx_write_P(const char *data);
80 void iota_gfx_clear_screen(void);
81
82 void iota_gfx_task_user(void);
83
84 void matrix_clear(struct CharacterMatrix *matrix);
85 void matrix_write_char_inner(struct CharacterMatrix *matrix, uint8_t c);
86 void matrix_write_char(struct CharacterMatrix *matrix, uint8_t c);
87 void matrix_write(struct CharacterMatrix *matrix, const char *data);
88 void matrix_write_P(struct CharacterMatrix *matrix, const char *data);
89 void matrix_render(struct CharacterMatrix *matrix);
90
91
92
93 #endif