Skip to content

Commit

Permalink
Set-NanoLeaf: Fixing Brightness (#7). Adding Tab Completion (#8). Add…
Browse files Browse the repository at this point in the history
…ing Examples
  • Loading branch information
James Brundage committed Mar 27, 2022
1 parent 85ed730 commit 4c2d880
Showing 1 changed file with 41 additions and 1 deletion.
42 changes: 41 additions & 1 deletion Set-NanoLeaf.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,14 @@
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
Set-NanoLeaf -Palette "#fedcba", "#abcdef" -PluginName Flow
.Example
Set-NanoLeaf -Palette "#012345", "#543210" -PluginName Wheel
.Example
Set-NanoLeaf -Palette "#ff0000", "#000000", "#00ff00", "#000000", "#0000ff", "#000000" -PluginName Fireworks -PluginType Rhythm
.Link
Get-NanoLeaf
.Link
Expand Down Expand Up @@ -88,6 +96,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 +127,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 @@ -258,9 +296,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 4c2d880

Please sign in to comment.