Mohsinsapraa / glcd-arduino

Automatically exported from code.google.com/p/glcd-arduino
0 stars 0 forks source link

Non ASCII Symbol support out of the box #44

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
I have been working on a compatibility sketch to run lcd smartie using the 
matrix orbitall driver. 

The only way of displaying the symbol is to add it to a font and call it 
directly using 

 GLCD.Puts((char)127); //Where 127 is the char number on my font.

Is there a way of exteding the library to support non ASCII characters and/or 
to draw freely any pixel of the display?

Original issue reported on code.google.com by ke...@kmai.com.ar on 28 Apr 2012 at 8:57

GoogleCodeExporter commented 8 years ago
I'm not sure what you are asking.
Puts() takes a pointer to a C string not a character value.
Maybe you meant PutChar() ?

Puts() and PutChar() paint glyphs based on an index value into the font 
provided.
The index can be any value between 1 and the maximum value supported by the font
with the exception of '\n' or 0x0a

Puts() uses a C string which is byte values up to a 0/NULL.

As far as drawing pixels, there are many API functions that provide support
for that. bitmaps, lines, circles, rectangles, even individual pixels so I'm
not sure what you are looking for.

See the included extensive documentation for the full list of API functions.

Original comment by bperry...@gmail.com on 29 Apr 2012 at 2:00

GoogleCodeExporter commented 8 years ago
Basically what I'm asking is how to include the non ASCII characters on fonts. 
with GLCD Font Creator 2, you need to add the characters by hand starting from 
U+00A0 (no break space) as you usually have a 32 char offset (from 0000 to 
001F) and then the ASCII characters. That means that besides ASCII, you need to 
draw all the rest by hand?

Is there a way of easy generating a range from the rest of the character map, 
instead of drawing all the accents? another problem I see is on how to map the 
font chars to the correct hex.

The  GLCD.Puts/Putchar is the only way I found to print the character, if I try 
using println or any string method, the character doesn't appear at all. Would 
it be possible to create a map of the font to assign unicode characters to 
glyphs on the font? That way, it'd be transparent to call special characters

Original comment by ke...@kmai.com.ar on 29 Apr 2012 at 3:20

GoogleCodeExporter commented 8 years ago
The glcd library uses a very simple approach to rendering glyphs in fonts.
It takes the 8 bit value and looks it up in the font data and then renders the
glyph. The library does no interpretation of any kind on the character value.
It could be ASCII or it might not be, it doesn't really care. It only only
knows how to render a character in a font based on the character value it is 
given.
The only limitation is that the character values are limited to 0-255.

Think of a font as a collection of glyphs or tiny bitmaps.
The character value is used to look up the glyph.

GLCD font creator lets you import any font on your machine to create a font 
file for the library.
The character "values" can start at pretty much anywhere including at 0 and go
as high as you like up to 255. 
Then to print the glyphs, it uses the characters value in the font.
For example, you can create a font with the glyphs for only the letters a-z.
You could assign the character glyphs to the values 0x61-0x7a, but you just as 
easily
could assign them 1-25
The difference is what value you use to print the glyph.

The library lets you include multiple fonts and define multiple text areas. 
Each text are can be assigned its own font and the font within a text area can 
be changed at any time.

println() calls write() which calls PutChar() so
if things are printing with PutChar() but not with println(),
then it sounds like something isn't working as it should.

Any kind of Unicode mapping or support will need to be done outside the glcd 
library as currently there is no support for Unicode in the Arduino Print class 
or in the glcd library.

Original comment by bperry...@gmail.com on 29 Apr 2012 at 6:54

GoogleCodeExporter commented 8 years ago
I know that I can create a font with symbols, but that still means that I need 
to switch between each font if I need to print a temperature, say 25°C or 
73°F?

On the other hand, is it possible to add support for MikroElektronika's GLCD 
Font Creator? http://www.mikroe.com/eng/products/view/683/glcd-font-creator/ 

An advantage I see on it, is that it renders not only the ASCII glyphs, but 
also special symbols, cleans each bitmap to reduce total font width/height.

It's output is pretty simmilar to the GLCD Font Creator 2 in Java that we're 
using, the only difference is that it doesn't create the following:

 *     uint16_t   font_Size_in_Bytes_over_all_included_Size_it_self;
 *     uint8_t    font_Width_in_Pixel_for_fixed_drawing;
 *     uint8_t    font_Height_in_Pixel_for_all_characters;
 *     unit8_t    font_First_Char;
 *     uint8_t    font_Char_Count;
 *     uint8_t    font_Char_Widths[font_Last_Char - font_First_Char +1];

Another thing I'd like to ask is, if there is any easy way of creating fixed 
width fonts.

Original comment by ke...@kmai.com.ar on 29 Apr 2012 at 6:51

GoogleCodeExporter commented 8 years ago
You can easily currently print a temperature like your example using a single 
font with the glcd library just
like you can with a standard hd44780 non glcd display. For temperatures all
you need is a font with numbers, the degree symbol, and "F" and "C".

Font data format is also very important. The data format from
that font creator tool differs by much more than just the header.
It also uses 16 bit words rather than 8 bit bytes and the bit/pixel ordering is 
not
always in the native glcd pixel order format so it requires runtime translation 
which while could be done, does not exist today in the glcd library.
When things get larger than 8 bits there are many alignment issues that also 
come into play. Like how to pad words and bytes when the pixel data doesn't use 
all the bits in the word/byte.
Then there are things like how/where to store glyph offsets and widths
Unfortunately, there is no real standard way of storing this stuff when it 
comes to embedded data structures for fonts and the original standardized font 
formats
don't often work very well for putting into C data structures.
So it is a bit of mess.

With respect to ASCII, the glcd library has no knowledge of ASCII. It simply
draws glyphs based on an 8 bit value that indexes into the font data. You are
free to create a set of glyphs with any patterns you want.

Unfortunately, today, the glcdfontcreator2 tool strips down each glyph to its
minimum width so it can't be used to create fixed width fonts.

All this kind of stuff is possible, but it isn't there today, As time goes
on maybe some of it will be rolled in. But remember the glcd library is 
currently
written to not only be very fast but to work with very small RAM footprints.
Many of the different types of rendering like rotated text and shifting
x/y origins and supporting LCDs with no read capability get much easier or 
become possible when there is a full frame buffer. I haven't yet decided to go 
down that path yet.

I looked at that tool in the past. I seem to recall that originally it wasn't 
free
and that the free version didn't create full font files. It seemed to create 
font files only up to some limited number of glyphs. Maybe that has changed.
I will also say that in general, I'm not a fan of tools that only work on 
Windows
as I don't want to force people to have to use Windows for anything.

In the mean time what could be done is to write a tool that converts a font 
file from
one of the GLCD FontCreator formats to a glcd library font.

Original comment by bperry...@gmail.com on 29 Apr 2012 at 8:38