better way to achieve newline in oled than this code

this function add newline based on the chars length but i am sure there is a better way to achieve this with alot less space any idea?

void displaynow(String content){

if (content.length() <= 13){

  oled.print(content);
 
        }
        else if(14 <= content.length() &&  content.length() <= 26){

  oled.print(content.substring(0, 12));
  oled.setCursor(0,2);
        oled.print(content.substring(12, 26));  
        }else if (27 <= content.length() &&  content.length() <= 40){

  oled.print(content.substring(0, 12));
  oled.setCursor(0,2);
    oled.print(content.substring(12, 26));
      oled.setCursor(0,4);
      oled.print(content.substring(26, 40));    
        }
        else if (41 <= content.length() &&  content.length() <= 54){

  oled.print(content.substring(0, 12));
  oled.setCursor(0,2);
    oled.print(content.substring(12, 26));
      oled.setCursor(0,4);
      oled.print(content.substring(26, 40));
      oled.setCursor(0,6);
      oled.print(content.substring(40, 54));
        }
        
    delay(8000); 
  
}

I refuse to read anything with such crazy indenting.

maxwe11: this function add newline based on the chars length but i am sure there is a better way to achieve this with alot less space any idea?

Not familiar with the library you're using, but if it's written correctly, then you should be able to print something, then go to the next line like this:

Where you have "[b]oled.print (.....)[/b]", change it to "[b]oled.print[color=red]ln[/color] (.....)[/b]".

Hope this helps.

oled.setCursor(0,2);

Newline ! WTF!

Mark

@krupski thanks man u gave me the hint i worked on the rest of the code. so much appreciate it.

maxwe11: @krupski thanks man u gave me the hint i worked on the rest of the code. so much appreciate it.

You're most welcomed. Glad I could be of help.