STM32F746NG-DISCO: LCD sometimes displays garbled text

12 Feb 2018

I sometimes get garbled text when using f.ex.

lcd.DisplayStringAt(0, LINE(5), (uint8_t *)my_str, CENTER_MODE);

Sometimes the text is cut short.

Please see attached image. This is probably user error somehow but I don't know how to make DisplayString work reliably. The garbling does not happen every time and some runs (after hw reset, button) run just fine, text is ok. Then next ones show the garbled text.

I am puzzled. Please see attached images, showing OK text, cut text?? and garbled text and garbled as zoomed.

My code snippet

...
    lcd.Clear(LCD_COLOR_BLACK);
    lcd.SetBackColor(LCD_COLOR_BLACK);
    lcd.SetTextColor(LCD_COLOR_WHITE);
    lcd.SetFont(&Font16);

    wait(3);
   
    pc.printf("Starting... \r\n");
    
    wp=&DataBuffer[0];
    old_wp=&DataBuffer[0];
    
    lcd.ClearStringLine(5);   
    success=snprintf(my_str, 50,"\0");
    lcd.DisplayStringAt(0, LINE(5), (uint8_t *)my_str, CENTER_MODE);
    wait_ms(1);

    lcd.ClearStringLine(5);   
    success=snprintf(my_str, 50,"Starting in 3... \0\0\0");
    lcd.DisplayStringAt(0, LINE(5), (uint8_t *)my_str, CENTER_MODE);
    wait_ms(1000);
    
    lcd.ClearStringLine(5);
    success=snprintf(my_str, 50,"Starting in 2... \0\0\0");
    lcd.DisplayStringAt(0, LINE(5), (uint8_t *)my_str, CENTER_MODE);
    wait_ms(1000);
...
12 Feb 2018

How did you declare ''my_str" ?

Note that it should have room for at least 50 chars.

char my_str [50];

Also note that you dont really have to add the ''\0'' to the string as that is automatically added by "snprintf()".

See here for an example.

17 Feb 2018

Hi!

This works! Thank you very much!