Installing TouchPhat under LibreElec

Just finished soldering up my TouchPhat, and was pondering using it to control my LibreElec travelling media player (running on a Pi Zero 1.3). At the moment I’ve got a protozero on top with 6x buttons connected via the GPIO, but I think the TouchPhat would be a nicer option.

My question is what is the best way to install things on the software side? Will the one-line curl set-up work, or do I need to do something manually to get it to work as looking in the bash script LibreElec isn’t amongst the recognised OS’s.

Is there a simple way to set up the python libraries needed to get it to work from the GitHub repo?

Is Libre ELEC one of those systems that mounts / as read-only, treating it a bit like firmware, so you can’t do anything untoward with it accidentally?

I think @RogueM is planning on looking into these at some point, since it’s not an uncommon question: How can I make SHIMs play nicely with Xbian/Kodi?

yes, I have grabbed current versions of all the gazillion KODI providing distros out there to make some assessment and roll support where possible.

It won’t happen right away however as I want to have an overview of what I’m dealing with across distros rather than code in support for specific distros if I can help it.

Gents,

Yes it’s a fairly locked down system in terms of adding stuff directly to the OS itself. LE is arguably the most locked-down of them all, although I wouldn’t say there’s gazillions of them (LE and OSMC being the main two, with OpenElec and XBian the other two specific Kodi-only packages, as opposed to just installing Kodi under a full OS like Raspbian or Arch).

But Kodi uses an add-on structure, and you can install python packages through those. If you set up a service add-on which runs at boot-time, then you can have the script available in the background to sit there and take inputs from the pHAT and take action on it (passing command calls to Kodi itself based on the board inputs in this case).

I’m working on it to see what I can get running, but it’s knowing quite what I need to cherry-pick out of the GitHub repo to include, and then how/where to put it in the add-on set-up so that the running python script can import it. Is it just the init.py script in the touchphat library plus the cat1xxx one, or is anything else required?

I will post detailed manual instructions to the touch phat repo in the course of the day. You don’t have to worry about cat1xxx as it is a declared dependency.

But in a nutshell:

sudo pip install touchphat
or
sudo pip3 install touchphat

is all you need. If not then we have a problem Houston…

well, and obviously you need the I2C interface available and python smbus around, but I assume you know that!

I don’t think pip or pip3 are available under LibreElec, so Houston may indeed have a problem (although it would probably work under other distros like OSMC that have a fuller install beneath them and can apt-get and suchlike). Hence my original question, as it’ll need to be done without install but with a manual set-up inside the Kodi add-on.

I’ve been talking to some other Team Kodi members (I’m one too, but not a coder) and have some pointers on how to integrate things, so will try them later and let you know. If I can get it working I’ll gladly share the add-on with you so you can review it and maybe do it better.

you can try the fully manual way, documented under ‘development’ here:

… ultimately you may struggle to get smbus going. Media server distros are really not designed to make life easy for any low-level GPIO stuff (besides possibly simple digital IO interfacing).

My current aim is to try to support OSMC as best as possible, as it has few restrictions I can foresee as problematic… any other KODI-providing distros I will do my best but throw limited efforts towards, we simply can’t provide full support for every single distro under the sun ;-)

@RogueM OK a quick update.

I checked with the LE guys, and smbus is available under LibreElec (it’s in the system tools addon). I’ve got that installed, plus written an add-on which includes your py files for touchphat and cat1xxx, plus I incorporated your button.py file as a test. The addon runs without generating any python errors in the log file, but the pHAT doesn’t do anything.

The hardware is fine, as I checked it under a new Raspbian Lite install with your one-line set-up and after a reboot it worked as expected with the button.py test file.

If I get time I’ll do more testing tonight, as I want to fully check that I2C is enabled (LE has an I2C tools add-on but I’ve not explored yet what it can offer) and whether I can get anything working via SSH directly outside Kodi. If it would be useful I’d be happy to send you the add-on plus instructions on what else LE may need adding to get you in the same set-up as I have.

One other question - does the touchphat require any specific dtoverlay settings in config.txt?