SSD1306 OLED mit einem WEMO betreiben

Hier ein kleines Beispiel wie ein SSD1306 OLED an einem WEMO D1 mini angeschlossen wird.
Text zu schreiben ist ja bereits ausreichend Dokumentiert. Die Verwendung von Logos und Bitmaps ist allerdings nicht ganz so einfach. Es gibt einige Programme mit denen man Bilder in entsprechende Bin oder Hex Datein umwandeln kann. Da nicht alle Konverter sauber funktioniert haben, haben wir ein Onlinetool benutzt, welches ganz gut funktioniert hat.
Um ein Logo einzufügen erstellt Ihr eine Bitmap Grafik und geht auf folgende Webseite: http://javl.github.io/image2cpp/
Als Beispiel habe ich das TowiLab Logo benutzt:
Den Programmcode fügt ihr dann in euer C Programm ein. Das Beispielprogramm zeigt ein Logo an und zählt anschließend einen Wert hoch.
//WEMO Logo und Display Test
#include <Wire.h>
#include <SPI.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#define SCREEN_WIDTH 128 // OLED display breite, in pixeln
#define SCREEN_HEIGHT 64 // OLED display hoehe, in pixeln
// Zuordung der Pins fuer SDA und SCL am SSD1206 Display
#define OLED_RESET 0 // Reset pin
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
// TowiLab Logo
const unsigned char towilab_logo [] PROGMEM = {
0xff, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0xc7, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00,
0xff, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0xc7, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00,
0xff, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0xc7, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00,
0xff, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0xc7, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00,
0x01, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 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
0x01, 0xf8, 0x0f, 0xc1, 0xf8, 0x7d, 0xe7, 0xfe, 0x0f, 0xc7, 0x00, 0x1c, 0x07, 0x0e, 0x01, 0xc0,
0x01, 0xf8, 0x0f, 0xc1, 0xf8, 0x7f, 0xc3, 0xfe, 0x0f, 0xc7, 0x00, 0x1c, 0x07, 0x0e, 0x03, 0xc0,
0x01, 0xf8, 0x07, 0xe3, 0xf0, 0x3f, 0xc3, 0xfc, 0x0f, 0xc7, 0x00, 0x1c, 0x07, 0x0e, 0x03, 0x80,
0x01, 0xf8, 0x07, 0xff, 0xf0, 0x3f, 0xc3, 0xfc, 0x0f, 0xc7, 0x00, 0x1e, 0x1f, 0x0e, 0x07, 0x80,
0x01, 0xf8, 0x03, 0xff, 0xe0, 0x3f, 0xc3, 0xfc, 0x0f, 0xc7, 0xff, 0xcf, 0xff, 0x0f, 0xff, 0x00,
0x01, 0xf8, 0x01, 0xff, 0xc0, 0x1f, 0x81, 0xf8, 0x0f, 0xc7, 0xff, 0xcf, 0xf7, 0x0f, 0xfe, 0x00,
0x01, 0xf8, 0x00, 0x7f, 0x00, 0x1f, 0x81, 0xf8, 0x0f, 0xc7, 0xff, 0xc3, 0xc7, 0x0e, 0xfc, 0x00
};
int i = 0;
void setup(){
Wire.begin();
display.begin(SSD1306_SWITCHCAPVCC, 0x3C); //Adresse des OLED's
display.clearDisplay(); //Display loeschen
display.drawBitmap(3, 20, towilab_logo, 122, 23, WHITE); //Logo zeichnen
display.display(); //Werte setzen
delay(2000);
}
void loop(){
display.clearDisplay(); //Display loeschen
display.setCursor(0, 0); //Cursor setzen
display.setTextSize(2); //Text groeße einstellen
display.setTextColor(WHITE); //Farbe einstellen
display.println(i); //Zaehler anzeigen
display.display(); //Werte setzen
i++;
delay(1000);
}

