@@ -42,6 +42,7 @@ New-Variable -Name "Alphabet" -Value @{
42
42
" !" = 0x17
43
43
" " = 0X00 , 0X00
44
44
" -" = 0x04 , 0x04 , 0x04
45
+ " :" = 0x0A
45
46
} - Scope Script
46
47
47
48
function Select-ScrollpHat {
@@ -54,6 +55,24 @@ function Select-ScrollpHat {
54
55
$Script :Device
55
56
}
56
57
58
+ # Combine the following two Functions to define the LEDs' brightness. Maximum brightness:
59
+ # - Set-PhatBrightnessByNumber 255
60
+ # - Set-PhatBrightness Highest
61
+ # Lowest:
62
+ # - Set-PhatBrightnessByNumber 1
63
+ # - Set-PhatBrightness Lowest
64
+ function Set-PhatBrightnessByNumber {
65
+ [CmdletBinding ()]
66
+ param (
67
+ [Parameter (Mandatory = $true )]
68
+ [ValidateRange (0 , 255 )]
69
+ [int ]$Intensity
70
+ )
71
+ [int ]$PWMRegisterAddress = 0x19
72
+ Set-I2CRegister - Device $Script :Device - Register $PWMRegisterAddress - Data $Intensity
73
+ Update-PhatRegisters
74
+ }
75
+
57
76
function Set-PhatBrightness {
58
77
[CmdletBinding ()]
59
78
param (
@@ -119,49 +138,7 @@ function Write-PhatChar {
119
138
[ValidateLength (1 , 1 )]
120
139
[string ]$char
121
140
)
122
- # #############TEMP#################
123
- # $alphabet = @{
124
- # A = 0x3E, 0x05, 0x3E
125
- # B = 0x1F, 0x15, 0x0A
126
- # C = 0x0E, 0x11, 0x11
127
- # D = 0x1F, 0x11, 0x0E
128
- # E = 0x1F, 0x15, 0x11
129
- # F = 0x1F, 0x05, 0x01
130
- # G = 0x0E, 0x11, 0x1D
131
- # H = 0x1F, 0x04, 0x1F
132
- # I = 0x11, 0x1F, 0x11
133
- # J = 0x09, 0x11, 0x0F
134
- # K = 0x1F, 0x04, 0x1B
135
- # L = 0x1F, 0x10, 0x10
136
- # M = 0x1F, 0x02, 0x04, 0x02, 0x1F
137
- # N = 0x1F, 0x02, 0x0C, 0x1F
138
- # O = 0x0E, 0x11, 0x0E
139
- # P = 0x1F, 0x09, 0x06
140
- # Q = 0x0E, 0x11, 0x09, 0x16
141
- # R = 0x1F, 0x09, 0x16
142
- # S = 0x12, 0x15, 0x09
143
- # T = 0x01, 0x1F, 0x01
144
- # U = 0x0F, 0x10, 0x10, 0x0F
145
- # V = 0x0F, 0x10, 0x0F
146
- # W = 0x0F, 0x10, 0x08,0x10,0x0F
147
- # X = 0x1D, 0x04, 0x1D
148
- # Y = 0x03, 0x1C, 0x03
149
- # Z = 0x19, 0x15, 0x13
150
- # "1" = 0x12, 0x1F, 0x10
151
- # "2" = 0x19, 0x15, 0x12
152
- # "3" = 0x11, 0x15, 0x0A
153
- # "4" = 0x0E, 0x09, 0x1C
154
- # "5" = 0x17, 0x15, 0x09
155
- # "6" = 0x0E, 0x15, 0x08
156
- # "7" = 0x19, 0x05, 0x03
157
- # "8" = 0x0A, 0x15, 0x0A
158
- # "9" = 0x02, 0x15, 0x0E
159
- # "0" = 0x0E, 0x15, 0x0E
160
- # "!" = 0x17
161
- # " " = 0X00,0X00
162
- # "-" = 0x04,0x04,0x04
163
- # }
164
- # ##################################
141
+
165
142
# get respective bits from hashtable
166
143
$bitsArray = $Script :Alphabet [$char ] # this is an array with required data
167
144
$totalRegistersRequired = $Script :CurrentRegisterValues.Count + $bitsArray.Count
@@ -174,24 +151,27 @@ function Write-PhatChar {
174
151
$wroteWhiteSpace = $false
175
152
while ($i -lt $bitsArray.Count )
176
153
{
177
- # send the first value out.
178
- $null , $Script :CurrentRegisterValues = $Script :CurrentRegisterValues
179
-
180
- # SHIFT!
181
- for ($j = 1 ; $j -le 10 ; ++ $j ) # 10 because we will leave the 11 to the new value
182
- {
183
- Set-I2CRegister - Device $Script :Device - Register $j - Data $Script :CurrentRegisterValues [$j - 1 ]
184
- # Update-PhatRegisters
185
- }
186
- # start by writing a white column
187
- if ($wroteWhiteSpace -eq $false )
188
- {
189
- Set-I2CRegister - Device $Script :Device - Register 0xB - Data 0
190
- $Script :CurrentRegisterValues += 0
191
- # Update-PhatRegisters
192
- $wroteWhiteSpace = $true
193
- continue
194
- }
154
+ if ( $Script :CurrentRegisterValues.Count -ge $Script :TotalRegisters )
155
+ {
156
+ # send the first value out.
157
+ $null , $Script :CurrentRegisterValues = $Script :CurrentRegisterValues
158
+
159
+ # SHIFT!
160
+ for ($j = 1 ; $j -le 10 ; ++ $j ) # 10 because we will leave the 11 to the new value
161
+ {
162
+ Set-I2CRegister - Device $Script :Device - Register $j - Data $Script :CurrentRegisterValues [$j - 1 ]
163
+ Update-PhatRegisters # #######EDITED
164
+ }
165
+ # start by writing a white column
166
+ if ($wroteWhiteSpace -eq $false )
167
+ {
168
+ Set-I2CRegister - Device $Script :Device - Register 0xB - Data 0
169
+ $Script :CurrentRegisterValues += 0
170
+ # Update-PhatRegisters
171
+ $wroteWhiteSpace = $true
172
+ continue
173
+ }
174
+ }
195
175
196
176
Set-I2CRegister - Device $Script :Device - Register 0xB - Data $bitsArray [$i ]
197
177
$Script :CurrentRegisterValues += $bitsArray [$i ++ ]
0 commit comments