@@ -306,7 +306,7 @@ boolean MicroOLED::begin(uint8_t deviceAddress, TwoWire &wirePort)
306
306
return (true );
307
307
}
308
308
309
- /* * \brief Initialisation of MicroOLED Library - common to all begin methods. PRIVATE.
309
+ /* * \brief Initialisation of MicroOLED Library - common to all begin methods.
310
310
311
311
Setup IO pins for the chosen interface then send initialisation commands to the SSD1306 controller inside the OLED.
312
312
*/
@@ -318,17 +318,31 @@ void MicroOLED::beginCommon()
318
318
setDrawMode (NORM);
319
319
setCursor (0 , 0 );
320
320
321
- // Display reset routine
322
- pinMode (rstPin, OUTPUT); // Set RST pin as OUTPUT
323
- digitalWrite (rstPin, HIGH); // Initially set RST HIGH
324
- delay (5 ); // VDD (3.3V) goes high at start, lets just chill for 5 ms
325
- digitalWrite (rstPin, LOW); // Bring RST low, reset the display
326
- delay (10 ); // wait 10ms
327
- digitalWrite (rstPin, HIGH); // Set RST HIGH, bring out of reset
321
+ if (rstPin != 255 )
322
+ {
323
+ // Display reset routine
324
+ pinMode (rstPin, OUTPUT); // Set RST pin as OUTPUT
325
+ digitalWrite (rstPin, HIGH); // Initially set RST HIGH
326
+ delay (5 ); // VDD (3.3V) goes high at start, lets just chill for 5 ms
327
+ digitalWrite (rstPin, LOW); // Bring RST low, reset the display
328
+ delay (10 ); // wait 10ms
329
+ digitalWrite (rstPin, HIGH); // Set RST HIGH, bring out of reset
330
+ }
328
331
329
332
// Display Init sequence for 64x48 OLED module
330
333
command (DISPLAYOFF); // 0xAE
331
334
335
+ initDisplay ();
336
+
337
+ command (DISPLAYON); // --turn on oled panel
338
+ }
339
+
340
+ /* * \brief Set CGRAM and display settings
341
+
342
+ Set the unique SSD1306 settings for the MicroOLED setup.
343
+ */
344
+ void MicroOLED::initDisplay (bool clearDisplay)
345
+ {
332
346
command (SETDISPLAYCLOCKDIV); // 0xD5
333
347
command (0x80 ); // the suggested ratio 0x80
334
348
@@ -361,8 +375,8 @@ void MicroOLED::beginCommon()
361
375
command (SETVCOMDESELECT); // 0xDB
362
376
command (0x40 );
363
377
364
- command (DISPLAYON); // --turn on oled panel
365
- clear (ALL); // Erase hardware memory inside the OLED controller to avoid random data in memory.
378
+ if (clearDisplay)
379
+ clear (ALL); // Erase hardware memory inside the OLED controller to avoid random data in memory.
366
380
}
367
381
368
382
// Calling this function with nothing sets the debug port to Serial
0 commit comments