// ← back to all

diya_flame

// diya_flame · by 0x1306 · 6 frames · 83ms · indian
// views · runs
// preview
frame_00 / 06// 83ms per frame
// space: play/pause · ←→: step frames
// size
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
#include <Wire.h> #include <Adafruit_GFX.h> #include <Adafruit_SSD1306.h> // 0x1306.dev · animation: diya_flame · 6 frames · 83ms #define SCREEN_WIDTH 128 #define SCREEN_HEIGHT 64 #define OLED_RESET -1 #define SCREEN_ADDRESS 0x3C Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET); #define FRAME_COUNT 6 #define FRAME_DELAY 83 void drawFrame(int frame) { display.clearDisplay(); int cx = 64; int cy = 40; // --- base --- display.drawFastHLine(cx - 15, cy + 12, 30, WHITE); display.drawFastHLine(cx - 10, cy + 14, 20, WHITE); // --- bowl --- display.fillRect(cx - 20, cy, 40, 6, WHITE); display.fillCircle(cx, cy + 6, 15, WHITE); // wait till mask display.fillRect(cx - 20, cy - 15, 40, 15, BLACK); // mask the top half of circle // --- wick --- display.drawFastVLine(cx, cy - 6, 6, WHITE); // --- flame --- int8_t flameX[] = { 0, 1, -1, 2, -2, 1}; int8_t flameY[] = {-8, -9, -7, -8, -9, -7}; int fx = cx + flameX[frame]; int fy = cy + flameY[frame]; display.fillCircle(fx, fy - 2, 6, WHITE); display.fillTriangle(fx - 6, fy - 2, fx + 6, fy - 2, fx, fy - 14, WHITE); display.display(); } void setup() { Wire.begin(21, 22); // SDA=21, SCL=22 for ESP32 DevKit // change to 0x3D if display not found display.begin(SSD1306_SWITCHCAPVCC, SCREEN_ADDRESS); display.clearDisplay(); display.display(); } void loop() { for (int i = 0; i < FRAME_COUNT; i++) { drawFrame(i); delay(FRAME_DELAY); } }
// share
// embed
// paste into any html · 320×200 · transparent click opens detail page