OLED Display 0,96 und Bilder

Hallo alle zusammen,
habe mich in den letzten Tagen mit dem Oled Display beschäftigt.
https://shop.diy-dreams.de/collections/displays/products/0-96zolldisplay?variant=26462709385
hierbei bin ich auf die "Bildfunktion" gestoßen. Also habe ich das Display kurzerhand an einen D1 Mini angeschlossen und mich mit den installierten Library beschäftigt, insbesondere der SSD1306SimpleDemo, beschäftigt. U
hier mal der vollständige Code:

/**
 * The MIT License (MIT)
 *
 * Copyright (c) 2016 by Daniel Eichhorn
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in all
 * copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 *
 */

// Include the correct display library
// For a connection via I2C using Wire include
#include <Wire.h>  // Only needed for Arduino 1.6.5 and earlier
#include "SSD1306.h" // alias for `#include "SSD1306Wire.h"`
// or #include "SH1106.h" alis for `#include "SH1106Wire.h"`
// For a connection via I2C using brzo_i2c (must be installed) include
// #include <brzo_i2c.h> // Only needed for Arduino 1.6.5 and earlier
// #include "SSD1306Brzo.h"
// #include "SH1106Brzo.h"
// For a connection via SPI include
// #include <SPI.h> // Only needed for Arduino 1.6.5 and earlier
// #include "SSD1306Spi.h"
// #include "SH1106SPi.h"

// Include custom images
#include "images.h"

// Initialize the OLED display using SPI
// D5 -> CLK
// D7 -> MOSI (DOUT)
// D0 -> RES
// D2 -> DC
// D8 -> CS
// SSD1306Spi        display(D0, D2, D8);
// or
// SH1106Spi         display(D0, D2);

// Initialize the OLED display using brzo_i2c
// D3 -> SDA
// D5 -> SCL
// SSD1306Brzo display(0x3c, D3, D5);
// or
// SH1106Brzo  display(0x3c, D3, D5);

// Initialize the OLED display using Wire library
SSD1306  display(0x3c, D2, D1);
// SH1106 display(0x3c, D3, D5);


#define DEMO_DURATION 3000
typedef void (*Demo)(void);

int demoMode = 0;
int counter = 1;

void setup() {
  Serial.begin(115200);
  Serial.println();
  Serial.println();


  // Initialising the UI will init the display too.
  display.init();

  display.flipScreenVertically();
  display.setFont(ArialMT_Plain_10);

}

void drawFontFaceDemo() {
    // Font Demo1
    // create more fonts at http://oleddisplay.squix.ch/
    display.setTextAlignment(TEXT_ALIGN_LEFT);
    display.setFont(ArialMT_Plain_10);
    display.drawString(0, 0, "Hello world");
    display.setFont(ArialMT_Plain_16);
    display.drawString(0, 10, "Hello world");
    display.setFont(ArialMT_Plain_24);
    display.drawString(0, 26, "Hello world");
}

void drawTextFlowDemo() {
    display.setFont(ArialMT_Plain_10);
    display.setTextAlignment(TEXT_ALIGN_LEFT);
    display.drawStringMaxWidth(0, 0, 128,
      "Lorem ipsum\n dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore." );
}

void drawTextAlignmentDemo() {
    // Text alignment demo
  display.setFont(ArialMT_Plain_10);

  // The coordinates define the left starting point of the text
  display.setTextAlignment(TEXT_ALIGN_LEFT);
  display.drawString(0, 10, "Left aligned (0,10)");

  // The coordinates define the center of the text
  display.setTextAlignment(TEXT_ALIGN_CENTER);
  display.drawString(64, 22, "Center aligned (64,22)");

  // The coordinates define the right end of the text
  display.setTextAlignment(TEXT_ALIGN_RIGHT);
  display.drawString(128, 33, "Right aligned (128,33)");
}

void drawRectDemo() {
      // Draw a pixel at given position
    for (int i = 0; i < 10; i++) {
      display.setPixel(i, i);
      display.setPixel(10 - i, i);
    }
    display.drawRect(12, 12, 20, 20);

    // Fill the rectangle
    display.fillRect(14, 14, 17, 17);

    // Draw a line horizontally
    display.drawHorizontalLine(0, 40, 20);

    // Draw a line horizontally
    display.drawVerticalLine(40, 0, 20);
}

void drawCircleDemo() {
  for (int i=1; i < 8; i++) {
    display.setColor(WHITE);
    display.drawCircle(32, 32, i*3);
    if (i % 2 == 0) {
      display.setColor(BLACK);
    }
    display.fillCircle(96, 32, 32 - i* 3);
  }
}

void drawProgressBarDemo() {
  int progress = (counter / 5) % 100;
  // draw the progress bar
  display.drawProgressBar(0, 32, 120, 10, progress);

  // draw the percentage as String
  display.setTextAlignment(TEXT_ALIGN_CENTER);
  display.drawString(64, 15, String(progress) + "%");
}

void drawImageDemo() {
    // see http://blog.squix.org/2015/05/esp8266-nodemcu-how-to-create-xbm.html
    // on how to create xbm files
    display.drawXbm(34, 14, WiFi_Logo_width, WiFi_Logo_height, WiFi_Logo_bits);
}

Demo demos[] = {drawFontFaceDemo, drawTextFlowDemo, drawTextAlignmentDemo, drawRectDemo, drawCircleDemo, drawProgressBarDemo, drawImageDemo};
int demoLength = (sizeof(demos) / sizeof(Demo));
long timeSinceLastModeSwitch = 0;

void loop() {
  // clear the display
  display.clear();
  // draw the current demo method
  demos[demoMode]();

  display.setTextAlignment(TEXT_ALIGN_RIGHT);
  display.drawString(10, 128, String(millis()));
  // write the buffer to the display
  display.display();

  if (millis() - timeSinceLastModeSwitch > DEMO_DURATION) {
    demoMode = (demoMode + 1)  % demoLength;
    timeSinceLastModeSwitch = millis();
  }
  counter++;
  delay(10);
}

und hier das Bild:

#define WiFi_Logo_width 60
#define WiFi_Logo_height 36
const char WiFi_Logo_bits[] PROGMEM = {
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xFF, 0x07, 0x00, 0x00, 0x00,
  0x00, 0x00, 0xE0, 0xFF, 0x1F, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 0xFF,
.........  
  0x00, 0x00, 0x80, 0xFF, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFC,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  };

Um die Grenzen des Systems aus zu loten wollte ich nun ein Bild(BMP selbst erstellt) einbinden.
hierfür habe ich in Paint ein BMP erstellt mit 128x64 punkten im sw. und als monocrom Bitmap gespeichert. Mit dem Tool LCDAssistant habe ich dieses dann convertiert und mit ein em c Editor angepasst. Die Datei Images.h benant und anstelle der alten Datei eingebunden. Leider kam egal mit welchen Optionen ich das BMP umgewandelt habe nur Schrott bei raus. Zwei Dinge zeichneten sich aber während der Test's ab:

  1. Die Bilder wurden Farbinvertiert dargestellt
  2. die "besten Ergebnisse erziehlte ich mit der Byteausrichtung Horizontal. Bei vertikal gabs nur Schnee

hier noch die Datei des neuen Bild:

#define WiFi_Logo_width 128
#define WiFi_Logo_height 64
const char WiFi_Logo_bits[] PROGMEM = {
0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
..........
0x7C, 0x7C, 0x7C, 0x7C, 0x7C, 0x7C, 0x7C, 0x7C, 0x7C, 0x7C, 0x7C, 0x7C, 0x7C, 0x7C, 0x7C, 0x7C,
0x7C, 0x7C, 0x7C, 0x7C, 0x7C, 0x7C, 0x7C, 0x7C, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F, 0x3F, 0x7F,
0x7F, 0x3F, 0x1F, 0x0F, 0x07, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};

Ich gehe davon aus das dies nur ein Fehler im erstellen der Bildinformation sein kann. Kennt jemand einen Idiotensicheren Weg zum erstellen dieser.

Nerviges Problem, keine Ahnung was manche da mit der Software machen...
hier gehts zur Lösung

vielen Dank für die Antworten
leider arbeiten die beiden Tool's unter Win7 nicht wegen fehlender DLL's

Die kann man oft über Google finden.

Gruß Tommy

klar das so ein Kommentar von Tommy kommt

Ich glaube ich habe in den letzten 48h gefühlt nicht anders gemacht.
Anfangs hatte ich noch nicht mal nen Plan wofür ich so was brauchen könnte. Hat mich halt nur interessiert. Mittlerweile bekomme ich das Gefühl ich werde ohne Bildchen nicht mehr der selbe sein.

Aber Spaß mal bei Seite. Es gibt ja wirklich viele Beiträge und Seiten zu genau diesem Fehler aber entweder führen die Lösungen zu Programmen die ums Verrecken nicht zum laufen zu bringen sind oder die Lösungsansätze funktionieren bei mir einfach nicht.

hat noch jemand einen Vorschlag?

habe jetzt meine Lösung gefunden
Bitmap in GIMP erstellen oder Laden
dann exportieren als xbm
Kopfzeihlen anpassen
und einbinden
passt

Danke

Gundelputz:
klar das so ein Kommentar von Tommy kommt

Ich glaube ich habe in den letzten 48h gefühlt nicht anders gemacht.

Dann solltest Du uns das auch mitteilen oder meinst Du, wir sind Hellseher?

Würdest Du den Forenteilnehmern auch noch die notwendigen Änderungen der Kopfzeilen erläutern?

Gruß Tommy

hier noch Bildchen

habe gerade erst deine Bitte gelesen
Also kommt sofort:
Aus der entstandenen XBM-Datei entnehme ich nur die Hex Zeilen

   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  .......
   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
   0x00, 0x00, 0x00, 0x00

und setze dann vor diesen(Kopfzeilen):
#define WiFi_Logo_width 128
#define WiFi_Logo_height 64
const char WiFi_Logo_bits[] PROGMEM = {
und am Ende das:
};

habe ich fast vergessen zu erwähnen

ich gehe davon aus das ich erst versuche ein Problem ohne fremde Hilfe zu Lösen und schreibe erst wenn ich nicht mehr weiterkomme meine Fragen hier ins Forum.

Mir ist klar das ihr, die Erfahreneren, öfter mit Schnipsel Jägern zu tun habt aber genau wie ihr mache ich das überwiegend zum Spaß und um zu lernen.

Daher nichts für Ungut und vielen Dank an euch alle da draußen.

Gundelputz:
habe gerade erst deine Bitte gelesen
Also kommt sofort:

Danke.

Gruß Tommy

Hmmm ... ich habe gerade vor Kurzem ein Oled Colour getestet. In diesem Sketch werden bmp-Dateien von einer SD-Karte gelesen und dargestellt.
Ich werde diesen mal auskramen

Gundelputz:
...
Daher nichts für Ungut und vielen Dank an euch alle da draußen.

Eine Rückmeldung ist für mich immer wieder ein Grund, einen Karmapunkt zu geben. Einem Feedback, das auch noch so nett ist, würde ich zwei Punkte geben, wenn ich könnte.

Gruß

Gregor

hier nach mal ein Nachtrag

Wie sich heraus gestellt hat habe ich zwei verschiedene Lib's für das Display installiert.
die erste ist welche ich im Beitrag angegeben(SSD1306) habe und die zweite ist die Adafruit_SSD1306.
hier gibt es drei Knackpunkte:

  1. in der Adafruit_SSD1306.h Datei muss der Displaytyp von 128x32 auf 128x64 umgestellt werden
  2. am besten hat bei ,ir das convertieren von PNG-Dateien mit diesem Toll geklappt
    Convert picture to C code array
  3. im Sketch müssen einige Befehle anders geschrieben werden

Der Aufruf des Bildes so:

display.clearDisplay(); //Display leeren
display.drawBitmap(0, 0, Oxen_bild, 128, 64, 1); //Vorgefertigtes Logo 
display.display();
delay(10);

Die "Kopfzeile so:
static const unsigned char PROGMEM Oxen_bild[] =

Dann noch ein schönes Wochenende

@Berni_P: würde mich auch interessieren wie man mit einer Speichererweiterung mehr Bilder zur Verfügung stellen kann

Hier ein kleines Demo

hier der Sketch für ein OLED Colour. Dieser ist in der Adafruit-SSD1331-OLED-Driver-Library-for-Arduino als Example vorhanden und funktionierte auf Anhieb

die Bilder wurden mit einem Grafikprogramm (Windows Paint) in das gebrauchte Format gebracht.