aboutsummaryrefslogtreecommitdiff
path: root/keyboards/sol/common
diff options
context:
space:
mode:
Diffstat (limited to 'keyboards/sol/common')
-rw-r--r--keyboards/sol/common/glcdfont.c140
-rw-r--r--keyboards/sol/common/ssd1306.c329
-rw-r--r--keyboards/sol/common/ssd1306.h92
3 files changed, 68 insertions, 493 deletions
diff --git a/keyboards/sol/common/glcdfont.c b/keyboards/sol/common/glcdfont.c
index 89665ba07..f772e3181 100644
--- a/keyboards/sol/common/glcdfont.c
+++ b/keyboards/sol/common/glcdfont.c
@@ -1,8 +1,4 @@
1// This is the 'classic' fixed-space bitmap font for Adafruit_GFX since 1.0. 1#pragma once
2// See gfxfont.h for newer custom bitmap font info.
3
4#ifndef FONT5X7_H
5#define FONT5X7_H
6 2
7#ifdef __AVR__ 3#ifdef __AVR__
8 #include <avr/io.h> 4 #include <avr/io.h>
@@ -13,7 +9,8 @@
13 #define PROGMEM 9 #define PROGMEM
14#endif 10#endif
15 11
16// Standard ASCII 5x7 font 12// Helidox 8x6 font with RGBKB SOL Logo
13// Online editor: http://teripom.x0.com/
17 14
18static const unsigned char font[] PROGMEM = { 15static const unsigned char font[] PROGMEM = {
19 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 16 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
@@ -144,27 +141,27 @@ static const unsigned char font[] PROGMEM = {
144 0x00, 0x41, 0x36, 0x08, 0x00, 0x00, 141 0x00, 0x41, 0x36, 0x08, 0x00, 0x00,
145 0x02, 0x01, 0x02, 0x04, 0x02, 0x00, 142 0x02, 0x01, 0x02, 0x04, 0x02, 0x00,
146 0x3C, 0x26, 0x23, 0x26, 0x3C, 0x00, 143 0x3C, 0x26, 0x23, 0x26, 0x3C, 0x00,
147 0x03, 0x07, 0x1F, 0x7F, 0xFF, 0xFF, 144 0x00, 0x00, 0x00, 0x00, 0x80, 0x00,
148 0xFE, 0xF8, 0xF0, 0xC0, 0x20, 0xF8, 145 0x00, 0x00, 0x00, 0x80, 0x80, 0x80,
149 0xFE, 0xFF, 0xFE, 0x79, 0x27, 0x1F,
150 0x7F, 0xFF, 0xFF, 0xFE, 0xF8, 0xF0,
151 0xC0, 0x20, 0xF8, 0xFE, 0xFF, 0xFF,
152 0x7F, 0x3F, 0x3F, 0x7F, 0xFF, 0xFE,
153 0xF8, 0xF0, 0xC0, 0x00, 0x00, 0x00,
154 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
155 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00,
156 0x00, 0x00, 0xFF, 0x7F, 0x7F, 0x7F,
157 0xBF, 0xBF, 0xC0, 0xC0, 0xC0, 0xE0,
158 0xE0, 0xE0, 0xE0, 0xF0, 0xF0, 0xF0,
159 0xF8, 0x78, 0x78, 0x7C, 0x3C, 0x3C,
160 0xFE, 0xFE, 0xFE, 0xFF, 0xFF, 0xFF,
161 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
162 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 146 0x00, 0x00, 0x00, 0x00, 0x80, 0x80,
163 0xBF, 0xBF, 0xDF, 0xDF, 0xEF, 0xEF, 147 0x80, 0x80, 0x80, 0x80, 0x80, 0x00,
164 0x00, 0x03, 0x07, 0x1F, 0x7F, 0xFF, 148 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
165 0xFF, 0xFF, 0xFE, 0xF8, 0xE0, 0xC0, 149 0x00, 0x00, 0x00, 0x80, 0x00, 0x00,
166 0xE0, 0xF8, 0xFE, 0xFF, 0xFF, 0xFF, 150 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
167 0x7F, 0x1F, 0x07, 0x03, 0x00, 0x00, 151 0x00, 0x80, 0x00, 0x00, 0x0C, 0x90,
152 0xB0, 0xE0, 0x72, 0x31, 0x9B, 0xDE,
153 0xCE, 0xEC, 0xEE, 0xE9, 0xE9, 0xEC,
154 0xCF, 0xDA, 0x99, 0x3E, 0x62, 0xE4,
155 0xC4, 0x70, 0x10, 0x10, 0x00, 0x00,
156 0x00, 0x00, 0x00, 0x00, 0x00, 0x60,
157 0xC0, 0xC0, 0x80, 0x80, 0x02, 0x85,
158 0x85, 0x87, 0x85, 0x89, 0x89, 0x92,
159 0xEA, 0xC6, 0xC4, 0x48, 0x50, 0x60,
160 0x40, 0x40, 0x40, 0x40, 0xC0, 0xE0,
161 0x50, 0x28, 0x10, 0x10, 0x60, 0xC0,
162 0x40, 0x40, 0x40, 0x40, 0x80, 0x80,
163 0x80, 0x80, 0x80, 0xE0, 0xF8, 0xFC,
164 0xF8, 0xF0, 0x00, 0x00, 0x00, 0x00,
168 0xE0, 0xF0, 0xF0, 0xF0, 0xE0, 0xEC, 165 0xE0, 0xF0, 0xF0, 0xF0, 0xE0, 0xEC,
169 0xEE, 0xF7, 0xF3, 0x70, 0x20, 0x00, 166 0xEE, 0xF7, 0xF3, 0x70, 0x20, 0x00,
170 0x7C, 0x7C, 0x7C, 0x7E, 0x00, 0x7E, 167 0x7C, 0x7C, 0x7C, 0x7E, 0x00, 0x7E,
@@ -173,30 +170,30 @@ static const unsigned char font[] PROGMEM = {
173 0x4F, 0x5B, 0xFE, 0xC0, 0x00, 0x00, 170 0x4F, 0x5B, 0xFE, 0xC0, 0x00, 0x00,
174 0xC0, 0x00, 0xDC, 0xD7, 0xDE, 0xDE, 171 0xC0, 0x00, 0xDC, 0xD7, 0xDE, 0xDE,
175 0xDE, 0xD7, 0xDC, 0x00, 0xC0, 0x00, 172 0xDE, 0xD7, 0xDC, 0x00, 0xC0, 0x00,
176 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 173 0x00, 0x00, 0x00, 0xE0, 0xEC, 0xDF,
177 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 174 0xFC, 0xE0, 0x00, 0x00, 0x00, 0x00,
178 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 175 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
179 0x00, 0x00, 0x00, 0x00, 0xC1, 0xF3, 176 0x00, 0x00, 0x00, 0x7F, 0x80, 0x80,
180 0xCF, 0xBF, 0x7F, 0xFF, 0xFF, 0xFC, 177 0x80, 0x70, 0x0F, 0x00, 0x00, 0x80,
181 0xFB, 0xE7, 0x81, 0x00, 0x00, 0x00, 178 0x7F, 0x00, 0x00, 0x7F, 0x80, 0x80,
182 0x00, 0x80, 0xE3, 0xCF, 0x3F, 0xFF, 179 0x80, 0x80, 0x80, 0x80, 0x80, 0x7F,
183 0xFF, 0xFF, 0xFC, 0xFB, 0xE7, 0x81, 180 0x00, 0x00, 0x80, 0x80, 0x80, 0x80,
184 0x00, 0x00, 0x00, 0x00, 0x81, 0xE7, 181 0x80, 0x80, 0x80, 0xFF, 0x00, 0x00,
185 0xFF, 0xFF, 0xFF, 0xFF, 0x3C, 0x00, 182 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
186 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 183 0x00, 0x40, 0x21, 0x33, 0x3B, 0x7B,
187 0xFF, 0xF8, 0xF8, 0xFC, 0x7C, 0x7E, 184 0xFF, 0x00, 0x7C, 0xFF, 0xFF, 0xFF,
188 0x7E, 0x3E, 0xFE, 0xFF, 0xFF, 0xFF,
189 0xFF, 0xFF, 0xF7, 0xF7, 0xF7, 0xFB,
190 0xFB, 0x7D, 0x7D, 0x7D, 0xBE, 0xBE,
191 0xBE, 0xDF, 0xDF, 0xE0, 0xE0, 0x00,
192 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
193 0x00, 0xFC, 0xFC, 0x7C, 0x7E, 0x7E,
194 0x3E, 0x3E, 0x1F, 0x1F, 0x1F, 0x0F,
195 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 185 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
196 0x00, 0x00, 0x00, 0x00, 0x00, 0x81, 186 0xFF, 0xFF, 0xFF, 0xFF, 0x7C, 0x01,
197 0xE7, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 187 0xFF, 0xDE, 0x8C, 0x04, 0x0C, 0x08,
198 0xFF, 0xFF, 0xFF, 0xFF, 0xE7, 0x81, 188 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
199 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 189 0x00, 0x01, 0x01, 0x01, 0x7F, 0x80,
190 0x80, 0xBE, 0xBE, 0x80, 0x80, 0x80,
191 0xC1, 0xFF, 0x80, 0x04, 0x32, 0x5E,
192 0x1C, 0x3D, 0x26, 0x10, 0xC1, 0xFF,
193 0x3E, 0x00, 0x00, 0x08, 0x36, 0xC1,
194 0x08, 0x08, 0x14, 0x77, 0x94, 0x94,
195 0x94, 0xF7, 0x94, 0xF7, 0x9C, 0x9C,
196 0xFF, 0xFF, 0x1E, 0x00, 0x00, 0x00,
200 0x0F, 0x1F, 0x3F, 0x7F, 0x7F, 0x7F, 197 0x0F, 0x1F, 0x3F, 0x7F, 0x7F, 0x7F,
201 0x7F, 0x7F, 0x3F, 0x1E, 0x0C, 0x00, 198 0x7F, 0x7F, 0x3F, 0x1E, 0x0C, 0x00,
202 0x1F, 0x1F, 0x1F, 0x3F, 0x00, 0x3F, 199 0x1F, 0x1F, 0x1F, 0x3F, 0x00, 0x3F,
@@ -205,30 +202,31 @@ static const unsigned char font[] PROGMEM = {
205 0x20, 0x30, 0x78, 0x7F, 0x3B, 0x00, 202 0x20, 0x30, 0x78, 0x7F, 0x3B, 0x00,
206 0x03, 0x00, 0x0F, 0x7F, 0x0F, 0x0F, 203 0x03, 0x00, 0x0F, 0x7F, 0x0F, 0x0F,
207 0x0F, 0x7F, 0x0F, 0x00, 0x03, 0x00, 204 0x0F, 0x7F, 0x0F, 0x00, 0x03, 0x00,
205 0x40, 0x7C, 0x3F, 0x3F, 0x23, 0x01,
206 0x23, 0x3F, 0x37, 0x6C, 0x40, 0x00,
207 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
208 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
209 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
210 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
211 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
212 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
213 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
208 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 214 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
215 0x00, 0x00, 0x00, 0x06, 0x02, 0x06,
216 0x4D, 0x4F, 0x8C, 0xF9, 0x73, 0x37,
217 0x27, 0x2F, 0x2F, 0xAF, 0xEF, 0x6F,
218 0x77, 0x17, 0x33, 0x79, 0xCC, 0x1F,
219 0x31, 0x20, 0x21, 0x02, 0x02, 0x00,
209 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 220 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
221 0x00, 0x00, 0x00, 0x00, 0x40, 0xE0,
222 0xA0, 0xA0, 0xD0, 0x90, 0x48, 0x48,
223 0x25, 0x2B, 0x11, 0x09, 0x05, 0x03,
224 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
225 0x01, 0x03, 0x02, 0x04, 0x03, 0x01,
226 0x01, 0x01, 0x01, 0x01, 0x01, 0x00,
227 0x00, 0x00, 0x00, 0x03, 0x0F, 0x1F,
228 0x0F, 0x03, 0x00, 0x00, 0x00, 0x00,
210 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 229 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
211 0x60, 0x70, 0x7C, 0x7F, 0x7F, 0x7F,
212 0x7F, 0x1F, 0x06, 0x01, 0x03, 0x0F,
213 0x3F, 0x7F, 0x7F, 0x7E, 0x7C, 0x7C,
214 0x7E, 0x7F, 0x7F, 0x7F, 0x1F, 0x06,
215 0x01, 0x07, 0x0F, 0x3F, 0x7F, 0x7F,
216 0x7E, 0x7C, 0x7C, 0x7E, 0x7F, 0x7F,
217 0x3F, 0x0F, 0x03, 0x00, 0x00, 0x00,
218 0x00, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F,
219 0x7F, 0x00, 0x00, 0x00, 0x00, 0x00,
220 0x00, 0x00, 0x7F, 0x7F, 0x7F, 0x7F,
221 0x7F, 0x7F, 0x7D, 0x7D, 0x3D, 0x3E,
222 0x1E, 0x1F, 0x1F, 0x1F, 0x0F, 0x0F,
223 0x07, 0x07, 0x07, 0x03, 0x03, 0x00,
224 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F,
225 0x7C, 0x7C, 0x7C, 0x7C, 0x7C, 0x7C,
226 0x7C, 0x7C, 0x7C, 0x7C, 0x7C, 0x00,
227 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F,
228 0x00, 0x40, 0x70, 0x78, 0x7E, 0x7F,
229 0x7F, 0x7F, 0x3F, 0x0F, 0x03, 0x01,
230 0x03, 0x0F, 0x3F, 0x7F, 0x7F, 0x7F,
231 0x7E, 0x78, 0x70, 0x40, 0x00, 0x00,
232 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 230 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
233 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 231 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
234 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 232 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
@@ -239,6 +237,4 @@ static const unsigned char font[] PROGMEM = {
239 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 237 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
240 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 238 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
241 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 239 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
242 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
243}; 240};
244#endif // FONT5X7_H
diff --git a/keyboards/sol/common/ssd1306.c b/keyboards/sol/common/ssd1306.c
deleted file mode 100644
index b3e55a67c..000000000
--- a/keyboards/sol/common/ssd1306.c
+++ /dev/null
@@ -1,329 +0,0 @@
1#ifdef SSD1306OLED
2
3#include "ssd1306.h"
4#include "i2c.h"
5#include <string.h>
6#include "print.h"
7#ifndef LOCAL_GLCDFONT
8#include "common/glcdfont.c"
9#else
10#include <helixfont.h>
11#endif
12#ifdef ADAFRUIT_BLE_ENABLE
13#include "adafruit_ble.h"
14#endif
15#ifdef PROTOCOL_LUFA
16#include "lufa.h"
17#endif
18#include "sendchar.h"
19#include "timer.h"
20
21// Set this to 1 to help diagnose early startup problems
22// when testing power-on with ble. Turn it off otherwise,
23// as the latency of printing most of the debug info messes
24// with the matrix scan, causing keys to drop.
25#define DEBUG_TO_SCREEN 0
26
27//static uint16_t last_battery_update;
28//static uint32_t vbat;
29//#define BatteryUpdateInterval 10000 /* milliseconds */
30#define ScreenOffInterval 300000 /* milliseconds */
31#if DEBUG_TO_SCREEN
32static uint8_t displaying;
33#endif
34static uint16_t last_flush;
35
36// Write command sequence.
37// Returns true on success.
38static inline bool _send_cmd1(uint8_t cmd) {
39 bool res = false;
40
41 if (i2c_start_write(SSD1306_ADDRESS)) {
42 xprintf("failed to start write to %d\n", SSD1306_ADDRESS);
43 goto done;
44 }
45
46 if (i2c_master_write(0x0 /* command byte follows */)) {
47 print("failed to write control byte\n");
48
49 goto done;
50 }
51
52 if (i2c_master_write(cmd)) {
53 xprintf("failed to write command %d\n", cmd);
54 goto done;
55 }
56 res = true;
57done:
58 i2c_master_stop();
59 return res;
60}
61
62// Write 2-byte command sequence.
63// Returns true on success
64static inline bool _send_cmd2(uint8_t cmd, uint8_t opr) {
65 if (!_send_cmd1(cmd)) {
66 return false;
67 }
68 return _send_cmd1(opr);
69}
70
71// Write 3-byte command sequence.
72// Returns true on success
73static inline bool _send_cmd3(uint8_t cmd, uint8_t opr1, uint8_t opr2) {
74 if (!_send_cmd1(cmd)) {
75 return false;
76 }
77 if (!_send_cmd1(opr1)) {
78 return false;
79 }
80 return _send_cmd1(opr2);
81}
82
83#define send_cmd1(c) if (!_send_cmd1(c)) {goto done;}
84#define send_cmd2(c,o) if (!_send_cmd2(c,o)) {goto done;}
85#define send_cmd3(c,o1,o2) if (!_send_cmd3(c,o1,o2)) {goto done;}
86
87static void clear_display(void) {
88 matrix_clear(&display);
89
90 // Clear all of the display bits (there can be random noise
91 // in the RAM on startup)
92 send_cmd3(PageAddr, 0, (DisplayHeight / 8) - 1);
93 send_cmd3(ColumnAddr, 0, DisplayWidth - 1);
94
95 if (i2c_start_write(SSD1306_ADDRESS)) {
96 goto done;
97 }
98 if (i2c_master_write(0x40)) {
99 // Data mode
100 goto done;
101 }
102 for (uint8_t row = 0; row < MatrixRows; ++row) {
103 for (uint8_t col = 0; col < DisplayWidth; ++col) {
104 i2c_master_write(0);
105 }
106 }
107
108 display.dirty = false;
109
110done:
111 i2c_master_stop();
112}
113
114#if DEBUG_TO_SCREEN
115#undef sendchar
116static int8_t capture_sendchar(uint8_t c) {
117 sendchar(c);
118 iota_gfx_write_char(c);
119
120 if (!displaying) {
121 iota_gfx_flush();
122 }
123 return 0;
124}
125#endif
126
127bool iota_gfx_init(bool rotate) {
128 bool success = false;
129
130 i2c_master_init();
131 send_cmd1(DisplayOff);
132 send_cmd2(SetDisplayClockDiv, 0x80);
133 send_cmd2(SetMultiPlex, DisplayHeight - 1);
134
135 send_cmd2(SetDisplayOffset, 0);
136
137
138 send_cmd1(SetStartLine | 0x0);
139 send_cmd2(SetChargePump, 0x14 /* Enable */);
140 send_cmd2(SetMemoryMode, 0 /* horizontal addressing */);
141
142 if(rotate){
143 // the following Flip the display orientation 180 degrees
144 send_cmd1(SegRemap);
145 send_cmd1(ComScanInc);
146 }else{
147 // Flips the display orientation 0 degrees
148 send_cmd1(SegRemap | 0x1);
149 send_cmd1(ComScanDec);
150 }
151
152 send_cmd2(SetComPins, 0x2);
153 send_cmd2(SetContrast, 0x8f);
154 send_cmd2(SetPreCharge, 0xf1);
155 send_cmd2(SetVComDetect, 0x40);
156 send_cmd1(DisplayAllOnResume);
157 send_cmd1(NormalDisplay);
158 send_cmd1(DeActivateScroll);
159 send_cmd1(DisplayOn);
160
161 send_cmd2(SetContrast, 0); // Dim
162
163 clear_display();
164
165 success = true;
166
167 iota_gfx_flush();
168
169#if DEBUG_TO_SCREEN
170 print_set_sendchar(capture_sendchar);
171#endif
172
173done:
174 return success;
175}
176
177bool iota_gfx_off(void) {
178 bool success = false;
179
180 send_cmd1(DisplayOff);
181 success = true;
182
183done:
184 return success;
185}
186
187bool iota_gfx_on(void) {
188 bool success = false;
189
190 send_cmd1(DisplayOn);
191 success = true;
192
193done:
194 return success;
195}
196
197void matrix_write_char_inner(struct CharacterMatrix *matrix, uint8_t c) {
198 *matrix->cursor = c;
199 ++matrix->cursor;
200
201 if (matrix->cursor - &matrix->display[0][0] == sizeof(matrix->display)) {
202 // We went off the end; scroll the display upwards by one line
203 memmove(&matrix->display[0], &matrix->display[1],
204 MatrixCols * (MatrixRows - 1));
205 matrix->cursor = &matrix->display[MatrixRows - 1][0];
206 memset(matrix->cursor, ' ', MatrixCols);
207 }
208}
209
210void matrix_write_char(struct CharacterMatrix *matrix, uint8_t c) {
211 matrix->dirty = true;
212
213 if (c == '\n') {
214 // Clear to end of line from the cursor and then move to the
215 // start of the next line
216 uint8_t cursor_col = (matrix->cursor - &matrix->display[0][0]) % MatrixCols;
217
218 while (cursor_col++ < MatrixCols) {
219 matrix_write_char_inner(matrix, ' ');
220 }
221 return;
222 }
223
224 matrix_write_char_inner(matrix, c);
225}
226
227void iota_gfx_write_char(uint8_t c) {
228 matrix_write_char(&display, c);
229}
230
231void matrix_write(struct CharacterMatrix *matrix, const char *data) {
232 const char *end = data + strlen(data);
233 while (data < end) {
234 matrix_write_char(matrix, *data);
235 ++data;
236 }
237}
238
239void iota_gfx_write(const char *data) {
240 matrix_write(&display, data);
241}
242
243void matrix_write_P(struct CharacterMatrix *matrix, const char *data) {
244 while (true) {
245 uint8_t c = pgm_read_byte(data);
246 if (c == 0) {
247 return;
248 }
249 matrix_write_char(matrix, c);
250 ++data;
251 }
252}
253
254void iota_gfx_write_P(const char *data) {
255 matrix_write_P(&display, data);
256}
257
258void matrix_clear(struct CharacterMatrix *matrix) {
259 memset(matrix->display, ' ', sizeof(matrix->display));
260 matrix->cursor = &matrix->display[0][0];
261 matrix->dirty = true;
262}
263
264void iota_gfx_clear_screen(void) {
265 matrix_clear(&display);
266}
267
268void matrix_render(struct CharacterMatrix *matrix) {
269 last_flush = timer_read();
270 iota_gfx_on();
271#if DEBUG_TO_SCREEN
272 ++displaying;
273#endif
274
275 // Move to the home position
276 send_cmd3(PageAddr, 0, MatrixRows - 1);
277 send_cmd3(ColumnAddr, 0, (MatrixCols * FontWidth) - 1);
278
279 if (i2c_start_write(SSD1306_ADDRESS)) {
280 goto done;
281 }
282 if (i2c_master_write(0x40)) {
283 // Data mode
284 goto done;
285 }
286
287 for (uint8_t row = 0; row < MatrixRows; ++row) {
288 for (uint8_t col = 0; col < MatrixCols; ++col) {
289 const uint8_t *glyph = font + (matrix->display[row][col] * FontWidth);
290
291 for (uint8_t glyphCol = 0; glyphCol < FontWidth; ++glyphCol) {
292 uint8_t colBits = pgm_read_byte(glyph + glyphCol);
293 i2c_master_write(colBits);
294 }
295
296 // 1 column of space between chars (it's not included in the glyph)
297 //i2c_master_write(0);
298 }
299 }
300
301 matrix->dirty = false;
302
303done:
304 i2c_master_stop();
305#if DEBUG_TO_SCREEN
306 --displaying;
307#endif
308}
309
310void iota_gfx_flush(void) {
311 matrix_render(&display);
312}
313
314__attribute__ ((weak))
315void iota_gfx_task_user(void) {
316}
317
318void iota_gfx_task(void) {
319 iota_gfx_task_user();
320
321 if (display.dirty) {
322 iota_gfx_flush();
323 }
324
325 if (timer_elapsed(last_flush) > ScreenOffInterval) {
326 iota_gfx_off();
327 }
328}
329#endif
diff --git a/keyboards/sol/common/ssd1306.h b/keyboards/sol/common/ssd1306.h
deleted file mode 100644
index 77ce7c211..000000000
--- a/keyboards/sol/common/ssd1306.h
+++ /dev/null
@@ -1,92 +0,0 @@
1#ifndef SSD1306_H
2#define SSD1306_H
3
4#include <stdbool.h>
5#include <stdio.h>
6#include "pincontrol.h"
7
8enum ssd1306_cmds {
9 DisplayOff = 0xAE,
10 DisplayOn = 0xAF,
11
12 SetContrast = 0x81,
13 DisplayAllOnResume = 0xA4,
14
15 DisplayAllOn = 0xA5,
16 NormalDisplay = 0xA6,
17 InvertDisplay = 0xA7,
18 SetDisplayOffset = 0xD3,
19 SetComPins = 0xda,
20 SetVComDetect = 0xdb,
21 SetDisplayClockDiv = 0xD5,
22 SetPreCharge = 0xd9,
23 SetMultiPlex = 0xa8,
24 SetLowColumn = 0x00,
25 SetHighColumn = 0x10,
26 SetStartLine = 0x40,
27
28 SetMemoryMode = 0x20,
29 ColumnAddr = 0x21,
30 PageAddr = 0x22,
31
32 ComScanInc = 0xc0,
33 ComScanDec = 0xc8,
34 SegRemap = 0xa0,
35 SetChargePump = 0x8d,
36 ExternalVcc = 0x01,
37 SwitchCapVcc = 0x02,
38
39 ActivateScroll = 0x2f,
40 DeActivateScroll = 0x2e,
41 SetVerticalScrollArea = 0xa3,
42 RightHorizontalScroll = 0x26,
43 LeftHorizontalScroll = 0x27,
44 VerticalAndRightHorizontalScroll = 0x29,
45 VerticalAndLeftHorizontalScroll = 0x2a,
46};
47
48// Controls the SSD1306 128x32 OLED display via i2c
49
50#ifndef SSD1306_ADDRESS
51#define SSD1306_ADDRESS 0x3C
52#endif
53
54#define DisplayHeight 32
55#define DisplayWidth 128
56
57#define FontHeight 8
58#define FontWidth 6
59
60#define MatrixRows (DisplayHeight / FontHeight)
61#define MatrixCols (DisplayWidth / FontWidth)
62
63struct CharacterMatrix {
64 uint8_t display[MatrixRows][MatrixCols];
65 uint8_t *cursor;
66 bool dirty;
67};
68
69struct CharacterMatrix display;
70
71bool iota_gfx_init(bool rotate);
72void iota_gfx_task(void);
73bool iota_gfx_off(void);
74bool iota_gfx_on(void);
75void iota_gfx_flush(void);
76void iota_gfx_write_char(uint8_t c);
77void iota_gfx_write(const char *data);
78void iota_gfx_write_P(const char *data);
79void iota_gfx_clear_screen(void);
80
81void iota_gfx_task_user(void);
82
83void matrix_clear(struct CharacterMatrix *matrix);
84void matrix_write_char_inner(struct CharacterMatrix *matrix, uint8_t c);
85void matrix_write_char(struct CharacterMatrix *matrix, uint8_t c);
86void matrix_write(struct CharacterMatrix *matrix, const char *data);
87void matrix_write_P(struct CharacterMatrix *matrix, const char *data);
88void matrix_render(struct CharacterMatrix *matrix);
89
90
91
92#endif