Moode Forum
[How to do instruction] 128x64 OLED with Song Status and Spectrum Display on Raspberry Pi - Printable Version

+- Moode Forum (https://moodeaudio.org/forum)
+-- Forum: moOde audio player (https://moodeaudio.org/forum/forumdisplay.php?fid=3)
+--- Forum: FAQ and Guides (https://moodeaudio.org/forum/forumdisplay.php?fid=9)
+--- Thread: [How to do instruction] 128x64 OLED with Song Status and Spectrum Display on Raspberry Pi (/showthread.php?tid=155)



RE: 128x64 OLED with Song Status and Spectrum Display on Raspberry Pi - pelukessss - 05-22-2018

(05-22-2018, 07:53 AM)adrii Wrote: Hi

If the patch program reports that the patch is already applied then that should mean that the changes were applied correctly.

There seem to be two factors in getting mpd.conf regenerated with the FIFO included: the Moode software appears to be cached, and so patches won't necessarily be seen straight away; the software has to receive a trigger to regenerate /etc/mpd.conf.

I have just checked the time stamp on my /etc/mpd.conf, and I can see that it has not been regenerated by a machine restart

Code:
pi@moode:~ $ ls -l /etc/mpd.conf
-rw-rw-rw- 1 mpd audio 1675 Apr 28 08:41 /etc/mpd.conf

In which case, in the Moode UI go to "Moode" / "Configure" / MPD, and click the first "APPLY" button on that page. This appears to trigger the regeneration of /etc/mpd.conf

Code:
pi@moode:~ $ ls -l /etc/mpd.conf
-rw-rw-rw- 1 mpd audio 1675 May 22 09:27 /etc/mpd.conf

If this works out, I will amend the installation instructions to carry out this action after the machine restart (which appears to clear the cache of the unpatched Moode software).

Thanks for the feedback!

Adrian
Ehm... I feel a little bit stupid, I just realized that I had volume on 0 (I'm testing it with no speakers connected), I'm sorry  Big Grin
I turned up the volume on Moode and now it seems to be working, even if I noticed something strange: when I turned up the volume, all the spectrum bars went to max level for a couple of seconds. After that they returned to a "normal" level...
Before the volume "issue" the mpd.conf file did not include the mpd_oled_fifo.conf configuration, after regenerating mpd.conf through the "APPLY" button the code was there...
If you need I can start from scratch and test if you have to regenerate the file in order to make it work...
Thank you again!


RE: 128x64 OLED with Song Status and Spectrum Display on Raspberry Pi - adrii - 05-22-2018

Hi

That is great!

The reason for the initial high values in the spectrum is that the Cava program, which calculates the spectrum, is run with a setting that lets it adapt to the audio level. Starting from zero volume, it prints high values when the audio starts, and then settles down to more appropriate values.

I have updated the Moode installation instructions with the extra step. Hopefully that is all the issues ironed out now! Thanks for offering to test on a fresh build (I previously did this, so I am surprised to see the issues). If you do this then that would be great, otherwise if Drone7 is going to be installing mpd_oled I will probably get some feedback then.

Adrian.


RE: 128x64 OLED with Song Status and Spectrum Display on Raspberry Pi - pelukessss - 06-01-2018

(05-22-2018, 02:44 PM)adrii Wrote: Hi

That is great!

The reason for the initial high values in the spectrum is that the Cava program, which calculates the spectrum, is run with a setting that lets it adapt to the audio level. Starting from zero volume, it prints high values when the audio starts, and then settles down to more appropriate values.

I have updated the Moode installation instructions with the extra step. Hopefully that is all the issues ironed out now! Thanks for offering to test on a fresh build (I previously did this, so I am surprised to see the issues). If you do this then that would be great, otherwise if Drone7 is going to be installing mpd_oled I will probably get some feedback then.

Adrian.

Hi Adrian!
Sorry, been busy... I started from scratch and it worked with the updated info!
I tried on another system with a Pi 3 with an Allo Boss DAC and I can confirm it also works connected to the Boss GPIO pins.

Now I'd like to customize a little bit the information shown by the display (e.g. I'd like to show the codec -FLAC, MP3 etc.- and other info, remove the clock when music is playing, stretch a little bit the spectrum analyzer in order to fill the entire screen width etc.), is there a way to modify the layout of the info on the OLED?

Thank you very much for your help!


RE: 128x64 OLED with Song Status and Spectrum Display on Raspberry Pi - adrii - 06-01-2018

Hi

There are no configuration options for the screen layout, but you could modify the display function: draw_spect_display() in main.cpp. The display widget functions are in display.h, and the parameter names indicate what each represents. The spectrum height and width can be set.

I thought I might include a few fixed layouts as an option, which is easier than making the layout configurable. If you want to share your layout I can include it when I add the option. I have also been asked to include scrolling for long text fields, and I will be adding this.

The codec name is not currently collected by mpd_oled, and so cannot be displayed. I am not really sure where to find it. On Volumio, "volumio status" includes it for some sources. The MPD "currentsong" command reports a file path/name, where the filename  extension could be extracted, but for a BBC radio stream it is a URL without a filename extension (maybe this "file" value is also returned by mpd_song_get_uri()  in libmpdclient). Is there another MPD command that specifically reports what codec is being used for the current audio?

Adrian.


RE: 128x64 OLED with Song Status and Spectrum Display on Raspberry Pi - pelukessss - 06-02-2018

(06-01-2018, 05:03 PM)adrii Wrote: Hi

There are no configuration options for the screen layout, but you could modify the display function: draw_spect_display() in main.cpp. The display widget functions are in display.h, and the parameter names indicate what each represents. The spectrum height and width can be set.

I thought I might include a few fixed layouts as an option, which is easier than making the layout configurable. If you want to share your layout I can include it when I add the option. I have also been asked to include scrolling for long text fields, and I will be adding this.

Adrian.

Hi
Thank you for your help! 
I'm trying to modify main.cpp, I'm not a coder so I don't really know how it works... I commented the "draw_time(display, 128-10*W, 2*H, 2);" line, saved the file and rebooted but nothing happened, do I need to recompile? How should I do it? Thank you and sorry for my dumb questions :-)

By the way the scrolling text is an awesome idea!


RE: 128x64 OLED with Song Status and Spectrum Display on Raspberry Pi - pelukessss - 06-07-2018

(06-01-2018, 05:03 PM)adrii Wrote: Hi

There are no configuration options for the screen layout, but you could modify the display function: draw_spect_display() in main.cpp. The display widget functions are in display.h, and the parameter names indicate what each represents. The spectrum height and width can be set.

I thought I might include a few fixed layouts as an option, which is easier than making the layout configurable. If you want to share your layout I can include it when I add the option. I have also been asked to include scrolling for long text fields, and I will be adding this.

The codec name is not currently collected by mpd_oled, and so cannot be displayed. I am not really sure where to find it. On Volumio, "volumio status" includes it for some sources. The MPD "currentsong" command reports a file path/name, where the filename  extension could be extracted, but for a BBC radio stream it is a URL without a filename extension (maybe this "file" value is also returned by mpd_song_get_uri()  in libmpdclient). Is there another MPD command that specifically reports what codec is being used for the current audio?

Adrian.

Hi Adrian,
is there also a way to turn the screen upside down? I may need to mount the screen turned by 180°... thank you!


RE: 128x64 OLED with Song Status and Spectrum Display on Raspberry Pi - adrii - 06-07-2018

Hi

I believe there is a function to rotate the screen, in which case I will provide an option it.

I asked on the MPD forum, and it is not possible to query MPD for the currently used  codec. As an alternative, I found a program (and possibly its library) called mediainfo, that will analyse the audio source and report its format. This works for files and streams.

For your custom display layout. I will add an option to choose the layout from a list. You could then send me a sketch of your layout and I could add it to the list.

I can't give a time frame for adding these things. However, the screen rotation is probably very easy, and I will look at that now.

Adrian.


RE: 128x64 OLED with Song Status and Spectrum Display on Raspberry Pi - pelukessss - 06-07-2018

(06-07-2018, 07:55 AM)adrii Wrote: Hi

I believe there is a function to rotate the screen, in which case I will provide an option it.

I asked on the MPD forum, and it is not possible to query MPD for the currently used  codec. As an alternative, I found a program (and possibly its library) called mediainfo, that will analyse the audio source and report its format. This works for files and streams.

For your custom display layout. I will add an option to choose the layout from a list. You could then send me a sketch of your layout and I could add it to the list.

I can't give a time frame for adding these things. However, the screen rotation is probably very easy, and I will look at that now.

Adrian.

Hi! Thank you for your support!
As I wrote on the previous post I modified main.cpp (even if I'm not a coder, so I don't really know how it works). I saved the file and rebooted but nothing happened, do I need to recompile? How should I do it? Thank you again and sorry if it's a silly question!


RE: 128x64 OLED with Song Status and Spectrum Display on Raspberry Pi - adrii - 06-07-2018

Hi

Yes, after changing the source code you will need to run 'make' to rebuild mpd_oled.

You shouldn't have to reboot to test your changes. I don't have Moode running right now, but you might be able to stop the installed mpd_oled with 'sudo systemctl stop mpd_oled' (and restart later with  'sudo systemctl start mpd_oled'). You can then run the local mpd_oled directly (and stop it with CTL-C) e.g.

Code:
sudo ./mpd_oled -o 6 -b 21 -g 1 -f 15


I looked at the 180 rotation of the display. It was not as easy as it appeared.

The Adafruit_GFX setRotation() function that rotates the screen turned out not to be included in the code I bundled with mpd_oled. I therefore grabbed the latest version of Adafruit_GFX, which does have the function, and incorporated it into mpd_oled. However, the included function is just a stub and needs to be implemented by the application! Anyway, I have written some code to do this. It is hardware  dependent, but I believe it supports all the display types supported by mpd_oled. I am going to keep using the latest Adafruit_GFX, so I want to do some more testing before releasing the changes that include the screen rotation.

Adrian.


RE: 128x64 OLED with Song Status and Spectrum Display on Raspberry Pi - pelukessss - 06-07-2018

(06-07-2018, 11:33 AM)adrii Wrote: Hi

Yes, after changing the source code you will need to run 'make' to rebuild mpd_oled.

You shouldn't have to reboot to test your changes. I don't have Moode running right now, but you might be able to stop the installed mpd_oled with 'sudo systemctl stop mpd_oled' (and restart later with  'sudo systemctl start mpd_oled'). You can then run the local mpd_oled directly (and stop it with CTL-C) e.g.

Code:
sudo ./mpd_oled -o 6 -b 21 -g 1 -f 15


I looked at the 180 rotation of the display. It was not as easy as it appeared.

The Adafruit_GFX setRotation() function that rotates the screen turned out not to be included in the code I bundled with mpd_oled. I therefore grabbed the latest version of Adafruit_GFX, which does have the function, and incorporated it into mpd_oled. However, the included function is just a stub and needs to be implemented by the application! Anyway, I have written some code to do this. It is hardware  dependent, but I believe it supports all the display types supported by mpd_oled. I am going to keep using the latest Adafruit_GFX, so I want to do some more testing before releasing the changes that include the screen rotation.

Adrian.

Thank you very much! I'll try to create some alternatives and send them to you.
If you need to do some testing I'm available