LCD display and buttons in Python (tutorial and code)

Raspberry Pi related support

Re: LCD display and buttons in Python (tutorial and code)

Postby Peter » 25 Jul 2015, 04:21

I'm currently rewriting the whole program


Hi @xplod

I am really looking forward to this. I have tried so many times, and just end up breaking Rune and having to reinstall. When you publish the I2C version, could you please make the instructions very simple and easy to follow...
I explain it like this - if you have your drivers license in Linux and Python, I am still learning to walk!

Cheers, and thanks for the inspiration.
i
User avatar
Peter
 
Posts: 64
Joined: 06 Mar 2014, 23:32

Re: LCD display and buttons in Python (tutorial and code)

Postby XploD » 26 Jul 2015, 23:02

Hi,

I'm pretty new at this as well, I just have some kind of background since I'm an engineering student but before RuneAudio, I never tried Arch Linux and also I never wrote anything more than "Hello World" in Python. Also, this year I started working with Raspberry Pi and using GPIO for the first time as well. I'll try to make it as easy as possible. Currently it's complicated because there are lots of dependencies for this to work. I should find a better way to include this directly to my program. For I2C, it's easier because I have a library directly included into program. You only have to install Python and to enable I2C and install required tools, I will write a tutorial once I finish.

Where are you getting stuck, on which step?
Music taste: xplodmusic @ Last.fm
Audio source: Raspberry Pi 2 + Sabre ES9023 DAC + WD 500 GB HDD + TP-Link TL-WN722N Wi-Fi + D-LINK Dub H7 USB hub
Hi-Fi: Phillips DCD-7010
Mixer: Nady Audio MM-242
Misc: Tube Stereo Vumeter (Magic Eye)
User avatar
XploD
 
Posts: 77
Joined: 24 Mar 2015, 18:32
Location: Croatia

Re: LCD display and buttons in Python (tutorial and code)

Postby Peter » 05 Aug 2015, 08:06

Hi there, I eventually got it working!! I am not sure quite how, but it works. With a combination of a majority of @XploD's advice, a dose of @Hairybikers's process - and some experimentation with Arch commands - it works. Now I need to clone the SD card so I have a working copy, before I try to redo and streamline the installation so I can reinstall when the SD card needs reflashing.

Just as an aside...Should this thread perhaps be in the DIY section? Then others who want to implement this great idea can access it more easily than in the general thread.

And lastly... could the code be included in the Runeaudio gitpull/ .4 release?
User avatar
Peter
 
Posts: 64
Joined: 06 Mar 2014, 23:32

Re: LCD display and buttons in Python (tutorial and code)

Postby XploD » 05 Aug 2015, 08:59

Hello. I'm glad that you got it working :) About DIY section, sincerely, I haven't seen this section till now :mrgreen: Maybe you're right. And about including it in the release, I don't know. The code is pretty a mess. The new code, maybe, but dev team will decide.

I wrote a completely new code, which supports 4x20, 2x16 and both I2C and parallel displays and it's much better. But currently I have a lot of problems with network on my Pi2, seems that RuneAudio for Pi2 is a mess so I'm waiting for the dev team to fix this. The code is on github, if you want to take a look: https://github.com/RandyCupic/RuneAudioLCD
Music taste: xplodmusic @ Last.fm
Audio source: Raspberry Pi 2 + Sabre ES9023 DAC + WD 500 GB HDD + TP-Link TL-WN722N Wi-Fi + D-LINK Dub H7 USB hub
Hi-Fi: Phillips DCD-7010
Mixer: Nady Audio MM-242
Misc: Tube Stereo Vumeter (Magic Eye)
User avatar
XploD
 
Posts: 77
Joined: 24 Mar 2015, 18:32
Location: Croatia

Re: LCD display and buttons in Python (tutorial and code)

Postby hondagx35 » 05 Aug 2015, 11:11

Hi XploD,

seems that RuneAudio for Pi2 is a mess so I'm waiting for the dev team to fix this


Please tell me more, what is the problem?

Edit:
You mean this one?

Frank
User avatar
hondagx35
 
Posts: 3042
Joined: 11 Sep 2014, 22:06
Location: Germany

Re: LCD display and buttons in Python (tutorial and code)

Postby jeroenrood » 06 Nov 2015, 14:52

Thank you XploD,
I've followed your instructions for the first display, and that went well. (A couple of months ago)
Now I've installed a I2C back-pack and installed your second version. With a 20x4 display this is much nicer!
The only problem was that the i2c-dev was not loading. I had to insert the module in /etc/modules-load.d/raspberrypi.conf .
After that, everything works fine,
so thank you for developing the software.
Jeroen.
jeroenrood
 
Posts: 15
Joined: 06 Nov 2015, 14:45

Re: LCD display and buttons in Python (tutorial and code)

Postby matock » 22 Nov 2015, 18:49

Hi XploD,

I recently discovered the RuneAudio. Thank you guys for this fabulous project. Thank you also XploD for this tuto. This LCD is the "bonus touch" for an audio server.

I'm trying to install a LCD HD44780 (no I2C, "ordinary" 4 bits wire) on my Raspberry Pi2 with the last RuneAudio 0.3beta. I was able to:
- (python2 was already installed)
- install gcc & unzip
- install the RPi.GPIO library (v0.5.11)
- install the Adafruit LCD library

But I'm not able to tweak the Adafruit LCD library because the folders
/usr/lib/python2.7/site-packages/Adafruit_CharLCD-1.0.0-py2.7.egg
/usr/lib/python2.7/site-packages/Adafruit_GPIO-0.9.3-py2.7.egg
don't exist. The are 2 files with this names in site-packages folder, but no folders.

And of course, if I don't do that I receive the error below when I execute RA_LCD_Buttons.py

[root@runeaudio RA_LCD_Buttons]# python2 RA_LCD_Buttons.py
Code: Select all
Traceback (most recent call last):
  File "RA_LCD_Buttons.py", line 11, in <module>
    import Adafruit_CharLCD as LCD
  File "build/bdist.linux-armv7l/egg/Adafruit_CharLCD/__init__.py", line 1, in <module>
  File "build/bdist.linux-armv7l/egg/Adafruit_CharLCD/Adafruit_CharLCD.py", line 24, in <module>
  File "build/bdist.linux-armv7l/egg/Adafruit_GPIO/I2C.py", line 25, in <module>
ImportError: No module named smbus


What can I do?

Thank you very much for your help.
Matock
matock
 
Posts: 10
Joined: 22 Nov 2015, 18:43

Re: LCD display and buttons in Python (tutorial and code)

Postby matock » 24 Nov 2015, 11:38

Hi XploD and all others,

I spent many hours to try to understand what happened (cf my post just above) and finally I found a solution. I'm a beginner in Linux and Python, so may be my method is not the best, but it works.

My guess is the Adafruit libraries and/or the last RuneAudio distro have changed since you wrote your tuto. I expose here a solution. First of all, I precise again the context: Raspberry Pi2 / RuneAudio 0.3beta / LCD HD44780 (4 bits wire, no I2C).

My numbers here refer to the chapter numbers from your tuto.

1) Python2 was already installed (comes with RuneAudio 0.3?). Nothing to do here.

4) Installing RPi.GPIO
No, don't.
Install Adafruit_Python_GPIO instead:
Code: Select all
   wget https://github.com/adafruit/Adafruit_Python_GPIO/archive/master.zip
   unzip master.zip
   cd Adafruit_Python_GPIO
   python2 setup.py install

The reason is that the Adafruit CharLCD library needs it.

5) Installing Adafruit LCD library
Yes but slightly different.
Get and unzip the library, then go to the Adafruit_Python_CharLCD-master folder, as described.

5.1) We have to edit and update the source file of the library, BEFORE building and installing it:
Code: Select all
   cd Adafruit_CharLCD
   nano Adafruit_CharLCD.py
      - comment the line 24 (as you described): #import Adafruit_GPIO.I2C as I2C
      - comment the line 25 (this module also uses I2C): #import Adafruit_GPIO.MCP230xx as MCP
      - comment the last class at the end of the file (as you described): '''class Adafruit_CharLCDPlate(Adafruit_RGBCharLCD) ... '''

5.2) Then, install the library:
Code: Select all
   python2 setup.py install


Et voilà !
matock
 
Posts: 10
Joined: 22 Nov 2015, 18:43

Re: LCD display and buttons in Python (tutorial and code)

Postby XploD » 24 Nov 2015, 13:51

Hello @matock, sorry for my late reply, I haven't visited this forum for a few days. I'm glad that you found a solution for your problem and that you got it working, and also thanks for your tutorial! You're right, the cause for your problems is probably the change of Adafruit library, but also, as far as I remember, this tutorial and code was written for Raspberry Pi model B (not RPi2) so there may be some differences as well.

As I already stated somewhere, now I use RPi2 and I don't use this code anymore, I wrote a new one, much better than this one, and you can find it on my GitHub: https://github.com/RandyCupic/RuneAudioLCD if you want to try. But currently it supports only I2C display, I haven't written a class for "normal" 4-wire displays yet. Also, it still needs some polishing so that's the reason I haven't written a tutorial for it yet. I'm planning to change I2C library because this one is pretty slow (visible when scrolling text), I'm planning to add a 4-wire display support and also I'll try to move to Redis client instead of MPD, because on this current code, Spotify won't work on LCD, only MPD (local files, radio and DLNA). Also Airplay doesn't work (it works but doesn't show on display, the same is for Spotify).
Music taste: xplodmusic @ Last.fm
Audio source: Raspberry Pi 2 + Sabre ES9023 DAC + WD 500 GB HDD + TP-Link TL-WN722N Wi-Fi + D-LINK Dub H7 USB hub
Hi-Fi: Phillips DCD-7010
Mixer: Nady Audio MM-242
Misc: Tube Stereo Vumeter (Magic Eye)
User avatar
XploD
 
Posts: 77
Joined: 24 Mar 2015, 18:32
Location: Croatia

Re: LCD display and buttons in Python (tutorial and code)

Postby matock » 09 Dec 2015, 22:31

Hi XploD,

Thank you for your link. I will have a look when I have some time, by curiosity. My LCD is a normal "4 wire" and I would like to keep this solution. I tweaked a little bit your script and my LCD works fine now.

Thank you again for this work.
Matock
matock
 
Posts: 10
Joined: 22 Nov 2015, 18:43

support RuneAudio Donate with PayPal

PreviousNext

Return to Raspberry Pi

Who is online

Users browsing this forum: No registered users and 24 guests