#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <math.h>
#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 64
int coy, x = 0;
int vcoy = 1;
bool showtext = true;
int textttl = 20;
Adafruit_SSD1306 oled(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1);
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
if(!oled.begin(SSD1306_SWITCHCAPVCC, 0x3C)) {
Serial.println(F("SSD1306 allocation failed"));
while (true);
}
}
void loop() {
oled.clearDisplay();
oled.setTextColor(WHITE);
if(showtext) {
textttl = textttl - 1;
oled.setCursor(0, 0);
oled.println("screensaver made by d");
oled.setCursor(0, 32);
oled.println("special thanks to maybe_cube");
if(textttl == 0) {
showtext = false;
}
} else {
for (int i = 0; i<4;i++ ){
oled.drawLine(0, 30+i*10, 128, 30+i*10, WHITE);
}
for (int i = 0; i<9; i++) {
oled.drawLine((i*15)+x, 30, ((i*15)+x)*2-64, 64, WHITE);
}
for (int i = 0; i<5; i++) {
oled.fillRect((rand() % 128), (rand() % 30), 2, 2,WHITE);
}
oled.fillCircle(64,22+coy, 10,INVERSE);
if (x % 5 == 0) vcoy = vcoy * -1;
coy = coy + vcoy;
x %= 15;
x++;
}
oled.display();
delay(50);
}