Adafruit I2C 16X2 RGB 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
catchgame
 
Posts: 7
Joined: Thu Dec 05, 2013 1:00 pm

Adafruit I2C 16X2 RGB LCD Pi Plate

Post by catchgame »

Hi guys,
Ive just bought my plate and followed all the instructions on the website but when i run the Adafruit_CharLCDPlate.py code i get this error

Code: Select all

  File "Adafruit_CharLCDPlate.py", line 129
    self.displayshift   = (self.LCD_CURSORMOVE |
       ^
SyntaxError: invalid syntax
Is there anything i can do.The lcd wont turn on!
Thanks in advance
Catchgame

User avatar
adafruit_support_mike
 
Posts: 67485
Joined: Thu Feb 11, 2010 2:51 pm

Re: Adafruit I2C 16X2 RGB LCD Pi Plate

Post by adafruit_support_mike »

That's a strange one.

The only clue that I can see is the line number.. in the version of the library I have, the code shown above lives in line 131 rather than line 129. What do the first few lines of your Adafruit_CharLCDPlate.py file look like?

catchgame
 
Posts: 7
Joined: Thu Dec 05, 2013 1:00 pm

Re: Adafruit I2C 16X2 RGB LCD Pi Plate

Post by catchgame »

adafruit_support_mike wrote:That's a strange one.

The only clue that I can see is the line number.. in the version of the library I have, the code shown above lives in line 131 rather than line 129. What do the first few lines of your Adafruit_CharLCDPlate.py file look like?
It looks like this

Code: Select all

#!/usr/bin/python

# Python library for Adafruit RGB-backlit LCD plate for Raspberry Pi.
# Written by Adafruit Industries.  MIT license.

# This is essentially a complete rewrite, but the calling syntax
# and constants are based on code from lrvick and LiquidCrystal.
# lrvic - https://github.com/lrvick/raspi-hd44780/blob/master/hd44780.py
# LiquidCrystal - https://github.com/arduino/Arduino/blob/master/libraries/LiquidCrystal/LiquidCrystal.cpp

from Adafruit_I2C import Adafruit_I2C
from time import sleep

class Adafruit_CharLCDPlate(Adafruit_I2C):

    # ----------------------------------------------------------------------
    # Constants

    # Port expander registers
    MCP23017_IOCON_BANK0    = 0x0A  # IOCON when Bank 0 active
    MCP23017_IOCON_BANK1    = 0x15  # IOCON when Bank 1 active
    # These are register addresses when in Bank 1 only:
    MCP23017_GPIOA          = 0x09
    MCP23017_IODIRB         = 0x10
    MCP23017_GPIOB          = 0x19

    # Port expander input pin definitions
    SELECT                  = 0
    RIGHT                   = 1
    DOWN                    = 2
    UP                      = 3

User avatar
adafruit_support_mike
 
Posts: 67485
Joined: Thu Feb 11, 2010 2:51 pm

Re: Adafruit I2C 16X2 RGB LCD Pi Plate

Post by adafruit_support_mike »

Okay, that looks right.

We could poke around in the code ad nauseam, but let's try the brute force approach first: try downloading a new copy of the Adafruit RasPi code and see if a fresh copy of the library will work for you.

catchgame
 
Posts: 7
Joined: Thu Dec 05, 2013 1:00 pm

Re: Adafruit I2C 16X2 RGB LCD Pi Plate

Post by catchgame »

Still returns

Code: Select all

  File "Adafruit_CharLCDPlate.py", line 129
    self.displayshift   = (self.LCD_CURSORMOVE |
       ^
SyntaxError: invalid syntax
:(

User avatar
adafruit_support_mike
 
Posts: 67485
Joined: Thu Feb 11, 2010 2:51 pm

Re: Adafruit I2C 16X2 RGB LCD Pi Plate

Post by adafruit_support_mike »

Hmm.. I just noticed something about the way you worded the issue: are you trying to execute the file 'Adafruit_CharLCDPlate.py' itself, or the example script 'LCDtest.py' (or some other script that imports the Adafruit_CharLCDPlate module)?

catchgame
 
Posts: 7
Joined: Thu Dec 05, 2013 1:00 pm

Re: Adafruit I2C 16X2 RGB LCD Pi Plate

Post by catchgame »

i am using the file Adafruit_CharLCDPlate.py

User avatar
adafruit_support_mike
 
Posts: 67485
Joined: Thu Feb 11, 2010 2:51 pm

Re: Adafruit I2C 16X2 RGB LCD Pi Plate

Post by adafruit_support_mike »

Okay, now I understand what's happening.

That file is only a library. Other scripts refer to it to gain functionality, but it isn't meant to be executed by itself. Try the LCDTest script and see if that works.

catchgame
 
Posts: 7
Joined: Thu Dec 05, 2013 1:00 pm

Re: Adafruit I2C 16X2 RGB LCD Pi Plate

Post by catchgame »

Doing that i got the error

Code: Select all

Traceback (most recent call last):
  File "LCDtest.py", line 4, in <module>
    from Adafruit_CharLCDPlate import Adafruit_CharLCDPlate
  File "/home/pi/Adafruit-Raspberry-Pi-Python-Code/Adafruit_CharLCDPlate/Adafruit_CharLCDPlate.py", line 129
    self.displayshift   = (self.LCD_CURSORMOVE |
       ^
SyntaxError: invalid syntax
HELP! :(

User avatar
adafruit_support_mike
 
Posts: 67485
Joined: Thu Feb 11, 2010 2:51 pm

Re: Adafruit I2C 16X2 RGB LCD Pi Plate

Post by adafruit_support_mike »

Okay, something unusual is happening here. The error doesn't seem to make any sense, but appears even though you've loaded a new copy of the code.

Please post what's in your copy of Adafruit_CharLCDPlate.py between lines 120 and 140. Also, what's the exact command you're using when you try to run the script?

catchgame
 
Posts: 7
Joined: Thu Dec 05, 2013 1:00 pm

Re: Adafruit I2C 16X2 RGB LCD Pi Plate

Post by catchgame »

Ok i have reloaded the code once again and i get a new errors.For Adafruit_CharLCDPlate i got

Code: Select all

Traceback (most recent call last):
  File "Adafruit_CharLCDPlate.py", line 442, in <module>
    lcd = Adafruit_CharLCDPlate()
  File "Adafruit_CharLCDPlate.py", line 81, in __init__
    self.i2c = Adafruit_I2C(addr, busnum, debug)
  File "/home/pi/Adafruit-Raspberry-Pi-Python-Code/Adafruit_CharLCDPlate/Adafruit_I2C.py", line 36, in __init__
    busnum if busnum >= 0 else Adafruit_I2C.getPiI2CBusNumber())
IOError: [Errno 2] No such file or directory
for LCDTest igot

Code: Select all

Traceback (most recent call last):
  File "LCDtest.py", line 8, in <module>
    lcd = Adafruit_CharLCDPlate()
  File "/home/pi/Adafruit-Raspberry-Pi-Python-Code/Adafruit_CharLCDPlate/Adafruit_CharLCDPlate.py", line 81, in __init__
    self.i2c = Adafruit_I2C(addr, busnum, debug)
  File "/home/pi/Adafruit-Raspberry-Pi-Python-Code/Adafruit_CharLCDPlate/Adafruit_I2C.py", line 36, in __init__
    busnum if busnum >= 0 else Adafruit_I2C.getPiI2CBusNumber())
IOError: [Errno 2] No such file or directory
secondly between lines 120 and 140 i have

Code: Select all

           self.portb ]) # OLATB     turning on R+G+B backlight LEDs.

        # Switch to Bank 1 and disable sequential operation.
        # From this point forward, the register addresses do NOT match
        # the list immediately above.  Instead, use the constants defined
        # at the start of the class.  Also, the address register will no
        # longer increment automatically after this -- multi-byte
        # operations must be broken down into single-byte calls.
        self.i2c.bus.write_byte_data(
          self.i2c.address, self.MCP23017_IOCON_BANK0, 0b10100000)

        self.displayshift   = (self.LCD_CURSORMOVE |
                               self.LCD_MOVERIGHT)
        self.displaymode    = (self.LCD_ENTRYLEFT |
                               self.LCD_ENTRYSHIFTDECREMENT)
        self.displaycontrol = (self.LCD_DISPLAYON |
                               self.LCD_CURSOROFF |
                               self.LCD_BLINKOFF)

        self.write(0x33) # Init
        self.write(0x32) # Init
Lastly i use the command

Code: Select all

sudo python LCDtest.py

User avatar
adafruit_support_mike
 
Posts: 67485
Joined: Thu Feb 11, 2010 2:51 pm

Re: Adafruit I2C 16X2 RGB LCD Pi Plate

Post by adafruit_support_mike »

Okay, those errors make it look like there's no device driver for the I2C bus. What do you have in /etc/modules and /etc/modprobe.d/raspi-blacklist.conf ?

catchgame
 
Posts: 7
Joined: Thu Dec 05, 2013 1:00 pm

Re: Adafruit I2C 16X2 RGB LCD Pi Plate

Post by catchgame »

Hi
I dont have the file /etc/modules and in etc/modprobes.d/raspi-blacklist.conf the file is empty
:? :? :? :?

User avatar
adafruit_support_mike
 
Posts: 67485
Joined: Thu Feb 11, 2010 2:51 pm

Re: Adafruit I2C 16X2 RGB LCD Pi Plate

Post by adafruit_support_mike »

Hrm.. have you gone through the "GPIO Setup" tutorial? http://learn.adafruit.com/adafruits-ras ... gpio-setup

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”