Display Hat Mini adopt screen symbols in PirateAudio display.py

I am trying to use Display Hat Mini with PirateRadio by modifying display.py. So far successful but symbols for dropdown ( button X ) and volume loudspeaker need repositioning . Unfortunately I cannot find the parameters location in display.py. Any help appreciated.My testbed is running on PiZeroW and volumio v3.179.

Best Regards
Carl Blyh in Helsinki

1 Like

It’s in the def f_content(field, fontsize, top, shadowoffset=1) part of the display.py script, specifically lines 389-399:

        # paste button symbol overlay in light/dark mode
        if status == 'play':
            # draw.text((4, 53), u"\uf04C", font=font_fas, fill=txt_col)  # Fontawesome symbol pause
            f_drawtext(4, 53, u"\uf04C", font_fas, txt_col)
        else:
            # draw.text((4, 53), u"\uf04b", font=font_fas, fill=txt_col)  # Fontawesome symbol play
            f_drawtext(4, 53, u"\uf04b", font_fas, txt_col)
        # draw.text((210, 53), u"\uf0c9", font=font_fas, fill=txt_col)  # Fontawesome symbol menu
        f_drawtext(210, 53, u"\uf0c9", font_fas, txt_col)
        # draw.text((210, 174), u"\uf028", font=font_fas, fill=txt_col)  # Fontawesome symbol speaker
        f_drawtext(210, 174, u"\uf028", font_fas, txt_col)

The first two numbers are the X and Y co-ordinates of the fontawesome icon, and the menu and speaker ones that you need are the last two. As you can see, they are currently using a fixed position which is wrong for the displayhat as it’s a wider screen than the pirate audio one.

What I did for mine was to make the position variable, depending on the screen width:

        f_drawtext((WIDTH-30), 53, u"\uf0c9", font_fas, txt_col)
        f_drawtext((WIDTH-30), 174, u"\uf028", font_fas, txt_col)

It’s in the script I shared with you in the Pimoroni forum (this one). Alternatively you can just set the new fixed positions if you want - the width is 320 pixels so the X co-ord would be 290 rather than the original 210.

1 Like

Thanks Darren, changes implemented, works great. Easy job when you know howto…

1 Like

If it’s fulfilled everything, you can mark is as the solution.

Glad to hear it’s working though, and yes, once you know where to look and how to do, the job’s not that tricky. Even an idiot like me could do it :wink:


This Diy Tweak is now fulfilled

Thanks Darren for your contribution

I successfully installed the newest version of volumio (v3.423) and the PirateAudio plugin (v0.1.1). The plugin worked, but I still have to make some changes to make it look good on the Display Hat Mini from Pimoroni. I tried to modify some parameters in display.py, but without much success.

Can someone provide a display.py code for the PirateAudio plugin(v0.1.1), that works for the display hat mini? :pray:
I already tried the code that DarrenHill posted as a link, but it seems to be for an older version of the plugin.
Unfortunately I am a complete beginner in programming, so I don’t have the skills to create a working file myself :grimacing:
Thanks for your help!

Best regards
Henrik from Germany

Hello Henrik in Germany
My internet radio is running on Volumio veraion 3.233
Pirate radio plugin is version 0.0.6
It is about one year ago now I made this installation and with the modifications
and help from Darren Hill.
I have been thinking af making an new installation on latest available version
of Volumio 3.423 and PirateAudio 0.1.1
I assume you have seen the tweaks sent ny DarrenHill to me a yraer ago.
Likewise as you say I am not skilled programmer at all so I need to consider is it worth
the effort to make a new installation while I am very happy with my present version.
I dont know van i be of any further help to you, but please imform me how uou are proceeding with your version
Is there in the plugins section already o plugin for Pirate Audio v o.1.1? I didsome search but couldnot find
Good Luck to you

Carl Blyh
Helsinki / Finland

So I started outof curiosity to download v 3.423 the problem however I couldnot find and install any version of pirateaudio plugin so is what benefits are there to use v3.423 and plugin v0.1.1 compared to my earlier installation

Greetings from Helsinki
Carl

Also in my case, my radio is still going using the older version of the plugin (although the current one of Volumio itself) as it’s heavily modified as noted above (and still works fine for my needs). Plus my Display Hat Mini is now built into another project, so difficult to use for testing.

When i can find some time this week I’ll look into the new version of the plugin and see if I can find any significant changes that might be messing things up. But from the photo posted above, it looks like it’s set to the wrong screen dimensions, giving the random pixelation across the top and the banding on the main image.

I would suggest to confirm exactly what display dimensions are set, as I don’t think what you have is correct. The DH mini is 320x240 pixels - check that’s what is set up in the code.

I think the PirateAudio plugin is still in beta status, so you need to enable test plugins via your-volumio-ip/dev

@HenniM Could you post the part of display.py that you are running which defines the screen?

It should be somewhere near the top of the script, and look something like this:

disp = ST7789.ST7789(
    height=240, #v0.0.6
    width=320, #v0.0.6
    rotation=180,  # Needed to display the right way up on Pirate Audio
    port=0,       # SPI port
    cs=1,         # SPI port Chip-select channel
    dc=9,         # BCM pin used for data/command
    backlight=13,
    spi_speed_hz=60 * 1000 * 1000,
    offset_left=0, #v0.0.6
    offset_top=0 #v0.0.6
)

The above is my code from when I was running the plug-in remotely on my Display Hat Mini, note the width=320 and the rotation = 180, both of which are different from the original plugin for the actual pirate audio display. Also the spi_speed_hz is 60* for the DM but 80* for the pirate audio.

Can you see what your script has for those three items in the display definition, and if they are different from the above try the values I’ve posted.