Thank you for your donation!


Cloudsmith graciously provides open-source package management and distribution for our project.


Instruction Guide LCD/OLED display using pydPiper
#1
On the official pydPiper page there is a list of displays that can be controlled using pydPiper. I personnally have experimented with the following:

16x2 oled using parallel interface
20x4 LCD using i2c interface
128x64 oled using i2c interface

The good thing with pydPiper is that it gives you complete control over the information to display and how to display it (font type and size, position on the screen, scroll direction and speed), and it can even display an image (yes, even on a 16x2 oled!). 

Here is the tutorial.
Create your moode installation and add the ssh file.
ssh to moode. Password is moodeaudio

1. Install the docker
Code:
cd /home/pi
git clone https://github.com/dhrone/pydPiper
cd pydPiper
sudo ./install_docker.sh
Be patient. It takes several minutes. Make sure there is a message at the end saying the docker is installed. Otherwise it will not work.

2. Activate i2c interface:
Code:
sudo raspi-config
Using the arrow keys, select "Interfacing options", "i2c", Yes, Ok, finish

3. Configuration. You will have to answer a few questions depending on the display you use. 
Code:
sudo python configure.py
For the 16x2 oled display with parallel interface. Note that this is not actually a code. You answer manually line per line (copy and paste). I presented it as a code so it is easy to distinguish from the other text.
Code:
[STARTUP]
startup_msg_duration = 5

[DISPLAY]
display_driver = winstar_weg
display_pin_rs = 7
display_pin_e = 8
display_pin_d4 = 25
display_pin_d5 = 24
display_pin_d6 = 23
display_pin_d7 = 27
display_width = 80
display_height = 16
display_enable_duration = 0.1
pagefile = pages_weh_80x16.py
animation_smoothing = 0.15

[SYSTEM]
logfile = /var/log/pydPiper.log
loglevel = info
timezone = US/Eastern (change this according to your location)
time24hour = true
temperature = celsius

[SOURCE]
source_type = moode
mpd_server = localhost
mpd_port = 6600
mpd_password = moodeaudio

For the 20x4 lcd with i2c interface (system and source are the same as above) 
Code:
[DISPLAY]
display_driver = hd44780_i2c
display_width = 100
display_height = 32
display_enable_duration = 1
display_i2c_port = 1
display_i2c_address = 0x27
pagefile = pages_lcd_20x4.py
animation_smoothing = 0.15

For the 16x2 lcd with i2c interface (system and source are the same as above) 
Code:
[DISPLAY]
display_driver = hd44780_i2c
display_width = 80
display_height = 16
display_enable_duration = 1
display_i2c_port = 1
display_i2c_address = 0x27
pagefile = pages_lcd_16x2.py
animation_smoothing = 0.15

For the 128x64 pixels oled using i2c interface and ssd1306 driver:
Code:
[DISPLAY]
display_driver = luma_i2c
display_i2c_port = 1
display_i2c_address = 0x3C
display_devicetype = ssd1306
display_width = 128
display_height = 64
pagefile = pages_ssd1306.py
animation_smoothing = 0.15

4. To test if it works
Code:
sudo /usr/bin/docker run --network=host --privileged -ti -v /var/log:/var/log:rw -v /home/pi/pydPiper:/app:rw dhrone/pydpiper:v0.31-alpha /bin/bash
python pydPiper.py
"control-c" to end the test, "exit" to go back to the command prompt.

5. To complete the installation:
Code:
cd pydPiper
sudo cp pydpiper.service /etc/systemd/system
sudo systemctl enable pydpiper
sudo systemctl start pydpiper

That's all. To customise the display you have to edit the page file used in your configuration. It is found in the directory /home/pi/pydPiper

Take note that:

For the i2c interface, use this command to detect your i2c adress:
Code:
sudo i2cdetect -y 1
You will have numbers only like 27 or numbers with letters like 3c, your i2c adress is 0x27 and 0x3c.

If the display works but complains that there is no widget available, you have to edit your page file in order to get data from MPD:
Code:
cd pydPiper
sudo nano pages_weh_80x16.py (or any other page file corresponding to your display)
In the sequence section, replace every "stream" by  "encoding", so that you have db['encoding'] instead of db['stream'].
ctrl-x, yes, enter when finished.

i2c interface is known to be slow. To improve the performance for a good refresh rate, you have to edit the configuration.
Code:
sudo nano /boot/config.txt
Add the following line
Code:
dtparam=i2c_arm_baudrate=400000
ctrl-x, yes, enter when finished, and restart

Remy
Reply
#2
A few pictures:

How to wire a 16x2 oled using parallel interface. Use the wiring on the picture on the right

[Image: file.php?id=218]

pydPiper on a 16x2 oled: 

[Image: file.php?id=629]

pydPiper on a 2.42 inches 128x64 using i2c:

[Image: file.php?id=663]

pydPiper on a 20x4 LCD:

[Image: 32021213-a93ed444-b9ca-11e7-8886-80fee92de79e.jpg]


Remy
Reply
#3
Thanks for such a detailed write up Remy !

I plan to try the 20x4 lcd version this weekend on a MoOde Radio player  for our kitchen.

Edit Tried with instructions for 20x4 lcd with i2c interface and nothing output to display. (oddly there is now no radio logo artwork displayed in the moode web interface!!)

Must be something vital missing here...is it a complete a to z or are there other settings we need to configure within MoOde...lcd update engine, metadata, path to .py script ???

What needs configuring for the page file for the 20x4 lcd with i2c interface ?  is there a sample we can use to get first output then modify to suit..?
----------
bob
Reply
#4
A big thanks to Remy1961 for his excellent tutorial. It’s great to see a well written and complete tutorial.

After a couple of pm’s alerting me to details in the tutorial that in my enthusiasmI had missed, I have a fully working 16x2 lcd display operating. The steps that I overlooked were:

Step 3: “Note that this is not actually a code. You answer manually line per line (copy and paste). “ and

Step 5: “you have to edit the page file used in your configuration. It is found in the directory /home/pi/pydPiper”

In the page file for your chosen display, change any instances of ‘stream’ to ‘encoding’ under “SEQUENCES > ‘canvases’ to avoid a “no active widgets” error message when playing a track. (Also included in remy1961’s “Notes” edit)

            
Reply
#5
Reinstalled and reconfigured.
Still no output to display... no welcome message.
Rechecked wiring all ok.

Any debugging I can run ?
----------
bob
Reply
#6
(09-10-2018, 08:52 PM)DRONE7 Wrote: Reinstalled and reconfigured.
Still no output to display... no welcome message.
Rechecked wiring all ok.

Any debugging I can run ?

Hi DRONE7,
It might help if we can we see the content of the file /home/pi/pydPiper/pydPiper.cfg

Remy
Reply
#7
Hi Remy....

[STARTUP]
startup_msg_duration = 5

[DISPLAY]
display_driver = hd44780_i2c
display_width = 100
display_height = 32
display_enable_duration = 1
display_i2c_port = 1
display_i2c_address = 0x3f
pagefile = pages_lcd_20x4.py
animation_smoothing = 0.15

[SYSTEM]
logfile = /var/log/pydPiper.log
loglevel = info
timezone = Pacific/Auckland
time24hour = true
temperature = celsius

[SOURCE]
source_type = moode
mpd_server = localhost
mpd_port = 6600
mpd_password = moodeaudio


Looks as it should.....
I checked  /var/log/pydPiper.log but that is an empty file..

Running the test code after install starts docker and the app... seems to be running only no output.... I'm a bit lost from here...
----------
bob
Reply
#8
Hi,
I guess the i2c adress 0x27 did not work, and that 0x3f was from sudo i2cdetect -y 1.
Other than that everything in the configuration seems good for a 20x4 LCD with i2c interface.
I assume the connections are correct (sda connected to physical pin 3 and scl connected to physical pin 5).
What about the docker, I assume it was installed correctly, with towards the end of the installation several packages being downloaded and extracted.
If nothing works, let me know, I will try to do again an installation from scratch since I happen to have the same display.
Remy
Reply
#9
correct for all.... unsure about docker packages as I was away from the screen and returned to find it at the prompt..... docker seems to start but i will rerun the install to check...
Other variables here I see....1) running on a PiB ver2 (single core, 512Ram)
                                            2) using 5v to vcc on the display and 3.3v to the backpack as per this advisory...
https://www.instructables.com/id/Raspber...r-1602-Sc/

Edit.. OK!  running now.....poor little PiB takes a lo-o-ong  time to load and execute pydPiper.py. That was the problem....I didn't wait long enough = 5 Minutes+....
I went off for refreshments and when I returned it was starting !.

Will finish the install and test a while but I might be returning to BryceJ's script which has a lesser overhead for this Pi.
C P U L O A D

CPU %usr %sys %idle
all 66.32 14.74 18.42
0 66.32 14.74 18.42

P R O C E S S L O A D

PRI RTPRIO COMMAND %MEM PSR %CPU
19 - python 5.1 0 65.2
29 - mpd 3.4 0 6.6
19 - sysinfo.sh 0.5 0 2.8
19 - dockerd 11.4 0 2.0
19 - docker-containe 5.6 0 1.1
19 - worker.php 2.5 0 1.0
19 - sudo 0.6 0 0.7
19 - systemd 1.2 0 0.4
19 - docker 5.4 0 0.3


BryceJ's script....
C P U L O A D

CPU %usr %sys %idle
all 11.11 5.56 82.32
0 11.11 5.56 82.32

P R O C E S S L O A D

PRI RTPRIO COMMAND %MEM PSR %CPU
29 - mpd 5.5 0 6.6
19 - sysinfo.sh 0.5 0 4.5
19 - systemd 1.3 0 1.4
19 - sudo 0.6 0 1.2
19 - worker.php 2.4 0 1.1
19 - php-fpm7.0 2.3 0 1.0
19 - python 1.3 0 0.9
19 - php-fpm7.0 2.4 0 0.6
19 - systemd-journal 0.9 0 0.5



Docker and Python at 65% cpu vs BryceJ's script at 0.9%!!!

Thanks for your help to get this running, I will use it on a Pi2 or a Pi3 but not for a PiB....lol

Cheers,
Bob.
----------
bob
Reply
#10
Hello Bob,

I had a 20x4 display in addition to the 16x2. I have been testing on a Pi2B with Moode 3.8.4.

Changed displays and repeated Step 3: sudo python configure.py and edited the "pages_lcd_20x4.py" file. No problems and works on address 0x27.

I am also powering the display and backpack with 5 Volts only to the backpack without problems.

 pydPiper starts less than a minute after moOde boots.

Next move is to install on Pi 3B+ with moOde 4.2 and using a level converter as described at:

https://www.raspberrypi-spy.co.uk/2015/0...pberry-pi/

Richard.
Reply


Forum Jump: