Skip to content

Commit 1efbcab

Browse files
committed
Successfully initialized the communication with phat. For now I'm able to light up any led
1 parent 805f0a0 commit 1efbcab

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

Initialize_SadJoey.ps1

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
Import-Module Microsoft.PowerShell.IoT
2+
3+
function Set-RegisterValue {
4+
param($Device, [int]$Register, [int]$Value)
5+
######### Update register Address and value #########
6+
[int]$UpdateRegisterAddress = 0x0C
7+
[int]$UpdateValue = 0xFF # for what I understood, it can be any value " A write operation of any 8-bit value to the Update Column Register is required to update the Data Registers"
8+
9+
Set-I2CRegister -Device $Device -Register $Register -Data $Value #Write the value
10+
Write-Host "Device: $($Device) - Value: $($Value) - Register: $($Register)"
11+
Set-I2CRegister -Device $Device -Register $UpdateRegisterAddress -Data $UpdateValue #update the register
12+
}
13+
14+
[int]$DeviceAddress = 0x60
15+
16+
######### Configuration Register and Value #########
17+
18+
[int]$ConfigurationRegisterAddress = 0x00
19+
[int]$ConfigurationRegisterValue = 0x1B
20+
21+
######### Matrix Registers and value #########
22+
[int[]]$Matrix1DataRegisterAddress = 0x01 ..0x0B
23+
[int[]]$values = 0x0,0x0,0x0,0x11,0x08,0x08,0x08,0x11,0x0,0x0,0x0
24+
######### Lightning Effect Register and value #########
25+
[int]$LightningEffectRegisterAddress = 0x0D
26+
[int]$LightningEffectRegisterValue = 0x08
27+
######### Get the device and set the Configuration Register
28+
$Device = Get-I2CDevice -Id $DeviceAddress -FriendlyName phat
29+
Set-I2CRegister -Device $Device -Register $ConfigurationRegisterAddress -Data $ConfigurationRegisterValue
30+
31+
######## Lightning Effect #####
32+
Set-I2CRegister -Device $Device -Register $LightningEffectRegisterAddress -Data $LightningEffectRegisterValue
33+
34+
######### Write the #sadJoey pattern to the Data registers #########
35+
36+
$i = 0
37+
foreach ($register in $Matrix1DataRegisterAddress) {
38+
Set-RegisterValue -Device $Device -Register $register -Value $values[$i]
39+
$i++
40+
}

0 commit comments

Comments
 (0)