OLED print problem - Photon


So - I have wired up a 128x64 OLED display (SSD1306 chip) and added the SparkFunMicroOled code.

All builds just fine, and it even runs, as far as initialisation, displaying the log - well part of it :-(( (probably as the original code was for a smaller display ???).

BUT - then it hits 'oled.print(xxx) - inside ‘printTitle’ - then it bombs bigtime. Red flashing LED’s, reboot and USB dropping out etc.

I gradually reduced the code to see how far it got before crashing and thats it - ‘oled.print’.

Looking at the code - it seems that print is NOT actually defined in the Spark code - so I assume its relying on the underlying ‘Print’ class - on which there is VERY little detail :-(( - hence this post :wink:

Has something changed in the Photon implementation which has broken this dependency maybe ???.

The SparkFun header includes ‘application.h’ - which apparently should also bring in Print…

The trouble is that it actually compiles with no errors.

OR is this code written for a different OLED driver chip maybe ???.

Any views/comments much appreciated please :slight_smile:

Many Thanks


@GrahamS, which library are you using for the display (link please)?


I am using the SparkFun code rather than a separate library - as I haven’t yet figured how to include a library using Dev :open_mouth:

So I just grabbed the code and dropped it into my own folder.

NB Its now working, as I just thought - what did I change ???. I changed the display size, just by changing the #defines for width and height - SILLY ME - should have built and tested before changing that !!!.

The display now works but uses a fraction of the screen (nicely centered though ;-)).

Looks like the screenmemory array is not redefined when changing the screen dimensions - so I was probably simply overflowing the buffer :-(( - classic old problem…

So - I will now try to figure what i need to do to make it bigger. Its defined by the LOGO bytes, so I might just forego that and define it with numbers ;-).

Hope this helps someone else to avoid such a stupid mistake ;-)).


@GrahamS, I just looked at the Sparkfun library for that display. It is odd that they have display size defines but the buffer allocation is no adjusted accordingly. There are other SSD1306 libraries in the IDE available that may provide more flexibility. I adapted an SSD1306 driver to work with the mfGFX (multi-font) graphics library (Adafruit_SSD1306_mfGFX and Adafruit_mfGFX). Both are available on the web IDE. :smiley:

Yes - thats not the only place where its hard coded :frowning:

Just increased it to 1024 bytes (LCDWIDTH * LCDHEIGHT / 8) and upped the defines. It builds and (sort of) runs, but other test code is all misaligned :-((.

Maybe I’ll try to figure out how to add the libraries you mentione using Particle Dev - as I don’ use Web Build much…

Thanks for the advice…


@GrahamS, you can just get the github link from each library and get the code directly from the repos. Just click on the “View it on Github” link for each library. :smile:

Hi peekay123,

May thanks for your advice and help. This is all now working ;-)). I ended up copying the code from the WebBuild editor and pasting it into new files under Dev :-O.

Never been a big user of GitHub so find it difficult to manage my way through it ;-)).

It will be great when library support comes native in Dev, as I personally find Dev to be a much better environment to work with (coming from an IDE background (Microsoft and Microchip ;-)).

Thanks again

1 Like