// simple project using Arduino UNO and 128x64 SSD1306 IIC OLED Display to display animated icon from www.icons8.com
// created by upir, 2023
// youtube channel: https://www.youtube.com/upir_upir
// YOUTUBE VIDEO: https://youtu.be/o3PhC_VJdXo
// Links from the video:
// WOKWI animator: https://animator.wokwi.com/
// Animated icons: https://icons8.com/icons/set/popular--animated
// Infinity icon: https://icons8.com/icons/set/infinity--animated
// 128x64 SSD1306 OLED Display 1.54": https://s.click.aliexpress.com/e/_DCYdWXb
// 128x64 SSD1306 OLED Display 0.96": https://s.click.aliexpress.com/e/_DCKdvnh
// 128x64 SSD1306 OLED Display 2.42": https://s.click.aliexpress.com/e/_DFdMoTh
// Arduino UNO: https://s.click.aliexpress.com/e/_AXDw1h
// Arduino breadboard prototyping shield: https://s.click.aliexpress.com/e/_ApbCwx
// Image2cpp (convert image to c-style array): https://javl.github.io/image2cpp/
// Photopea (online graphics editor like Photoshop): https://www.photopea.com/
// Piskel Application (online animation editor): https://www.piskelapp.com/p/create/sprite
// Related videos with Arduino UNO and 128x64 OLED screen:
// Arduino OLED menu: https://youtu.be/HVHVkKt-ldc
// U8g vs U8g2: https://youtu.be/K5e0lFRvZ2E
// Arduino Parking Sensor - https://youtu.be/sEWw087KOj0
// Turbo pressure gauge with Arduino and OLED display - https://youtu.be/JXmw1xOlBdk
// Arduino Car Cluster with OLED Display - https://youtu.be/El5SJelwV_0
// Knob over OLED Display - https://youtu.be/SmbcNx7tbX8
// Arduino + OLED = 3D ? - https://youtu.be/kBAcaA7NAlA
// Arduino OLED Gauge - https://youtu.be/xI6dXTA02UQ
// Smaller & Faster Arduino - https://youtu.be/4GfPQoIRqW8
// Save Image from OLED Display to PC - https://youtu.be/Ft2pRMVm44E
#include <Arduino.h>
#include <U8g2lib.h>
#include <Wire.h> // library required for IIC communication
U8G2_SSD1306_128X64_NONAME_F_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); // initialization for the used OLED display
// the arrays below are generated from the image2cpp tool, scroll down for the actual code
// 'frm0', 40x40px
const unsigned char state_mad_frm0 [] PROGMEM = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0xc0,
0x03, 0x1f, 0x00, 0x00, 0xc0, 0x03, 0x1f, 0x00, 0x00, 0xc0, 0x03, 0x1f, 0x00, 0x00, 0xc0, 0x03,
0x3f, 0x00, 0x00, 0xc0, 0x07, 0x7e, 0x00, 0x00, 0xc0, 0x07, 0x7e, 0x00, 0x00, 0xc0, 0x07, 0xfc,
0x1f, 0x00, 0xc0, 0x07, 0xf8, 0x3f, 0x00, 0xc0, 0x07, 0xf8, 0x3f, 0x00, 0xc0, 0x07, 0xe0, 0x1f,
0x00, 0xc0, 0x07, 0xc0, 0x1f, 0x00, 0xc0, 0x07, 0x00, 0x00, 0x00, 0xc0, 0x07, 0x00, 0x00, 0x00,
0xf0, 0x03, 0x00, 0x00, 0x00, 0xf8, 0x03, 0x00, 0x00, 0x00, 0xfe, 0x01, 0x00, 0x00, 0x00, 0x7e,
0x00, 0x00, 0xc0, 0x03, 0x7e, 0x00, 0x00, 0xe0, 0x07, 0x3e, 0x00, 0x00, 0xf8, 0x07, 0x00, 0x00,
0x00, 0xfc, 0x07, 0x00, 0x00, 0x00, 0xfe, 0x07, 0x00, 0x00, 0x00, 0x7e, 0x00, 0x00, 0x00, 0x00,
0x1f, 0x00, 0x00, 0x1e, 0x00, 0x1f, 0x00, 0xc0, 0x3f, 0x00, 0x1f, 0x00, 0xe0, 0xff, 0x00, 0x1f,
0x00, 0xe0, 0xff, 0x01, 0x1f, 0x00, 0xe0, 0xff, 0x03, 0x1f, 0x00, 0xc0, 0xe0, 0x07, 0x1f, 0x00,
0x00, 0xc0, 0x07, 0x1e, 0x00, 0x00, 0xc0, 0x0f, 0x1e, 0x00, 0x00, 0x00, 0x1f, 0x0c, 0x00, 0x00,
0x00, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x00,
0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
// 'frm1', 40x40px
const unsigned char state_mad_frm1 [] PROGMEM = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00,
0x01, 0x0f, 0x00, 0x00, 0xc0, 0x07, 0x1f, 0x00, 0x00, 0xc0, 0x07, 0x1f, 0x00, 0x00, 0xc0, 0x0f,
0x3f, 0x00, 0x00, 0xc0, 0x0f, 0xfe, 0x00, 0x00, 0xc0, 0x0f, 0xfc, 0x30, 0x00, 0xc0, 0x0f, 0xfc,
0x7f, 0x00, 0xc0, 0x0f, 0xf8, 0x7f, 0x00, 0xc0, 0x0f, 0xf0, 0x7f, 0x00, 0xc0, 0x0f, 0xc0, 0x7f,
0x00, 0xc0, 0x07, 0x80, 0x3f, 0x00, 0xc0, 0x07, 0x00, 0x04, 0x00, 0xfc, 0x03, 0x00, 0x00, 0x00,
0xfe, 0x03, 0x00, 0x00, 0x00, 0xfe, 0x01, 0x00, 0x00, 0x00, 0xfe, 0x00, 0x00, 0x70, 0x00, 0x38,
0x00, 0x00, 0xf8, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x00, 0x00, 0x00, 0x00, 0xfc, 0x00, 0x00, 0x00,
0x00, 0x7e, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x03, 0x00,
0x1f, 0x00, 0xc0, 0x1f, 0x80, 0x1f, 0x00, 0xe0, 0x7f, 0x80, 0x1f, 0x00, 0xf0, 0xff, 0x80, 0x1f,
0x00, 0xe0, 0xff, 0x03, 0x1f, 0x00, 0xc0, 0xff, 0x07, 0x1f, 0x00, 0x00, 0xf0, 0x07, 0x3f, 0x00,
0x00, 0xe0, 0x0f, 0x3f, 0x00, 0x00, 0x80, 0x0f, 0x3e, 0x00, 0x00, 0x00, 0x0f, 0x7e, 0x00, 0x00,
0x00, 0x1f, 0x7c, 0x00, 0x00, 0x00, 0x1f, 0x3c, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x00,
0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
// 'frm2', 40x40px
const unsigned char state_mad_frm2 [] PROGMEM = {
0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0xc0, 0x07, 0x00, 0x00, 0x00,
0xc0, 0x07, 0x00, 0x00, 0xf0, 0x80, 0x0f, 0x00, 0x00, 0xf0, 0x80, 0x0f, 0x00, 0x00, 0xf0, 0x00,
0x1f, 0x00, 0x00, 0xf0, 0x01, 0x3f, 0x00, 0x00, 0xf0, 0x01, 0xff, 0x00, 0x00, 0xf0, 0x01, 0xfc,
0x0f, 0x00, 0xf0, 0x01, 0xfc, 0x1f, 0x00, 0xf0, 0x01, 0xf0, 0x0f, 0x00, 0xf0, 0x01, 0xc0, 0x07,
0x00, 0xf0, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x00, 0x00, 0x00, 0x00,
0x78, 0x00, 0x00, 0x00, 0x00, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x00, 0x00, 0x70, 0x00, 0x3e,
0x00, 0x00, 0xf8, 0x00, 0x0c, 0x00, 0x00, 0xfc, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x00, 0x00, 0x00,
0x00, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x80, 0x0f, 0x00, 0x00, 0x00, 0x80,
0x07, 0x00, 0x60, 0x00, 0x80, 0x07, 0x00, 0xfc, 0x07, 0x80, 0x07, 0x00, 0xfc, 0x0f, 0x80, 0x07,
0x00, 0xfc, 0x3f, 0x80, 0x07, 0x00, 0xf8, 0x3f, 0x80, 0x07, 0x00, 0x00, 0x7e, 0x80, 0x07, 0x00,
0x00, 0xf8, 0x80, 0x0f, 0x00, 0x00, 0xf8, 0x00, 0x07, 0x00, 0x00, 0xf8, 0x00, 0x06, 0x00, 0x00,
0xf0, 0x00, 0x02, 0x00, 0x00, 0xf0, 0x01, 0x00, 0x00, 0x00, 0xf0, 0x01, 0x00, 0x00, 0x00, 0xe0,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
void setup(void) {
u8g2.begin(); // start the u8g2 library
}
void loop(void) {
state_mad();
}
void state_mad() {
u8g2.clearBuffer(); // clear the internal memory
u8g2.drawXBMP(88, 0, 40, 40, state_mad_frm0); // draw frame of the animation
u8g2.drawBox(19, 50, 30, 6);
u8g2.drawBox(80, 50, 30, 6);
u8g2.sendBuffer(); // transfer internal memory to the display
delay(150);
u8g2.clearBuffer(); // clear the internal memory
u8g2.drawXBMP(88, 0, 40, 40, state_mad_frm1); // draw frame of the animation
u8g2.drawBox(19, 50, 30, 6);
u8g2.drawBox(80, 50, 30, 6);
u8g2.sendBuffer(); // transfer internal memory to the display
delay(150);
u8g2.clearBuffer(); // clear the internal memory
u8g2.drawXBMP(88, 0, 40, 40, state_mad_frm2); // draw frame of the animation
u8g2.drawBox(19, 50, 30, 6);
u8g2.drawBox(80, 50, 30, 6);
u8g2.sendBuffer(); // transfer internal memory to the display
delay(150);
}