So I've admittedly had a PocketCHIP on my desk for several months now when I finally picked it up and decided to play around with it. The first thing that came to mind was mounting it to a wall somewhere and using it as a touch screen control panel. Problem is I don't want it to look like a little computer, I want it to look like a control panel. This means I don't want to launch software from the desktop I just want it to be there when I walk up to interface with it. In this article I'll show you how to display a UI on the PocketCHIP touch screen complete with buttons and sensor read outs. We'll write the GUI application in Python using TKinter and we will boot the PocketCHIP straight into our GUI application so it looks just like a control panel.
For this project I used:
I installed SSH on CHIP since it was not installed by default. I find this much easier than using the key board on PocketCHIP. It's usable but not as good as a real key board. Also I can use SSH to upload files to CHIP for an added bonus. I also highly recommend turning off power management on the CHIP as explained here, this will keep your SSH connection from bricking all the time when you let it sit idle.
You'll need smbus in order to control I2C devices from Python on PocketCHIP, unless you want to use low level C file calls(YUCK). So install SMBUS like this
sudo apt-get install python-smbus
TKinter comes pre-installed in Python so nothing to do there.
That is pretty much all I did to the stock PocketCHIP.
I created a github repo with the Python script that runs the UI on TKinter and the shell script that launches that Python script using crontab on reboot. Take a look here. There is not allot going on in the shell script. You will notice a shady sleep 30 at the top though. The reason for this is the PocketCHIP display is not ready when this script is ran by cron so we need to wait 30 seconds for the PocketCHIP to boot just a bit more. The Python code is pretty well commented, if I do say so myself, but if you have any questions on it please ask in the comments below.
SSH into PocketCHIP. You should be at /home/chip when you ssh in. If so create a directory there where we will put everything:
Go ahead and download the launcher.sh and Hello.py to your computer and then upload them to the PocketCHIP using SSH like this(note you need to be on your computer and not ssh'd into the chip when you do this):
scp <source> <destination>
<source> being the location of Hello.py or launcher.sh and <destination> being chipIPAddress/home/chip/pyscripts For more info please do a google search for SSH file upload and you will find all kinds of info.
Upload both files to the pyscripts directory on the PocketCHIP and we are ready to move one.
We need to make launcher.sh executable so navigate to the /pyscripts directory and enter:
chmod 755 launcher.sh
Now we need to tell crontab to run that shell script any time the CHIP reboots. On the CHIP SSH terminal enter:
sudo crontab -e
scroll down to the bottom of that file and enter:
@reboot sh /home/chip/pyscripts/launcher.sh
cron will now run this shell script any time the CHIP boots. This will launch our GUI application immediately without even displaying CHIP's desktop.
Finally reboot CHIP and it should go straight to the canned UI i created in TKinter:
That's it. Pretty simple huh!?
Now feel free to go nuts customizing the UI with TKinter. You really can do quite a bit with it. I just put this really simple UI together to show how to get started.
Did you replicate this project? Share it!I made one
Love this project? Think it could be improved? Tell us what you think!