#include <SPI.h>
#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 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);
void setup() {
// put your setup code here, to run once:
// SSD1306_SWITCHCAPVCC = generate display voltage from 3.3V internally
if (!display.begin(SSD1306_SWITCHCAPVCC, SCREEN_ADDRESS)) {
Serial.println(F("SSD1306 allocation failed"));
for (;;); // Don't proceed, loop forever
}
display.clearDisplay();
display.setTextWrap(false);
display.setTextSize(2); // 2x scale text
display.setTextColor(SSD1306_WHITE, SSD1306_BLACK); // Draw white text on solid black background
display.setCursor(0, 0);
//display.println("LipSync");
display.setTextSize(1);
//display.println("v4.0.1");
//display.println("Makers Making Change");
//Main splash screen
/*
display.setTextSize(2);
drawCentreString("LipSync", 64, 12);
display.setTextSize(1);
drawCentreString("v4.0.1", 64, 32);
drawCentreString("Makers Making Change", 64, 54);
*/
display.setTextSize(2);
drawCentreString("LipSync", 64, 0);
display.setTextSize(1);
drawCentreString("v4.0.1", 64, 16);
drawCentreString("Makers Making Change", 64, 28);
drawCentreString("Mode:", 64, 40);
display.setTextSize(2);
drawCentreString("USB Mouse", 64, 48);
display.display();
}
void loop() {
// put your main code here, to run repeatedly:
}
void drawCentreString(const String &buf, int x, int y)
{
int16_t x1, y1;
uint16_t w, h;
display.getTextBounds(buf, x, y, &x1, &y1, &w, &h); //calc width of new string
display.setCursor(x - w / 2, y);
display.print(buf);
}