// https://10print.org/10_PRINT_121114.pdf
#include <Adafruit_SSD1306.h>
#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 64
#define OLED_RESET 4
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
int x, y, maxRowOlws = 12, maxColOled = 24, crlf, maxColSerial = 80;
int charLeft = 47, charRight = 92, charHeight = 5, charWidth = 5;
void setup() {
Serial.begin(115200);
randomSeed(analogRead(A0));
display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
display.clearDisplay();
display.display();
display.setTextSize(1);
display.setTextColor(SSD1306_WHITE);
// ascii();
}
void loop() {
oled10PRINT();
// serial10PRINT();
}
void oled10PRINT() {
display.setCursor(x * charWidth, y * charHeight);
display.write(random(2) ? charLeft : charRight);
display.display();
x++;
if (x > maxColOled) {
x = 0;
y++;
if (y == maxRowOlws) {
y = 0;
display.clearDisplay();
display.display();
display.setCursor(0, 0);
}
}
}
void serial10PRINT() {
Serial.write(random(2) ? charLeft : charRight);
if (++x > maxColSerial) {
x = 0;
Serial.println();
}
}
void ascii() {
for (int j = 0; j < 8; j++) {
for (int i = 0; i < 20; i++) {
display.setCursor(i * 6, j * 8);
display.write(j * 20 + i);
display.display();
}
}
}