DEV: [PLUGIN] MPD_OLED for x86 based systems

Just playing around, but this is a dirty solution, but working for the time being.

/usr/local/bin/mpd_oled -o SSD1306,128X64,I2C,bus_number=$(dmesg | grep -iE "i2c-ch341-usb 3-6:1.0: ch341_i2c_probe: created i2c device" | sed 's/^.*[/]//' | sed 's/.*-//') -f 50

I am not currently working on anything (!), but hopefully that won’t be for too much longer.

1 Like

For the smart ones:
If I start mpd_oled via a service (executing a bash script), 2 pipes are created, but CAVA won’t work.
image

If I start the same script manual, 2 new pipes are created and CAVA works.
image

Which logic am I missing here?

Is the same mpd_oled command being run in both cases? You could print the contents of the two cava_config_XXXXXXX files and see if cava is reading audio data from the same place.

Not working:

volumio@volumio-x86-s2:~$ sudo cat /tmp/cava_config_H9ldn8
[general]
framerate = 50
bars = 16

[input]
method = fifo
source = /tmp/mpd_oled_fifo

[output]
method = raw
data_format = binary
channels = mono
raw_target = /tmp/cava_fifo_1757
bit_format = 8bit
volumio@volumio-x86-s2:~$

Working:

volumio@volumio-x86-s2:~$ sudo cat /tmp/cava_config_4yHvuo
[general]
framerate = 50
bars = 16

[input]
method = fifo
source = /tmp/mpd_oled_fifo

[output]
method = raw
data_format = binary
channels = mono
raw_target = /tmp/cava_fifo_1977
bit_format = 8bit
volumio@volumio-x86-s2:~$

both uses the same script…
Not working is started via a service:

volumio@volumio-x86-s2:~$ sudo cat /lib/systemd/system/oled.service
[Unit]
Description=MPD OLED Plugin
After=network.target sound.target mpd.service
Requires=mpd.service

[Service]
ExecStart=/bin/bash /home/volumio/scripts/start_mpd.sh

[Install]
WantedBy=multi-user.target

The working one started via putty.
./start_mpd.sh

#/bin/bash
sleep 10s
/usr/local/bin/mpd_oled -o SSD1306,128X64,I2C,bus_number=$(dmesg | grep -iE "i2c-ch341-usb 3-6:1.0: ch341_i2c_probe: created i2c device" | sed 's/^.*[/]//' | sed 's/.*-//') -f 50

The config files seem fine. I recommend stopping the mpd_oled service, checking no copies of mpd_oled or mpd_oled_cava are running, then restart mpd and then start the mpd_oled service again. Sometimes when running a lot of test mpd_oled commands the spectrum fails to work for some reason, and so checking using a fairly fresh state should hopefully discount this.

Just got my adapter delivered, attached an I2C OLED, and plugged it in to a laptop. All working fine. I have unplugged it several times and plugged it into different USB ports and it is always assigned bus number 8 (there are existing entries 0 - 7).

dollatek_test01

1 Like

The issue is that the service is started as root.
Even adding

User=volumio
Group=volumio

Doesn’t make a difference.

volumio@volumio-x86-s2:~$ sudo ps aux | grep oled
root      1767  1.6  0.0  82844  3332 ?        Sl   17:16   0:01 /usr/local/bin/mpd_oled -o SSD1306,128X64,I2C,bus_number=0 -f 50
volumio   1852  0.0  0.0   3084   884 pts/0    S+   17:17   0:00 grep oled
volumio@volumio-x86-s2:~$ sudo ps aux | grep oled
root      1767  1.0  0.0  82844  3332 ?        Sl   17:16   0:01 /usr/local/bin/mpd_oled -o SSD1306,128X64,I2C,bus_number=0 -f 50
volumio   1884  1.1  0.0  82844  3444 pts/1    Dl+  17:18   0:00 /usr/local/bin/mpd_oled -o SSD1306,128X64,I2C,bus_number=0 -f 50
volumio   1894  0.0  0.0   2388   752 pts/1    S+   17:18   0:00 sh -c mpd_oled_cava -p /tmp/cava_config_ZJsXNC
volumio   1895 18.0  0.0  16880  6416 pts/1    Sl+  17:18   0:00 mpd_oled_cava -p /tmp/cava_config_ZJsXNC
volumio   1900  0.0  0.0   3084   880 pts/0    S+   17:18   0:00 grep oled

Running volumio on that machine, or just linux?

I am running Ubuntu 22.04 on the laptop.

Ah, the holy hand! Good work!

I’ve ordered the same USB dongle to do some testing on Windows. I think I’ll probably have to bite the bullet and install linux if I wanna do any serious dev because so far there’s better/faster drivers for the USB to I2C devices.

I wonder if I could install Ubuntu 22.04 on a VM :rofl: I have loads of random computers around the house, I don’t wanna have to buy another :joy: I’d need Ubuntu on a laptop, I do have an old laptop upstairs, it’s a bit slow hmmm…

1 Like

If the script is executing as root, could you use sudo -u volumio /usr/local/bin/mpd_oled ... in the script.

Yes that did the trick, me the old :goat: learned something new :slight_smile:

:partying_face: :+1: :partying_face: :+1: :partying_face: :+1::partying_face: :+1::partying_face: :+1:

1 Like

I have windows running in a VM on Ubuntu, and then WSL Windows subsytem for Linux installed in that, which is like Ubuntu in Windows on Ubuntu (I do have a reason for this!). I just tried to build the adapter module in that, but I could not install the kernel headers package as it is not available. I saw comments that there is now a WSL2 now that does have headers available and sugestions that modules could be built on it, so that might be an option.

Otherwise, if you have older hardware then Lubuntu is pretty good. I used it for years on netbooks and a core 2 duo.

1 Like

Let me get this correct as this is mind bubbling…
You have a Linux OS, Which runs Windows in a VM, that again runs Ubuntu in a VM?

Final results:
MPD_OLED on x86 works for, including CAVA:

  • Music Library
  • Web radio plugins
  • Web radio
  • Qobuz

Not working with CAVA, (Which doesn’t bother me):

  • Spop
  • Airplay
1 Like

I am not entirely sure of the details, but I am using WSL1, which seems to be not exaclty a VM, but WSL2 does appears to be one

Install WSL | Microsoft Learn

It works well. The user experience is just like starting a program, only you get a bash shell in a terminal window that appears to be on an Ubuntu system. It is sufficiently the same that I have a project that I share as Ubuntu binary packages on Launchpad, and these can be installed and run directly in this bash shell.

Aha, ok thanks for the clarification. Now it makes sense :smile:
image

1 Like

CH341 on a pure Windows system is possible. I had to install a driver and use the supplied DLL. I didn’t fancy writing more code to output random lines to the display. :yawning_face::yawning_face::yawning_face:

It seems that Linux is better equipped based both your experiments. No point using .NET to drive displays if you want a decent frame rate. :grimacing: Very handy to be able to have GPIO and I2C on x86 though :grin:

4 left, one for immediate shipping, 3 after replacing the 3V cmos battery (coming Friday).

1 Like

@Adrii

Would be great if could have an option regarding the lay-out of the spectrum display:

image

void draw_spect_display(U8G2 &u8g2, const display_info &disp_info)
{
  draw_text(u8g2, 5, 55, "31", u8g2_font_tom_thumb_4x6_t_all);
  draw_text(u8g2, 15, 55, "63", u8g2_font_tom_thumb_4x6_t_all);
  draw_text(u8g2, 25, 55, "125", u8g2_font_tom_thumb_4x6_t_all);
  draw_text(u8g2, 39, 55, "250", u8g2_font_tom_thumb_4x6_t_all);
  draw_text(u8g2, 53, 55, "500", u8g2_font_tom_thumb_4x6_t_all);
  draw_text(u8g2, 65, 55, "1k", u8g2_font_tom_thumb_4x6_t_all);
  draw_text(u8g2, 77, 55, "2k", u8g2_font_tom_thumb_4x6_t_all);
  draw_text(u8g2, 89, 55, "4k", u8g2_font_tom_thumb_4x6_t_all);
  draw_text(u8g2, 101, 55, "8k", u8g2_font_tom_thumb_4x6_t_all);
  draw_text(u8g2, 113, 55, "16k", u8g2_font_tom_thumb_4x6_t_all);
  
  draw_spectrum(u8g2, 5, 0, 128, 53, disp_info.spect);