With this example, we will see how we can interact with Scroll pHat.
After reading the driver's data sheet we know the following:
There are three "types" of registers: Configuration register, Update register and data registers. The configuration register value is set to have the expected behaviour of this pHat.
There are 11 data registers, ranging from address 0x01 to 1x0B. Each register holds 1byte, but since ScrollPHat only has 5 lines, only 5bits are used. To set the LED on, you need to set the correspondent bits as 1, as example, to achieve the following:
we need to set the register 1 with data 0x0D (0000 1101).
Installation instructions can be found here.
sudo raspi-config
5 Interfacing options
P5 I2C
Would you like ARM I2C interface to be enabled -> Yes
Start PowerShell (with sudo, so that you can access the I2C bus)
sudo pwsh
git clone https://github.com/PowerShell/PowerShell-IoT.git #if you haven't already
./PowerShell-IoT/Examples/Microsoft.PowerShell.IoT.Scroll_pHat/Microsoft.PowerShell.IoT.SadJoey.ps1
After running this code, you should see a "Sad Joey" on your Scroll pHat.
Note: What's "Sad Joey"? - #SadJoey became "popular" meme/hastag on twitter during the #PSConfEU 2018
This is what you should see: