OLED Display Makes The Code Stuck

Hey! I am using 128x64 oled display with Adafruit_SSD1306 library.

Whenever i try to use this algorithm if I write display.print("something") , my code get stuck.

Without this algorithm display work perfectly.

I think this problem might be about sketch memory or oled buffer...
My sketch memory is %99 :confused: .

int sample=40;
int maxsample=50;
float alt[51];
float tim[51];

LOOP FUNCTION

float tempo=millis();

for(int i = 1 ; i <= maxsample ; i++){
alt[(i-1)]=alt*;*
tim[(i-1)]=tim*;*
};
alt[maxsample]=altitude; //altitude is variable from pressure sensor (pressure sensor works fine)!
tim[maxsample]=tempo;
float stime=tim[maxsample-sample];
float N1=0;
float N2=0;
float N3=0;
float D1=0;
float D2=0;
for(int i = (maxsample-sample) ; i < maxsample ; i++){
N1+=(tim_-stime)alt;
N2+=(tim-stime);
N3+=(alt);
D1+=(tim-stime)(tim*-stime);
D2+=(tim-stime);
};
float vario=0; // reset old value_

_vario=1000((sampleN1)-N2N3)/(sampleD1 - D2D2); //set new value_

You are probably running out of memory. The OLED library needs to set up a buffer for the whole screen which it then writes to the display when it's updated.

Thank You so much I couldn't have thought that. Now I have reduced the ram usage and it works like a charm.

Thanks Again!! :slight_smile:

Hello
My OLED is also freezing, working fine for a while then locking up fro no apparent reason.
My sketch only uses 52% programme memory and 14% of Dynamic memory
May I ask. what steps did you take to reduce the RAM?
Should I also be looking at hardware issues?

My OLED is also freezing, working fine for a while then locking up fro no apparent reason.

You allocating anything in memory? Sounds like pointer issues to me.

-jim lee