Skip to content

Commit

Permalink
Merge pull request #10 from StartAutomating/NanoLeafImprovement
Browse files Browse the repository at this point in the history
NanoLeafImprovement
  • Loading branch information
StartAutomating authored Mar 27, 2022
2 parents 85ed730 + 05a6f7f commit f633163
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 4 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 0.2.1:
* Set-NanoLeaf: Adding -EffectOption parameter help (#9). Adding examples.
* Set-NanoLeaf: Fixing Brightness (#7). Adding Tab Completion (#8). Adding Examples
---

## 0.2:
Adding: Disconnect-HueBridge, Disconnect-NanoLeaf, Disconnect-Twinkly (#2)
Adding Pixoo commands: Connect/Disconnect/Get/Set-Pixoo (#4)
Expand Down
8 changes: 6 additions & 2 deletions LightScript.psd1
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@{
ModuleVersion = '0.2'
ModuleVersion = '0.2.1'
RootModule = 'LightScript.psm1'
Description = 'Smarter Lighting with PowerShell'
FormatsToProcess = 'LightScript.format.ps1xml'
Expand All @@ -9,11 +9,15 @@
Copyright = '2021 Start-Automating'
PrivateData = @{
PSData = @{
Tags = 'IoT','Hue', 'Twinkly', 'NanoLeaf'
Tags = 'IoT','Hue', 'Twinkly', 'NanoLeaf', 'Pixoo', 'Divoom'
ProjectURI = 'https://github.com/StartAutomating/LightScript'
LicenseURI = 'https://github.com/StartAutomating/LightScript/blob/main/LICENSE'
IconURI = 'https://github.com/StartAutomating/LightScript/blob/main/Assets/LightScript.png'
ReleaseNotes = @'
## 0.2.1:
* Set-NanoLeaf: Adding -EffectOption parameter help (#9). Adding examples.
* Set-NanoLeaf: Fixing Brightness (#7). Adding Tab Completion (#8). Adding Examples
---
## 0.2:
Adding: Disconnect-HueBridge, Disconnect-NanoLeaf, Disconnect-Twinkly (#2)
Adding Pixoo commands: Connect/Disconnect/Get/Set-Pixoo (#4)
Expand Down
76 changes: 74 additions & 2 deletions Set-NanoLeaf.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,29 @@
Set-NanoLeaf -Hue (Get-Random -Min 0 -Max 360) -Saturation ((Get-Random -Min 0 -Max 1)/100) -Brightness ((Get-Random -Min 0 -Max 1)/100)
.Example
Set-NanoLeaf -EffectName Blaze
.Example
Set-NanoLeaf -Palette "#fedcba", "#abcdef" # Fade between two colors
.Example
# Flow between two colors
Set-NanoLeaf -Palette "#fedcba", "#abcdef" -PluginName Flow
.EXAMPLE
# Flow downward between two colors
Set-NanoLeaf -Palette "#abcdef", "#890aef" -PluginName Flow -PluginOption @{linDirection="down"}
.Example
# Make a color wheel
Set-NanoLeaf -Palette "#012345", "#543210" -PluginName Wheel
.EXAMPLE
# Make a color wheel that rotates as slowly as it can, counter clockwise
Set-NanoLeaf -Palette "#012345", "#543210" -PluginName Wheel -PluginOption @{rotDirection="ccw";delayTime=600;transTime=600}
.Example
# Set up a Rhythm based RGB Fireworks
Set-NanoLeaf -Palette "#ff0000", "#000000", "#00ff00", "#000000", "#0000ff", "#000000" -PluginName Fireworks -PluginType Rhythm
.Example
# Set up a Rhythm based RGB Fireworks, with a very short flash
Set-NanoLeaf -Palette "#ff0000", "#00ff00", "#0000ff", "#000000" -PluginName Fireworks -PluginType Rhythm -PluginOption @{
delayTime = 1
transTime = 1
}
.Link
Get-NanoLeaf
.Link
Expand All @@ -19,6 +42,7 @@
[CmdletBinding(SupportsShouldProcess,ConfirmImpact='Low',DefaultParameterSetName='SimpleSet')]
[OutputType([PSObject])]
[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSAvoidAssignmentToAutomaticVariable", "", Justification=" Side-Effects Desired ")]
[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSShouldProcess", "", Justification=" Handled by underlying function")]
param(
# If set, will turn the nanoleaf off
[Parameter(ValueFromPipelineByPropertyName)]
Expand Down Expand Up @@ -88,6 +112,21 @@
$ColorTemperature,

# The name of the effect.
[ArgumentCompleter({
param ( $commandName,
$parameterName,
$wordToComplete,
$commandAst,
$fakeBoundParameters )
$effectNames = @(Get-NanoLeaf -ListEffectName |
Select-Object -Unique)
if ($wordToComplete) {
$toComplete = $wordToComplete -replace "^'" -replace "'$"
return @($effectNames -like "$toComplete*" -replace '^', "'" -replace '$',"'")
} else {
return @($effectNames -replace '^', "'" -replace '$',"'")
}
})]
[Parameter(ValueFromPipelineByPropertyName)]
[Alias('animName')]
[string]
Expand All @@ -104,6 +143,21 @@
$ExternalControl,

# The name of the effect plugin.
[ArgumentCompleter({
param ( $commandName,
$parameterName,
$wordToComplete,
$commandAst,
$fakeBoundParameters )
$pluginNames = @(Get-NanoLeaf -ListPlugin |
Select-Object -Unique -ExpandProperty name)
if ($wordToComplete) {
$toComplete = $wordToComplete -replace "^'" -replace "'$"
return @($pluginNames -like "$toComplete*" -replace '^', "'" -replace '$',"'")
} else {
return @($pluginNames -replace '^', "'" -replace '$',"'")
}
})]
[Parameter(ValueFromPipelineByPropertyName)]
[string]
$PluginName,
Expand Down Expand Up @@ -171,7 +225,23 @@
[Collections.IDictionary]
$Panel = @{},

# The effect options
<#
The effect options.
Plugins can use any of the Nanoleaf-approved option types to further control how panels render light.
|Option | type | limits | description |
|---------------|-------|----------------------|---------------------------------------------------------------------------|
|transTime | int |1-600 |The time it takes to go from one palette colour to another (tenths/second).|
|loop | bool | | Indicates whether an animation should loop or not |
|linDirection |string |left, right, up, down | Linear direction, based on user's global orientation |
|radDirection |string |in, out | Radial direction, based on layout center |
|rotDirection |string |cw, ccw | Circular Direction, around the layout center |
|delayTime | int |0-600 | How long the plugin will dwell on a palette colour (tenths/second). |
|nColorsPerFrame|int |1-50 | Modifier that indicates how much of a palette is shown on the layout. |
|mainColorProb |double |0.0-100.0 | Probability of background colour being used |
#>
[Parameter(ValueFromPipelineByPropertyName)]
[Alias('PluginOption','PluginOptions','EffectOptions')]
[Collections.IDictionary]
Expand Down Expand Up @@ -258,9 +328,11 @@


if ($Brightness) {
$sendData.brightness = @{value=[Math]::Round($Brightness * 100)}
$sendData.brightness = [Ordered]@{value=[int][Math]::Round($Brightness * 100)}
if ($Duration.TotalSeconds) {
$sendData.brightness.duration = [int][Math]::Round($Duration.TotalSeconds)
} else {
$sendData.brightness.duration = 0
}
}

Expand Down

0 comments on commit f633163

Please sign in to comment.