Using a Raspberry Pi 2 with Ubuntu Snappy installed we’re going to write a simple snap that will flash a piglow attached to the gpio pins.
If you want to skip these steps you can download the snap itself from here
1. A simple piglow flashing binary
To make things simple we’ll use go to produce a simple binary that will flash the legs of the piglow. We’re using go because the static compilation means our snap will have no dependencies to deal with. The code itself is small. https://github.com/mattyw/flasher I modified the piglow library I was using to get a bit more feedback about piglow errors, the change is trivial to revert should you need to.
2. Create the snap
The package structure is simple
1 2 3 4 5 |
|
flasher is the binary I produced in step 1. The package.yaml just contains information about the snap:
1 2 3 4 5 |
|
Once you’ve got all this in place build it and send it over to your pi.
1 2 |
|
3. On the Pi
You need to give your snap permission to access the i2c device
1
|
|
4. You’re done
1
|
|
If all goes well you should have a flashing piglow