Go Down

Topic: OLED Display Makes The Code Stuck  (Read 159 times) previous topic - next topic

berkeozkir

May 15, 2019, 11:25 am Last Edit: May 15, 2019, 11:42 am by berkeozkir
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 :smiley-confuse: .


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*((sample*N1)-N2*N3)/(sample*D1 - D2*D2);       //set new value

GuitarPhil

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.

berkeozkir

#2
May 17, 2019, 10:14 pm Last Edit: May 17, 2019, 10:50 pm by berkeozkir
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!! :)

lancsdude

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?

jimLee

Quote
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
PNW Ardiuno & Maker club
1012 9Th Street, Anacortes, WA 98221 (Around the back of building)

Go Up