// 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, crlf;
void setup() {
// Serial.begin(115200);
randomSeed(analogRead(A0));
display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
display.clearDisplay();
display.display();
display.setTextSize(1);
display.setTextColor(SSD1306_WHITE);
}
void loop() {
// asciiset1();
// asciiset2(); // line drawing
angles10PRINT();
// blocks10PRINT();
// serial10PRINT();
display.display();
delay(1000);
display.clearDisplay();
display.setCursor(0,0);
// while (1) {};
}
void blocks10PRINT() {
int rows = 8, cols = 21, left = 219, right = 220;
for (int i = 0; i < rows * cols; i++) {
display.write(random(2) ? left : right);
}
display.setCursor(0, 0);
}
void angles10PRINT() {
int rows = 12, cols = 24, left = 47, right = 92;
int height = 5, width = 5;
for (int y = 0; y < rows; y++) {
for (x = 0; x < cols; x++) {
display.setCursor(x * width, y * height);
display.write(random(2) ? left : right);
}
}
}
void serial10PRINT() {
int cols = 80;
Serial.write(random(2) ? 47 : 92);
if (++x > cols) {
x = 0;
Serial.println();
}
}
void asciiset1() {
for (int i = 0; i < 172; i++) {
if (x == 21) {
x = 0;
display.println();
}
if (i != 0 && i != 10 && i != 32) {
display.write(i);
x++;
}
if (i == 0)
x--;
}
}
void asciiset2() {
for (int i = 173; i < 256; i++) {
if (x == 21) {
x = 0;
display.println();
}
if (i != 0 && i != 10 && i != 32) {
display.write(i);
x++;
}
if (i == 0)
x--;
}
}Loading
ssd1306
ssd1306