Question about code when using a different display device

Hi all, so I’m thinking of giving this project from SparkFun a go:

But the only problem here is that I don’t have the OLED. I’m wondering if it’s possible to replace it with a Grove Serial LCD?
If so, would I have to start from scratch in terms of code? For example, in the code given on that page (under New Photon Code):

void updateWeather()
    // softwareDebounce() (defined at the bottom of the application code)
    // makes sure button presses can only occur every BUTTON_DEBOUNCE_TIME ms.
    if (softwareDebounce()) 
        oled.clear(PAGE); // Clear the display
        oled.setFontType(0); // Smallest font
        oled.setCursor(0, 0); // Cursor to top-left
        // multiLinePrint takes a long string, and tries to break it into multiple
        // lines - split by spaces in the string.
        multiLinePrint("Updating Current Weather!");
        oled.display(); // Update the display

Could I just replace the lines that have oled… with lcd… and still have it working?


@limxx518, the OLED is graphical whereas the Grove Serial LCD is text only. You will not be able to swap the display without substantially changing the code since the weather app does display graphics.

@peekay123 Thanks! What about the Adafruit 12C LED Matrix? Would that work?

@limxx518, do you have a link for the specific product?

@peekay123 Sure! This one:

@limxx518, nice display but not suitable. The OLED is 64x48 pixels I believe. The SparkFun code is specifically designed for that. To use anything different will require a change of code.

@peekay123 Thanks. What about this:

Could I use the code for the alarm clock from the sparkfun website, while replacing the code from this page for the weather forecast, while using the Grove Serial LCD?

That last example is really more about showing off the LOSANT platform than anything else, hence almost no code on the Particle. However you could certainly take bits from each of them to create a derivative project that does whatever it is you are trying to do. Just remember that everything in the sparkfun example to do with writing to the display is calling functions in a library specifically for a graphical display. By contrast the LOSANT one lets the cloud control the display using a particle function leaving you with little to copy.

1 Like

@Viscacha Initially my idea was to exactly try out the experiment in the sparkfun page, but since I didn’t have the OLED, I wondered if I could just replace the part with a different type. I have two kinds of display available to me, one is the Serial grove LCD, and the other is the Adafruit 12C LED Matrix. Which do you think is better to replace the OLED in the Sparkfun experiment? Is there a link somewhere that could teach me how to program the display like that in the sparkfun page? I’m a beginner, so I’m intimidated in coming up with all thee code by myself. Some examples would be very helpful. Thanks!

Well sparkfun/ada/grove etc who make these little modules available to hobbyists all include sample code and project to work with them. Granted some of them may be “arduino examples” but in many cases not much will change, apart from some pin names for any buttons etc. However here is a thread Adafruit Led Matrix 8x8 that has several examples linked in it. Any example with an LCD in it will show you how to write to one, the only bit that might change is the initiaisation/setup depending on its address and if it is serial or not.

There are also plenty more in the projects section as well as examples included with the libraries that control the displays. As a general rule the libraries tend to be written in “proper” C++ so they use concepts like objects, inheritance and other things that you could also read about on the side so you can follow how they work. If you’ve ever used something like C#, Java,PHP or Python (to name but a few) you will have met these before.

1 Like