#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include "images.h" // See the file content
#include "anims.h" // See the file content
const int SCREEN_WIDTH = 128; // OLED display width, in pixels
const int SCREEN_HEIGHT = 64; // OLED display height, in pixels
// Declaration for an SSD1306 display connected to I2C (SDA, SCL pins)
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1);
void setup() {
Serial.begin(9600);
if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { // Address 0x3D for 128x64
Serial.println(F("SSD1306 allocation failed"));
while(true);
}
}
/* the Important function */
void draw_bitmap(int x, int y, int width, int height, int color, const unsigned char img_data[])
{
display.clearDisplay();
display.drawBitmap(x, y, img_data, width, height, color);
display.display();
}
const int anim_nb_frames = 6;
const unsigned char *anim_frames[] = {
frame_00, frame_06, frame_12, frame_18, frame_24, frame_30
};
void draw_animation(int loop, int pause)
{
int i;
while(loop) {
for (i = 0; i < anim_nb_frames; i++) {
draw_bitmap(0, 0, 128, 64, WHITE, anim_frames[i]);
delay(pause);
}
loop--;
}
}
void loop()
{
draw_bitmap(0, 0, 128, 64, WHITE, NaN);
delay(1000);
draw_animation(5, 50);
delay(1000);
}