Ist der abgebildete Fehler auf einem 2.4"-OLED mit SSD1309 nach Eurer Meinung ein Displayfehler (kam im ungepolsterten Briefumschlag an) oder könnte es daran liegen, dass der SSD1309 doch nicht vollständig kompatibel zum SSD1306 ist? Meine Initialisierungssequenz habe ich bisher nur mit SSD1306-Displays genutzt. Dort problemlos. Ausschnittweise angehängt.
1 | // initialize display |
2 | |
3 | bool |
4 | oled_init() |
5 | { |
6 | // check jumper J1: no jumper == OLED with SD1306 chip; jumper installed == OLED with SH1106 chip (not supported by this example) |
7 | |
8 | if (Jumper1 == false) |
9 | { |
10 | // initialize SPI |
11 | |
12 | SPCR = |
13 | |
14 | (0 << SPIE) | // interrupt: disabled |
15 | (1 << SPE ) | // SPI: enabled |
16 | (0 << DORD) | // data order: MSB first |
17 | (1 << MSTR) | // mode: master |
18 | (0 << SPR1) | // clock: f_OSC / 4 (4.6MHz) |
19 | (0 << SPR0); // clock: f_OSC / 4 (4.6MHz) |
20 | |
21 | // reset oled |
22 | |
23 | oled_reset(); |
24 | |
25 | // select oled |
26 | |
27 | oled_select(); |
28 | |
29 | // send init sequence for 128x64 OLED module |
30 | |
31 | oled_command(OLED_SSD1306_DISPLAYOFF); |
32 | |
33 | oled_command(OLED_SSD1306_SETVCOMDETECT); |
34 | oled_command(0x20); |
35 | |
36 | oled_command(OLED_SSD1306_SETMULTIPLEX); |
37 | oled_command(0x3F); |
38 | |
39 | oled_command(OLED_SSD1306_SETDISPLAYOFFSET); |
40 | oled_command(0x0); // no offset |
41 | |
42 | oled_command(OLED_SSD1306_SETSTARTLINE | 0x0); // line 0 |
43 | |
44 | oled_command(OLED_SSD1306_MEMORYMODE); |
45 | oled_command(0x00); // horizontal addressing mode |
46 | |
47 | oled_command(OLED_SSD1306_SEGREMAP | 0x1); |
48 | oled_command(OLED_SSD1306_COMSCANDEC); |
49 | |
50 | oled_command(OLED_SSD1306_SETCOMPINS); |
51 | oled_command(0x12); |
52 | |
53 | oled_command(OLED_SSD1306_SETCONTRAST); |
54 | |
55 | #ifdef EXTERNALVCC |
56 | oled_command(0x9F); |
57 | #else |
58 | oled_command(0xCF); |
59 | #endif |
60 | |
61 | oled_command(OLED_SSD1306_DISPLAYALLON_RAM); |
62 | |
63 | oled_command(OLED_SSD1306_NORMALDISPLAY); |
64 | |
65 | oled_command(OLED_SSD1306_SETDISPLAYCLOCKDIV); |
66 | oled_command(0x80); // suggested ratio 0x80 |
67 | |
68 | oled_command(OLED_SSD1306_SETPRECHARGE); |
69 | |
70 | #ifdef EXTERNALVCC |
71 | oled_command(0x22); |
72 | #else |
73 | oled_command(0xF1); |
74 | #endif |
75 | |
76 | oled_command(OLED_SSD1306_CHARGEPUMP); |
77 | |
78 | #ifdef EXTERNALVCC |
79 | oled_command(0x10); |
80 | #else |
81 | oled_command(0x14); |
82 | #endif |
83 | |
84 | // turn on oled panel |
85 | |
86 | oled_command(OLED_SSD1306_DISPLAYON); |
87 | |
88 | oled_invert(true); |
89 | |
90 | return(true); |
91 | } |
92 | |
93 | return(false); |
94 | } |