Created
May 7, 2018 08:18
-
-
Save DanielSSilva/ea2d5ddbaffa1ff5576622ea4543badd to your computer and use it in GitHub Desktop.
The referred error might happen between line 58 and 86
This file contains 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
function Write-Char { | |
param( | |
[ValidateLength(1,1)] | |
[string]$char | |
) | |
##############TEMP################# | |
$alphabet = @{ | |
A = 0x3E, 0x05, 0x3E | |
B = 0x1F, 0x15, 0x0A | |
C = 0x0E, 0x11, 0x11 | |
D = 0x1F, 0x11, 0x0E | |
E = 0x1F, 0x15, 0x11 | |
F = 0x1F, 0x05, 0x01 | |
G = 0x0E, 0x11, 0x1D | |
H = 0x1F, 0x04, 0x1F | |
I = 0x11, 0x1F, 0x11 | |
J = 0x09, 0x11, 0x0F | |
K = 0x1F, 0x04, 0x1B | |
L = 0x1F, 0x10, 0x10 | |
M = 0x1F, 0x02, 0x04, 0x02, 0x1F | |
N = 0x1F, 0x02, 0x0C, 0x1F | |
O = 0x0E, 0x11, 0x0E | |
P = 0x1F, 0x09, 0x06 | |
Q = 0x0E, 0x11, 0x09, 0x16 | |
R = 0x1F, 0x09, 0x16 | |
S = 0x12, 0x15, 0x09 | |
T = 0x01, 0x1F, 0x01 | |
U = 0x0F, 0x10, 0x10, 0x0F | |
V = 0x0F, 0x10, 0x0F | |
W = 0x0F, 0x10, 0x08,0x10,0x0F | |
X = 0x1D, 0x04, 0x1D | |
Y = 0x03, 0x1C, 0x03 | |
Z = 0x19, 0x15, 0x13 | |
"1" = 0x12, 0x1F, 0x10 | |
"2" = 0x19, 0x15, 0x12 | |
"3" = 0x11, 0x15, 0x0A | |
"4" = 0x0E, 0x09, 0x1C | |
"5" = 0x17, 0x15, 0x09 | |
"6" = 0x0E, 0x15, 0x08 | |
"7" = 0x19, 0x05, 0x03 | |
"8" = 0x0A, 0x15, 0x0A | |
"9" = 0x02, 0x15, 0x0E | |
"0" = 0x0E, 0x15, 0x0E | |
"!" = 0x17 | |
" " = 0X00,0X00 | |
} | |
################################### | |
#get respective bits from hashtable | |
$bitsArray = $alphabet[$char] # this is an array with required data | |
$totalRegistersRequired = $Script:CurrentRegisterValues.Count + $bitsArray.Count | |
$registers = ($Script:CurrentRegisterValues.Count+1) .. $totalRegistersRequired | |
if($totalRegistersRequired -gt $Script:TotalRegisters ) # this means that we will need to start shifting | |
{ | |
$i = 0 | |
$wroteWhiteSpace = $false | |
while($i -lt $bitsArray.Count) | |
{ | |
#send the first value out. | |
$null, $Script:CurrentRegisterValues = $Script:CurrentRegisterValues | |
#SHIFT! | |
for($j = 1 ; $j -le 10; ++$j) #10 because we will leave the 11 to the new value | |
{ | |
Set-I2CRegister -Device $Script:Device -Register $j -Data $Script:CurrentRegisterValues[$j-1] | |
Update-Registers | |
} | |
#start by writing a white column | |
if($wroteWhiteSpace -eq $false) | |
{ | |
Set-I2CRegister -Device $Script:Device -Register 0xB -Data 0 | |
$Script:CurrentRegisterValues+= 0 | |
#Update-Registers | |
$wroteWhiteSpace = $true | |
continue | |
} | |
Set-I2CRegister -Device $Script:Device -Register 0xB -Data $bitsArray[$i] | |
$Script:CurrentRegisterValues += $bitsArray[$i++] | |
Update-Registers | |
Start-Sleep -Milliseconds 5 | |
} | |
return | |
} | |
#if we get here, this is one of the first letters | |
$i = 0 | |
foreach($register in $registers) | |
{ | |
Set-I2CRegister -Device $Script:Device -Register $register -Data $bitsArray[$i] | |
$Script:CurrentRegisterValues += $bitsArray[$i++] | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment