A Gif converter to write the frames into a C array for monochrome OLED displays with grayscale.
OLED_C-Array.ino
OpenDev 📧 GitHub Profile
See #define SWVERSION
05.05.2024
None reported
Free
Adafruit_SSD1306 Library: Adafruit_SSD1306
Signal | MCU |
---|---|
I2C | I2C |
- Clone or download the repository to your local machine.
- Install the required libraries using the command above.
- Run the script
GIFtoOLED.py
. - Click on the "Browse" button to select a GIF file.
- The converted C array will be saved as
frames_array.h
in the same directory as the script.
The Gif converter performs the following steps:
- Extracts the frames from the selected GIF file.
- Converts the individual images to grayscale.
- Converts the grayscale images into a C array.
- Determines the frame rate (FPS) of the GIF.
- Writes the result to a header file.
An example for Arduino is included.
#include <Adafruit_SSD1306.h>
#include <Wire.h>
#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64 // OLED display height, in pixels
// Declaration for an SSD1306 display connected to I2C (SDA, SCL pins)
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1);
#define SWVERSION "1.0"
// Frame data
const uint8_t frames[][SCREEN_WIDTH * SCREEN_HEIGHT / 8] PROGMEM = {
// Include the frame data from frames_array.h here
};
void setup() {
Serial.begin(115200);
// Initialize the display
if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) {
Serial.println(F("SSD1306 allocation failed"));
for(;;);
}
display.display();
delay(2000); // Pause for 2 seconds
// Clear the buffer
display.clearDisplay();
}
void loop() {
// Display each frame
for(int i = 0; i < sizeof(frames)/sizeof(frames[0]); i++) {
display.clearDisplay();
display.drawBitmap(0, 0, frames[i], SCREEN_WIDTH, SCREEN_HEIGHT, SSD1306_WHITE);
display.display();
delay(100); // Adjust this delay to change the frame rate
}
}