#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include "Gif1.h"
#include "Gif2.h"
#define SCREEN_I2C_ADDR 0x3C
#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64 // OLED display height, in pixels
#define OLED_RST_PIN -1 // Reset pin (-1 if not available)
Adafruit_SSD1306 display(128, 64, &Wire, OLED_RST_PIN);
// OLED Animation: alarm clock
// Code auto-generated by https://wokwi.com/animator, graphics by icons8.com
#define FRAME_DELAY (10)
#define FRAME_WIDTH (32)
#define FRAME_HEIGHT (32)
#define FRAME_COUNT (sizeof(gif1) / sizeof(gif1[0]))
const int SW=3;
void setup() {
Serial.begin(115200);
pinMode(SW, INPUT_PULLUP);
display.begin(SSD1306_SWITCHCAPVCC, SCREEN_I2C_ADDR);
}
int frame = 0;
void loop() {
display.clearDisplay();
if(digitalRead(SW)==HIGH) display.drawBitmap(52,0, gif1[frame], FRAME_WIDTH, FRAME_HEIGHT, 1);
else display.drawBitmap(52,32, gif2[frame], FRAME_WIDTH, FRAME_HEIGHT, 1);
display.display();
frame = (frame + 1) % FRAME_COUNT;
delay(FRAME_DELAY);
}