#include <Adafruit_SSD1306.h> // https://github.com/adafruit/Adafruit_SSD1306
#include "bitmap.h" // graphic object

#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 64
#define I2C_ADDRESS 0x3C
#define BITMAP_WIDTH  25
#define BITMAP_HEIGHT 13

int MAXX = SCREEN_WIDTH - BITMAP_WIDTH; // size of usable screen width
int MAXY = SCREEN_HEIGHT - BITMAP_HEIGHT; // size of usable screen height

int xMov = 2; // horizontal movement
int yMov = 2; // vertical movement
int x = random(SCREEN_WIDTH); // starting x location
int y = random(SCREEN_HEIGHT); // starting y location

Adafruit_SSD1306 oled(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1); // create oled object

void setup() {
  Serial.begin(9600);
  if (!oled.begin(SSD1306_SWITCHCAPVCC, I2C_ADDRESS)) {
    Serial.println(F("SSD1306 allocation failed"));
    while (1); // hold here after device failure
  }
}

void loop() {
  dvd();
}

void dvd() {
  if (x <= 0 || x >= MAXX) // x boundries
    xMov = -xMov;

  if (y <= 0 || y >= MAXY) // y boundries
    yMov = -yMov;

  x += xMov;
  y += yMov;

  oled.clearDisplay();
  oled.drawBitmap(x, y, myBitmap, BITMAP_WIDTH, BITMAP_HEIGHT, WHITE);
  oled.display();
}
USB
PWR