16x2 LCD & custom Chars

EL Wire/Tape/Panels, LEDs, pixels and strips, LCDs and TFTs, etc products from Adafruit

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
dschu
 
Posts: 3
Joined: Tue Jan 29, 2013 7:13 am

16x2 LCD & custom Chars

Post by dschu »

Hello everybody!

I'm currently trying to create a custom character on my 16x2 LED Pi Plate with Adafruits CharLCDPlate Library (Python).
I found the following C code in the adurino forum and tried to rewrite it in python: http://arduino.cc/forum/index.php/topic,54411.0.html

What I've got is this:

Code: Select all

#!/usr/bin/python
# -*- coding: utf-8 -*-

from time import sleep
from Adafruit_CharLCDPlate import Adafruit_CharLCDPlate

# Initialize the LCD plate.  Should auto-detect correct I2C bus.  If not,
# pass '0' for early 256 MB Model B boards or '1' for all later versions
lcd = Adafruit_CharLCDPlate()

# Clear display and show greeting, pause 1 sec
lcd.clear()
lcd.message("Hello World!")
sleep(5)

lcd.begin(16,2)
lcd.clear()



lcd.backlight(lcd.VIOLET)
thumb0 = [0B00100,0B00011,0B00100,0B00011,0B00100,0B00011,0B00010,0B00001]
thumb1 = [0B00000,0B00000,0B00000,0B00000,0B00000,0B00000,0B00000,0B00011]
thumb2 = [0B00000,0B00000,0B00000,0B00000,0B00000,0B00000,0B00001,0B11110]
thumb3 = [0B00000,0B01100,0B10010,0B10010,0B10001,0B01000,0B11110,0B00000]
thumb4 = [0B00010,0B00010,0B00010,0B00010,0B00010,0B01110,0B10000,0B00000]
thumb5 = [0B00000,0B00000,0B00000,0B00000,0B00000,0B10000,0B01000,0B00110]
lcd.createChar(0, thumb0)
lcd.createChar(1, thumb1)
lcd.createChar(2, thumb2)
lcd.createChar(3, thumb3)
lcd.createChar(4, thumb4)
lcd.createChar(5, thumb5)
lcd.setCursor(4,1)
lcd.write(0)
lcd.setCursor(4,0)
lcd.write(1)
lcd.setCursor(5,1)
lcd.write(2)
lcd.setCursor(5,0)
lcd.write(3)
lcd.setCursor(6,1)
lcd.write(4)
lcd.setCursor(6,0)
lcd.write(5)
The "Hello World" message is displayed accordingly, but after the backlight changes into violet, there is nothing to see and there is also no error code.
So I think this might be a problem with the Cursor and/or with the character string itself?

It would be great if someone with more experience could point me into the right direction.

Thanks a lot!

User avatar
Renate
 
Posts: 291
Joined: Tue Nov 13, 2012 3:21 pm

Re: 16x2 LCD & custom Chars

Post by Renate »

Error codes? When you're down to the metal, you don't get error codes.
You just get stuff that doesn't do what you wanted.

I have no ideas of the libraries you're using so I can't specifically address that.
However, a few days ago I did write code for the ATMega32u4 to set and use custom characters.
(In my case, it was for proper descenders on g, j, p, q, y and back slash and tilde.)

(Point #1, are you sure that lcd.write() is the function for outputting a single char? No idea.)

You're going to have to do some debugging
First, get rid of all those setCursor's except for the first one.
Then try mixing in 'A' and 'B' to see that you are writing chars and that they are on a visible part of the screen.

You can even get rid of the stuff between Hello World and the test and see if the chars follow after World.

Speedy2k
 
Posts: 3
Joined: Wed Apr 10, 2013 11:18 pm

Re: 16x2 LCD & custom Chars

Post by Speedy2k »

Hi, i would like to know if you have found the way to do it? I have tried to make a custom character with the Adafruit_CharLCDPlate library but with no luck!

User avatar
bluecamel
 
Posts: 6
Joined: Sat Jun 22, 2013 7:49 pm

Re: 16x2 LCD & custom Chars

Post by bluecamel »

Thanks to this thread, I figured out how to create and use custom characters. dschu had everything right, except a second parameter to the write call. Instead of lcd.write(0) to write the first custom character, try lcd.write(0, True).

nathankorth
 
Posts: 2
Joined: Thu Dec 26, 2013 11:13 pm

Re: 16x2 LCD & custom Chars

Post by nathankorth »

This thread helped me! I also discovered that you can write custom characters with the normal lcd.message interface using \x escaping. Here's the relevant part of my code:

Code: Select all

# degree symbol
lcd.createChar(1, [0b01100,
                   0b10010,
                   0b10010,
                   0b01100,
                   0b00000,
                   0b00000,
                   0b00000,
                   0b00000])
# hourglass
lcd.createChar(2, [0b11111,
                   0b10001,
                   0b01110,
                   0b00100,
                   0b01010,
                   0b10001,
                   0b11111,
                   0b00000])

lcd.message("Degrees: \x01")
lcd.message("\n")
lcd.message("Hourglass: \x02")

User avatar
hasham12
 
Posts: 1
Joined: Thu Jun 04, 2015 2:04 am

Re: 16x2 LCD & custom Chars

Post by hasham12 »

i want to buy LCD any one suggest plz

Locked
Please be positive and constructive with your questions and comments.

Return to “Glowy things (LCD, LED, TFT, EL) purchased at Adafruit”