Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ufukbakan/logitech-g-led-node
Node.js implementation of Logitech's Led Illumination SDK
https://github.com/ufukbakan/logitech-g-led-node
led logitech node nodejs rgb sdk
Last synced: 4 days ago
JSON representation
Node.js implementation of Logitech's Led Illumination SDK
- Host: GitHub
- URL: https://github.com/ufukbakan/logitech-g-led-node
- Owner: ufukbakan
- License: mit
- Created: 2024-03-30T23:24:02.000Z (9 months ago)
- Default Branch: main
- Last Pushed: 2024-04-08T05:41:30.000Z (9 months ago)
- Last Synced: 2024-12-18T06:24:23.141Z (16 days ago)
- Topics: led, logitech, node, nodejs, rgb, sdk
- Language: TypeScript
- Homepage:
- Size: 376 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# logitech-g-led-node
Node.js implementation of [Logitech's Led Illumination SDK](https://www.logitechg.com/en-us/innovation/developer-lab.html)## Changelog
- v1.1.0
- Windows x32 support
- v1.0.0:alpha:
- Windows x64 support## Prerequirements
![Enabling application illumination control](example/images/prereq1.png)
![Disabling on-board memory mode](example/images/prereq2.png)## Usage
```ts
import gLed from "logitech-g-led-node";function sleep(x: number) {
return new Promise(r => setTimeout(r, x));
}// You need logitech G hub to be running in the background
// Also your device shouldn't be on onboard memory mode
async function main() {
try {
const initResult: boolean = gLed.init();
await sleep(1000); // Logitech SDK documentation recommends sleep after init
if (!initResult) {
throw new Error("could not initialize logi led sdk");
}gLed.saveCurrentLighting();
gLed.pulseLighting(100, 0, 0, 500, 250); // r,g,b + Pulse for 500ms, each pulse finishes in 250 msawait sleep(1500);
gLed.restoreLighting();
}
catch (e) {
console.error(e.message);
}
}main();
```## Interface
```ts
interface Gsdk {
init(): boolean;
initWithName(name: string): boolean;
getConfigOptionNumber(configPath: string, defaultNumber: number): boolean;
getConfigOptionBool(configPath: string, defaultRed: boolean): boolean;
getConfigOptionColor(configPath: string, defaultRed: number, defaultGreen: number, defaultBlue: number): boolean;
getConfigOptionKeyInput(configPath: string, buffer: string, bufsize: number): boolean;
setTargetDevice(targetDevice: number): boolean;
getSdkVersion(majorNum: number, minorNum: number, buildNum: number): boolean;
saveCurrentLighting(): boolean;
setLighting(redPercentage: number, greenPercentage: number, bluePercentage: number): boolean;
restoreLighting(): boolean;
flashLighting(redPercentage: number, greenPercentage: number, bluePercentage: number, milliSecondsDuration: number, milliSecondsInterval: number): boolean;
pulseLighting(redPercentage: number, greenPercentage: number, bluePercentage: number, milliSecondsDuration: number, milliSecondsInterval: number): boolean;
stopEffects(): boolean;
excludeKeysFromBitmap(keyList: KeyName[], listCount: number): boolean;
setLightingFromBitmap(bitmap: number[]): boolean;
setLightingForKeyWithScanCode(keyCode: number, redPercentage: number, greenPercentage: number, bluePercentage: number): boolean;
setLightingForKeyWithHidCode(keyCode: number, redPercentage: number, greenPercentage: number, bluePercentage: number): boolean;
setLightingForKeyWithQuartzCode(keyCode: number, redPercentage: number, greenPercentage: number, bluePercentage: number): boolean;
setLightingForKeyWithKeyName(keyCode: KeyName, redPercentage: number, greenPercentage: number, bluePercentage: number): boolean;
saveLightingForKey(keyName: KeyName): boolean;
restoreLightingForKey(keyName: KeyName): boolean;
flashSingleKey(keyName: KeyName, redPercentage: number, greenPercentage: number, bluePercentage: number, msDuration: number, msInterval: number): boolean;
pulseSingleKey(keyName: KeyName, startRedPercentage: number, startGreenPercentage: number, startBluePercentage: number, finishRedPercentage: number, finishGreenPercentage: number, finishBluePercentage: number, msDuration: number, isInfinite: boolean): boolean;
stopEffectsOnKey(keyName: KeyName): boolean;
setLightingForTargetZone(deviceType: DeviceType, zone: number, redPercentage: number, greenPercentage: number, bluePercentage: number): boolean;
shutdown(): void;
}
```