Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
In general this commit resolves the comments received for the last tw…
…o commits in the pull request #859 discussion.

- moved all files into teh components directory into the sub-dircetory /components/displays/HD44780-i2c/
- added shebang for Python3 for the driver and the main script
- removed the path to the executable (python3) from the sample service file
- added README.md file which describes the features, usage and installation of the code.
  • Loading branch information
SimonChelkowski committed Mar 14, 2020
commit e8bafa41052e64864e2a2649cedf52dd804a6efa
57 changes: 57 additions & 0 deletions components/displays/HD44780-i2c/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
The following files allow using LCD displays based on HD44780 connected via i2c bus for this project. The following displays have been used for testing:
- 2x16 display
- 4x20 display (recommended as more information can be displayed)

Various informations such as artist, album, track_number, track_title, track_time and many more can be displayed see main script for more display options.

The required files are:
- components/displays/HD44780-i2c/i2c_lcd.py
- components/displays/HD44780-i2c/i2c_lcd_driver.py
- components/displays/HD44780-i2c/i2c-lcd.service.default.sample
- components/displays/HD44780-i2c/README.md


The first file is the main LCD script that makes use of I2C_LCD_driver.py.
The second file is the library needed to drive the LCD via i2c, originates from DenisFromHR (Denis Pleic) see http://www.circuitbasics.com/raspberry-pi-i2c-lcd-set-up-and-programming
The third is used as sample service file that runs the i2c_lcd.py main script at boot-up if the service is properly installed (install description can be found below.).
The fourth file is this file which describes the features, usage and installation of the code.

### Installation

1. You need to install additional python libraries. Run the following two command in the command line:
`sudo apt-get install i2c-tools python-smbus python3-numpy python-mpdclient python-mpd`
`pip install smbus numpy python-mpd2`
Copy link
Copy Markdown
Collaborator

@s-martin s-martin Mar 15, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add a requirements.txt file with all necessary pip packages?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will do so, soon.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@SimonChelkowski, isn't this redundant to install the apt packages and one line later the same(?) pip packages?

2. You need to know which I2C bus your Raspberry Pi has available on GPIOs:
`ls /dev/i2c-*`
It'll output "/dev/i2c-x", where x is your bus number. Note this bus number as you will need it in step 6.
3. Now detect the adapter by using the i2cdetect command, inserting your bus number:
`sudo i2cdetect -y bus_number`
The I2C address of my LCD is 27. Take note of this number, it will be need in step 6.
4. if i2cdetect is not found install i2c-tools
`sudo apt-get update`
`sudo apt-get install i2c-tools`
5. Next we need to install SMBUS, which gives the Python library we’re going to use access to the I2C bus on the Pi. At the command prompt, enter
`sudo apt-get install python-smbus`
6. Modify "i2c_lcd_driver.py" line 19 which reads "I2CBUS = 1" and adapt it to your bus number (see step 2.) Furthermore modify line 22 which reads "ADDRESS = 0x27" and adapt it to your I2C address (see step 3.)
7. Modify "i2c_lcd.py" to adapt it yo your specific display e.g. 2x16 or 4x20 (default). The lines 15-19 look like the following:
```################# CHANGE YOUR SETTINGS HERE!!! ###########################################
## Display settings ##
n_cols = 20 # EDIT!!! <-- number of cols your display has ##
n_rows = 4 # EDIT!!! <-- number of rows your display has ##
val_delay = 0.4 # EDIT!!! <-- speed of the scolling text ##
```
Check if "n_cols" and "n_rows" need to be changed and modify them if necessary. The "val_delay" constant leave for the time being. Lower values will speed up things but will make the text less visible/readable.

8. next install and start "i2c-lcd.service"
`sudo cp /home/pi/RPi-Jukebox-RFID/components/displays/HD44780-i2c/i2c-lcd.service.default.sample /etc/systemd/system/i2c-lcd.service`
9. register service by running, it will thereby start on the next boot-up
`sudo systemctl enable i2c-lcd`
10. reboot and enjoy!
For test purposes you can use the following command to start and stop the service without rebooting
to start the service instantly run
`sudo systemctl start i2c-lcd`
to stop the service instantly run
`sudo systemctl stop i2c-lcd`

Best regards,
Simon
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ User=pi
Group=pi
Restart=always
WorkingDirectory=/home/pi/RPi-Jukebox-RFID
ExecStart=/usr/bin/python /home/pi/RPi-Jukebox-RFID/scripts/i2c_lcd.py
ExecStart=/home/pi/RPi-Jukebox-RFID/components/displays/HD44780-i2c/i2c_lcd.py

[Install]
WantedBy=multi-user.target
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!/usr/bin/python3
# -*- coding: utf-8 -*-
Comment thread
s-martin marked this conversation as resolved.
import i2c_lcd_driver
from time import *
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!/usr/bin/python3
# -*- coding: utf-8 -*-
Comment thread
s-martin marked this conversation as resolved.
# Original code found at:
# https://gist.github.com/DenisFromHR/cc863375a6e19dce359d
Expand Down