Last active
December 20, 2023 07:29
-
-
Save poiriersimon/eaee208ce8ea79f30b4cc7d3a078c3bc to your computer and use it in GitHub Desktop.
Logitech Litra Glow Beam Powershell Function
This file contains hidden or 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
#Litra Glow and Litra Beam Powershell Controller | |
#Download hidapitester here : https://github.com/todbot/hidapitester/releases | |
#Based on https://www.reddit.com/r/LogitechG/comments/sacz2x/comment/j7doia4/?utm_source=share&utm_medium=web2x&context=3 | |
#Change to point to the extract folder | |
$HIDAPItesterFolderPath = "C:\Users\username\Scripts\" | |
#HIDAPItester | |
$global:HIDAPItesterPath = $HIDAPItesterFolderPath + "hidapitester.exe" | |
Function Set-HIDAPItester { | |
[CmdletBinding()] | |
param ( | |
[Parameter(Mandatory = $true)] | |
[string] $vidpid, | |
[Parameter(Mandatory = $true)] | |
[string] $OpenPath, | |
[Parameter(Mandatory = $true)] | |
[string] $output, | |
[Parameter(Mandatory = $true)] | |
[string] $usagePage, | |
[string] $HIDAPItesterPath = $global:HIDAPItesterPath | |
) | |
$null = &($HIDAPItesterPath) --vidpid $vidpid --usagePage $usagePage --open-path $OpenPath --send-output $output | |
} | |
Function Get-LitraLight { | |
[CmdletBinding()] | |
param ( | |
[switch] $Beam, | |
[switch] $Glow | |
) | |
if($Beam){ | |
$LitraRaw= &($HIDAPItesterPath) --vidpid 046d/c901 --usagePage FF43 --list-detail | |
} | |
elseif($Glow){ | |
$LitraRaw= &($HIDAPItesterPath) --vidpid 046d/c900 --usagePage FF43 --list-detail | |
}else{ | |
$LitraRaw= &($HIDAPItesterPath) --usagePage FF43 --list-detail | |
} | |
#$litraRaw | |
$i=0 | |
[Array]$LitraLights = @() | |
$LitraLight = New-Object PSObject | |
foreach($line in $litraRaw){ | |
$i++ | |
if($i -eq 1){ | |
$name = "vidpid" | |
$value = $line.split(":")[0].trim() | |
}else{ | |
$name = $line.split(":")[0].trim() | |
$value = $line.split(":")[-1].trim() | |
} | |
if(!$([string]::IsNullOrempty($name))){ | |
$LitraLight | Add-Member NoteProperty -Name $name -Value $value | |
} | |
if($i -gt 8){ | |
$i=0 | |
[Array]$LitraLights+=$LitraLight | |
$LitraLight = New-Object PSObject | |
} | |
} | |
return $LitraLights | |
} | |
function Set-LitraLight { | |
[CmdletBinding()] | |
param ( | |
[Parameter(Mandatory = $true)] | |
[string] $vidpid, | |
[Parameter(Mandatory = $true)] | |
[string] $OpenPath, | |
[ValidateRange(1, 100)] | |
[int] $Brightness, | |
[ValidateRange(2700, 6500)] | |
[int] $temperature | |
) | |
if($Brightness -gt 0){ | |
[int]$brightnessvalue = [math]::floor(31 + ($Brightness/100*368)) | |
$brightnessvalue | |
$hex = $brightnessvalue | Format-Hex | |
$hex | |
$output= "0x11,0xFF,0x04,0x4F,0x"+ $hex.HexBytes.Split(" ")[1] +",0x"+ $hex.HexBytes.Split(" ")[0] | |
Set-HIDAPItester -vidpid $vidpid -usagePage ff43 -OpenPath $OpenPath -output $output | |
} | |
if($temperature -gt 0){ | |
$hex = $temperature | Format-Hex | |
$hex | |
$output = "0x11,0xFF,0x04,0x9D,0x"+ $hex.HexBytes.Split(" ")[1] +",0x" + $hex.HexBytes.Split(" ")[0] | |
Set-HIDAPItester -vidpid $vidpid -usagePage ff43 -OpenPath $OpenPath -output $output | |
} | |
} | |
Function Start-LitraLight { | |
[CmdletBinding()] | |
param ( | |
[Parameter(Mandatory = $true)] | |
[string] $vidpid, | |
[Parameter(Mandatory = $true)] | |
[string] $OpenPath | |
) | |
$output = "0x11,0xFF,0x04,0x1D,0x01" | |
Set-HIDAPItester -vidpid $vidpid -usagePage ff43 -OpenPath $OpenPath -output $output | |
} | |
Function Stop-LitraLight { | |
[CmdletBinding()] | |
param ( | |
[Parameter(Mandatory = $true)] | |
[string] $vidpid, | |
[Parameter(Mandatory = $true)] | |
[string] $OpenPath | |
) | |
$output = "0x11,0xFF,0x04,0x1D,0x00" | |
Set-HIDAPItester -vidpid $vidpid -usagePage ff43 -OpenPath $OpenPath -output $output | |
} | |
#Exemple: | |
Write-host "All Off" | |
$lights = Get-LitraLight | |
foreach($Light in $Lights){ | |
Stop-LitraLight -vidpid $light.vidpid -OpenPath $light.path | |
} | |
Write-host "All On" | |
$lights = Get-LitraLight | |
foreach($Light in $Lights){ | |
start-LitraLight -vidpid $light.vidpid -OpenPath $light.path | |
} | |
Write-host "Beam On" | |
$lights = Get-LitraLight -Beam | |
foreach($Light in $Lights){ | |
start-LitraLight -vidpid $light.vidpid -OpenPath $light.path | |
} | |
Author
poiriersimon
commented
Dec 19, 2023
via email
Thanks for sharing your results!
Le mar. 19 déc. 2023, 13 h 38, Tim Maiden ***@***.***> a
écrit :
… ***@***.**** commented on this gist.
------------------------------
Thank you for the reply. I managed to get it working with Bluetooth, that
was not the issue.
I believe it was due to these lights being brand new, and seemingly a
newer iteration, or at least a different version.
I had to use the --read-input-forever of hidapitester to monitor the hex
values being passed when I manually turned the lights off and on, to work
out the required hex values to pass.
In case it helps anyone else:
To Turn the RGB lights ON:
Set-HIDAPItester -vidpid $vidpid -usagePage ff43 -OpenPath $OpenPath
-output "0x11,0xFF,0x0A,0x4E,0x01" -HIDAPItesterPath $HIDAPItesterPath
To Turn the RGB lights OFF:
Set-HIDAPItester -vidpid $vidpid -usagePage ff43 -OpenPath $OpenPath
-output "0x11,0xFF,0x0A,0x4E,0x00" -HIDAPItesterPath $HIDAPItesterPath
To Turn the White lights ON:
Set-HIDAPItester -vidpid $vidpid -usagePage ff43 -OpenPath $OpenPath
-output "0x11,0xFF,0x06,0x1E,0x01" -HIDAPItesterPath $HIDAPItesterPath
To Turn the White lights OFF:
Set-HIDAPItester -vidpid $vidpid -usagePage ff43 -OpenPath $OpenPath
-output "0x11,0xFF,0x06,0x1E,0x00" -HIDAPItesterPath $HIDAPItesterPath
—
Reply to this email directly, view it on GitHub
<https://gist.github.com/poiriersimon/eaee208ce8ea79f30b4cc7d3a078c3bc#gistcomment-4800471>
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AHKNXI3U66JKPLXWTSGZSYDYKHNLVBFKMF2HI4TJMJ2XIZLTSKBKK5TBNR2WLJDHNFZXJJDOMFWWLK3UNBZGKYLEL52HS4DFQKSXMYLMOVS2I5DSOVS2I3TBNVS3W5DIOJSWCZC7OBQXE5DJMNUXAYLOORPWCY3UNF3GS5DZVRZXKYTKMVRXIX3UPFYGLK2HNFZXIQ3PNVWWK3TUUZ2G64DJMNZZDAVEOR4XAZNEM5UXG5FFOZQWY5LFVEYTEMRQGE2DONJQU52HE2LHM5SXFJTDOJSWC5DF>
.
You are receiving this email because you authored the thread.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>
.
No problem 😊. Thank you again for creating this in the first place!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment