Changing current song and artist to a string

Volumio 3.198, Python3.x,
I want show the current song and artist (= new_title) from V’s API on my simple Preamp 20x2 display.
The first problem is that it will only display simple ASCII characters so I have a python line to ‘convert’ it.

title = unicodedata.normalize(“NFD”, new_title).encode(‘ascii’, ‘ignore’)

That seems to produce a byte string which I think I need to ‘convert’ to a simple string.
I have tried title = str(title), but that produces, for example.

b’Dire Straits - Once Upon A Time In’

And I am not sure how that will display.
Will it be ok or should I use another method?
Thanks

If I understand correctly you have a LCD matrix display, correct?
Depending on the manufacturer, you can most likely define a char map to use.
Something like:
mylcd = CharLCD('PCF8574', 0x27,charmap='A00')

With a bit of luck, you can solve it by adding this at the start of the script and leave all conversions out.

#!/usr/bin/python
# -*- coding: utf-8 -*-

Please take a look at my topic for a different mediaserver.

#!/usr/bin/python
# -*- coding: utf-8 -*-
import os, sys
from RPLCD.i2c import CharLCD

lcd = CharLCD('PCF8574', 0x27,charmap='A00')
lcd.write_string(u'Vänskä')

image

Thanks for your reply and suggestions. What you have described is all new to me so please excuse my simple questions. I didn’t write the original code, I am just trying to get what worked on a PI2B with V’ 2.x and python2 with a PI3B, V’3.x and python3, it originates from here: https://github.com/Djuke-DIYAudio/preamp
I believe the unicodedata.normalize line is there to handle any non-english characters in the song title/artist, whenever they appear. Won’t that make choosing a character set difficult?
Another possible complication, which perhaps I should have mentioned, is that the PI GPIO output is passed to a Preamp microcontroller and then on to the display. As far as I know the firmware just handles it with a python line like, preamp.write("title 9 " + title).
If it helps my display is a MIDAS MC22005A

Please post issue on github to update coding to pythin3, as this will become a gamble exercise for me. Don’t have the hardware.

Thanks for your interest.
As the original design and Github data was created by someone else I think I should ask their permission.
Also, as I have only ever downloaded data I will have to do a serious bit of learning to upload what I have done. If I may I will send you a message when it is available rather than use this thread.

Actually what i meant was to report that it’s not working on Volumio V3.xxx. Due to upgrade from Python2 to Python3 But if you have it working now you can share the code with Menno.

He is well aware and has helped me with some of the steps. A fellow Dutchman I believe !
I have already emailed him to ask if he wants a copy of my ‘procedure’ to date, which, if the preceding b is not an issue to the Controller, is now useable. I am just checking my PuTTY logs to make sure I have everything correctly recorded.

Yeah, Looking at his name he’s Dutch.