#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <Fonts/FreeSerif9pt7b.h>
#include <Fonts/FreeSerifBold9pt7b.h>
#include <Fonts/FreeSerifItalic9pt7b.h>
#include <Fonts/FreeSerifBoldItalic9pt7b.h>
#include <Fonts/FreeMono9pt7b.h>
#include <Fonts/FreeMonoBold9pt7b.h>
#include <Fonts/FreeMonoBoldOblique9pt7b.h>
#include <Fonts/FreeMonoOblique9pt7b.h>
#include <Fonts/FreeSans9pt7b.h>
#include <Fonts/FreeSansBold9pt7b.h>
#include <Fonts/FreeSansBoldOblique9pt7b.h>
#include <Fonts/Picopixel.h>
#include <Fonts/TomThumb.h>
#include <Fonts/Tiny3x3a2pt7b.h>
#include <Fonts/Org_01.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);
//GFXcanvas1 canvas(128, 64); // 128x32 pixel canvas
void setup() {
Serial.begin(115200);
// 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.setTextColor(SSD1306_WHITE); // Draw white text
}
void loop() {
testFont(NULL, "System Font", 1000, 1, 11);
testFont(&Picopixel, "Picopixel", 1000, 1, 15);
testFont(&TomThumb, "TomThumb", 1000, 1, 16);
testFont(&Tiny3x3a2pt7b, "Tiny3x3a2pt7b", 1000, 1, 13);
testFont(&Org_01, "Org_01", 1000, 1, 15);
testFont(&FreeMonoBoldOblique9pt7b, "FreeMonoBoldOblique", 1000, 1, 22);
testFont(&FreeSerif9pt7b, "FreeSerif", 1000, 1, 23);
testFont(&FreeMonoBold9pt7b, "FreeMonoBold", 1000, 1, 22);
testFont(&FreeMonoOblique9pt7b, "FreeMonoOblique", 1000, 1, 22);
testFont(&FreeSans9pt7b, "FreeSans", 1000, 1, 24);
testFont(&FreeSansBold9pt7b, "FreeSansBold", 1000, 1, 23);
}
void testFont(const GFXfont* typeface, char* name, int time, int size, int h_offset) {
display.setFont(NULL);
display.setTextSize(1);
display.setCursor(0, 0);
if (name) display.println(name);
if (!name) display.println("System Typeface");
display.drawLine(0, 9, 128, 9, SSD1306_WHITE);
display.setFont(typeface);
display.setTextSize(size); // Normal 1:1 pixel scale
display.setTextColor(SSD1306_WHITE); // Draw white text
display.setCursor(0, h_offset); // Start at offset height
display.cp437(true); // Use full 256 char 'Code Page 437' font
display.println("0123456789");
display.println("ABCDEFGHIJKLMNOPQRSTUVWXYZ");
display.println("!!@#$%^&*()_+-=`~");
// Not all the characters will fit on the display. This is normal.
// Library will draw what it can and the rest will be clipped.
// for (int16_t i = 0; i < 256; i++) {
// display.write(i);
//}
display.display();
delay(time);
display.clearDisplay();
display.display();
}