I want to move a bitmap accress a 128x64 OLED.
Came up this solution but it takes almost half the programspace.
/*********
Rui Santos
Complete project details at https://randomnerdtutorials.com
*********/
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 64
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1);
const unsigned char NaN[] PROGMEM = {
// 'SRD-MC, 64x64px
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x11, 0xe0, 0x03, 0xbe, 0x00, 0x00, 0x00, 0x00, 0x3b, 0xe0,
0x03, 0xd8, 0x00, 0x00, 0x00, 0x00, 0x3d, 0x80, 0x03, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x3e, 0x00,
0x0d, 0xf0, 0x00, 0x00, 0x00, 0x00, 0xcf, 0x00, 0x3e, 0xf0, 0x00, 0x00, 0x00, 0x03, 0xef, 0x00,
0x7c, 0x7e, 0x00, 0x00, 0x00, 0x07, 0xc7, 0xc0, 0x38, 0x38, 0x00, 0x00, 0x00, 0x03, 0x01, 0x80,
0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x07, 0x80, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x17, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x17, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x07, 0x03, 0x83, 0xf0, 0x3e, 0x00, 0x00, 0x00, 0x0b, 0x8f, 0xe3, 0xfc, 0x7f, 0xc0, 0x00,
0x00, 0x03, 0x9f, 0xf3, 0xfe, 0x7f, 0xe0, 0x00, 0x00, 0x01, 0xde, 0xf3, 0xff, 0x7f, 0xf0, 0x00,
0x00, 0x00, 0xec, 0x03, 0x8f, 0x70, 0xf0, 0x00, 0x00, 0x00, 0x76, 0x03, 0x87, 0x70, 0x70, 0x00,
0x00, 0x00, 0x73, 0xe3, 0x8f, 0x70, 0x70, 0x00, 0x00, 0x00, 0x39, 0xf3, 0xfe, 0x70, 0x70, 0x00,
0x00, 0x00, 0x5c, 0xfb, 0xfc, 0x70, 0x70, 0x00, 0x00, 0x00, 0x2f, 0x3b, 0xfc, 0x70, 0xf0, 0x00,
0x00, 0x00, 0x37, 0xbb, 0x9e, 0x7f, 0xf0, 0x00, 0x00, 0x00, 0x19, 0xd3, 0x8f, 0x7f, 0xe0, 0x00,
0x00, 0x00, 0x0c, 0xe3, 0x8f, 0x7f, 0xc0, 0x00, 0x00, 0x00, 0x07, 0x79, 0x07, 0x3f, 0x00, 0x00,
0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x80, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x03, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x08, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x3f, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xe0, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0,
0x03, 0xde, 0x00, 0x00, 0x00, 0x00, 0x33, 0xe0, 0x03, 0xec, 0x00, 0x00, 0x00, 0x00, 0x39, 0xc0,
0x01, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x0e, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x5e, 0x00,
0x3f, 0x78, 0x00, 0x00, 0x00, 0x01, 0xef, 0x00, 0x3e, 0x3e, 0x00, 0x00, 0x00, 0x07, 0xe7, 0x00,
0x18, 0x18, 0x00, 0x00, 0x00, 0x03, 0x83, 0xc0, 0x00, 0x18, 0x00, 0x00, 0x00, 0x03, 0x01, 0x00,
0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
void setup() {
Serial.begin(115200);
if (!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) {
Serial.println(F("SSD1306 allocation failed"));
for (;;)
;
}
delay(2000); // Pause for 2 seconds
// Clear the buffer.
display.clearDisplay();
// Draw bitmap on the screen
// display.drawBitmap(0, 0, image_data_Saraarray, 128, 64, 1);
display.drawBitmap(0, 0, NaN, 64, 64, 1);
display.display();
}
void loop() {
for (int i = 0; i <= 127; i++) {
display.clearDisplay();
display.drawBitmap(i, 0, NaN, 64, 64, 1);
display.display();
}
}
Is there a way to create smaller code??