/*
  How I render animations using the Gyver lib
  Special thx to Alex Gyver and his amazing little library
  @ http://alexgyver.ru/gyveroled/
*/
#include <GyverOLED.h>
#include "data.h"
#define OLED_SPEED 133000000
#define FRAME_COUNT 13
#define ARRAY_W 128
#define ARRAY_H 64
GyverOLED<SSD1306_128x64, OLED_BUFFER> oled;
uint32_t timer;
int currentAnimationIndex = 0;
bool* animationArrays[FRAME_COUNT] = {
  (bool*)RUNNING_WOLF_00,
  (bool*)RUNNING_WOLF_01,
  (bool*)RUNNING_WOLF_02,
  (bool*)RUNNING_WOLF_03,
  (bool*)RUNNING_WOLF_04,
  (bool*)RUNNING_WOLF_05,
  (bool*)RUNNING_WOLF_06,
  (bool*)RUNNING_WOLF_07,
  (bool*)RUNNING_WOLF_08,
  (bool*)RUNNING_WOLF_09,
  (bool*)RUNNING_WOLF_10,
  (bool*)RUNNING_WOLF_11,
  (bool*)RUNNING_WOLF_12,
};
void setup() {
  Serial1.begin(115200);
  oled.init();
  Wire.setClock(OLED_SPEED);
}
void loop() {
  oled.clear();
  oled.home();
  drawAnimation();
  oled.update();
  timer = millis() - timer;
  //Serial1.printf("Core temperature: %2.1fC\n", analogReadTemp());
  //delay(50);  // remove for unlimited speed
}
void drawAnimation() {
  for (int i = 0; i < ARRAY_H; i++) {
    for (int j = 0; j < ARRAY_W; j++) {
      oled.dot(j, i, animationArrays[currentAnimationIndex][i * ARRAY_W + j]);
    }
  }
  oled.print(1000 / timer);
  timer = millis();
  currentAnimationIndex++;
  if (currentAnimationIndex >= FRAME_COUNT) {
    currentAnimationIndex = 0;
  }  
}