Report
1 year, 1 month ago.

How to show a highlighted text? LCD 16x2

Hello has all, I wish to invert the bits of a chain(channel) of tank to post(show) him(it) highlighted, Here is my basic code for afin my text:

#include "TextLCD.h"
#include <mbed.h>

TextLCD lcd(PTC17, PTA16, PTA17, PTE31, PTD6, PTD7, TextLCD::LCD16x2); // rs, e, d4-d7, LCDType

char chaine[] = "Salut";

int main()
{
    while(1)
    {
        lcd.locate(0,1); 
        lcd.printf("%d", chaine);
    }
}

How I can make? Thank you

Comment on this question

1 Answer

1 year, 1 month ago.

Hello Antoine,

the standard HD44780 LCD controller does not support ''inverted'' characters (ie black->white, and white->black). There are some options:

  • Find a display that inverts the image. You need a display with a backlight that shows white characters and has a dark background. The character color could also be red, green etc depending on the type of LED backlight. Note that all characters will have the same color. So probably not what you are looking for.
  • You could prepare some user defined characters (UDC) that are the inverse of the regular fontset. There are a maximum of 8 different characters possible for most controllers (some support 16). You can redefine the UDCs on the fly for different text messages.

See my TextLCD lib for some images of inverted (white on blue) and UDC examples.

Some more recent clones of the HD44780 do support inverted characters, but typically the whole display will be inverted. So again you cant really highlight only part of the text. The ''setInvert()'' method is supported in the TextLCD lib for some HD44780 compatible devices (eg KS0073). You will need to find the right display type, select the correct controller for the TextLCD instantiation and activate this feature in the ''TextLCD_Config.h'' file.

BTW. There is an error in your code. It should be

...
lcd.printf("%s", chaine);
...


To post an answer, please log in.