Ich habe mir mal den Spass erlaubt ein ssd1306 mit i2c an den Nano zu klemmen.
Das geht ganz einfach, da der i2c Bus an
SDA -> A4
SCL -> A5
VCC -> 3,3V
GND -> GND
liegt und die Pins noch frei sind.
Mit der DEV-Version und dem Einfügen der beiden Libraries und der Bilddatei im Kopf
#include <Tonuino.h> //enthält das Tonuino-Logo
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
// Declaration for an SSD1306 display connected to I2C (SDA, SCL pins)
#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64 // OLED display height, in pixels
#define OLED_RESET -1 // Reset pin # (or -1 if sharing Arduino reset pin)
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
und dem im setup eingefügten Testcode:
// SSD1306_SWITCHCAPVCC = generate display voltage from 3.3V internally
if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { // kann auch Addresse 0x3D haben.
Serial.println(F("SSD1306 allocation failed"));
for(;;); // Don't proceed, loop forever
}
// Show initial display buffer contents on the screen --
// the library initializes this with an Adafruit splash screen.
display.display();
delay(2); // Pause for 2 seconds
display.clearDisplay();
display.setTextSize(2); // Draw 2X-scale text
display.setTextColor(SSD1306_WHITE);
display.setCursor(0, 0);
display.println(F("TonUINO"));
display.println(F("Vers. 2.0"));
display.setTextSize(1); // Draw 1X-scale text
display.setTextColor(SSD1306_WHITE);
display.setCursor(0, 40);
display.println(F("(c) Thorsten Voss"));
display.display(); // Show initial text
delay(10000);
display.clearDisplay();
display.drawBitmap(
(display.width() - tonuino_width) / 2,
(display.height() - tonuino_height) / 2,
tonuino_data, tonuino_width, tonuino_height, 1);
display.display();
delay(1000);
zeigt das LCD-Ausgaben möglich sind.
Das läßt den Speicherhunger der DEV-Version dann aber auf 28618 Bytes (93%) des Programmspeicherplatzes wachsen. Das Maximum sind 30720 Bytes.
So waren das etwas über 60%
Ich hänge mal das Bild also tonuino.h hier hinter.
#define tonuino_width 128
#define tonuino_height 64
const uint8_t PROGMEM tonuino_data[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x7f, 0xff, 0xe0, 0x00, 0x00, 0x00, 0x03, 0x80, 0x0e, 0x0e, 0x07, 0x80, 0x18, 0x00, 0xff, 0x80,
0x7f, 0xff, 0xe0, 0x00, 0x00, 0x00, 0x03, 0x80, 0x0e, 0x0e, 0x07, 0xc0, 0x18, 0x03, 0xff, 0xc0,
0x7f, 0xff, 0xe0, 0x00, 0x00, 0x00, 0x03, 0x80, 0x0e, 0x0e, 0x07, 0xc0, 0x18, 0x07, 0xc1, 0xe0,
0x00, 0x70, 0x00, 0x00, 0x00, 0x00, 0x03, 0x80, 0x0e, 0x0e, 0x07, 0xe0, 0x18, 0x0f, 0x00, 0xf0,
0x00, 0x70, 0x00, 0x00, 0x00, 0x00, 0x03, 0x80, 0x0e, 0x0e, 0x07, 0xe0, 0x18, 0x0e, 0x00, 0x78,
0x00, 0x70, 0x0f, 0xc0, 0x0c, 0x7c, 0x03, 0x80, 0x0e, 0x0e, 0x07, 0x70, 0x18, 0x1c, 0x00, 0x38,
0x00, 0x70, 0x1f, 0xf0, 0x1d, 0xfe, 0x03, 0x80, 0x0e, 0x0e, 0x07, 0x70, 0x18, 0x1c, 0x00, 0x3c,
0x00, 0x70, 0x3e, 0xf8, 0x1f, 0xdf, 0x03, 0x80, 0x0e, 0x0e, 0x07, 0x38, 0x18, 0x1c, 0x00, 0x1c,
0x00, 0x70, 0x70, 0x3c, 0x1f, 0x07, 0x03, 0x80, 0x0e, 0x0e, 0x07, 0x38, 0x18, 0x38, 0x00, 0x1c,
0x00, 0x70, 0x70, 0x1c, 0x1e, 0x03, 0x03, 0x80, 0x0e, 0x0e, 0x07, 0x1c, 0x18, 0x38, 0x00, 0x1c,
0x00, 0x70, 0xe0, 0x1e, 0x1c, 0x03, 0x83, 0x80, 0x0e, 0x0e, 0x07, 0x0c, 0x18, 0x38, 0x00, 0x1c,
0x00, 0x70, 0xe0, 0x0e, 0x1c, 0x03, 0x83, 0x80, 0x0e, 0x0e, 0x07, 0x0e, 0x18, 0x38, 0x00, 0x1c,
0x00, 0x70, 0xe0, 0x0e, 0x1c, 0x03, 0x83, 0x80, 0x0e, 0x0e, 0x07, 0x0f, 0x18, 0x38, 0x00, 0x1c,
0x00, 0x70, 0xe0, 0x0e, 0x1c, 0x03, 0x83, 0x80, 0x0e, 0x0e, 0x07, 0x07, 0x18, 0x38, 0x00, 0x1c,
0x00, 0x70, 0xe0, 0x0e, 0x1c, 0x03, 0x83, 0x80, 0x0e, 0x0e, 0x07, 0x03, 0x18, 0x1c, 0x00, 0x1c,
0x00, 0x70, 0xe0, 0x0e, 0x1c, 0x03, 0x83, 0x80, 0x0e, 0x0e, 0x07, 0x03, 0x98, 0x1c, 0x00, 0x3c,
0x00, 0x70, 0xe0, 0x0e, 0x1c, 0x03, 0x83, 0x80, 0x1c, 0x0e, 0x07, 0x01, 0x98, 0x1c, 0x00, 0x38,
0x00, 0x70, 0xe0, 0x1c, 0x1c, 0x03, 0x81, 0xc0, 0x1c, 0x0e, 0x07, 0x01, 0xf8, 0x0e, 0x00, 0x78,
0x00, 0x70, 0x70, 0x1c, 0x1c, 0x03, 0x81, 0xc0, 0x3c, 0x0e, 0x07, 0x00, 0xf8, 0x0f, 0x00, 0xf0,
0x00, 0x70, 0x78, 0x38, 0x1c, 0x03, 0x80, 0xf0, 0x78, 0x0e, 0x07, 0x00, 0xf8, 0x07, 0xc1, 0xe0,
0x00, 0x70, 0x3f, 0xf0, 0x1c, 0x03, 0x80, 0xff, 0xf0, 0x0e, 0x07, 0x00, 0x78, 0x03, 0xff, 0xc0,
0x00, 0x70, 0x0f, 0xe0, 0x1c, 0x03, 0x80, 0x3f, 0xe0, 0x0e, 0x07, 0x00, 0x78, 0x00, 0xff, 0x00,
0x00, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1c, 0x00,
0x00, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1c, 0x00,
0x00, 0xe0, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1c, 0x00,
0x00, 0xe0, 0x00, 0x00, 0x00, 0x03, 0x80, 0x08, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x1c, 0x00,
0x00, 0xe0, 0x00, 0x00, 0x00, 0x06, 0xc0, 0x1c, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x1c, 0x00,
0x00, 0xe0, 0x00, 0x00, 0x00, 0x03, 0x80, 0x36, 0x00, 0x36, 0x00, 0x00, 0x00, 0x00, 0x1c, 0x00,
0x00, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x1c, 0x00,
0x00, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1c, 0x00,
0x00, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1c, 0x00,
0x00, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1c, 0x00,
0x00, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1c, 0x00,
0x00, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1c, 0x00,
0x00, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x01, 0xff, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1c, 0x00,
0x00, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x03, 0xc1, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1c, 0x00,
0x00, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1c, 0x00,
0x00, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1c, 0x00,
0x00, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1c, 0x00,
0x00, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1c, 0x00,
0x00, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x10, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1c, 0x00,
0x00, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x38, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1c, 0x00,
0x00, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x6c, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1c, 0x00,
0x00, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x38, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1c, 0x00,
0x00, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1c, 0x00,
0x00, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1c, 0x00,
0x00, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1c, 0x00,
0x00, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1c, 0x00,
0x00, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1c, 0x00,
0x00, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x03, 0xc1, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1c, 0x00,
0x00, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x01, 0xff, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1c, 0x00,
0x00, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1c, 0x00,
0x00, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1c, 0x00,
0x00, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1c, 0x00,
0x00, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1c, 0x00,
0x00, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1c, 0x00,
0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc, 0x00,
0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc, 0x00,
0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc, 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,
};