Why must I define the optional [reset] pin when running an OLED display?

My widget uses an Herkulex DRS-0401_SER0034 LCD and merrily runs this code

#include <Arduino.h>
#include <SPI.h>
#include <U8g2lib.h>

  U8G2_SSD1325_NHD_128X64_1_4W_SW_SPI u8g2(
  /* rotation zero */ U8G2_R0,  /* clock=*/ 13, /* data=*/ 11, 
  /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8);

void setup(void) 

void loop(void) 
 do {
 u8g2.drawStr(5, 15, "Hello World!");
 u8g2.drawStr(20, 35, "Goodbye!");
 u8g2.drawStr(0, 64, "No snow in Perth");
 } while (u8g2.nextPage());


The datasheet describes the relevant u8g2 instance as
U8G2_SSD1325_NHD_128X64_1_4W_SW_SPI(rotation, clock, data, cs, dc [, reset])
which, as I understand it means that defining 'reset' is optional.

I tried leaving it out and the widget did not work. I declared it and BINGO! All singing! All dancing!

Is that just a glitch in the datasheet, or is there a more sinister underlying reason?



Probably some kind of glitch.
The code is far too large to track down the problem: https://github.com/olikraus/u8g2.
It might be a minor bug or it might be a timing problem which is solved with a dummy reset pin.

When a parameter is optional, it is set to a default value in the *.h file.
In U8g2lib.h you can find that it is default set to "U8X8_PIN_NONE". In the code, the part that uses the reset pin is skipped when it was not used.

Thanks Koepel

The constructor is:

public: U8G2_SSD1325_NHD_128X64_1_4W_SW_SPI(const u8g2_cb_t *rotation, uint8_t clock, uint8_t data, uint8_t cs, uint8_t dc, uint8_t reset = U8X8_PIN_NONE) : U8G2() {

So it should work fine without a reset as long as your screen indeed has no reset line :slight_smile:

So it should work fine without a reset as long as your screen indeed has no reset line :slight_smile:

I wholeheartedly agree. It should! :slight_smile:

It don't! >:(

That's why I made the original post.

Do you agree with Koepel that it is ... some kind if glitch ?

But you now define it with some pin but don't use that pin?