Skip to content

Commit dd24998

Browse files
committed
initial test with plaster, in order to create the module
1 parent 1efbcab commit dd24998

File tree

5 files changed

+229
-0
lines changed

5 files changed

+229
-0
lines changed

.vscode/settings.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
// When enabled, will trim trailing whitespace when you save a file.
3+
"files.trimTrailingWhitespace": true
4+
}

.vscode/tasks.json

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
// Available variables which can be used inside of strings.
2+
// ${workspaceRoot}: the root folder of the team
3+
// ${file}: the current opened file
4+
// ${relativeFile}: the current opened file relative to workspaceRoot
5+
// ${fileBasename}: the current opened file's basename
6+
// ${fileDirname}: the current opened file's dirname
7+
// ${fileExtname}: the current opened file's extension
8+
// ${cwd}: the current working directory of the spawned process
9+
{
10+
// See https://go.microsoft.com/fwlink/?LinkId=733558
11+
// for the documentation about the tasks.json format
12+
"version": "2.0.0",
13+
14+
// Start PowerShell
15+
"windows": {
16+
"command": "${env:windir}/System32/WindowsPowerShell/v1.0/powershell.exe",
17+
//"command": "${env:ProgramFiles}/PowerShell/6.0.0/powershell.exe",
18+
"args": [ "-NoProfile", "-ExecutionPolicy", "Bypass" ]
19+
},
20+
"linux": {
21+
"command": "/usr/bin/powershell",
22+
"args": [ "-NoProfile" ]
23+
},
24+
"osx": {
25+
"command": "/usr/local/bin/powershell",
26+
"args": [ "-NoProfile" ]
27+
},
28+
29+
// Associate with test task runner
30+
"tasks": [
31+
{
32+
"taskName": "Test",
33+
"suppressTaskName": true,
34+
"isTestCommand": true,
35+
"args": [
36+
"Write-Host 'Invoking Pester...'; $ProgressPreference = 'SilentlyContinue'; Invoke-Pester -Script test -PesterOption @{IncludeVSCodeMarker=$true};",
37+
"Invoke-Command { Write-Host 'Completed Test task in task runner.' }"
38+
],
39+
"problemMatcher": "$pester"
40+
}
41+
]
42+
}

ScrollpHat.psd1

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
#
2+
# Module manifest for module 'ScrollpHat'
3+
#
4+
# Generated by: daniel
5+
#
6+
# Generated on: 4/26/18
7+
#
8+
9+
@{
10+
11+
# Script module or binary module file associated with this manifest.
12+
RootModule = 'ScrollpHat.psm1'
13+
14+
# Version number of this module.
15+
ModuleVersion = '0.0.1'
16+
17+
# Supported PSEditions
18+
# CompatiblePSEditions = @()
19+
20+
# ID used to uniquely identify this module
21+
GUID = '1e33972d-bbfd-4ebb-a112-8d6a63b9f36e'
22+
23+
# Author of this module
24+
Author = 'daniel'
25+
26+
# Company or vendor of this module
27+
CompanyName = 'Unknown'
28+
29+
# Copyright statement for this module
30+
Copyright = '(c) daniel. All rights reserved.'
31+
32+
# Description of the functionality provided by this module
33+
# Description = ''
34+
35+
# Minimum version of the PowerShell engine required by this module
36+
# PowerShellVersion = ''
37+
38+
# Name of the PowerShell host required by this module
39+
# PowerShellHostName = ''
40+
41+
# Minimum version of the PowerShell host required by this module
42+
# PowerShellHostVersion = ''
43+
44+
# Minimum version of Microsoft .NET Framework required by this module. This prerequisite is valid for the PowerShell Desktop edition only.
45+
# DotNetFrameworkVersion = ''
46+
47+
# Minimum version of the common language runtime (CLR) required by this module. This prerequisite is valid for the PowerShell Desktop edition only.
48+
# CLRVersion = ''
49+
50+
# Processor architecture (None, X86, Amd64) required by this module
51+
# ProcessorArchitecture = ''
52+
53+
# Modules that must be imported into the global environment prior to importing this module
54+
RequiredModules = @("Microsoft.PowerShell.IoT")
55+
56+
# Assemblies that must be loaded prior to importing this module
57+
# RequiredAssemblies = @()
58+
59+
# Script files (.ps1) that are run in the caller's environment prior to importing this module.
60+
# ScriptsToProcess = @()
61+
62+
# Type files (.ps1xml) to be loaded when importing this module
63+
# TypesToProcess = @()
64+
65+
# Format files (.ps1xml) to be loaded when importing this module
66+
# FormatsToProcess = @()
67+
68+
# Modules to import as nested modules of the module specified in RootModule/ModuleToProcess
69+
# NestedModules = @()
70+
71+
# 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 = '*'
73+
74+
# 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.
75+
CmdletsToExport = '*'
76+
77+
# Variables to export from this module
78+
VariablesToExport = '*'
79+
80+
# Aliases 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 aliases to export.
81+
AliasesToExport = '*'
82+
83+
# DSC resources to export from this module
84+
# DscResourcesToExport = @()
85+
86+
# List of all modules packaged with this module
87+
# ModuleList = @()
88+
89+
# List of all files packaged with this module
90+
# FileList = @()
91+
92+
# Private data to pass to the module specified in RootModule/ModuleToProcess. This may also contain a PSData hashtable with additional module metadata used by PowerShell.
93+
PrivateData = @{
94+
95+
PSData = @{
96+
97+
# Tags applied to this module. These help with module discovery in online galleries.
98+
# Tags = @()
99+
100+
# A URL to the license for this module.
101+
# LicenseUri = ''
102+
103+
# A URL to the main website for this project.
104+
# ProjectUri = ''
105+
106+
# A URL to an icon representing this module.
107+
# IconUri = ''
108+
109+
# ReleaseNotes of this module
110+
# ReleaseNotes = ''
111+
112+
} # End of PSData hashtable
113+
114+
} # End of PrivateData hashtable
115+
116+
# HelpInfo URI of this module
117+
# HelpInfoURI = ''
118+
119+
# Default prefix for commands exported from this module. Override the default prefix using Import-Module -Prefix.
120+
# DefaultCommandPrefix = ''
121+
122+
}
123+
124+

ScrollpHat.psm1

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# Implement your module commands in this script.
2+
function Select-ScrollpHat {
3+
[int]$DeviceAddress = 0x60
4+
######### Configuration Register and Value #########
5+
[int]$ConfigurationRegisterAddress = 0x00
6+
[int]$ConfigurationRegisterValue = 0x1B
7+
$Script:Device = Get-I2CDevice -Id $DeviceAddress -FriendlyName phat
8+
Set-I2CRegister -Device $Device -Register $ConfigurationRegisterAddress -Data $ConfigurationRegisterValue
9+
$Script:Device
10+
}
11+
12+
function Set-Brightness{
13+
[CmdletBinding()]
14+
param (
15+
[ValidateSet('Low', 'Medium', 'High')]
16+
[string]$Intensity
17+
)
18+
[int]$LightningEffectRegisterAddress = 0x0D
19+
$IntensityMap = @{
20+
Low = [convert]::toint32('0001001',2)
21+
Medium = [convert]::toint32('0000000',2)
22+
High = [convert]::toint32('0000111',2)
23+
}
24+
Set-I2CRegister -Device $Script:Device -Register $LightningEffectRegisterAddress -Data $IntensityMap[$Intensity]
25+
}
26+
27+
function Write-Char {
28+
[CmdletBinding()]
29+
param (
30+
[char]$character
31+
)
32+
#Until the dictionary is complete, this method will write the letter A on the 1st position, just for debug
33+
#Get-NextAvailableRegister
34+
[int[]]$Matrix1DataRegisterAddress = 0x01 ..0x03
35+
[int[]]$values = 0x3E, 0x05, 0x3E
36+
Set-I2CRegister -Device $Script:Device -Register $Register -Data $Value #Write the value
37+
Update-Registers
38+
}
39+
40+
function Update-Registers{
41+
[int]$UpdateRegisterAddress = 0x0C
42+
[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"
43+
Set-I2CRegister -Device $Script:Device -Register $UpdateRegisterAddress -Data $UpdateValue
44+
}
45+
46+
# Export only the functions using PowerShell standard verb-noun naming.
47+
# Be sure to list each exported functions in the FunctionsToExport field of the module manifest file.
48+
# This improves performance of command discovery in PowerShell.
49+
Export-ModuleMember -Function *-*

test/ScrollpHat.Tests.ps1

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
$ModuleManifestName = 'ScrollpHat.psd1'
2+
$ModuleManifestPath = "$PSScriptRoot\..\$ModuleManifestName"
3+
4+
Describe 'Module Manifest Tests' {
5+
It 'Passes Test-ModuleManifest' {
6+
Test-ModuleManifest -Path $ModuleManifestPath | Should Not BeNullOrEmpty
7+
$? | Should Be $true
8+
}
9+
}
10+

0 commit comments

Comments
 (0)