Skip to content

Commit ecd7b54

Browse files
committed
removed helper functions from the module usage. Moved the alphabet variable to a script variable
1 parent 15a0a57 commit ecd7b54

File tree

2 files changed

+84
-64
lines changed

2 files changed

+84
-64
lines changed

ScrollpHat.psd1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ RequiredModules = @("Microsoft.PowerShell.IoT")
6969
# NestedModules = @()
7070

7171
# Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export.
72-
FunctionsToExport = '*'
72+
FunctionsToExport = @('Set-PhatBrightness','Write-PhatString','Write-PhatChar',)
7373

7474
# Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export.
7575
CmdletsToExport = '*'

ScrollpHat.psm1

Lines changed: 83 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,47 @@
22

33
New-Variable -Name "TotalRegisters" -Value 11 -Option Constant -Scope Script
44
New-Variable -Name "CurrentRegisterValues" -Value @() -Scope Script
5+
New-Variable -Name "Alphabet" -Value @{
6+
A = 0x3E, 0x05, 0x3E
7+
B = 0x1F, 0x15, 0x0A
8+
C = 0x0E, 0x11, 0x11
9+
D = 0x1F, 0x11, 0x0E
10+
E = 0x1F, 0x15, 0x11
11+
F = 0x1F, 0x05, 0x01
12+
G = 0x0E, 0x11, 0x1D
13+
H = 0x1F, 0x04, 0x1F
14+
I = 0x11, 0x1F, 0x11
15+
J = 0x09, 0x11, 0x0F
16+
K = 0x1F, 0x04, 0x1B
17+
L = 0x1F, 0x10, 0x10
18+
M = 0x1F, 0x02, 0x04, 0x02, 0x1F
19+
N = 0x1F, 0x02, 0x0C, 0x1F
20+
O = 0x0E, 0x11, 0x0E
21+
P = 0x1F, 0x09, 0x06
22+
Q = 0x0E, 0x11, 0x09, 0x16
23+
R = 0x1F, 0x09, 0x16
24+
S = 0x12, 0x15, 0x09
25+
T = 0x01, 0x1F, 0x01
26+
U = 0x0F, 0x10, 0x10, 0x0F
27+
V = 0x0F, 0x10, 0x0F
28+
W = 0x0F, 0x10, 0x08,0x10,0x0F
29+
X = 0x1D, 0x04, 0x1D
30+
Y = 0x03, 0x1C, 0x03
31+
Z = 0x19, 0x15, 0x13
32+
"1" = 0x12, 0x1F, 0x10
33+
"2" = 0x19, 0x15, 0x12
34+
"3" = 0x11, 0x15, 0x0A
35+
"4" = 0x0E, 0x09, 0x1C
36+
"5" = 0x17, 0x15, 0x09
37+
"6" = 0x0E, 0x15, 0x08
38+
"7" = 0x19, 0x05, 0x03
39+
"8" = 0x0A, 0x15, 0x0A
40+
"9" = 0x02, 0x15, 0x0E
41+
"0" = 0x0E, 0x15, 0x0E
42+
"!" = 0x17
43+
" " = 0X00,0X00
44+
"-" = 0x04,0x04,0x04
45+
} -Scope Script
546

647
function Select-ScrollpHat {
748
[int]$DeviceAddress = 0x60
@@ -79,50 +120,50 @@ function Write-PhatChar {
79120
[string]$char
80121
)
81122
##############TEMP#################
82-
$alphabet = @{
83-
A = 0x3E, 0x05, 0x3E
84-
B = 0x1F, 0x15, 0x0A
85-
C = 0x0E, 0x11, 0x11
86-
D = 0x1F, 0x11, 0x0E
87-
E = 0x1F, 0x15, 0x11
88-
F = 0x1F, 0x05, 0x01
89-
G = 0x0E, 0x11, 0x1D
90-
H = 0x1F, 0x04, 0x1F
91-
I = 0x11, 0x1F, 0x11
92-
J = 0x09, 0x11, 0x0F
93-
K = 0x1F, 0x04, 0x1B
94-
L = 0x1F, 0x10, 0x10
95-
M = 0x1F, 0x02, 0x04, 0x02, 0x1F
96-
N = 0x1F, 0x02, 0x0C, 0x1F
97-
O = 0x0E, 0x11, 0x0E
98-
P = 0x1F, 0x09, 0x06
99-
Q = 0x0E, 0x11, 0x09, 0x16
100-
R = 0x1F, 0x09, 0x16
101-
S = 0x12, 0x15, 0x09
102-
T = 0x01, 0x1F, 0x01
103-
U = 0x0F, 0x10, 0x10, 0x0F
104-
V = 0x0F, 0x10, 0x0F
105-
W = 0x0F, 0x10, 0x08,0x10,0x0F
106-
X = 0x1D, 0x04, 0x1D
107-
Y = 0x03, 0x1C, 0x03
108-
Z = 0x19, 0x15, 0x13
109-
"1" = 0x12, 0x1F, 0x10
110-
"2" = 0x19, 0x15, 0x12
111-
"3" = 0x11, 0x15, 0x0A
112-
"4" = 0x0E, 0x09, 0x1C
113-
"5" = 0x17, 0x15, 0x09
114-
"6" = 0x0E, 0x15, 0x08
115-
"7" = 0x19, 0x05, 0x03
116-
"8" = 0x0A, 0x15, 0x0A
117-
"9" = 0x02, 0x15, 0x0E
118-
"0" = 0x0E, 0x15, 0x0E
119-
"!" = 0x17
120-
" " = 0X00,0X00
121-
"-" = 0x04,0x04,0x04
122-
}
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+
# }
123164
###################################
124165
#get respective bits from hashtable
125-
$bitsArray = $alphabet[$char] # this is an array with required data
166+
$bitsArray = $Script:Alphabet[$char] # this is an array with required data
126167
$totalRegistersRequired = $Script:CurrentRegisterValues.Count + $bitsArray.Count
127168

128169
$registers = ($Script:CurrentRegisterValues.Count+1) .. $totalRegistersRequired
@@ -182,27 +223,6 @@ function Set-PhatLedsOff {
182223
Update-PhatRegisters
183224
}
184225

185-
function Reset-PhatRegisters {
186-
$resetRegisterAddress = 0xFF
187-
$resetRegisterValue = 0xF #can be any value
188-
Set-I2CRegister -Device $Script:Device -Register $resetRegisterAddress -Data $resetRegisterValue
189-
}
190-
191-
function Get-NextAvailableRegisters {
192-
param(
193-
[int]$numberOfRequiredRegisters
194-
)
195-
196-
$availableRegisters = $Script:MatrixRegisters | Where-Object {$_.InUse -eq $false}
197-
198-
$requestedRegisters = $availableRegisters | Select-Object -First $numberOfRequiredRegisters
199-
200-
return [PSCustomObject]@{
201-
RequestedRegisters = $requestedRegisters
202-
TotalAvailable = $availableRegisters.Count
203-
}
204-
}
205-
206226
function Set-PhatCrazyLeds () {
207227
$brightnessValues = 'Lowest','Low', 'Medium', 'High', 'Highest'
208228
$iteration

0 commit comments

Comments
 (0)