It is really very strange.
Starting from a situation where the display works well, if I add in the
loop() section some extra instrucions (serial commands handling), the
OLED initalization phase (well behind, in the setup() section) fails sending
on the serial port the message:
SSD1306 allocation failed
Details.
If I add just before the end of loop() section:
if (Serial.available()) {
ch = Serial.read();
Serial.print(ch);
// if(ch=='h') printMenu();
// else if(ch=='2') writeEnableMask();
// else if(ch=='3') readEnableMask();
// else if(ch=='4') resetTrigger();
// else if(ch=='6') setEEPROM_tempoSecondi();
// else if(ch=='7') setEEPROM_numEventi();
// else if(ch=='8') setEEPROM_updateInterval();
// else if(ch=='r') { wdt_enable(WDTO_30MS); while(1); };
Serial.print("\n\r>");
}
the program continues to work.
If I uncomment
if(ch=='h') printMenu();
the OLED init fails at boot
---> "SSD1306 allocation failed"
here in the setup() section
if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) {
Serial.println(F("SSD1306 allocation failed"));
for(;;); // Don't proceed, loop forever
}
WHY???
Someone already faced that?
Someone who can try my program?