Volumio Player Part 5 - WyrmTech

Go to content

Volumio Player Part 5

Pi Bits > Volumio Player
Tweaks to the Display Settings

I had a couple of niggles with the way the information was displayed from the NanoSound plugin.
  • The icon for cloud playback had a missing line down it.
  • Scrolling for the Track name
  • Scrolling for the Album name

The python script for the display is held at /home/volumio/nanodac_oled.py so I thought I would have a play. Please bear in mind I am not a programmer, this has been done in the spirit of tinkering.

It's not a NanoMesher device so I didn't want it display the NanoSound name when it starts up.
So in nanodac_oled.py I changed the line
draw.text((5, 2), "NanoSound v1.5.2",font=font1, fill="white")
to
draw.text((1, 2), "Volumio v2.413",font=font1, fill="white")

The Cloud icon
The font FontAwesome is used for the icons on the display
The icon for cloud playback, , (u+f1be) that is used I felt didn't look very good, as when it was shown on the small display it just looked like it had a line missing as though the display was broken so I had a look through the character map and decided on this one instead , (u+f0c2) which seems to display well.
So I changed the line
webradio="\uf1be"
to
webradio="\uf0c2"

Scrolling text
The scrolling text is controlled by the start / finish position of the displayed text, not by the number of characters, to increase the range I changed the line
for x in range(100,-10,-3):
to
for x in range(125,-25,-3):
This starts the text display at an earlier position and finishes it at a later position so the scroll will start 3 pixels in from the right and scroll for an additional 40 pixels.

I have also altered the behaviour of the scroll, as 18 characters seem to fit on the display, the original only scrolled the track title regardless of whether it fitted on the display  or not.
I have some files with long track names and some with long Artist names (even some with both). So for both the Title and Artist I wanted them to scroll if the text was longer than 18 characters.
The line draw.text((x, 2), title,font=font1, fill="white") scrolls the Title and after a bit of fiddling I came up with this:

# draw.text((x, 2), title,font=font1, fill="white")
w4, h4 = draw.textsize(text=title,font=font1)
left4 = (device.width - w4) / 2
if len(title) > 18:
draw.text((x, 2), title,font=font1, fill="white")
else:
draw.text((left4, 2), title,font=font1, fill="white")

Which seems to manage to centralise the text if it is less than 18 Characters, but provide the scroll if greater.
As that worked for me I then applied the same idea to the Artist text (the left position has already been worked out in the original code):

# draw.text((left, 18), artist,font=font1, fill="white")
if len(artist) > 18:
draw.text((x, 18), artist,font=font1, fill="white")
else:
draw.text((left, 18), artist,font=font1, fill="white")

I've provided a copy of the whole changed section of code below:


with canvas(device) as draw:
draw.rectangle((0, 0, device.width-1, device.height-1), outline="white", fill="black")
# draw.text((x, 2), title,font=font1, fill="white")
w3, h3 = draw.textsize(text="\uf177", font=awesomefont)
w, h = draw.textsize(text=artist,font=font1)
w2,h2 = draw.textsize(text=bitrate)
left = (device.width - w) / 2
left2 = (device.width - w2) / 2
w4, h4 = draw.textsize(text=title,font=font1)
left4 = (device.width - w4) / 2
if len(title) > 18:
draw.text((x, 2), title,font=font1, fill="white")
else:
draw.text((left4, 2), title,font=font1, fill="white")
# draw.text((left, 18), artist,font=font1, fill="white")
if len(artist) > 18:
draw.text((x, 18), artist,font=font1, fill="white")
else:
draw.text((left, 18), artist,font=font1, fill="white")
draw.text((5,36), filetype, font=awesomefont,fill="white")
if(ampon):
draw.text((device.width - 17,36), headphone, font=awesomefont,fill="white")
else:
draw.text((device.width - 17,36), " ", font=awesomefont,fill="white")
draw.text((left2, 36), bitrate, fill="white")
draw.text((10, 50), elapsed, fill="white")
draw.text((60, 50), repeat, font=awesomefont, fill="white")
draw.text((75, 50), random, font=awesomefont, fill="white")
draw.text((92, 50), text="\uf028", font=awesomefont,fill="white")
draw.text((105, 50), volume, fill="white")
time.sleep(0.35)
Visitor Number:
Back to content