This repository was archived by the owner on Jun 14, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 29
Add example for Scroll pHat #41
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
69066c7
Added an example and a README for the Scroll pHat device
DanielSSilva 9fc5caf
added the image
DanielSSilva 99ba98b
yet another image, this time it's the result of the script
DanielSSilva 9bc2e8b
Added the copyright. Changed from Lightning effect to brightness to b…
DanielSSilva e061066
Forgot to change one "lightning"
DanielSSilva File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
36 changes: 36 additions & 0 deletions
36
Examples/Microsoft.PowerShell.IoT.Scroll_pHat/Microsoft.PowerShell.IoT.SadJoey.ps1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# Copyright (c) Microsoft Corporation. All rights reserved. | ||
# Licensed under the MIT License. | ||
Import-Module Microsoft.PowerShell.IoT | ||
|
||
[int]$DeviceAddress = 0x60 | ||
######### Configuration Register and Value ######### | ||
[int]$ConfigurationRegisterAddress = 0x00 | ||
[int]$ConfigurationRegisterValue = 0x1B | ||
|
||
######### Data Registers and value ######### | ||
[int[]]$DataRegisterAddress = 0x04 ..0x08 | ||
[int[]]$values = 0x12,0x08,0x08,0x08,0x12 | ||
######### Brightness Register and value ######### | ||
[int]$BrightnessRegisterAddress = 0x0D | ||
[int]$BrightnessRegisterValue = 0x08 #Lowest intensity | ||
|
||
######### Get the device and set the Configuration Register | ||
$Device = Get-I2CDevice -Id $DeviceAddress -FriendlyName phat | ||
Set-I2CRegister -Device $Device -Register $ConfigurationRegisterAddress -Data $ConfigurationRegisterValue | ||
|
||
######## Brightness ##### | ||
Set-I2CRegister -Device $Device -Register $BrightnessRegisterAddress -Data $BrightnessRegisterValue | ||
|
||
######### Write the #sadJoey pattern to the Data registers ######### | ||
$i = 0 | ||
foreach ($register in $DataRegisterAddress) { | ||
Set-I2CRegister -Device $Device -Register $register -Data $values[$i] | ||
$i++ | ||
} | ||
|
||
#In order to update the registers, we need to write something to the column register, accoding to the datasheet: "A write operation of any 8-bit value to the Update Column Register is required to update the Data Registers" | ||
[int]$UpdateRegisterAddress = 0x0C | ||
[int]$UpdateValue = 0xFF | ||
|
||
#After executing this instruction, a Sad Joey should appear on your pHat :) | ||
Set-I2CRegister -Device $Device -Register $UpdateRegisterAddress -Data $UpdateValue |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# Example on how to interact with Scroll pHat | ||
|
||
With this example, we will see how we can interact with [Scroll pHat](https://shop.pimoroni.com/products/scroll-phat). | ||
|
||
## Information | ||
|
||
After reading the [driver's data sheet](http://www.issi.com/WW/pdf/31FL3730.pdf) 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). | ||
|
||
## Software setup | ||
|
||
### Install PowerShell Core on Raspberry Pi | ||
|
||
Installation instructions can be found [here](https://github.com/PowerShell/PowerShell/tree/master/docs/installation/linux.md#raspbian). | ||
|
||
### Enable I2C interface on Raspberry Pi | ||
|
||
1. `sudo raspi-config` | ||
2. `5 Interfacing options` | ||
3. `P5 I2C` | ||
4. `Would you like ARM I2C interface to be enabled -> Yes` | ||
|
||
Start PowerShell (**with sudo, so that you can access the I2C bus**) | ||
|
||
```powershell | ||
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](https://twitter.com/search?q=%23sadJoey&src=typd) during the #PSConfEU 2018 | ||
|
||
This is what you should see: | ||
|
||
 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh yeah this file will need the copyright. You can do it if you want or I can add it before merging.