OLED MIDI Display – Part 2

As I mentioned in my previous post, it should be possible to connect multiple displays to the same microcontroller. This projects looks into that in a bit more detail.

Spoiler – it almost works, but has software limitations!  Read on for details.

Warning! I strongly recommend using an old or second hand keyboard for your MIDI experiments.  I am not responsible for any damage to expensive instruments!

These are the key Arduino tutorials for the main concepts used in this project:

If you are new to Arduino, see the Getting Started pages.

Parts list

  • Arduino Uno
  • 2x 0.9″ I2C OLED displays based on the SSD1306
  • A MIDI receive module (see: Arduino MIDI Interfaces)
  • Breadboard and jumper wires

The Circuit

OLEDDualMIDIDisplay_bb

These displays should be “chainable” up to a point.  Just duplicate the four connections – GND – VCC – SCL – SDA as shown above.  Once again, be sure to check your own variant of the display to make sure all the pins are the right way round.

My modules have a “jumper” (actually a 4K7 surface mount resistor) in the back that allows the I2C address to be changed.  If you are able to de-solder and re-solder surface mount components, this jumper can be “swapped”.

2020-10-30 16.17.33

My soldering skills weren’t quite up to the job – after three failed attempts I just wasn’t able to get a good connection when re-soldering the resistor to the board.  So in the end I gave up and cheated!  The two “choices” for the jumper are between GND (the default) and the positive line out of the power regulator.  I just soldered a normal “through hole” 4K7 resistor between the I2C address pin and the appropriate leg of the regulator as shown below.

2020-10-30 16.17.55

It isn’t pretty, and I’ve managed to slightly melt the casing of the rectifier (soldering really isn’t my strong point!), but it works.

Of course, your modules might be different to mine.

The Code

For a simple test, I recommend trying the standard Adafruit example:

Examples -> Adafruit SSD1306 -> ssd1306_128x64_i2c

Find the line:

if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3D)) { // Address 0x3D for 128x64

The default Adafruit modules use address 0x3D so try that first.  Run this code and you should see the demonstration programme running on the modified display.  These displays default to 0x3C not 0x3D.

Then change the 0x3D above to 0x3C and re-download.  Now the demonstration should be running on the second display.

In principle, to use two displays at the same time it is just a matter of duplicating the initialisation code as follows.

Adafruit_SSD1306 display1(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
Adafruit_SSD1306 display2(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
...

  if(!display1.begin(SSD1306_SWITCHCAPVCC, 0x3C)) {
    Serial.println(F("SSD1306 allocation 1 failed"));
    for(;;); // Don't proceed, loop forever
  }

  if(!display2.begin(SSD1306_SWITCHCAPVCC, 0x3D)) {
    Serial.println(F("SSD1306 allocation 2 failed"));
    for(;;); // Don't proceed, loop forever
  }

Unfortunately the second allocation fails.  This is because each display needs an in-memory buffer on which to draw the “screen”.  For a display of size 128×64, this will require 128 x 64 / 8 bytes of memory (at least) which comes to 1024 bytes per display – i.e. 1KB.

The problem is that the Arduino Uno (and any ATMega328 based microcontrollers) only have 2KB in total.  So all working memory would be taken up by maintaining two screen buffers!

It is possible to get something working using less resolution with the display.  I’ve updated my OLED MIDI Display to support two displays using the above techniques, but it uses a vertical display resolution of 32 rather than 64 (I’ve changed OLED_H at the top to 32 rather than 64).

You can see it running below.

2020-10-30 15.58.08

This shows the general idea, but to get the full 128×64 resolution (twice) will need something with more memory…

Find it on GitHub here.

Closing Thoughts

There are alternative SSD1306 libraries that can support some basic text output without maintaining a full in-memory frame buffer, so they might be worth a look.

However, at this point one has to ask what is being achieved when a full colour 160×128 resolution TFT display could be used instead.

Still these OLED displays do look pretty nice.

Kevin

Leave a comment