#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64 // OLED display height, in pixels
#define SSD1306_NO_SPLASH
#define OLED_RESET -1 // Reset pin # (or -1 if sharing Arduino reset pin)
#define SCREEN_ADDRESS 0x3C ///< See datasheet for Address; 0x3D for 128x64, 0x3C for 128x32
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
// 'logo', 64x64px
#define LOGO_WIDTH 64
#define LOGO_HEIGHT 64
const unsigned char PROGMEM epd_bitmap_logo[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x88, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xaa, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x5f, 0xfe, 0x00, 0x00,
0x00, 0x00, 0x00, 0x02, 0xbb, 0xba, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x07, 0xff, 0xfe, 0x00, 0x00,
0x00, 0x00, 0x00, 0x0e, 0xee, 0xee, 0x00, 0x08, 0x00, 0x00, 0x00, 0x0f, 0xff, 0xfe, 0x00, 0x00,
0x00, 0x00, 0x00, 0x0b, 0xbb, 0xba, 0x00, 0x28, 0x00, 0x00, 0x00, 0x1f, 0xff, 0xfe, 0x00, 0x00,
0x00, 0x00, 0x00, 0x2e, 0xee, 0x00, 0x00, 0xa0, 0x00, 0x00, 0x00, 0x3f, 0xfc, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x3b, 0xb8, 0x00, 0x00, 0xa0, 0x00, 0x00, 0x00, 0x3f, 0xf8, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x2e, 0xe8, 0x00, 0x02, 0x80, 0x00, 0x00, 0x00, 0x3f, 0xf8, 0x00, 0x00, 0x00,
0x00, 0x00, 0x03, 0xbb, 0xbb, 0xb8, 0x0a, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xfc, 0x00, 0x00,
0x00, 0x00, 0x06, 0xee, 0xee, 0xec, 0x08, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xfc, 0x00, 0x00,
0x00, 0x00, 0x03, 0xbb, 0xbb, 0xb8, 0x28, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xfc, 0x00, 0x00,
0x00, 0x00, 0x06, 0xee, 0xee, 0xec, 0x80, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xfc, 0x00, 0x00,
0x00, 0x00, 0x00, 0x3b, 0xb8, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xf8, 0x00, 0x00, 0x00,
0x80, 0x00, 0x00, 0x2e, 0xe8, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xf8, 0x00, 0x00, 0x00,
0xaa, 0x00, 0x00, 0x3b, 0xb8, 0x28, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xf8, 0x00, 0x00, 0x00,
0x0a, 0xa8, 0x00, 0x2e, 0xe8, 0xa0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xf8, 0x00, 0x00, 0x00,
0x00, 0x2a, 0xa0, 0x3b, 0xb8, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xf8, 0x00, 0x00, 0x00,
0x00, 0x00, 0xaa, 0x2e, 0xe8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xf8, 0x00, 0x00, 0x00,
0x00, 0x00, 0x02, 0x3b, 0xb8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xf8, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x2e, 0xe8, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xf8, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x3b, 0xb8, 0xaa, 0x80, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xf8, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x2e, 0xe8, 0x08, 0xaa, 0x80, 0x00, 0x00, 0x00, 0x3f, 0xf8, 0x00, 0x00, 0x00,
0x00, 0x00, 0x02, 0x3b, 0xb8, 0x00, 0x02, 0xaa, 0x00, 0x00, 0x00, 0x3f, 0xf8, 0x00, 0x00, 0x00,
0x00, 0x00, 0x08, 0x2e, 0xe8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xf8, 0x00, 0x00, 0x00,
0x00, 0x00, 0xa0, 0x3b, 0xb8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xf8, 0x00, 0x00, 0x00,
0x00, 0x08, 0x80, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
void setup() {
// put your setup code here, to run once:
display.begin(SSD1306_SWITCHCAPVCC, SCREEN_ADDRESS);
/* display.display();
delay(2000); // Pause for 2 seconds
// Clear the buffer
display.clearDisplay();
display.setTextSize(1); // Normal 1:1 pixel scale
display.setTextColor(SSD1306_WHITE); // Draw white text
display.setCursor(0,0); // Start at top-left corner
display.println(F("Hello, world!"));
display.setTextColor(SSD1306_BLACK, SSD1306_WHITE); // Draw 'inverse' text
display.println(3.141592);
display.setTextSize(2); // Draw 2X-scale text
display.setTextColor(SSD1306_WHITE);
display.print(F("0x")); display.println(0xDEADBEEF, HEX);
display.display();*/
display.clearDisplay();
display.drawBitmap(
(display.width() - LOGO_WIDTH ) / 2,
(display.height() - LOGO_HEIGHT) / 2,
epd_bitmap_logo, LOGO_WIDTH, LOGO_HEIGHT, 1);
display.display();
delay(4000);
// Clear the buffer
display.clearDisplay();
display.setTextColor(WHITE);
// status line
display.setTextSize(1);
display.setCursor(0,0);
display.print(" OFF CV");
display.setCursor(127-4*6,0);
display.print("v1.0");
display.drawLine(0, 9, display.width(), 9, WHITE);
display.setTextSize(2); // Draw 2X-scale text
// place units, right align
display.setCursor(127-13,12+7);
display.print("V");
display.setCursor(127-13,41+7);
display.print("A");
display.setTextSize(3); // draw 3x-scale text
display.setCursor(0,12);
display.print(" 12.2");
display.setCursor(0,41);
display.print(" 0.12");
display.display();
delay(3000);
display.dim(true); // after timeout dim the display brightness - unfortunately, HW does not support to simulate dimming
//display.invertDisplay(true);
delay(3000);
// Clear the buffer
display.clearDisplay();
display.setTextColor(WHITE);
// status line
display.setTextSize(1);
display.setCursor(0,0);
display.print(" OFF CV");
display.setCursor(127-4*6,0);
display.print("v1.0");
display.drawLine(0, 9, display.width(), 9, WHITE);
display.setTextSize(2); // Draw 2X-scale text
// place units, right align
display.setCursor(127-11,12+7);
display.print("V");
display.setCursor(127-11,41+7);
display.print("A");
display.setTextSize(3);
display.setCursor(17,12);
display.print("12.2");
display.setTextSize(2); // Draw 2X-scale text
display.setCursor(127-5*12-3,41+7);
display.print("0.12");
display.setCursor(0,41+7);
display.print("1.05");
display.display();
}
void loop() {
// put your main code here, to run repeatedly:
delay(100);
}