|
1 /* |
|
2 |
|
3 u8x8_d_sh1107.c |
|
4 |
|
5 Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/) |
|
6 |
|
7 Copyright (c) 2017, olikraus@gmail.com |
|
8 All rights reserved. |
|
9 |
|
10 Redistribution and use in source and binary forms, with or without modification, |
|
11 are permitted provided that the following conditions are met: |
|
12 |
|
13 * Redistributions of source code must retain the above copyright notice, this list |
|
14 of conditions and the following disclaimer. |
|
15 |
|
16 * Redistributions in binary form must reproduce the above copyright notice, this |
|
17 list of conditions and the following disclaimer in the documentation and/or other |
|
18 materials provided with the distribution. |
|
19 |
|
20 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND |
|
21 CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, |
|
22 INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
|
23 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
|
24 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR |
|
25 CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
|
26 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
|
27 NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
|
28 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
|
29 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, |
|
30 STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
|
31 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF |
|
32 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
|
33 |
|
34 */ |
|
35 |
|
36 |
|
37 #include "u8x8.h" |
|
38 |
|
39 /* code copyied from SSD1306 */ |
|
40 |
|
41 |
|
42 |
|
43 static const uint8_t u8x8_d_sh1107_64x128_noname_powersave0_seq[] = { |
|
44 U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */ |
|
45 U8X8_C(0x0af), /* display on */ |
|
46 U8X8_END_TRANSFER(), /* disable chip */ |
|
47 U8X8_END() /* end of sequence */ |
|
48 }; |
|
49 |
|
50 static const uint8_t u8x8_d_sh1107_64x128_noname_powersave1_seq[] = { |
|
51 U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */ |
|
52 U8X8_C(0x0ae), /* display off */ |
|
53 U8X8_END_TRANSFER(), /* disable chip */ |
|
54 U8X8_END() /* end of sequence */ |
|
55 }; |
|
56 |
|
57 static const uint8_t u8x8_d_sh1107_64x128_noname_flip0_seq[] = { |
|
58 U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */ |
|
59 U8X8_C(0x0a1), /* segment remap a0/a1*/ |
|
60 U8X8_C(0x0c8), /* c0: scan dir normal, c8: reverse */ |
|
61 U8X8_END_TRANSFER(), /* disable chip */ |
|
62 U8X8_END() /* end of sequence */ |
|
63 }; |
|
64 |
|
65 static const uint8_t u8x8_d_sh1107_64x128_noname_flip1_seq[] = { |
|
66 U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */ |
|
67 U8X8_C(0x0a0), /* segment remap a0/a1*/ |
|
68 U8X8_C(0x0c0), /* c0: scan dir normal, c8: reverse */ |
|
69 U8X8_END_TRANSFER(), /* disable chip */ |
|
70 U8X8_END() /* end of sequence */ |
|
71 }; |
|
72 |
|
73 |
|
74 static uint8_t u8x8_d_sh1107_generic(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr) |
|
75 { |
|
76 uint8_t x, c; |
|
77 uint8_t *ptr; |
|
78 switch(msg) |
|
79 { |
|
80 /* handled by the calling function |
|
81 case U8X8_MSG_DISPLAY_SETUP_MEMORY: |
|
82 u8x8_d_helper_display_setup_memory(u8x8, &u8x8_sh1107_64x128_noname_display_info); |
|
83 break; |
|
84 */ |
|
85 /* handled by the calling function |
|
86 case U8X8_MSG_DISPLAY_INIT: |
|
87 u8x8_d_helper_display_init(u8x8); |
|
88 u8x8_cad_SendSequence(u8x8, u8x8_d_sh1107_64x128_noname_init_seq); |
|
89 break; |
|
90 */ |
|
91 case U8X8_MSG_DISPLAY_SET_POWER_SAVE: |
|
92 if ( arg_int == 0 ) |
|
93 u8x8_cad_SendSequence(u8x8, u8x8_d_sh1107_64x128_noname_powersave0_seq); |
|
94 else |
|
95 u8x8_cad_SendSequence(u8x8, u8x8_d_sh1107_64x128_noname_powersave1_seq); |
|
96 break; |
|
97 case U8X8_MSG_DISPLAY_SET_FLIP_MODE: |
|
98 if ( arg_int == 0 ) |
|
99 { |
|
100 u8x8_cad_SendSequence(u8x8, u8x8_d_sh1107_64x128_noname_flip0_seq); |
|
101 u8x8->x_offset = u8x8->display_info->default_x_offset; |
|
102 } |
|
103 else |
|
104 { |
|
105 u8x8_cad_SendSequence(u8x8, u8x8_d_sh1107_64x128_noname_flip1_seq); |
|
106 u8x8->x_offset = u8x8->display_info->flipmode_x_offset; |
|
107 } |
|
108 break; |
|
109 #ifdef U8X8_WITH_SET_CONTRAST |
|
110 case U8X8_MSG_DISPLAY_SET_CONTRAST: |
|
111 u8x8_cad_StartTransfer(u8x8); |
|
112 u8x8_cad_SendCmd(u8x8, 0x081 ); |
|
113 u8x8_cad_SendArg(u8x8, arg_int ); /* sh1107 has range from 0 to 255 */ |
|
114 u8x8_cad_EndTransfer(u8x8); |
|
115 break; |
|
116 #endif |
|
117 case U8X8_MSG_DISPLAY_DRAW_TILE: |
|
118 u8x8_cad_StartTransfer(u8x8); |
|
119 x = ((u8x8_tile_t *)arg_ptr)->x_pos; |
|
120 x *= 8; |
|
121 x += u8x8->x_offset; |
|
122 |
|
123 //u8x8_cad_SendCmd(u8x8, 0x040 ); /* set line offset to 0 */ |
|
124 |
|
125 // set column address |
|
126 u8x8_cad_SendCmd(u8x8, 0x010 | (x >> 4)); |
|
127 u8x8_cad_SendCmd(u8x8, 0x000 | ((x & 15))); /* probably wrong, should be SendCmd */ |
|
128 |
|
129 // set page address |
|
130 u8x8_cad_SendCmd(u8x8, 0x0b0 | (((u8x8_tile_t *)arg_ptr)->y_pos)); /* probably wrong, should be SendCmd */ |
|
131 |
|
132 do |
|
133 { |
|
134 c = ((u8x8_tile_t *)arg_ptr)->cnt; |
|
135 ptr = ((u8x8_tile_t *)arg_ptr)->tile_ptr; |
|
136 u8x8_cad_SendData(u8x8, c*8, ptr); /* note: SendData can not handle more than 255 bytes */ |
|
137 /* |
|
138 do |
|
139 { |
|
140 u8x8_cad_SendData(u8x8, 8, ptr); |
|
141 ptr += 8; |
|
142 c--; |
|
143 } while( c > 0 ); |
|
144 */ |
|
145 arg_int--; |
|
146 } while( arg_int > 0 ); |
|
147 |
|
148 u8x8_cad_EndTransfer(u8x8); |
|
149 break; |
|
150 default: |
|
151 return 0; |
|
152 } |
|
153 return 1; |
|
154 } |
|
155 |
|
156 /*==================================================*/ |
|
157 |
|
158 /* QG-6428TSWKG01 */ |
|
159 static const uint8_t u8x8_d_sh1107_64x128_noname_init_seq[] = { |
|
160 |
|
161 U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */ |
|
162 |
|
163 |
|
164 U8X8_C(0x0ae), /* display off */ |
|
165 U8X8_CA(0x0dc, 0x000), /* start line */ |
|
166 U8X8_CA(0x081, 0x02f), /* [2] set contrast control */ |
|
167 U8X8_C(0x020), /* use page addressing mode */ |
|
168 |
|
169 // U8X8_C(0x0a1), /* segment remap a0/a1*/ |
|
170 // U8X8_C(0x0c8), /* c0: scan dir normal, c8: reverse */ |
|
171 // Flipmode |
|
172 U8X8_C(0x0a0), /* segment remap a0/a1*/ |
|
173 U8X8_C(0x0c0), /* c0: scan dir normal, c8: reverse */ |
|
174 |
|
175 U8X8_CA(0x0a8, 0x7f), /* 0x03f) multiplex ratio */ |
|
176 U8X8_CA(0x0d3, 0x060), /* display offset */ |
|
177 U8X8_CA(0x0d5, 0x051), /* clock divide ratio (0x00=1) and oscillator frequency (0x8) */ |
|
178 U8X8_CA(0x0d9, 0x022), /* [2] pre-charge period 0x022/f1*/ |
|
179 U8X8_CA(0x0db, 0x035), /* vcomh deselect level */ |
|
180 |
|
181 U8X8_C(0x0b0), /* set page address */ |
|
182 U8X8_CA(0x0da, 0x012), /* set com pins */ |
|
183 U8X8_C(0x0a4), /* output ram to display */ |
|
184 U8X8_C(0x0a6), /* none inverted normal display mode */ |
|
185 |
|
186 U8X8_END_TRANSFER(), /* disable chip */ |
|
187 U8X8_END() /* end of sequence */ |
|
188 }; |
|
189 |
|
190 static const u8x8_display_info_t u8x8_sh1107_64x128_noname_display_info = |
|
191 { |
|
192 /* chip_enable_level = */ 0, |
|
193 /* chip_disable_level = */ 1, |
|
194 |
|
195 /* post_chip_enable_wait_ns = */ 20, |
|
196 /* pre_chip_disable_wait_ns = */ 10, |
|
197 /* reset_pulse_width_ms = */ 100, /* sh1107: 3 us */ |
|
198 /* post_reset_wait_ms = */ 100, /* far east OLEDs need much longer setup time */ |
|
199 /* sda_setup_time_ns = */ 50, /* sh1107: 15ns, but cycle time is 100ns, so use 100/2 */ |
|
200 /* sck_pulse_width_ns = */ 50, /* sh1107: 20ns, but cycle time is 100ns, so use 100/2, AVR: below 70: 8 MHz, >= 70 --> 4MHz clock */ |
|
201 /* sck_clock_hz = */ 8000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */ |
|
202 /* spi_mode = */ 0, /* active high, rising edge */ |
|
203 /* i2c_bus_clock_100kHz = */ 4, |
|
204 /* data_setup_time_ns = */ 40, |
|
205 /* write_pulse_width_ns = */ 150, /* sh1107: cycle time is 300ns, so use 300/2 = 150 */ |
|
206 /* tile_width = */ 8, |
|
207 /* tile_height = */ 16, |
|
208 /* default_x_offset = */ 0, |
|
209 /* flipmode_x_offset = */ 0, |
|
210 /* pixel_width = */ 64, |
|
211 /* pixel_height = */ 128 |
|
212 }; |
|
213 |
|
214 uint8_t u8x8_d_sh1107_64x128(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr) |
|
215 { |
|
216 |
|
217 if ( u8x8_d_sh1107_generic(u8x8, msg, arg_int, arg_ptr) != 0 ) |
|
218 return 1; |
|
219 |
|
220 switch(msg) |
|
221 { |
|
222 case U8X8_MSG_DISPLAY_INIT: |
|
223 u8x8_d_helper_display_init(u8x8); |
|
224 u8x8_cad_SendSequence(u8x8, u8x8_d_sh1107_64x128_noname_init_seq); |
|
225 break; |
|
226 case U8X8_MSG_DISPLAY_SETUP_MEMORY: |
|
227 u8x8_d_helper_display_setup_memory(u8x8, &u8x8_sh1107_64x128_noname_display_info); |
|
228 break; |
|
229 default: |
|
230 return 0; |
|
231 } |
|
232 return 1; |
|
233 } |
|
234 |
|
235 /*==================================================*/ |
|
236 |
|
237 /* init sequence from Grove OLED 96x96 */ |
|
238 static const uint8_t u8x8_d_sh1107_seeed_96x96_init_seq[] = { |
|
239 |
|
240 U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */ |
|
241 |
|
242 |
|
243 U8X8_C(0x0ae), /* display off */ |
|
244 U8X8_CA(0x0d5, 0x050), /* clock divide ratio (0x00=1) and oscillator frequency (0x5) */ |
|
245 U8X8_C(0x020), /* use page addressing mode */ |
|
246 //U8X8_CA(0x0a8, 0x03f), /* multiplex ratio */ |
|
247 U8X8_CA(0x0d3, 0x000), /* display offset */ |
|
248 U8X8_CA(0x0dc, 0x000), /* start line */ |
|
249 //U8X8_CA(0x020, 0x000), /* page addressing mode */ |
|
250 |
|
251 U8X8_C(0x0a1), /* segment remap a0/a1*/ |
|
252 U8X8_C(0x0c8), /* c0: scan dir normal, c8: reverse */ |
|
253 // Flipmode |
|
254 // U8X8_C(0x0a0), /* segment remap a0/a1*/ |
|
255 // U8X8_C(0x0c0), /* c0: scan dir normal, c8: reverse */ |
|
256 |
|
257 //U8X8_CA(0x0da, 0x012), /* com pin HW config, sequential com pin config (bit 4), disable left/right remap (bit 5) */ |
|
258 |
|
259 U8X8_CA(0x081, 0x080), /* [2] set contrast control */ |
|
260 U8X8_CA(0x0ad, 0x080), /* */ |
|
261 U8X8_CA(0x0d9, 0x01f), /* [2] pre-charge period 0x022/f1*/ |
|
262 U8X8_CA(0x0db, 0x027), /* vcomh deselect level */ |
|
263 // if vcomh is 0, then this will give the biggest range for contrast control issue #98 |
|
264 // restored the old values for the noname constructor, because vcomh=0 will not work for all OLEDs, #116 |
|
265 |
|
266 //U8X8_C(0x02e), /* Deactivate scroll */ |
|
267 U8X8_C(0x0a4), /* output ram to display */ |
|
268 U8X8_C(0x0a6), /* none inverted normal display mode */ |
|
269 |
|
270 U8X8_END_TRANSFER(), /* disable chip */ |
|
271 U8X8_END() /* end of sequence */ |
|
272 }; |
|
273 |
|
274 static const u8x8_display_info_t u8x8_sh1107_seeed_96x96_display_info = |
|
275 { |
|
276 /* chip_enable_level = */ 0, |
|
277 /* chip_disable_level = */ 1, |
|
278 |
|
279 /* post_chip_enable_wait_ns = */ 20, |
|
280 /* pre_chip_disable_wait_ns = */ 10, |
|
281 /* reset_pulse_width_ms = */ 100, /* */ |
|
282 /* post_reset_wait_ms = */ 100, /* far east OLEDs need much longer setup time */ |
|
283 /* sda_setup_time_ns = */ 100, /* cycle time is 100ns, so use 100/2 */ |
|
284 /* sck_pulse_width_ns = */ 100, /* cycle time is 100ns, so use 100/2, AVR: below 70: 8 MHz, >= 70 --> 4MHz clock */ |
|
285 /* sck_clock_hz = */ 4000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */ |
|
286 /* spi_mode = */ 0, /* active high, rising edge */ |
|
287 /* i2c_bus_clock_100kHz = */ 4, |
|
288 /* data_setup_time_ns = */ 40, |
|
289 /* write_pulse_width_ns = */ 150, /* sh1107: cycle time is 300ns, so use 300/2 = 150 */ |
|
290 /* tile_width = */ 12, |
|
291 /* tile_hight = */ 12, |
|
292 /* default_x_offset = */ 0, |
|
293 /* flipmode_x_offset = */ 0, |
|
294 /* pixel_width = */ 96, |
|
295 /* pixel_height = */ 96 |
|
296 }; |
|
297 |
|
298 uint8_t u8x8_d_sh1107_seeed_96x96(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr) |
|
299 { |
|
300 |
|
301 if ( u8x8_d_sh1107_generic(u8x8, msg, arg_int, arg_ptr) != 0 ) |
|
302 return 1; |
|
303 |
|
304 switch(msg) |
|
305 { |
|
306 case U8X8_MSG_DISPLAY_INIT: |
|
307 u8x8_d_helper_display_init(u8x8); |
|
308 u8x8_cad_SendSequence(u8x8, u8x8_d_sh1107_seeed_96x96_init_seq); |
|
309 break; |
|
310 case U8X8_MSG_DISPLAY_SETUP_MEMORY: |
|
311 u8x8_d_helper_display_setup_memory(u8x8, &u8x8_sh1107_seeed_96x96_display_info); |
|
312 break; |
|
313 default: |
|
314 return 0; |
|
315 } |
|
316 return 1; |
|
317 } |
|
318 |
|
319 |
|
320 /*==================================================*/ |
|
321 /* 128x128 OLED: this display has a very strange x offset */ |
|
322 |
|
323 /* sequence taken over from 64x128 sequence, because it seems to work mostly */ |
|
324 static const uint8_t u8x8_d_sh1107_128x128_init_seq[] = { |
|
325 |
|
326 U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */ |
|
327 |
|
328 |
|
329 U8X8_C(0x0ae), /* display off */ |
|
330 U8X8_CA(0x0dc, 0x000), /* start line */ |
|
331 U8X8_CA(0x081, 0x02f), /* [2] set contrast control */ |
|
332 U8X8_C(0x020), /* use page addressing mode */ |
|
333 |
|
334 // U8X8_C(0x0a1), /* segment remap a0/a1*/ |
|
335 // U8X8_C(0x0c8), /* c0: scan dir normal, c8: reverse */ |
|
336 // Flipmode |
|
337 U8X8_C(0x0a0), /* segment remap a0/a1*/ |
|
338 U8X8_C(0x0c0), /* c0: scan dir normal, c8: reverse */ |
|
339 |
|
340 U8X8_CA(0x0a8, 0x7f), /* 0x03f multiplex ratio */ |
|
341 //U8X8_CA(0x0d3, 0x060), /* display offset (removed, not in datasheet ) */ |
|
342 U8X8_CA(0x0d5, 0x050), /* clock divide ratio (0x00=1) and oscillator frequency (0x8), changed to 0x051, issue 501 */ |
|
343 U8X8_CA(0x0d9, 0x022), /* [2] pre-charge period 0x022/f1*/ |
|
344 U8X8_CA(0x0db, 0x035), /* vcomh deselect level */ |
|
345 |
|
346 U8X8_C(0x0b0), /* set page address */ |
|
347 U8X8_CA(0x0da, 0x012), /* set com pins */ |
|
348 U8X8_C(0x0a4), /* output ram to display */ |
|
349 U8X8_C(0x0a6), /* none inverted normal display mode */ |
|
350 |
|
351 U8X8_END_TRANSFER(), /* disable chip */ |
|
352 U8X8_END() /* end of sequence */ |
|
353 }; |
|
354 |
|
355 |
|
356 static const u8x8_display_info_t u8x8_sh1107_128x128_display_info = |
|
357 { |
|
358 /* chip_enable_level = */ 0, |
|
359 /* chip_disable_level = */ 1, |
|
360 |
|
361 /* post_chip_enable_wait_ns = */ 20, |
|
362 /* pre_chip_disable_wait_ns = */ 10, |
|
363 /* reset_pulse_width_ms = */ 100, /* */ |
|
364 /* post_reset_wait_ms = */ 100, /* far east OLEDs need much longer setup time */ |
|
365 /* sda_setup_time_ns = */ 100, /* cycle time is 100ns, so use 100/2 */ |
|
366 /* sck_pulse_width_ns = */ 100, /* cycle time is 100ns, so use 100/2, AVR: below 70: 8 MHz, >= 70 --> 4MHz clock */ |
|
367 /* sck_clock_hz = */ 4000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */ |
|
368 /* spi_mode = */ 0, /* active high, rising edge */ |
|
369 /* i2c_bus_clock_100kHz = */ 4, |
|
370 /* data_setup_time_ns = */ 40, |
|
371 /* write_pulse_width_ns = */ 150, /* sh1107: cycle time is 300ns, so use 300/2 = 150 */ |
|
372 /* tile_width = */ 16, |
|
373 /* tile_hight = */ 16, |
|
374 /* default_x_offset = */ 96, |
|
375 /* flipmode_x_offset = */ 96, |
|
376 /* pixel_width = */ 128, |
|
377 /* pixel_height = */ 128 |
|
378 }; |
|
379 |
|
380 uint8_t u8x8_d_sh1107_128x128(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr) |
|
381 { |
|
382 |
|
383 if ( u8x8_d_sh1107_generic(u8x8, msg, arg_int, arg_ptr) != 0 ) |
|
384 return 1; |
|
385 |
|
386 switch(msg) |
|
387 { |
|
388 case U8X8_MSG_DISPLAY_INIT: |
|
389 u8x8_d_helper_display_init(u8x8); |
|
390 u8x8_cad_SendSequence(u8x8, u8x8_d_sh1107_128x128_init_seq); |
|
391 break; |
|
392 case U8X8_MSG_DISPLAY_SETUP_MEMORY: |
|
393 u8x8_d_helper_display_setup_memory(u8x8, &u8x8_sh1107_128x128_display_info); |
|
394 break; |
|
395 default: |
|
396 return 0; |
|
397 } |
|
398 return 1; |
|
399 } |
|
400 |
|
401 /*==================================================*/ |
|
402 /* pimoroni_128x128_display */ |
|
403 |
|
404 static const u8x8_display_info_t u8x8_sh1107_pimoroni_128x128_display_info = |
|
405 { |
|
406 /* chip_enable_level = */ 0, |
|
407 /* chip_disable_level = */ 1, |
|
408 |
|
409 /* post_chip_enable_wait_ns = */ 20, |
|
410 /* pre_chip_disable_wait_ns = */ 10, |
|
411 /* reset_pulse_width_ms = */ 100, /* */ |
|
412 /* post_reset_wait_ms = */ 100, /* far east OLEDs need much longer setup time */ |
|
413 /* sda_setup_time_ns = */ 100, /* cycle time is 100ns, so use 100/2 */ |
|
414 /* sck_pulse_width_ns = */ 100, /* cycle time is 100ns, so use 100/2, AVR: below 70: 8 MHz, >= 70 --> 4MHz clock */ |
|
415 /* sck_clock_hz = */ 4000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */ |
|
416 /* spi_mode = */ 0, /* active high, rising edge */ |
|
417 /* i2c_bus_clock_100kHz = */ 4, |
|
418 /* data_setup_time_ns = */ 40, |
|
419 /* write_pulse_width_ns = */ 150, /* sh1107: cycle time is 300ns, so use 300/2 = 150 */ |
|
420 /* tile_width = */ 16, |
|
421 /* tile_hight = */ 16, |
|
422 /* default_x_offset = */ 0, |
|
423 /* flipmode_x_offset = */ 0, |
|
424 /* pixel_width = */ 128, |
|
425 /* pixel_height = */ 128 |
|
426 }; |
|
427 |
|
428 uint8_t u8x8_d_sh1107_pimoroni_128x128(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr) |
|
429 { |
|
430 |
|
431 if ( u8x8_d_sh1107_generic(u8x8, msg, arg_int, arg_ptr) != 0 ) |
|
432 return 1; |
|
433 |
|
434 switch(msg) |
|
435 { |
|
436 case U8X8_MSG_DISPLAY_INIT: |
|
437 u8x8_d_helper_display_init(u8x8); |
|
438 u8x8_cad_SendSequence(u8x8, u8x8_d_sh1107_128x128_init_seq); |
|
439 break; |
|
440 case U8X8_MSG_DISPLAY_SETUP_MEMORY: |
|
441 u8x8_d_helper_display_setup_memory(u8x8, &u8x8_sh1107_pimoroni_128x128_display_info); |
|
442 break; |
|
443 default: |
|
444 return 0; |
|
445 } |
|
446 return 1; |
|
447 } |
|
448 |
|
449 /*==================================================*/ |
|
450 /* |
|
451 Name: SH1107_seeed_128x128 |
|
452 URL: https://www.seeedstudio.com/Grove-OLED-Display-1-12-V2.html |
|
453 Display is there in my lab. Backside PCB label: "OLED Display 1.12 inch v1.0" |
|
454 Tookover code from SSD1327_SEEED_96X96 because none of the other displays did work |
|
455 and at least the 96x96 driver did show something. |
|
456 */ |
|
457 |
|
458 static const u8x8_display_info_t u8x8_seeed_128x128_display_info = |
|
459 { |
|
460 /* chip_enable_level = */ 0, |
|
461 /* chip_disable_level = */ 1, |
|
462 |
|
463 /* post_chip_enable_wait_ns = */ 20, |
|
464 /* pre_chip_disable_wait_ns = */ 10, |
|
465 /* reset_pulse_width_ms = */ 100, /* */ |
|
466 /* post_reset_wait_ms = */ 100, /* far east OLEDs need much longer setup time */ |
|
467 /* sda_setup_time_ns = */ 100, /* cycle time is 100ns, so use 100/2 */ |
|
468 /* sck_pulse_width_ns = */ 100, /* cycle time is 100ns, so use 100/2, AVR: below 70: 8 MHz, >= 70 --> 4MHz clock */ |
|
469 /* sck_clock_hz = */ 4000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */ |
|
470 /* spi_mode = */ 0, /* active high, rising edge */ |
|
471 /* i2c_bus_clock_100kHz = */ 2, // 400kHz does not work, but 200kHz seems to be ok |
|
472 /* data_setup_time_ns = */ 40, |
|
473 /* write_pulse_width_ns = */ 150, /* sh1107: cycle time is 300ns, so use 300/2 = 150 */ |
|
474 /* tile_width = */ 16, |
|
475 /* tile_hight = */ 16, |
|
476 /* default_x_offset = */ 0, |
|
477 /* flipmode_x_offset = */ 0, |
|
478 /* pixel_width = */ 128, |
|
479 /* pixel_height = */ 128 |
|
480 }; |
|
481 |
|
482 uint8_t u8x8_d_sh1107_seeed_128x128(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr) |
|
483 { |
|
484 |
|
485 if ( u8x8_d_sh1107_generic(u8x8, msg, arg_int, arg_ptr) != 0 ) |
|
486 return 1; |
|
487 |
|
488 switch(msg) |
|
489 { |
|
490 case U8X8_MSG_DISPLAY_INIT: |
|
491 u8x8_d_helper_display_init(u8x8); |
|
492 u8x8_cad_SendSequence(u8x8, u8x8_d_sh1107_128x128_init_seq); |
|
493 break; |
|
494 case U8X8_MSG_DISPLAY_SETUP_MEMORY: |
|
495 u8x8_d_helper_display_setup_memory(u8x8, &u8x8_seeed_128x128_display_info); |
|
496 break; |
|
497 default: |
|
498 return 0; |
|
499 } |
|
500 return 1; |
|
501 } |