-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathevilOLED.cpp
430 lines (402 loc) · 20.9 KB
/
evilOLED.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
/*
evilOLED is an Arduino library for efficient use of SSD1306 based
displays, specifically 128x64 pixel ones using the I2C 2-wire
interface. This driver does not use a framebuffer, therefore
leaving you with plenty of dynamic memory for your own code!
Written by Nick Veitch, 2014 <[email protected]>
Released under MIT license
Latest versions available at https://github.com/evilnick/evilOLED/
*/
#include "evilOLED.h"
const char fb[1024] PROGMEM = {
B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000,
B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000,
B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000,
B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000,
B00000000, B00000000, B00000000, B00000000, B00010000, B00000000, B00000000, B00000000,
B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000,
B00000000, B00000000, B00000000, B00000000, B00010000, B00000000, B00000000, B00000000,
B00000000, B00000000, B00000000, B00000000, B00010000, B00000000, B00000000, B00000000,
B00000000, B00000000, B00000000, B00000000, B00010000, B00000000, B01000000, B00000000,
B00000000, B00000000, B00000000, B00000000, B00010000, B00000000, B01000000, B00000000,
B00000000, B00000000, B00000000, B00000000, B00010000, B00000000, B01000000, B00000000,
B00000000, B00000000, B00000000, B00000000, B00010000, B00000000, B01000000, B00000000,
B00010000, B00000000, B00000000, B00000000, B00010000, B00000000, B01000000, B00000000,
B00010000, B00000000, B00000000, B00000000, B00010000, B00000000, B01000000, B00000000,
B00010000, B00000000, B01000000, B00000000, B00010000, B00000000, B01000000, B00000000,
B00010000, B00000000, B00000000, B00000000, B00010000, B00000000, B01000000, B00000000,
B00010001, B00000000, B01000100, B00000000, B01010001, B00000000, B01010100, B00000000,
B00010001, B00000000, B01010100, B00000000, B01010001, B00000000, B01010100, B00000000,
B00010001, B00000000, B01000100, B00000000, B01010001, B00000000, B01010100, B00000000,
B00010001, B00000000, B01010100, B00000000, B01010001, B00000000, B01010100, B00000000,
B00010001, B00000000, B01010100, B00000000, B01010001, B00000000, B01010100, B00000000,
B01010001, B00000000, B01010100, B00000000, B01010001, B00000000, B01010100, B00000000,
B01010001, B00000000, B01010100, B00000000, B01010001, B00000000, B01010100, B00000000,
B01010001, B00000000, B01010100, B00000000, B01010001, B00000000, B01010100, B00000000,
B01010001, B00000000, B01010100, B00000000, B01010001, B00000000, B01010100, B00000000,
B01010001, B00000000, B01010101, B00000000, B01010001, B00000000, B01010100, B00000000,
B01010001, B00000000, B01010100, B00000000, B01010001, B00000000, B01010100, B00000000,
B01010001, B00000000, B01010101, B00000000, B01010001, B00000000, B01010100, B00000000,
B01010001, B00000000, B01010101, B00000000, B01010001, B00000000, B01010100, B00000000,
B01010101, B00000000, B01010101, B00000000, B01010001, B00000000, B01010100, B00000000,
B01010101, B00000000, B01010101, B00000000, B01010001, B00000000, B01010100, B00000000,
B01010101, B00000000, B01010101, B00000000, B01010001, B00100000, B01010101, B00000000,
B01010101, B00100010, B01010101, B10001000, B01010101, B00100010, B01010101, B10000000,
B01010101, B00100010, B01010101, B10001000, B01010101, B00100010, B01010101, B10000000,
B01010101, B00100010, B01010101, B10001000, B01010101, B00100010, B01010101, B10101000,
B01010101, B00100010, B01010101, B10001000, B01010101, B00100010, B01010101, B10001000,
B01010101, B00100010, B01010101, B10001000, B01010101, B00100010, B01010101, B10101000,
B01010101, B00100010, B01010101, B10001000, B01010101, B00100010, B01010101, B10101000,
B01010101, B00100010, B01010101, B10001000, B01010101, B10100010, B00000001, B11111000,
B11111001, B11111010, B11111001, B11111000, B01111001, B11111010, B11111001, B11111000,
B11111001, B11111010, B11111001, B11111000, B01111001, B10111010, B10011001, B10011000,
B01111001, B11111010, B11111001, B00000000, B01010101, B10100010, B01010101, B10101000,
B01010101, B00100010, B01010101, B10101000, B01010101, B10100010, B01010101, B10101000,
B01010101, B00100010, B01010101, B10101000, B01010101, B10100010, B01010101, B10101000,
B01010101, B10100010, B01010101, B10101000, B01010101, B10100010, B01010101, B10101000,
B01010101, B00100010, B01010101, B10101000, B01010101, B10100010, B01010101, B10101000,
B01010101, B10100010, B01010101, B10101000, B01010101, B10100010, B01010101, B10101000,
B01010101, B10100010, B01010101, B10101000, B01010101, B10100010, B01010101, B10101000,
B01010101, B10101010, B01010101, B10101010, B01010101, B10111010, B01010101, B10101010,
B01010101, B10101010, B01010101, B10101010, B01010101, B10111010, B01010101, B11101010,
B01010101, B10101010, B01010101, B10101010, B01010101, B10111010, B01010101, B11101010,
B01010101, B10111010, B01010101, B10101010, B01010101, B10111010, B01010101, B11101010,
B01010101, B10101010, B01010101, B10101010, B01010101, B10111010, B01010101, B11101010,
B01010101, B10111010, B01010101, B10101010, B01010101, B10111010, B01010101, B11101010,
B01010101, B10111010, B01010101, B10101010, B01010101, B10111010, B00000000, B11111111,
B11111111, B11111011, B11111101, B11001110, B11001110, B11001110, B11001100, B11111111,
B11111111, B11111111, B11111111, B11111100, B11001110, B11001111, B11001111, B11001111,
B11111111, B11111111, B11111111, B00000000, B01010101, B10111010, B01010101, B11101010,
B01010101, B10111010, B01010101, B11101010, B01010101, B10111010, B01010101, B11101010,
B01010101, B10111011, B01010101, B11101010, B01010101, B10111010, B01010101, B11101010,
B01010101, B10111010, B01010101, B11101010, B01010101, B10111010, B01010101, B11101010,
B01010101, B10111011, B01010101, B11101010, B01010101, B10111010, B01010101, B11101010,
B01010101, B10111011, B01010101, B11101010, B01010101, B10111010, B01010101, B11101010,
B01010101, B10111011, B01010101, B11101110, B01010101, B10111010, B01010101, B11101010,
B01010101, B11111011, B01010101, B11111111, B01010101, B11111011, B01010101, B11111110,
B01010101, B11111011, B01010101, B11111111, B01010101, B11111011, B01010101, B11111110,
B01010101, B11111011, B01010101, B11111111, B01010101, B11111011, B01010101, B11111110,
B01010101, B11111011, B01010101, B11111111, B01010101, B11111011, B01010101, B11111110,
B01010101, B11111111, B01010101, B11111111, B01110101, B11111011, B01010101, B11111111,
B01010101, B11111111, B01010101, B11111111, B01010101, B11111011, B01010101, B11111110,
B01010101, B11111111, B01010101, B11111111, B01110101, B11111011, B00000000, B11111111,
B11111111, B11111111, B11111111, B11110111, B11110111, B11110111, B11110111, B10110111,
B00110111, B10110111, B11110111, B11110111, B11110111, B11110111, B11110111, B11111111,
B11111111, B11111111, B11111111, B00000000, B01110101, B11111011, B11010101, B11111111,
B01010101, B11111111, B01010101, B11111111, B01110101, B11111111, B11010101, B11111111,
B01010101, B11111111, B01010101, B11111111, B01110101, B11111111, B11010101, B11111111,
B01110101, B11111111, B01010101, B11111111, B01110101, B11111111, B11010101, B11111111,
B01110101, B11111111, B01010101, B11111111, B01110101, B11111111, B11010101, B11111111,
B01110101, B11111111, B11010101, B11111111, B01110101, B11111111, B11010101, B11111111,
B01110101, B11111111, B11010101, B11111111, B01110101, B11111111, B11010101, B11111111,
B11110111, B11111111, B11111101, B11111111, B11110111, B11111111, B11111101, B11111111,
B11110111, B11111111, B11111101, B11111111, B11110111, B11111111, B11111101, B11111111,
B11110111, B11111111, B11111101, B11111111, B11110111, B11111111, B11111101, B11111111,
B01110111, B01111111, B00111101, B00111111, B00110111, B00111111, B00111101, B00111111,
B01110111, B01111111, B11111101, B11111111, B11110111, B11111111, B11111101, B11111111,
B11110111, B11111111, B11111101, B11111111, B11110111, B11111111, B11111101, B11111111,
B11110111, B11111111, B11111101, B11111111, B11110111, B11111111, B11111100, B11111101,
B11110101, B11111101, B11111101, B11111101, B11110101, B11111101, B10011101, B10011101,
B11110101, B11111101, B11111101, B00011101, B00010101, B11111101, B11111101, B11111101,
B11110101, B11111101, B11111101, B11111100, B11110111, B11111111, B11111101, B11111111,
B11110111, B11111111, B11111111, B10011111, B10010111, B11111111, B11111101, B11111111,
B11110111, B11111111, B11111111, B11111111, B11110111, B11111111, B11111101, B11111111,
B11110111, B00011111, B00011111, B11111111, B11110111, B11111111, B11111101, B11111111,
B11111111, B11111111, B11111111, B11111111, B11110111, B11111111, B11111101, B11111111,
B11111111, B11111111, B11111111, B11111111, B11110111, B11111111, B11111101, B11111111,
B11111111, B11111111, B11111111, B11111111, B11110111, B11111111, B11111111, B11111111,
B11111111, B11111111, B11111111, B11111111, B11111111, B11111111, B11111111, B11111111,
B11111111, B11111111, B11111111, B11111111, B11111111, B11111111, B11111111, B11111111,
B11111111, B11111111, B11111111, B11111111, B11111111, B00000111, B00000001, B11110000,
B11111100, B11111110, B00001110, B00000111, B01100111, B01101111, B00000111, B00000111,
B01111111, B01111110, B00111000, B10000001, B11000011, B11111111, B11111111, B00001111,
B00000011, B10010011, B10011001, B10011001, B10011001, B10011001, B10010001, B10000011,
B10000111, B11111111, B11111001, B11100001, B00000111, B00011111, B11111111, B11111111,
B00011111, B00000111, B11100001, B11111001, B11111111, B11111111, B00000001, B00000001,
B11111111, B11111111, B11111111, B00000000, B00000000, B11111111, B11111111, B11111111,
B00000001, B00000001, B11110011, B11111001, B11111001, B11110001, B00000001, B00000111,
B11111111, B11111111, B11111111, B00000001, B00000001, B11111111, B11111111, B00001111,
B00000011, B11110011, B11111001, B11111001, B11111001, B11111001, B11110011, B11111111,
B11111111, B00000000, B00000000, B10011111, B00001111, B01100111, B11110011, B11111001,
B11111101, B11111111, B11111111, B11111111, B11111111, B11111111, B11111111, B11111111,
B11111111, B11111111, B11111111, B11111111, B11111111, B11111111, B11111111, B11111111,
B11111111, B11111111, B11111111, B11111111, B11111111, B11111111, B11111111, B11111111,
B11111111, B11111111, B11111111, B11111111, B11111111, B11111111, B11111111, B11111111,
B11111111, B11111111, B11111111, B11111111, B11111111, B11111111, B11111111, B11111111,
B11111111, B11111111, B11111111, B11111111, B11111111, B11111110, B11111000, B11110000,
B11100011, B11100111, B11000111, B11001110, B11001110, B11001111, B11001110, B11100110,
B11100110, B11111111, B11111111, B11111111, B11111111, B11111111, B11111111, B11111111,
B11111100, B11111100, B11111001, B11111001, B11111001, B11111001, B11111001, B11111001,
B11111100, B11111111, B11111111, B11111111, B11111111, B11111100, B11111000, B11111000,
B11111100, B11111111, B11111111, B11111111, B11111111, B11111111, B11111000, B11111000,
B11111111, B11111111, B11111111, B11111000, B11111000, B11111111, B11111111, B11111111,
B11111000, B11111000, B11111111, B11111111, B11111111, B11111111, B11111000, B11111000,
B11111111, B11111111, B11111111, B11111000, B11111000, B11111111, B11111111, B11111111,
B11111100, B11111100, B11111001, B11111001, B11111001, B11111001, B11111100, B11111111,
B11111111, B11111000, B11111000, B11111111, B11111111, B11111110, B11111100, B11111001,
B11111011, B11111111, B11111111, B11111111, B11111111, B11111111, B11111111, B11111111,
B11111111, B11111111, B11111111, B11111111, B11111111, B11111111, B11111111, B11111111,
B11111111, B11111111, B11111111, B11111111, B11111111, B11111111, B11111111, B11111111
};
static const char font_bmap[64 * 8] PROGMEM =
{
B00011100, B00100010, B01010001, B01001001, B01000101, B00100010, B00011100, B00000000,
B00000000, B01000010, B01000001, B01111111, B01000000, B01000000, B00000000, B00000000,
B00000000, B01000010, B01100001, B01110001, B01011001, B01001101, B01000110, B00000000,
B00000000, B01000001, B01000001, B01001001, B01001001, B00110110, B00000000, B00000000,
B00000000, B00011100, B00010010, B00010001, B01111111, B00010000, B00010000, B00000000,
B00000000, B00001111, B01001001, B01001001, B01001001, B01001001, B00110001, B00000000,
B00000000, B00111000, B01000100, B01001010, B01001001, B01001001, B00110000, B00000000,
B00000000, B00000001, B00001001, B01001001, B00110001, B00001001, B00000111, B00000000,
B00000000, B00110110, B01001001, B01001001, B01001001, B01001001, B00110110, B00000000,
B00000000, B00000110, B01001001, B01001001, B00101001, B00010101, B00001110, B00000000,
B00000000, B00000000, B00000000, B00010100, B00000000, B00000000, B00000000, B00000000,
B01010101, B10101010, B11010101, B11101010, B11110101, B11111010, B11111101, B11111110,
B00000000, B00000000, B00001000, B00010100, B00100010, B00000000, B00000000, B00000000,
B00000000, B00010100, B00010100, B00010100, B00010100, B00000000, B00000000, B00000000,
B00000000, B00100010, B00010100, B00001000, B00000000, B00000000, B00000000, B00000000,
B00000000, B00000000, B00000010, B01010001, B01010001, B00001011, B00000110, B00000000,
B00000000, B00100010, B00010100, B00001000, B00010100, B00100010, B00000000, B00000000,
B01111100, B00001010, B00001001, B00001001, B00001010, B01111100, B00000000, B00000000,
B01111111, B01001001, B01001001, B01001001, B01001001, B00110110, B00000000, B00000000,
B00111110, B01000001, B01000001, B01000001, B01000001, B00100010, B00000000, B00000000,
B01111111, B01000001, B01000001, B01000001, B01100011, B00111110, B00000000, B00000000,
B01111111, B01001001, B01001001, B01001001, B01000001, B01000001, B00000000, B00000000,
B00000000, B01111111, B00001001, B00001001, B00001001, B00000001, B00000001, B00000000,
B00000000, B00011110, B00100001, B01000001, B01001001, B00111001, B00000000, B00000000,
B00000000, B01111111, B00001000, B00001000, B00001000, B00001000, B01111111, B00000000,
B00000000, B01000001, B01000001, B01111111, B01000001, B01000001, B00000000, B00000000,
B01000001, B01000001, B01100001, B00111111, B00000001, B00000001, B00000000, B00000000,
B01111111, B00001000, B00001100, B00010010, B01100001, B00000000, B00000000, B00000000,
B00000000, B01111111, B01000000, B01000000, B01000000, B01000000, B00000000, B00000000,
B01111111, B00000010, B00000100, B00001000, B00000100, B00000010, B01111111, B00000000,
B01111111, B00000110, B00001100, B00011000, B00110001, B01111111, B00000000, B00000000,
B00000000, B00011100, B00100010, B01000001, B01000001, B00100010, B00011100, B00000000,
B00000000, B01111111, B00001001, B00001001, B00001001, B00000110, B00000000, B00000000,
B00000000, B00111110, B01000001, B11000001, B01110001, B01000011, B00111110, B00000000,
B00000000, B01111111, B00001001, B00001001, B00011001, B01100110, B00000000, B00000000,
B00000000, B00100110, B01001001, B01001001, B01001001, B00110010, B00000000, B00000000,
B00000000, B00000001, B00000001, B01111111, B00000001, B00000001, B00000000, B00000000,
B00000000, B00000000, B00111111, B01000000, B01000000, B01000000, B00111111, B00000000,
B00000000, B00000011, B00001100, B00110000, B01000000, B00110000, B00001100, B00000011,
B00000000, B01111111, B01000000, B00111000, B01000000, B01111111, B00000000, B00000000,
B01100011, B00110110, B00011100, B00011100, B00110110, B01100011, B00000000, B00000000,
B00000000, B01000011, B01100110, B00111100, B00011000, B00001100, B00000111, B00000000,
B00000000, B01101001, B01111001, B01011001, B01001101, B01001111, B01001011, B00000000,
B00000000, B00000000, B01000001, B01000001, B01111111, B00000000, B00000000, B00000000,
B00011000, B00111100, B00111100, B00111100, B00111100, B00111100, B00111100, B00000000,
B00000000, B00000000, B01111111, B01000001, B01000001, B00000000, B00000000, B00000000,
B00111100, B01000010, B10111101, B10110101, B10101101, B10100001, B00111111, B00000000,
B00000000, B01111110, B01111110, B01111110, B01111110, B01111110, B01111110, B00000000,
B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000,
B01010101, B10101010, B01010101, B10101010, B01010101, B10101010, B01010101, B10101010,
B00000000, B00000000, B00111110, B00110110, B00100010, B00110110, B00111110, B00000000,
B00011100, B00110110, B00110110, B00110110, B00110110, B00011100, B00000000, B00000000,
B11111111, B10000001, B10000001, B10000001, B10000001, B10000001, B10000001, B11111111,
B00000000, B01111110, B01000010, B01000010, B01000010, B01000010, B01111110, B00000000,
B00000000, B01111110, B01000010, B01011010, B01011010, B01000010, B01111110, B00000000,
B00000000, B01111110, B01100010, B01010010, B01001010, B01000110, B01111110, B00000000,
B00000000, B01000000, B01100000, B01110000, B01111000, B01111100, B01111110, B00000000,
B00011000, B00011000, B00011000, B01011010, B01111110, B00111100, B00011000, B00000000,
B00000000, B00001111, B00011000, B11111111, B11111000, B00011111, B00000000, B00000000,
B01111110, B01100110, B01111110, B01100111, B01111110, B01100110, B01111111, B00000000,
B01010101, B01111111, B01010101, B01111111, B01010101, B01111111, B01010101, B01111111,
B11111111, B11111111, B11111111, B11111111, B11111111, B11111111, B11111111, B11111111,
B11111111, B11111111, B11111111, B11111111, B11111111, B11111111, B11111111, B11111111,
B11111111, B11111111, B11111111, B11111111, B11111111, B11111111, B11111111, B11111111
};
evilOLED::evilOLED(char sda, char scl)
{
_sda = sda;
_scl = scl;
int _col = 0x00;
int _row = 0x00;
init();
cls(0xff);
splash();
delay(1000);
}
void evilOLED::dataStart()
{
digitalWrite(_scl, HIGH);
digitalWrite(_sda, HIGH);
digitalWrite(_sda, LOW);
digitalWrite(_scl, LOW);
}
void evilOLED::dataStop()
{
digitalWrite(_scl, LOW);
digitalWrite(_sda, LOW);
digitalWrite(_scl, HIGH);
digitalWrite(_sda, HIGH);
}
void evilOLED::sendByte(unsigned char data)
{
char i;
for (i = 0; i < 8; i++)
{
if ((data << i) & 0x80) {
digitalWrite(_sda, HIGH);
}
else {
digitalWrite(_sda, LOW);
}
digitalWrite(_scl, HIGH);
digitalWrite(_scl, LOW);
}
digitalWrite(_sda, HIGH);
digitalWrite(_scl, HIGH);
digitalWrite(_scl, LOW);
}
void evilOLED::sendCmd(unsigned char cmd)
{
dataStart();
sendByte(_slave_address); //0x78 or 0x79
sendByte(0x00); //write command
sendByte(cmd);
dataStop();
}
void evilOLED::cls(char b = 0x00)
{
sendCmd(0x20);
sendCmd(0x00);
dataStart();
sendByte(_slave_address);
sendByte(0x40);
for (unsigned int n = 0; n < 1024; n++)
{
sendByte(b);
}
dataStop();
}
void evilOLED::setCursor(char x, char y)
{
_row = (
(y > 7)
? 7
: y
);
_col = (
(x > 15)
? 15
: x
);
sendCmd(0xB0 + _row); //set page from row
sendCmd(0x00 + (_col & 0x01) * 8);
sendCmd(0x10 + (_col >> 1));
}
void evilOLED::putChar(char c)
{
//assumes cursor is set to correct place
if (c == 0x20) // trap SPACE character
{
c = 0x30; //this is where I put it
}
else
{
c -= 0x30;
}
dataStart();
sendByte(0x78);
sendByte(0x40);
for (char i = 0; i < 8; i++)
{
sendByte(pgm_read_byte(&(font_bmap[8 * c + i])));
}
dataStop();
}
void evilOLED::putString(char* s)
{
//assumes cursor is set to correct place
dataStart();
sendByte(0x78);
sendByte(0x40);
int index = 0;
char c;
while (*(s + index) != 0x00) {
if (*(s + index) == 0x20) // trap SPACE character
{
c = 0x30; //this is where I put it
}
else
{
c = (*(s + index) - 0x30);
}
for (char i = 0; i < 8; i++)
{
sendByte(pgm_read_byte(&(font_bmap[8 * c + i])));
}
index++;
}
dataStop();
}
void evilOLED::putString(int s)
{
char buffer[16];
itoa(s, buffer, 10);
putString(buffer);
}
void evilOLED::flash(int d)
{
sendCmd(0xA7);
delay(d);
sendCmd(0xA6);
delay(d);
}
void evilOLED::alert(int d)
{
flash(d);
flash(d / 2);
flash(d / 2);
}
void evilOLED::splash()
{
int index = 0;
sendCmd(0x00);// -> page mode
sendCmd(0x00);// lower page
sendCmd(0x07);
for (int p = 0; p < 8; p++) {
sendCmd(0xb0 + p);
sendCmd(0x00);
sendCmd(0x10);
dataStart();
sendByte(0x78);
sendByte(0x40);
for (int n = 0; n < 128; n++)
{
sendByte(pgm_read_byte(&(fb[index++])));
}
dataStop();
}
}
void evilOLED::init()
{
//write command to the screen registers.
sendCmd(0xAE);//display off
sendCmd(0x00);//Set Memory Addressing Mode
sendCmd(0x10);//00,Horizontal Addressing Mode;01,Vertical Addressing Mode;10,Page Addressing Mode (RESET);11,Invalid
sendCmd(0x40);//Set Page Start Address for Page Addressing Mode,0-7
sendCmd(0xB0);//Set COM Output Scan Direction
sendCmd(0x81);//---set low column address
sendCmd(0xCF);//---set high column address
sendCmd(0xA1);//--set start line address
sendCmd(0xA6);//--set contrast control register
sendCmd(0xA8);
sendCmd(0x3F);//--set segment re-map 0 to 127
sendCmd(0xC8);//--set normal display
sendCmd(0xD3);//--set multiplex ratio(1 to 64)
sendCmd(0x00);//
sendCmd(0xD5);//0xa4,Output follows RAM content;0xa5,Output ignores RAM content
sendCmd(0x80);//-set display offset
sendCmd(0xD9);//-not offset
sendCmd(0xF1);//--set display clock divide ratio/oscillator frequency
sendCmd(0xDA);//--set divide ratio
sendCmd(0x12);//--set pre-charge period
sendCmd(0xDB);//
sendCmd(0x40);//--set com pins hardware configuration
sendCmd(0x8D);//--set vcomh
sendCmd(0x14);//0x20,0.77xVcc
sendCmd(0xAF);//--set DC-DC enable
//sendCmd(0xAF);//--turn on oled panel
delay(50);
}