mpd_oled - OLED status and spectrum display for Raspberry Pi

Build/modify/repair equipment and improve systems performance by yourself

Re: mpd_oled - OLED status and spectrum display for Raspberr

Postby Ripa » 15 Dec 2018, 11:12

adrii wrote:The mpd_oled program displays an information screen including a music frequency spectrum on a 128x64 OLED screen connected to a Raspberry Pi (or similar) running MPD. Installation instructions are provided for RuneAudio.
https://github.com/antiprism/mpd_oled

Image

Demonstration video
https://youtu.be/6pgxGQIAX9s

Adrian.


CC=clang ./configure is getting error see my picture
Ripa
 
Posts: 62
Joined: 04 Dec 2017, 03:55

Re: mpd_oled - OLED status and spectrum display for Raspberr

Postby adrii » 08 May 2019, 15:34

Hi Ripa

Sorry for not replying sooner! (I didn't get the notification about new messages).

Your screenshot doesn't include the error message, but I imagine it says that the compiler cannot build executables.

When I last tried RuneAudio I was unable to install a working build environment for C++ on my Raspberry Pi Zero W, and could therefore no longer build mpd_oled on it. See raspberry-pi-zero-support-in-0-4-t3711-130.html#p25376

I don't know what the current sitution is.

If you are still looking for help, and the error is something other than the compiler not working, then please post some more details and I will see if I can help.

Adrian.

P.S. If anyone posts a message for me here and I don't reply then I haven't seen the message. If you send an email to adrian@antiprism.com then I will check the thread and reply.
User avatar
adrii
 
Posts: 25
Joined: 17 Apr 2018, 11:03

Re: mpd_oled - OLED status and spectrum display for Raspberr

Postby adrii » 09 May 2019, 09:31

I had another go with the latest 0.5 beta 20180903_10_runeaudio_rpib1.img.gz , which I updated with the gitpull button.

I was unable to get a working C++ build environment.

Trying to install packages with "pacman -S" produces - error: failed retrieving file 'libatomic_ops-7.6.8-1-armv6h.pkg.tar.xz' from mirror.archlinuxarm.org : The requested URL returned error: 404.

Trying to install packages with "pacman -Sy" installs packages with library mismatches. For example, m4 will not run and prints an error that it could not find a library of a particular version.

Adrian.
User avatar
adrii
 
Posts: 25
Joined: 17 Apr 2018, 11:03

Re: mpd_oled - OLED status and spectrum display for Raspberr

Postby Mat » 21 May 2019, 09:01

Hi Adrian. I will try to describe my procedure for installing mpd_oled on latest version (05b-10). There is a lot of your commands in this description, I followed your instructions :).

1. Wiring the display
I use two types of display.
1. On 1.3 inch I2C 4 OLED pin display the wiring was quite straight forward.
2. On 2.42 inch SPI/I2C 7 pin OLED display I had some troubles, the solution is described below
2019-05-21_094624.png
2019-05-21_094624.png (28.95 KiB) Viewed 93 times


2. Display configuration
Add configuration in config.txt
Code: Select all
# nano /boot/config.txt

Code: Select all
dtparam=i2c1=on
dtparam=i2c_arm=on
dtparam=i2c_arm_baudrate=400000

Update libraries, install i2c-tools and create raspberrypi.conf file
Code: Select all
# pacman -Syy
# pacman -Sy i2c-tools
# nano /etc/modules-load.d/raspberrypi.conf

Put those two lines in rasspberrypi.conf:
Code: Select all
i2c-dev
i2c-bcm2708


3. Check if display is connected
You can now check if display is wired correctly and on which address it is:
Code: Select all
# i2cdetect -y 1

You should get something like this. If there is no address (see UU 3c), there is something wrong.
2019-05-21_094423.png
2019-05-21_094423.png (2.83 KiB) Viewed 93 times
[/img]

4. Install and build CAVA Spectrum
Code: Select all
# cd ~
# git clone https://github.com/karlstav/cava
# cd cava
# pacman -Sy autoconf automake clang make libtool fftw alsa-lib
# ./autogen.sh
# pacman -Sy llvm-libs
# pacman -Sy glibc
# pacman –Sy gcc
# CC=clang ./configure


5. Install and build MPD_OLED
Code: Select all
# cd ~
# git clone https://github.com/antiprism/mpd_oled
# cd mpd_oled
# cp mpd_oled_fifo.conf /usr/local/etc/
# CC=clang CXX=clang++ PLAYER=RUNEAUDIO make

Lets try if it works:
Code: Select all
# ./mpd_oled -o 6 -b 10 -g 1 -f 15

You should see something on display since CAVA spetcrum won't work yet.

6. Set MPD for sending data for CAVA algorithm
Becouse we cannot change MPD.conf there is another procedure, as described here: add-audio-output-fifo-to-mpd-conf-t6329.html

We should make correction in runeaudio.php:
Code: Select all
# nano /srv/http/app/libs/runeaudio.php

We should find two lines, somewhere around 2700 line of code:
Code: Select all
2698                         // write mpd.conf file to /tmp location
2699                         $fh = fopen('/tmp/mpd.conf', 'w');

Now insert line $output .= file_get_contents('/usr/local/etc/mpd_oled_fifo.conf'); between. The file /usr/local/etc/mpd_oled_fifo.conf exists, we copied it there in previous step. It should look like this now:
Code: Select all
2698                         // write mpd.conf file to /tmp location
2699                         $output .= file_get_contents('/usr/local/etc/mpd_oled_fifo.conf');
2700                         $fh = fopen('/tmp/mpd.conf', 'w');


Now reboot and check if it is working:
Code: Select all
# cd mpd_oled
# ./mpd_oled -o 6 -b 10 -g 1 -s 25.0,5.0,0.0 -f 25

It should work now. After updating new version (gitpull) you will probably have to repeat this step!!!


7. Set autostart
Once the display is working, edit the file mpd_oled.service to include your OLED command line:
Code: Select all
# cd ~/mpd_oled
# nano mpd_oled.service

In the [Service] part there is your configuration:
Code: Select all
1 [Unit]
 2 Description=MPD OLED Display
 3
 4 [Service]
 5 ExecStart=/usr/local/bin/mpd_oled -o 3 -r 25 -b 32 -g 1 -s 25.0,5.0,0.0 -f 25
 6
 7 [Install]
 8 WantedBy=multi-user.target

You can check parameters with
Code: Select all
# ./mpd_oled --help

and configure it as you like.


-------------------------------------------------------------
--------- ADD: Wiring 2.42 Display ----------------
-------------------------------------------------------------
It worked great on 1.3 inch display but it is quite small so I bought 2.42 OLED display. I had to solve two troubles:

1. It has SPI interface but it can be modified to I2C. I desoldered resistor from R4 and solder it on R3 and another one I bought on R5. It didn't work until I just put a wire (jumper) on R3 and R5. So do not bother with resistors, just unsolder one from R4 and connect contacts on R3 an R5 together.

2. I had a lot of issues with reset (RES) pin. I finally found a working solution. I connected reset pin on GPIO25 and have to set state in config.txt:
Code: Select all
# nano /boot/config.txt

Set initial state for pin GPIO25
Code: Select all
      # Set GPIO25 to be an output set to 1
      gpio=25=op,dh

That should do it. If you wire reset PIN on some other GPIO you define it in mpd_oled command line with switch -r (default is 25):
Code: Select all
mpd_oled -o 3 -r 25 -b 32 -g 1 -s 25.0,5.0,0.0 -f 25


-------------------------------------------------------------
--------- ADD: Modifying c++ -----------------------
-------------------------------------------------------------
If you change something in c++ code (I don't need volume indicator so I managed to put there a shuffle indicator), you need to compile new code:
Code: Select all
# CC=clang CXX=clang++ PLAYER=RUNEAUDIO make

and check...
Code: Select all
# ./mpd_oled -o 6 -r 25 -b 32 -g 1 -s 25.0,5.0,0.0 -f 25
Mat
 
Posts: 21
Joined: 01 Jul 2015, 12:19

Re: mpd_oled - OLED status and spectrum display for Raspberr

Postby adrii » 21 May 2019, 15:58

Hi Mat

That is great, thanks a lot for posting your steps!

Using "pacman -Sy' and installing the extra packages produced a working compiler.

Also, while looking at the runeaudio.php source I noticed that the patch is not necessary (which is good news). All that is needed is
Code: Select all
cp mpd_oled_fifo.conf /home/your-extra-mpd.conf


I'll prepare updated instructions, then check them on a clean install, and then update the mpd_oled repository.

Thanks again!

Adrian.
User avatar
adrii
 
Posts: 25
Joined: 17 Apr 2018, 11:03

Re: mpd_oled - OLED status and spectrum display for Raspberr

Postby adrii » 22 May 2019, 08:20

I have updated the mpd_oled repository with the new instructions

https://github.com/antiprism/mpd_oled/b ... NEAUDIO.md

Adrian.
User avatar
adrii
 
Posts: 25
Joined: 17 Apr 2018, 11:03

Re: mpd_oled - OLED status and spectrum display for Raspberr

Postby Mat » Yesterday, 15:00

Great Andii. Thanks for info about runeaudio.php, I didn't go so deep :)

I would like to ask you for an advice about c++. I havent seen c++ for a while, so basically no direct knowlegde about it but I understand how it works and I am familiar with other languages.

I can see that there is endless loop in main.cpp from which "draw_display" method is called. It reads data from mpd.

Now, I would like to add some kind of interrupts for displaying notifications. Like global variable which I can change from outside that program. I do not like to operate runeaudio with smartphone so I have a lot of commands on IR remote. For example loading different playlists, initiate shut down, etc. It would be great If I could display a short message on OLED screen when some action is made. Examples: "Playlist 01 loaded", "Radio stations loaded", "Shutting down in progress", ...

I would be thankful to hear what would be your approach to push "notifications" to infinite loop in main.cpp? What would be best solution for communication? I know that I could write message to file and check the file system from c++ but this is pretty nasty solution. If there was some kind of buffer or variable in mpd that would be probbably the correct way. So writing to buffer on one side and read/clean buffer on other side. But I do not know where to store that message. Maybe some other interrupts?

If you can give me some advice I would be thankful. Anyway thanks for mpd_oled program and instructions.

Regards, Mat
Mat
 
Posts: 21
Joined: 01 Jul 2015, 12:19

support RuneAudio Donate with PayPal

Previous

Return to DIY and tweaks

Who is online

Users browsing this forum: No registered users and 1 guest