speendo / raspi-mpd-lcd

A class based Python project to control a 20x04 (or 16x02) LCD via I2C. Here the framework is used to display time and mpd information, but most of the code can be reused to display any text that can be categorized into separate lines
GNU General Public License v2.0
8 stars 2 forks source link

20x4 Lcd on Raspberry volumio os. #2

Open mecaz opened 8 years ago

mecaz commented 8 years ago

I got following error please help. And couldnt make it work never.

sudo python main.py Traceback (most recent call last): File "main.py", line 7, in from LineController import * File "/home/pi/raspi-mpd-lcd/LineController.py", line 219, in class FetchLine(TextLine): File "/home/pi/raspi-mpd-lcd/LineController.py", line 220, in FetchLine from urllib import request ImportError: cannot import name request

speendo commented 8 years ago

Probably you use Python 2.x. The project is written in Python 3 however.

If you don't want to dive deep into the code and rewrite the Python 3 parts, I would suggest you make sure you have Python 3 installed and try

python3 main.py

If you use the latest Raspbian, no sudo is needed.

Hope that helps!

mecaz commented 8 years ago

Hello.

I got following smbus error. I tried to install that on volumio but couldnt make.

sudo python3 main.py Traceback (most recent call last): File "main.py", line 6, in from LCDController import * File "/home/pi/raspi-mpd-lcd/LCDController.py", line 4, in import LCDDriver File "/home/pi/raspi-mpd-lcd/LCDDriver.py", line 2, in import i2c_lib File "/home/pi/raspi-mpd-lcd/i2c_lib.py", line 1, in import smbus ImportError: No module named 'smbus'

My only goal is make a mpd player has 20x4 irc lcd screen. please help it work. my tested my screen with this: http://www.recantha.co.uk/blog/?p=4849 and it work well.

Regards

speendo commented 8 years ago

Have you installed the package python3-smbus?

mecaz commented 8 years ago

I solved smbus problem but stuck at mpd module.

sudo python3 main.py Traceback (most recent call last): File "main.py", line 7, in from LineController import * File "/home/pi/raspi-mpd-lcd/LineController.py", line 193, in class MPDLine(TextLine): File "/home/pi/raspi-mpd-lcd/LineController.py", line 194, in MPDLine from mpd import MPDClient ImportError: No module named 'mpd'

I cant install mpd module because of following error.

pip install mpd Downloading/unpacking mpd Could not find any downloads that satisfy the requirement mpd Cleaning up... No distributions at all found for mpd Storing debug log for failure in /home/pi/.pip/pip.log

speendo commented 8 years ago

No problem. You just need to install this project https://github.com/Mic92/python-mpd2. But again you need to use the Python 3 pendant of pip: pip3. When you have the package python3-pip installed

sudo pip3 install python-mpd2

should do the job.

mecaz commented 8 years ago

Thanks for your big help. I finally got worked my screen with mpd. I also edited main.py and make album name and artist name shown. Everything fine but some special characters.

Appreciated for your great care speendo. Regards

speendo commented 8 years ago

I'm glad that it worked.

The main.py as well as line_controller.py are not originally intended to work out of the box for every use case. I designed it to work with a web radio. If you want something else you will have to adapt the code for your needs.

But don't worry - this won't be very difficult and I will be there to help you.

If this is alright for you, I will close this issue now.

speendo commented 8 years ago

Oh, and you can adapt the special characters by creating your own local class (just take the other local files as a model).

If you make one, I can add it to my project.

mecaz commented 8 years ago

ok. i will work on it. and one last question. at time string. counting time on right side dont start over when song changes. it count to infinitive. is it normal? or is it suppose to show track status?

speendo commented 8 years ago

Yes, for my usecase this is fine. I want to count the time since the radio was switched on.

Maybe this could be changed for your purpose...

mecaz commented 8 years ago

I find lines to edit. but cant find proper code to show current playing song time

def update_time(self): self.clear_text()

    self.set_text_left(self.time.strftime('%H:%M:%S'))

    self.set_text_right(self.time.strftime("%H:%M:%S", self.time.gmtime(self.time.time() - self.start_time)))

I should adapt that lines. am i right?

speendo commented 8 years ago

That's right.

However I don't know where you can get the playing time of the song - is this something mpd "knows"? Then you could probably get it from the MPDClient

mecaz commented 8 years ago

yes it is something about mpd. i want to see elapsed time of track or the rest of it. Probably MPDClient provides that info but i dont know how to get it. sorry.

speendo commented 8 years ago

you could leave the lcd for a moment and play around with the MPDClient.

go to python

# python3

and enter

from mpd import MPDClient
client = MPDClient()
client.timeout = 10
client.connect("localhost", 6600)

client.currentsong()

This should get you a step forward.

speendo commented 8 years ago

more information can be found here: http://pythonhosted.org/python-mpd2/topics/commands.html