Arduino: The Noiasca Liquid Crystal with Language Support
As you have seen, my Noiasca Liquid Crystal can print special characters on the LCD even if they are encode as multi byte UTF-8 characters. But as there are only some special characters available in the ROM of the HD44780 LCD, this will fail for several Latin characters with diacritic marks (acute, grave, breve...) like À Ç È some Japanese letters will be printed instead. To avoid this, I have prepared some converters to replace letters with such diacritic with their plain ASCII (lower ANSI) counterpart to keep your text readable.
An Example: if you would print the French letters to the LCD you might get something like:
The Power of Character Converter Callback
With the ASCII converter this print will get readable. To avoid letters with diacritic you can use a UTF-8 to ASCII converter.
The full mapping will take around 1500 bytes of program memory because we have 500 characters and each will take 3 bytes. If you only have the need of one (or some) languages it might be enough if you choose a smaller subset for your need.
To activate the ASCII Converter you add one further parameter to your lcd object. The last parameter is a callback function which will do this conversion. An example based on the I2C LCD constructor looks like:
LiquidCrystal_I2C lcd(addr, cols, rows, convert_ANSI); // create LCD object
See the sketch 5030_Convert_ANSI with several converters.
ASCII converter for European Language Families
As the full ASCII converter is quite large and might take around 1500 bytes of Arduino flash memory, I've added smaller converters specific for some language families (if several languages use similar diacritics) or single languages
First: Lets see the he supported language families
- North Germanic - gmq
- West Germanic - gmw
- Romance - roa
- Slavic - sla
North Germanic - gmq
North Germanic (gmq) includes Danish, Norwegian, Swedish, Faroese and Icelandic and can be converted using this parameter::
LiquidCrystal_I2C lcd(addr, cols, rows, convert_gmq); // create LCD object
West Germanic - gmw
West Germanic (gmw) includes Dutch, English, German, Scots, Frisian
LiquidCrystal_I2C lcd(addr, cols, rows, convert_gmw); // create LCD object
Please keep in mind, that for German, there are several specific converters available. Also the large Umlauts can be converted to real diacritic letters. German speaking users should check the German site also.
For English some deprecated letters are replaced to their plain ASCII representation:
The Dutch ij is not present in the ASCII code, nor in any of the ISO 8859 character encodings. Therefore, this digraph is most often encoded as an i followed by a j. And even you will find these ligatures at 0xc4b2 and 0xc4b3 it will be just replaced by I.
Romance Languages - roa
Portuguese, Spanish, Catalan, French, Italian, Romanian are examples for Romance languages. They need a lot of conversions (but still less more than the full ASCII converter):
LiquidCrystal_I2C lcd(addr, cols, rows, convert_roa); // create LCD object
Slavic Languages - sla
For the Slavic languages (sla) like Czech, Slovak, Polish, Bulgarian, Mazedonian, Serbian, Croatian, Bosnian, Montenegrin, Burgenland Croatian, Slovene you can use
LiquidCrystal_I2C lcd(addr, cols, rows, convert_sla); // create LCD object
Language Specific Character Settings
The smallest flash usage can be achieved with language specific mappings. They are available if there is a legit need or if a language doesn't fit well in one of the above language families.
- en - English - just as starting point with some deprecated English letters
- es - Spanish - will also include the characters for Catalan
- de - German - as it is my native language
- fr - French - lot of characters. So you still can use romance-roa instead
- fi - Finnish - this Uralic language doesn't fit to well into the existing language families
- hu - Hungarian - this Uralic language doesn't fit to well into the existing language families
Estonian (beside being a Uralic language) is best covered with the Romance LCD converter.
According to wikipedia: the official Estonian alphabet has 27 letters: A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, R, S, Š, Z, Ž, T, U, V, Õ, Ä, Ö, Ü. Occasionally, the alphabet is recited without them, and thus originally has only 23 letters: A, B, D, E, G, H, I, J, K, L, M, N, O, P, R, S, T, U, V, Õ, Ä, Ö, Ü.
The library contains an example how to implement a converter including support of the Õ using 5 special characters (Ä Ö Ü Õ õ).
French is included in the Romance language Family and there is also a separate French only converter available which needs less flash memory:
LiquidCrystal_I2C lcd(addr, cols, rows, convert_fr); // create LCD object
Finnish is an Uralic language, you can use a dedicated character converter. Most of the characters are replaced by their plain counterparts because only ä and ö can be found in the HD44780 ROM.
LiquidCrystal_I2C lcd(addr, cols, rows, convert_fi); // create LCD object
If you use 8 special characters you could program your own converter for full support. See the Swedish Example 5013_Convert_Swedish how to do that.
Any default constructor (without explicit callback) enables the support for the small letters ä ö ü and ß as these letters are in the ROM A00. The large German umlauts Ä Ö Ü will be converted to their counterpart A O U, as there are no capital Umlauts in the Standard HD44780 A00 Character set.
The convert_small will convert large Umlauts into small umlauts. This comes handy if you need the difference Umlaut/ASCII. The Umlauts O and U are just one pixel smaller, so the difference is not much if you want to write österreich or überraschungsei to the LCD. There a very view words in German starting with Ä.
LiquidCrystal_I2C lcd(addr, cols, rows, convert_small); // Ä --> ä
In German it is very common to replace an Umlaut with the ASCII letter followed by a small e. But be carefully, because the text will expand by this additional letter!
LiquidCrystal_I2C lcd(addr, cols, rows, convert_ae); // Ä --> Ae
And finally there is one converter which uses the last three custom characters (5,6 and 7) for the representation of Ä Ö Ü. You have to use the callback "convert_special"
LiquidCrystal_I2C lcd(addr, cols, rows, convert_special); // Ä --> Ä
Additionally you have to create these custom characters. This can be done with a simple call of one method in the setup():
lcd.createUml(); // create 3 German Umlauts using Special Characters 5, 6, and 7 - used for convert_special
For German specific sketches, see the examples 0x05_xxx_German_Umlaut.
Hungarian is an Uralic language, you can use dedicated character converters. Most of the characters are replaced by their plain counterparts.
LiquidCrystal_I2C lcd(addr, cols, rows, convert_hu); // create LCD object
For Swedish there is also an example with a converter for full support using special characters. See the Example 5013_Convert_Swedish to see how to write your very specific converter with special characters.
Gaj's Latin alphabet
For the Serbo Croatian languages the Gaj's Latin alphabet is covered within the Slavic converter:
LiquidCrystal_I2C lcd(addr, cols, rows, convert_sla); // create LCD object
lcd.print("ČčĐđŠšŽž"); // Gaj's Latin
The Example Sketch 5030_Convert_ANSI
Most of the examples were made with the sketch 5030_Convert_ANSI. First you have to define which converter should be used, than you have to activate the Hardware specific LCD object. After compilation and upload you can jump through the examples by a simple send within the serial monitor. As always, if you find a bug - please let me know. If the ASCII converter occupies to much memory, try a smaller variant fitting to your language.
With the additional language converters it becomes very easy to convert from letters with diacritic signs to the printable ASCII letters. If you are from an European country and you need better support of Latin1-4 letters you should consider to buy a SPLC780D1 LCD - which is also supported by this library.