solved: limited number of lines in adafruit sh1106 library ?

hi

i m using a 1.3"" oled diplay with ssh1106 adafruit lib
is the number of lines that can be printed limited ?

when i uncomment
// display.setCursor(5, 57);
//display.print(" PRESS SCAN BUTTON");
display is frozen and program stops

regards jean-marie

void scan() {

display.clearDisplay();
//display.drawPixel(40, 35,WHITE ); display.drawLine(2, 50, 110, 50,WHITE);
//display.drawPixel(60, 35,WHITE);
// display.display();delay(2000);
screenswitch = 1;
display.drawLine(7, 0, 10, 0, WHITE);//5
display.drawLine(7, 10, 10, 10, WHITE);//4
display.drawLine(7, 20, 10, 20, WHITE);//3
display.drawLine(7, 30, 10, 30, WHITE);//2
display.drawLine(7, 40, 10, 40, WHITE);//1
display.drawLine(10, 0, 10, 43, WHITE);
display.drawLine(7, 40, 110, 40, WHITE);
display.drawLine(20, 40, 20, 43, WHITE);
display.drawLine(30, 40, 30, 43, WHITE);
display.drawLine(40, 40, 40, 43, WHITE);
display.drawLine(50, 40, 50, 43, WHITE);
display.drawLine(60, 40, 60, 45, WHITE);
display.drawLine(70, 40, 70, 43, WHITE);
display.drawLine(80, 40, 80, 43, WHITE);
display.drawLine(90, 40, 90, 43, WHITE);
display.drawLine(100, 40, 100, 43, WHITE);
display.drawLine(110, 40, 110, 43, WHITE);
display.setCursor(0, 17); display.setTextSize(1);
display.print("3");
//display.setCursor(0, 2);
//display.print("5");
display.display();
display.setCursor(5, 50);

display.print("SWR "); display.print(VSWR, 1);
display.setCursor(65, 50);
display.print(freq / 1000);
// display.setCursor(5, 57);
//display.print(" PRESS SCAN BUTTON");
display.display(); //delay(2000);
freqmin = freq - 200000;
bestfreq = freqmin;
bestswr = 10;
VSWR = 3.5;
for (int i = 5; i < 105; i++)
{ display.drawPixel(5 + i, 50 - (VSWR * 10), WHITE);
display.display();
}

The "ssh1106 adafruit lib" is not written by Adafruit.
It was hacked from an early version of Adafruit_SSD1306 library.

Please paste / attach the complete sketch.
Please say where you obtained your "ssh1106 adafruit lib" e.g. link to GitHub, ...
Please say which Arduino target board e.g. Uno, Nano, ...

Adafruit_SSD1306 "crash" problems are normally due to the buffer memory being allocated at runtime. Which might not leave enough SRAM memory for your stack, variables, etc
The "hacked" Adafruit_SSH1106 library that I have seen allocates the buffer at compile-time.

David.

hi david

i use a arduino nano
i found this library on github

complete sketch in attach

after compiling i use 80% memory and 87% global variables

regards
jean-marie

AA_mini_adabib_werk4.ino (8.42 KB)

It looks like GitHub - wonho-maker/Adafruit_SH1106: Adafruit graphic library for SH1106 dirver lcds. is the commonly used library.
It should behave like the 5-year-old Adafruit_SSD1306 that it was "adapted" from.
i.e. the buffer is allocated at compile-time

after compiling i use 80% memory and 87% global variables

87% global variables is a bit risky.

You can reduce the SRAM usage by changing any display.print("anonymous text") into display.print(F("anonymous text"))
Likewise with display.println("anonymous text") into display.println(F("anonymous text"))

This will probably solve your problems.
Please report back.

David.

hi david

now i can add new text
global variables are now 85%

what does this F function do ?

jean-marie

The F() macro ensures that your "anonymous text" remains in Flash where it belongs.
The Arduino print functions handle it as a String from Flash

Otherwise "all text" gets copied to SRAM.
Since you can't access any of these anonymous strings in SRAM, the SRAM is just wasted.

I looked at your sketch. There was opportunity to reduce the SRAM use. 85% is safer than 87%.
The OLED buffer takes 50%. I don't see where you are using the other 35%
Unless the si5351 library has some BIG arrays.

Serial will use some SRAM. I would remove the Serial.begin() statement since you don't use Serial in your sketch. (unless the mystery si5351 library does)

David.

david

i removed the serial.begin
now i have 77% memory and 75% global variables
my si5351 (= frequency generator DDS)is still working

thanks for all your support

jean-marie