Hi all,
I have been creating bitmaps on my colour OLED display with an Arduino Mega 2560 board. I recently encountered an problem where the OLED screen is appears completely black when the required program memory exceeds 70 kB.
The Arduino Mega 2560 has about 254 kB of flash memory so it should not have issues running the program. To determine whether the issue originates from the Arduino board or OLED display, I wrote a program shown below
#include <SPI.h>
#include <Adafruit_SSD1351.h>
#include <Adafruit_GFX.h>
#include "Drawing_Grayscale.h" // This header file contains the PROGMEM arrays of all the bitmaps
Adafruit_SSD1351 ucg = Adafruit_SSD1351(128,128,&SPI,47,48); // SCL = 52, SDA = 51, DC = 48, CS = 47
void setup() {
ucg.begin();
ucg.setRotation(1);
pinMode(16,OUTPUT); // Blinking LED to verify if the issue is from the display or Arduino Mega 2560
}
void loop() {
ucg.drawGrayscaleBitmap(0,0,landscape,128,128);
digitalWrite(16,HIGH);
delay(100);
digitalWrite(16,LOW);
ucg.drawGrayscaleBitmap(0,0,mono,128,128);
delay(100);
digitalWrite(16,HIGH);
ucg.drawGrayscaleBitmap(0,0,lego,128,128);
delay(100);
digitalWrite(16,LOW);
ucg.drawGrayscaleBitmap(0,0,gray,128,128);
delay(100);
}
Output message:
Sketch uses 76634 bytes (30%) of program storage space. Maximum is 253952 bytes.
Global variables use 239 bytes (2%) of dynamic memory, leaving 7953 bytes for local variables. Maximum is 8192 bytes.
When the program is uploaded, the LED does not flash and the SSD1351 screen appears black. If I comment out one of the 'drawGrayscaleBitmap' commands, the program runs as expected and the LED flashes. What could be causing this unusual problem?