"PS2Keyboard Library" - Problem with LCD Output for german special Characters
Hello to the Forum,
i am new to this forum, and i need your help for my following, hopefully understandable described problem, with Pauls "PS2Keyboard Library" in conjunction with a german PS/2 Keyboard.
What i want to do:
---------------------
Build a ARDUINO controlled "German Text-System with LCD-Display" to display static or random Alarm-Text, Menu-Text, etc.
- create text
- store created text in eeprom
- edit/change text on demand (characters, words, sentences)
- store edited text in eeprom
- display text during text creation on lcd-display
- display text during editing on lcd-display
- grab text fromm eeprom during runtime and display text on lcd-display
Hardware:
------------
- ARDUINO UNO
- Standard German PS/2 Keyboard
- either 16 x 2 LCD with Standard HITACHI 44780 Character Codes and Character Patterns (ROM Code: A00)
- or 20 x 2, 16 x 4, 20 x 4 LCD with Standard HITACHI 44780 Character Codes and Character Patterns (ROM Code: A00 or A02)
Software:
-----------
- ARDUINO 1.0.3 IDE
- PS2Keyboard 2.4 Library
- ARDUINO Sketch with "PS2Keymap_German"
Preparations:
---------------
First check availability for german Characters "ß", "ä", "Ä", "ö", "Ö", "ü", "Ü", "€" in LCD Character Codes and Character Patterns for ROM Code A00 and A02
ROM Code A00: http://html.alldatasheet.com/html-pdf/63673/HITACHI/HD44780/4262/17/HD44780.html
ROM Code A02: http://html.alldatasheet.com/html-pdf/63673/HITACHI/HD44780/4513/18/HD44780.html
- ROM Code A00 has characters for "ß", "ä", "ö", "ü"
- ROM Code A00 has no characters for "Ä", "Ö", "Ü" (capital Umlaute characters) and no character for "€" (EURO currencs character)
- ROM Code A02 has characters for "ä", "Ä", "ö", "Ö", "ü", "Ü"
- ROM Code A02 has no characters for "ß" (german special character) and no character for "€" (EURO currencs character)
Please note:
--------------
Since i use a 16 x 2 LCD with ROM Code A00 i have to customize my code to this LCD, which means:
- generally you can create up to 8 own characters max.
- i have to create the missing characters for "€", "Ä", "Ö", "Ü" by myself
Now create the missing characters in the ARDUINO code for "€", "Ä", "Ö", "Ü"
---------------------------------------------------------------------------------------
// create lcd-characters for german special characters
// EURO-Zeichen € (Euro currency symbol)
byte euro[8] = {
B00110,B01001,B11110,B01000,
B11110,B01001,B00110,B00000
};
// Ä-Zeichen, großes Ä (capital letter Ä)
byte A_umlaut[8] = {
B01010,B00100,B01010,B10001,
B11111,B10001,B10001,B00000
};
// Ö-Zeichen, großes Ö (capital letter Ö)
byte O_umlaut[8] = {
B01010,B01110,B10001,B10001,
B10001,B10001,B01110,B00000
};
// Ü-Zeichen, großes Ü (capital letter Ü)
byte U_umlaut[8] = {
B01010,B10001,B10001,B10001,
B10001,B10001,B01110,B00000
};
Find the LCD ROM Code A00 Addresses (in BIN) for "ß", "ä", "ö", "ü"
-----------------------------------------------------------------------------
- "ß" = 11100010 = 226
- "ä" = 11100001 = 225
- "ö" = 11101111 = 239
- "ü" = 11110101 = 245
Find the libraries key-code output for a. m. characters in the ARDUINO Serial Monitor
------------------------------------------------------------------------------------------------
// ARDUINO test snippet code for key-codes
void loop() {
if (keyboard.available()) {
// DEC code of the character
int key = keyboard.read();
....
....
// DEC character code control output for serial monitor
Serial.println(key);
delay(20);
}
}
Character dependency table
--------------------------------
char! Library Constant ! Serial Monitor Output ! LCD ROM Code A00 Addresses
-----!-------------------------------------------!-------------------------!--------------------------------------
"ß" ! #define PS2_SHARP_S 223 ! 159 ! 226
"ä" ! #define PS2_a_DIAERESIS 228 ! 164 ! 225
"Ä" ! #define PS2_A_DIAERESIS 196 ! 132 ! custom created character
"ö" ! #define PS2_o_DIAERESIS 246 ! 182 ! 239
"Ö" ! #define PS2_O_DIAERESIS 214 ! 150 ! custom created character
"ü" ! #define PS2_u_DIAERESIS 252 ! 188 ! 245
"Ü" ! #define PS2_U_DIAERESIS 220 ! 156 ! custom created character
"€" ! #define PS2_CURRENCY_SIGN 164 ! 164 ! custom created character
Attention Paul Stoffregen:
The PS2_CURRENCY_SIGN is defined as "¤", and not "€"! Is that by error or by purpose? Please explain!
In the a. m. "Character dependency table" you can see the first problem:
character "ä" and character "€" do have the same "Serial Monitor Output" (key-code 164). Consequently they collide, which results in pressing "€" key will display character "ä" instead of character "€"!
My simple function to map the key-codes (Serial Monitor Output) to the corresponding LCD ROM Code A00 Addresses
---------------------------------------------------------------------------------------------------------------
// function - get character and DEC key-code and return the
// appropriate lcd address for the german special characters/Umlaute
uint8_t germanSpecialCharacters(int c, int key) {
// check key-codes for ß(159), ä(164), Ä(132), ö(182), Ö(150), ü(188), Ü(156), €(164)
if (key == 159 || key == 164 || key == 132 || key == 182 || key == 150 || key == 188 || key == 156) {
switch(key) {
case 159:
c = uint8_t(226); // ß
return c;
break;
case 164:
c = uint8_t(225); // ä - conflicts with €-key and €-key conflicts with LEFTARROW-key
return c;
break;
case 132:
c = uint8_t(1); // Ä - conflicts with TAB-key
return c;
break;
case 182:
c = uint8_t(239); // ö
return c;
break;
case 150:
c = uint8_t(2); // Ö - conflicts with DOWNARROW-key
return c;
break;
case 188:
c = uint8_t(245); // ü
return c;
break;
case 156:
c = uint8_t(3); // Ü - conflicts UPARROW-key
return c;
break;
}
}
}
Test result:
------------
It seams, that i can control "ß" with key-code 159, "ö" (lowercase) with key-code 182, and "ü" (lowercase) with key-code 188 without conflicts. At least my tests didn't show me any collissions with other characters!
But for "Ä", "Ö", "Ü", "€", "ä" conflicts exists as following:
- "Ä" --> conflicts with TAB key (if i press TAB key "Ä" is displayed)
- "Ö" --> conflicts with DOWNARROW (if i press DOWNARROW key "Ö" is displayed)
- "Ü" --> conflicts with UPARROW (if i press UPARROW key "Ü" is displayed)
- "€" --> conflicts with LEFTARROW (if i press LEFTARROW key "€" is displayed)
- "€" --> conflicts with "ä" (if i press AltGr+E for "€" character "ä" will be displayed instead of "€")
Summary
-------
The character dependency between library key-code for "ß", "ö", "ü" output and ROM Code A00 seems to be OK. Mapping 159 to 226 for "ß", 182 to 239 for "ö", and 188 to 245 for "ü" seems to be OK. So far i didn't find any character conflicts.
The custom created charaters for "Ä", "Ö", "Ü", "€" will be displayed correctly too, but they have conflicts as a. m. with other keys, which means:
- the "PS2Keyboard" library produces for the concerned characters the same key-codes!?
Solution
--------
- for each a. m. pressed character key you need a unique key code, which only exists once, no matter which other key on the german ps/2 keyboard one will press!
Please help to find the german key-code problem so i can check in a "switch-case" statement for a unique key-code, and map this key-code to the appropriate lcd rom code.
Many thanks in advance, and best
Regards from Germany
rab
Hello to the Forum,
i am new to this forum, and i need your help for my following, hopefully understandable described problem, with Pauls "PS2Keyboard Library" in conjunction with a german PS/2 Keyboard.
What i want to do:
---------------------
Build a ARDUINO controlled "German Text-System with LCD-Display" to display static or random Alarm-Text, Menu-Text, etc.
- create text
- store created text in eeprom
- edit/change text on demand (characters, words, sentences)
- store edited text in eeprom
- display text during text creation on lcd-display
- display text during editing on lcd-display
- grab text fromm eeprom during runtime and display text on lcd-display
Hardware:
------------
- ARDUINO UNO
- Standard German PS/2 Keyboard
- either 16 x 2 LCD with Standard HITACHI 44780 Character Codes and Character Patterns (ROM Code: A00)
- or 20 x 2, 16 x 4, 20 x 4 LCD with Standard HITACHI 44780 Character Codes and Character Patterns (ROM Code: A00 or A02)
Software:
-----------
- ARDUINO 1.0.3 IDE
- PS2Keyboard 2.4 Library
- ARDUINO Sketch with "PS2Keymap_German"
Preparations:
---------------
First check availability for german Characters "ß", "ä", "Ä", "ö", "Ö", "ü", "Ü", "€" in LCD Character Codes and Character Patterns for ROM Code A00 and A02
ROM Code A00: http://html.alldatasheet.com/html-pdf/63673/HITACHI/HD44780/4262/17/HD44780.html
ROM Code A02: http://html.alldatasheet.com/html-pdf/63673/HITACHI/HD44780/4513/18/HD44780.html
- ROM Code A00 has characters for "ß", "ä", "ö", "ü"
- ROM Code A00 has no characters for "Ä", "Ö", "Ü" (capital Umlaute characters) and no character for "€" (EURO currencs character)
- ROM Code A02 has characters for "ä", "Ä", "ö", "Ö", "ü", "Ü"
- ROM Code A02 has no characters for "ß" (german special character) and no character for "€" (EURO currencs character)
Please note:
--------------
Since i use a 16 x 2 LCD with ROM Code A00 i have to customize my code to this LCD, which means:
- generally you can create up to 8 own characters max.
- i have to create the missing characters for "€", "Ä", "Ö", "Ü" by myself
Now create the missing characters in the ARDUINO code for "€", "Ä", "Ö", "Ü"
---------------------------------------------------------------------------------------
// create lcd-characters for german special characters
// EURO-Zeichen € (Euro currency symbol)
byte euro[8] = {
B00110,B01001,B11110,B01000,
B11110,B01001,B00110,B00000
};
// Ä-Zeichen, großes Ä (capital letter Ä)
byte A_umlaut[8] = {
B01010,B00100,B01010,B10001,
B11111,B10001,B10001,B00000
};
// Ö-Zeichen, großes Ö (capital letter Ö)
byte O_umlaut[8] = {
B01010,B01110,B10001,B10001,
B10001,B10001,B01110,B00000
};
// Ü-Zeichen, großes Ü (capital letter Ü)
byte U_umlaut[8] = {
B01010,B10001,B10001,B10001,
B10001,B10001,B01110,B00000
};
Find the LCD ROM Code A00 Addresses (in BIN) for "ß", "ä", "ö", "ü"
-----------------------------------------------------------------------------
- "ß" = 11100010 = 226
- "ä" = 11100001 = 225
- "ö" = 11101111 = 239
- "ü" = 11110101 = 245
Find the libraries key-code output for a. m. characters in the ARDUINO Serial Monitor
------------------------------------------------------------------------------------------------
// ARDUINO test snippet code for key-codes
void loop() {
if (keyboard.available()) {
// DEC code of the character
int key = keyboard.read();
....
....
// DEC character code control output for serial monitor
Serial.println(key);
delay(20);
}
}
Character dependency table
--------------------------------
char! Library Constant ! Serial Monitor Output ! LCD ROM Code A00 Addresses
-----!-------------------------------------------!-------------------------!--------------------------------------
"ß" ! #define PS2_SHARP_S 223 ! 159 ! 226
"ä" ! #define PS2_a_DIAERESIS 228 ! 164 ! 225
"Ä" ! #define PS2_A_DIAERESIS 196 ! 132 ! custom created character
"ö" ! #define PS2_o_DIAERESIS 246 ! 182 ! 239
"Ö" ! #define PS2_O_DIAERESIS 214 ! 150 ! custom created character
"ü" ! #define PS2_u_DIAERESIS 252 ! 188 ! 245
"Ü" ! #define PS2_U_DIAERESIS 220 ! 156 ! custom created character
"€" ! #define PS2_CURRENCY_SIGN 164 ! 164 ! custom created character
Attention Paul Stoffregen:
The PS2_CURRENCY_SIGN is defined as "¤", and not "€"! Is that by error or by purpose? Please explain!
In the a. m. "Character dependency table" you can see the first problem:
character "ä" and character "€" do have the same "Serial Monitor Output" (key-code 164). Consequently they collide, which results in pressing "€" key will display character "ä" instead of character "€"!
My simple function to map the key-codes (Serial Monitor Output) to the corresponding LCD ROM Code A00 Addresses
---------------------------------------------------------------------------------------------------------------
// function - get character and DEC key-code and return the
// appropriate lcd address for the german special characters/Umlaute
uint8_t germanSpecialCharacters(int c, int key) {
// check key-codes for ß(159), ä(164), Ä(132), ö(182), Ö(150), ü(188), Ü(156), €(164)
if (key == 159 || key == 164 || key == 132 || key == 182 || key == 150 || key == 188 || key == 156) {
switch(key) {
case 159:
c = uint8_t(226); // ß
return c;
break;
case 164:
c = uint8_t(225); // ä - conflicts with €-key and €-key conflicts with LEFTARROW-key
return c;
break;
case 132:
c = uint8_t(1); // Ä - conflicts with TAB-key
return c;
break;
case 182:
c = uint8_t(239); // ö
return c;
break;
case 150:
c = uint8_t(2); // Ö - conflicts with DOWNARROW-key
return c;
break;
case 188:
c = uint8_t(245); // ü
return c;
break;
case 156:
c = uint8_t(3); // Ü - conflicts UPARROW-key
return c;
break;
}
}
}
Test result:
------------
It seams, that i can control "ß" with key-code 159, "ö" (lowercase) with key-code 182, and "ü" (lowercase) with key-code 188 without conflicts. At least my tests didn't show me any collissions with other characters!
But for "Ä", "Ö", "Ü", "€", "ä" conflicts exists as following:
- "Ä" --> conflicts with TAB key (if i press TAB key "Ä" is displayed)
- "Ö" --> conflicts with DOWNARROW (if i press DOWNARROW key "Ö" is displayed)
- "Ü" --> conflicts with UPARROW (if i press UPARROW key "Ü" is displayed)
- "€" --> conflicts with LEFTARROW (if i press LEFTARROW key "€" is displayed)
- "€" --> conflicts with "ä" (if i press AltGr+E for "€" character "ä" will be displayed instead of "€")
Summary
-------
The character dependency between library key-code for "ß", "ö", "ü" output and ROM Code A00 seems to be OK. Mapping 159 to 226 for "ß", 182 to 239 for "ö", and 188 to 245 for "ü" seems to be OK. So far i didn't find any character conflicts.
The custom created charaters for "Ä", "Ö", "Ü", "€" will be displayed correctly too, but they have conflicts as a. m. with other keys, which means:
- the "PS2Keyboard" library produces for the concerned characters the same key-codes!?
Solution
--------
- for each a. m. pressed character key you need a unique key code, which only exists once, no matter which other key on the german ps/2 keyboard one will press!
Please help to find the german key-code problem so i can check in a "switch-case" statement for a unique key-code, and map this key-code to the appropriate lcd rom code.
Many thanks in advance, and best
Regards from Germany
rab