// 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
// 'snowflake', 25x25px
const unsigned char snowflake [] PROGMEM = {
0x00, 0x10, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x08, 0x38, 0x20, 0x00,
0x70, 0x10, 0x1c, 0x00, 0x70, 0x39, 0x1d, 0x00, 0xf0, 0x39, 0x1f, 0x00, 0xc0, 0x11, 0x07, 0x00,
0xe0, 0x39, 0x0f, 0x00, 0x00, 0xfe, 0x00, 0x00, 0x00, 0xfe, 0x00, 0x00, 0x6e, 0xef, 0xed, 0x00,
0xff, 0xc7, 0xff, 0x01, 0x6e, 0xef, 0xed, 0x00, 0x00, 0xfe, 0x00, 0x00, 0x00, 0xfe, 0x00, 0x00,
0xe0, 0x39, 0x0f, 0x00, 0xc0, 0x11, 0x07, 0x00, 0xf0, 0x39, 0x1f, 0x00, 0x70, 0x39, 0x1d, 0x00,
0x70, 0x10, 0x1c, 0x00, 0x08, 0x38, 0x20, 0x00, 0x00, 0x38, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00,
0x00, 0x10, 0x00, 0x00
};
// 'state_cold_eye', 31x31px
const unsigned char cold_eye [] PROGMEM = {
0x00, 0xf0, 0x07, 0x00, 0x00, 0xfe, 0x3f, 0x00, 0x80, 0xff, 0xff, 0x00, 0xc0, 0x0f, 0xf8, 0x01,
0xe0, 0x01, 0xc0, 0x03, 0xf0, 0x00, 0x80, 0x07, 0x78, 0x00, 0x00, 0x0f, 0x3c, 0x00, 0x00, 0x1e,
0x1c, 0x00, 0x00, 0x1c, 0x0e, 0x00, 0x00, 0x38, 0x0e, 0x00, 0x00, 0x38, 0x0e, 0x00, 0x00, 0x38,
0x07, 0x00, 0x00, 0x70, 0x07, 0x00, 0x00, 0x70, 0x07, 0x00, 0x00, 0x70, 0x07, 0x00, 0x00, 0x70,
0x07, 0x00, 0x00, 0x70, 0x07, 0x00, 0x00, 0x70, 0x07, 0x00, 0x00, 0x70, 0x0e, 0x00, 0x00, 0x38,
0x0e, 0x00, 0x00, 0x38, 0x0e, 0x00, 0x00, 0x38, 0x1c, 0x00, 0x00, 0x1c, 0x3c, 0x00, 0x00, 0x1e,
0x78, 0x00, 0x00, 0x0f, 0xf0, 0x00, 0x80, 0x07, 0xe0, 0x01, 0xc0, 0x03, 0xc0, 0x0f, 0xf8, 0x01,
0x80, 0xff, 0xff, 0x00, 0x00, 0xfe, 0x3f, 0x00, 0x00, 0xf0, 0x07, 0x00
};
void setup(void) {
u8g2.begin(); // start the u8g2 library
}
void loop(void) {
state_cold();
}
void state_cold() {
int shift_value = 2;
u8g2.clearBuffer(); // clear the internal memory
u8g2.drawXBMP(100, 3, 25, 25, snowflake);
u8g2.drawXBMP(23+shift_value, 28, 31, 31, cold_eye);
u8g2.drawXBMP(74+shift_value, 28, 31, 31, cold_eye);
u8g2.sendBuffer(); // transfer internal memory to the display
delay(25);
u8g2.clearBuffer(); // clear the internal memory
u8g2.drawXBMP(100, 3, 25, 25, snowflake);
u8g2.drawXBMP(23-shift_value, 28, 31, 31, cold_eye);
u8g2.drawXBMP(74-shift_value, 28, 31, 31, cold_eye);
u8g2.sendBuffer(); // transfer internal memory to the display
delay(25);
}