简体   繁体   中英

how to display bold character in lcd

I'm working on project which needs to display some string on lcd.

I created 2d-array having hex values corresponding to each characters which is working fine. But I am unable to figure outhow to display some character in BOLD.

char pixel[10][5] = { 
  {0x7E, 0x11, 0x11, 0x11, 0x7E},  // hex values to display A
  {0x7F, 0x49, 0x49, 0x49, 0x36}   //hex values to display B
};

using these hex value I get A and B on lcd display . But I need to display A and B (in bold).

It looks like your pixel array contains pixel columns for a 5x7 or 5x8 character matrix with the lowest bit in the top line and the left column first.

The two lines seem to produce

.XXX. = bit x1
X...X = bit x2
X...X = bit x4
X...X = bit x8
XXXXX = bit 1x
X...X = bit 2x
X...X = bit 4x
..... = bit 8x

and

XXXX.
X...X
X...X
XXXX.
X...X
X...X
XXXX.
.....

To get bold characters you have to think about how these should be displayed. In a 5x7 matrix it might not be possible to display all letters in bold, eg M . For A and B you could try to use patterns/numbers for patterns like this:

.XXX.
XX.XX
XX.XX
XX.XX
XXXXX
XX.XX
XX.XX
.....

{0x7E, 0x7F, 0x11, 0x7F, 0x7E}

or

XXXX.
XX.XX
XX.XX
XXXX.
XX.XX
XX.XX
XXXX.
.....

{0x7F, 0x7F, 0x49, 0x7F, 0x36}

Automatic generation of bold characters

It is possible to automatically generate the font (character generator) for bold characters from the regular one if you have enough background pixels between the character pixels by shifting the dots to the right by one and using an combining original and shifted values with bitwise or .

This automatic generation for fixed width characters may be difficult for characters with 3 vertical lines because you would need 9 pixels for this to have 1 column for the inter-character space. A simple algorithm could clear the rightmost column if you want to have 8 pixels width, but manual modification might produce nicer results.

Example M regular

X.....X..
XX...XX..
X.X.X.X..
X..X..X..
X..X..X..
X..X..X..
X..X..X..

M shifted to the right

.X.....X.
.XX...XX.
.X.X.X.X.
.X..X..X.
.X..X..X.
.X..X..X.
.X..X..X.

M bitwise or

XX....XX.
XXX..XXX.
XXXXXXXX.
XX.XX.XX.
XX.XX.XX.
XX.XX.XX.
XX.XX.XX.
.........

M bitwise or, last column cleared

XX....X.
XXX..XX.
XXXXXXX.
XX.XX.X.
XX.XX.X.
XX.XX.X.
XX.XX.X.
........

A handmade correction for 8x8 looks nicer

XX...XX.
XXX.XXX.
XXXXXXX.
XX.X.XX.
XX.X.XX.
XX.X.XX.
XX.X.XX.
........

A library for LCD probably contains a font table. Maybe there are already existing libraries that support bold characters.

A search for "arduino lcd bold" brought this top result: https://forum.arduino.cc/index.php?topic=458712.0

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM