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?
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 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 ;-)
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?