// ← back to all

cricket_bat

// cricket_bat · by 0x1306 · 8 frames · 83ms · indian
// views · runs
// preview
frame_00 / 08// 83ms per frame
// space: play/pause · ←→: step frames
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
#include <Wire.h> #include <Adafruit_GFX.h> #include <Adafruit_SSD1306.h> // 0x1306.dev · animation: cricket_bat · 8 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 8 #define FRAME_DELAY 83 void drawFrame(int frame) { display.clearDisplay(); int cx = 50; int cy = 40; // --- ball --- int8_t ballX[] = {70, 65, 60, 50, 40, 20, 0, -20}; int8_t ballY[] = {45, 45, 45, 45, 40, 30, 20, 10}; if (frame > 2) { display.fillCircle(ballX[frame], ballY[frame], 2, WHITE); display.drawFastHLine(ballX[frame] - 4, ballY[frame], 4, WHITE); } // --- bat swing --- int8_t hx[] = {cx-15, cx-10, cx-5, cx, cx+5, cx+10, cx+5, cx}; int8_t hy[] = {cy-20, cy-15, cy-10, cy-5, cy, cy+5, cy+15, cy+20}; int8_t tx[] = {cx-25, cx-10, cx+10, cx+25, cx+30,cx+20, cx+5, cx-10}; int8_t ty[] = {cy-40, cy-35, cy-25, cy-15, cy, cy+15, cy+30, cy+35}; display.drawLine(cx, cy, hx[frame], hy[frame], WHITE); // handle for(int offset = -3; offset <= 3; offset++) { display.drawLine(hx[frame] + offset, hy[frame], tx[frame] + offset, ty[frame], 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