Unicode chars on LCD Pi Plate?

Moderators: adafruit_support_bill, adafruit

Forum rules
Talk about Adafruit Raspberry Pi® accessories! Please do not ask for Linux support, this is for Adafruit products only! For Raspberry Pi help please visit: http://www.raspberrypi.org/phpBB3/
Locked
User avatar
heres2it
 
Posts: 1
Joined: Wed Jan 15, 2014 12:26 am

Unicode chars on LCD Pi Plate?

Post by heres2it »

Is it possible to display unicode characters using the Adafruit_CharLCDPlate object? I'd like to display the symbols for suits of playing cards, i.e. '\u2660', '\u2663', '\u2665', and '\u2666'. I tried using something like lcd.message('\u2660') where "lcd" has been initialized as an Adafruit_CharLCDPlate object, but it's not working as expected. If it is possible how would I send these character codes to the LCD to see symbols representing suits of playing cards? Thanks!!

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: Unicode chars on LCD Pi Plate?

Post by adafruit_support_rick »

The LCD has an 8-bit character rom, as documented in the data sheet (you probably have the A00 ROM, on page 17)
http://www.adafruit.com/datasheets/HD44780.pdf
The chip does allow up to 8 user-defined characters. Details of creating and uploading characters are in the data sheet.

User avatar
lbendlin
 
Posts: 50
Joined: Thu Nov 14, 2013 11:41 pm

Re: Unicode chars on LCD Pi Plate?

Post by lbendlin »

I have had a similar issue with umlauts and special ANSI characters, I ended up writing a small library that created custom characters on the fly as needed. The one issue I noticed is that character 0 cannot be used as that is the end of file/field marker in the text display driver. This leaves you with seven usable custom characters, and I have yet to see a situation where I have to replace more than that for a 32 digit string. not sure about your playing card situation though.

You will have to recreate the bitmaps yourself though.

SEALen
 
Posts: 8
Joined: Sat Jan 11, 2014 12:12 pm

Re: Unicode chars on LCD Pi Plate?

Post by SEALen »

Ok, I'm new to Phyton and want to add to the Adafruit_CharLCDPlate.py test code.

I want to write the ° sign (Degree sign, the small circle after temperatures). It's in the HD44780 A00 chart at position 1101,1111 but how do I know what char in a normal text file corresponds to that? Alot of trial and error? Or is there some smarter way?

I got this code to print the current time and temps from a file on the LCD.
The temps.txt is created and updated by a LUA script run by Domoticz.

Code: Select all

    while True:

        sleep(1)
        tempraturstr = open('/home/pi/Adafruit-Raspberry-Pi-Python-Code/Adafruit_CharLCDPlate/temps.txt', 'r').read()
        lcd.clear()
        lcd.message(datetime.datetime.now().strftime("%H:%M:%S") + ' ' + tempraturstr)
The temps.txt contains for example:

Code: Select all

U:4.7'C
I:22,7'C
I would like to replace that ' with the ° sign instead somehow. It does not need to be in the temps.txt file as I control all that is written to it too.

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: Unicode chars on LCD Pi Plate?

Post by adafruit_support_rick »

The character position is 1101,1111 = 0xDF, so the character code you use is 0xDF.

SEALen
 
Posts: 8
Joined: Sat Jan 11, 2014 12:12 pm

Re: Unicode chars on LCD Pi Plate?

Post by SEALen »

But there is no 0xDF char that I can send. Anything above 0x7F is 16 bits long in unicode and that will become two chars on the display.
Can I send 0xDF some other way in a string? Is there a hex to sting function?

SEALen
 
Posts: 8
Joined: Sat Jan 11, 2014 12:12 pm

Re: Unicode chars on LCD Pi Plate?

Post by SEALen »

Well, I finally managed to do this. I used a char x60 (´) in the temps.txt file that I probably never use myself and replace it with the xDF one.

Code: Select all

    while True:

        sleep(1)
        tempraturstr = open('/home/pi/Adafruit-Raspberry-Pi-Python-Code/Adafruit_CharLCDPlate/temps.txt', 'r').read()
        temp = tempraturstr.replace('`' ,'\xdf')

        lcd.clear()
        lcd.message(datetime.datetime.now().strftime("%H:%M:%S") + ' ' + temp)

Locked
Forum rules
Talk about Adafruit Raspberry Pi® accessories! Please do not ask for Linux support, this is for Adafruit products only! For Raspberry Pi help please visit: http://www.raspberrypi.org/phpBB3/

Return to “Adafruit Raspberry Pi® accessories”