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;
Serial.begin(115200);
oled.begin();
oled.selectFont(SystemFont5x7);
while(!SD.begin(pin_sd_cs)) {
Serial.println(MSG_NOSD);
text.println(MSG_NOSD);
delay(500);
}
oled.begin(); // Faster ?
File image = SD.open("bulboff.bmp");
if(!image) {
text.println(MSG_FILENOTFOUND);
Serial.println(MSG_FILENOTFOUND);
} else {
while (image.available()) {
vReadByte = image.read();
Serial.print("0x");
Serial.print(vReadByte,HEX);
vCount++;
if (vCount < 16) {
Serial.print(", ");
}
else {
Serial.println(",");
vCount = 0;
}
}
BMP_Status result = oled.displayBMP(image, 0, 0);
if(result != BMP_OK) {
Serial.print(MSG_BMPFAIL);
Serial.println((int) result);
text.print(MSG_BMPFAIL);
text.println((int) result);
}
}
}
void loop()
{
}