Challenge - won't work for me (yet)

128x128 pixel 1.5" full colour OLED display with MicroSD card slot. [Product page]
Post Reply
Posts: 5
Joined: Fri Jul 26, 2013 2:17 pm

Challenge - won't work for me (yet)

Post by mikehains » Sat Dec 12, 2015 10:27 pm

OK ... so I've created simple 16 colour bmp files (32x34 pixels) using each of the 3 different alternatives: GIMP + ImageMagick + Paint

I've got Python 3.0 running and have attempted to use The output I get is:

Code: Select all

>>> os.popen("python output.bmp")
<os._wrap_close object at 0x00000000025C0780>
>>> Traceback (most recent call last):
  File "", line 110, in <module>
    bin2header(args.input, output)
  File "", line 75, in bin2header
    as_hex = [ ("0x%02x" % b) for b in content ]
TypeError: %x format: a number is required, not str
Clearly I'm doing something wrong. Looking for help (Thanking You in advance)

Posts: 5
Joined: Fri Jul 26, 2013 2:17 pm

Re: Challenge - won't work for me (yet)

Post by mikehains » Sun Dec 13, 2015 5:39 am

OK - so here's how I solved this ... pretty easy actually !

I simply put the images on the SD card, loaded them through the module, and wrote back via serial the data that the FTOLED will be happy with. Then I just copied and pasted this data in an "h" file mimicking the "sprite" example ... works like a charm !

The little Arduino sketch I wrote to read back the file from sd card is very simple:

Code: Select all

#include <SPI.h>
#include <SD.h>
#include <FTOLED.h>
#include <fonts/SystemFont5x7.h>

const byte pin_cs = 7;
const byte pin_dc = 2;
const byte pin_reset = 3;
const byte pin_sd_cs = 4;

OLED oled(pin_cs, pin_dc, pin_reset);

#define MSG_NOSD F("MicroSD card not found")
#define MSG_FILENOTFOUND F("Label.bmp not found")
#define MSG_BMPFAIL F("Failed to load BMP: ")

OLED_TextBox text(oled);

void setup()
  byte vCount =0;
  byte vReadByte;

  while(!SD.begin(pin_sd_cs)) {
  oled.begin();  // Faster ?

  File image ="bulboff.bmp");
  if(!image) {
  } else {
    while (image.available()) {
      vReadByte =;
      if (vCount < 16) {
         Serial.print(", ");
      else {
         vCount = 0;        

    BMP_Status result = oled.displayBMP(image, 0, 0);
    if(result != BMP_OK) {
      Serial.println((int) result);
      text.println((int) result);

void loop()

Freetronics Staff
Freetronics Staff
Posts: 853
Joined: Tue Apr 09, 2013 11:19 pm
Location: Melbourne, Australia

Re: Challenge - won't work for me (yet)

Post by angusgr » Wed Dec 30, 2015 5:54 am

Nice solution!

To get things running with Python, try running

Code: Select all

python3 output.bmp
- depending on the system you're on, Python may default to Python 2 not 3.

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests