Hello,
I am attempting to store multiple arrays of bitmap data, to display on an OLED, on an external EEPROM to save memory for my sketch. I'm not having any trouble getting the data on the EEPROM, the trouble starts when I try to populate an array in the program.
I'm using the Adafruit SSD1306 library, which uses PROGMEM for the bitmap array. The reason for that is a little advanced for my understanding, but I do know that using PROGMEM requires a const variable. Because of that, I'm unable to populate the array from the EEPROM with a for loop. At least that's what I'm thinking.
I'm hoping someone can advise me about retrieving bitmap data from the EEPROM and displaying it on an OLED.
Here is my current unsuccessful code. Excuse the messy formatting:
#include <EEPROM.h>
#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64 // OLED display height, in pixels
#define OLED_RESET -1 // Reset pin # (or -1 if sharing Arduino reset pin)
#define SCREEN_ADDRESS 0x3C ///< See datasheet for Address; 0x3D for 128x64, 0x3C for 128x32
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
#define LOGO_HEIGHT 64
#define LOGO_WIDTH 128
int eeAddress = 0;
const byte PROGMEM logo_bmp[1024]; // I can not populate this array from the EEPROM
void setup() {
Serial.begin(9600);
for (int i=0;i<1024;i++){
EEPROM.get(eeAddress, logo_bmp[i]);
eeAddress++;
}
if(!display.begin(SSD1306_SWITCHCAPVCC, SCREEN_ADDRESS)) {
Serial.println(F("SSD1306 allocation failed"));
for(;;); // Don't proceed, loop forever
}
testdrawbitmap();
}
void loop() {
// put your main code here, to run repeatedly:
}
void testdrawbitmap(void) {
display.clearDisplay();
//delay(3000);
display.drawBitmap(
(display.width() - LOGO_WIDTH ) / 2,
(display.height() - LOGO_HEIGHT) / 2,
logo_bmp, LOGO_WIDTH, LOGO_HEIGHT, 1);
display.display();
delay(1000);
}
If I populate the array beforehand and get rid of the for loop in setup, the image displays fine.
I would appreciate any suggestions.