Pages: [1]   Go Down
Author Topic: åäö with LiquidCrystalLCD  (Read 477 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 39
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello. im writing a code that needs to be in swedish, therefore i need to use "åäö".
Now, when I write out  "åäö" i get something totaly different than i expected.

here is a test that only give me Test and then japanese signs on the display.
Any ideas?

Code:
#include <LiquidCrystal.h> // for LCD display
 LiquidCrystal lcd(12, 11, 10, 9, 8, 7, 6);
 int backLight = 13;    // pin 13 will control the backlight

 String message=" Test åäö ÅÄÖ ";
  lcd.begin(20, 4);           
  lcd.setCursor(0,0);
  lcd.print(message);
Logged

The Netherlands
Offline Offline
Edison Member
*
Karma: 35
Posts: 1293
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You should use a LCD that has a ROM containing those characters, or make your own characters.
Most ROMs used, have Japanese (i guess) characters instead of the ones you like to have.
So it would be better to define your own characters.
If i'm not mistaking, you have 8 programmable characters so you are limited here.
Logged

Have a look at "blink without delay".
Did you connect the grounds ?
Je kunt hier ook in het Nederlands terecht: http://arduino.cc/forum/index.php/board,77.0.html

Israel
Offline Offline
Sr. Member
****
Karma: 4
Posts: 277
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I'll second what MAS3 said.
I'm not familiar with the Swedish alphabet, but if there are 8 or less non-English characters, you can create your own custom chars and keep using your current LCD.
If there are more than 8, the you will have to find an LCD which contains the Swedish alphabet.
Logged


Offline Offline
Newbie
*
Karma: 0
Posts: 39
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

there are only 3 extra, so i need 6(for capital and regular letters) so it would be possible to make the special signs yourself.

Anyone got a link to where i can find an example how to do this?
I have already bought 4 displays of the same kind, feels silly to toss them due to this problem:)

thank you.. found a link over how to do this:) will be fun to see if i get it to work:) problems are there to be solved! right? smiley-grin

For reference for others: here is a guide over how to make your own signs:
http://arduino.cc/en/Reference/LiquidCrystalCreateChar

Logged

Israel
Offline Offline
Sr. Member
****
Karma: 4
Posts: 277
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Yes, it should be easily possible.
I use this tiny program to make my custom characters.
http://dlnmh9ip6v2uc.cloudfront.net/datasheets/LCD/Monochrome/HD44780CCGV1001.zip
Logged


Offline Offline
Newbie
*
Karma: 0
Posts: 39
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I made a function that makes the ones I want. the problem is, that they can only be fitted into the first 8 slots of the chart of caracters. that means that i also have to build some clever function that searches and replaces all this chars before i print them out to the lcd.. How could would it have been if you could have changed them all? you could make your own font smiley or bricks for a game or something like that...

anyway.. if someone from sweden needs this function, here it is..

(just call the function below somewere inside your setup().)

Code:
void createSweCaracters(){

 byte AwithRing[8] = {
  B00100,
  B01010,
  B01110,
  B00001,
  B01111,
  B10001,
  B01111,
  };
  
  byte AwithDots[8] = {
  B01010,
  B00000,
  B01110,
  B00001,
  B01111,
  B10001,
  B01111,
  };
  
  byte OwithDots[8] = {
  B01010,
  B00000,
  B01110,
  B10001,
  B10001,
  B10001,
  B01110,
  };
  
  byte CapitalAwithRing[8] = {
  B00100,
  B01010,
  B01110,
  B10001,
  B11111,
  B10001,
  B10001,
  };
  
  byte CapitalAwithDots[8] = {
  B01010,
  B00000,
  B01110,
  B10001,
  B11111,
  B10001,
  B10001,
  };
  
  byte CapitalOwithDots[8] = {
  B01010,
  B00000,
  B01110,
  B10001,
  B10001,
  B10001,
  B01110,
  };
  
  lcd.createChar(1, AwithRing);
  lcd.createChar(2, AwithDots);
  lcd.createChar(3, OwithDots);
  lcd.createChar(4, CapitalAwithRing);
  lcd.createChar(5, CapitalAwithDots);
  lcd.createChar(6, CapitalOwithDots);

}

after that you can use
 lcd.write(1);
  lcd.write(2);
  lcd.write(3);
  lcd.write(4);
  lcd.write(5);
  lcd.write(6);
to print them out to your display...
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 39
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hmm..

tried to make a String with some testtext..

Code:
String message=" Test åäö ÅÄÖ ";
message=message.replace("å", byte(1));
message=message.replace("ä", byte(2));
message=message.replace("ö", byte(3));
lcd.print(message);

gave me an error:
error: call of overloaded 'replace(const char [3], byte)' is ambiguous

Ideas over how to get this to work? I need to make a function that does this, as there are alot of texts(lists of names from SDcard) and they all need to be checked for swedish letters.
Logged

Israel
Offline Offline
Sr. Member
****
Karma: 4
Posts: 277
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

You're replacing a character, not a string, so change "x" to 'x'.
Logged


Offline Offline
Newbie
*
Karma: 0
Posts: 39
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

DOhh...
Thank you..
Logged

Western New York, USA
Offline Offline
Faraday Member
**
Karma: 25
Posts: 4108
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Hello. im writing a code that needs to be in swedish, therefore i need to use "åäö".

Quote
You should use a LCD that has a ROM containing those characters ...

Actually the most common HD44780U ROM (A00) contains two of those characters already.  You can display ä by using 0xe1 and you can display ö by using 0xef.

Don
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 39
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I have made my own library that parses in this caracters now, not the "best" way to do it, but the most fun anyway:)

Buying a cheap Chinese display is better in the end for me, and i got it to work in the end.. smiley
Logged

Pages: [1]   Go Up
Jump to: