Add capability to set LED color (#16)
This commit is contained in:
parent
70ba676151
commit
3b47df5146
12 changed files with 243 additions and 122 deletions
|
|
@ -1,5 +1,28 @@
|
|||
# Release notes
|
||||
|
||||
## Version 0.2.0.0 (2024-12-28)
|
||||
|
||||
### Download
|
||||
|
||||
[org.igox.busylight.v0.2.0.0.streamDeckPlugin](download/org.igox.busylight.v0.2.0.0.streamDeckPlugin)
|
||||
|
||||
### Features
|
||||
|
||||
- Add the capability to set the color diplayed by BusyLigh LEDs.
|
||||
|
||||
### Fixes
|
||||
|
||||
- None.
|
||||
|
||||
### Bugs & known limitations
|
||||
|
||||
- None known at publication time.
|
||||
|
||||
### Screenshot
|
||||
|
||||

|
||||
|
||||
|
||||
## Version 0.1.0.0 (2024-12-28)
|
||||
|
||||
### Download
|
||||
|
|
|
|||
Binary file not shown.
|
After Width: | Height: | Size: 24 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 24 KiB |
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"Name": "iGoX BusyLight",
|
||||
"Version": "0.1.0.0",
|
||||
"Version": "0.2.0.0",
|
||||
"Author": "iGoX",
|
||||
"$schema": "https://schemas.elgato.com/streamdeck/plugins/manifest.json",
|
||||
"Actions": [
|
||||
|
|
@ -51,8 +51,7 @@
|
|||
"TitleAlignment": "bottom"
|
||||
}
|
||||
]
|
||||
}
|
||||
,
|
||||
},
|
||||
{
|
||||
"Name": "Turn off the BusyLight",
|
||||
"UUID": "org.igox.busylight.status.off",
|
||||
|
|
@ -73,7 +72,7 @@
|
|||
"Name": "Set brightness",
|
||||
"UUID": "org.igox.busylight.brigthness.set",
|
||||
"Icon": "imgs/actions/brightness/brightness",
|
||||
"Tooltip": "Set brightness",
|
||||
"Tooltip": "Set LED brightness",
|
||||
"PropertyInspectorPath": "ui/brightness-config.html",
|
||||
"Controllers": [
|
||||
"Keypad"
|
||||
|
|
@ -84,6 +83,22 @@
|
|||
"TitleAlignment": "bottom"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"Name": "Set color",
|
||||
"UUID": "org.igox.busylight.color.set",
|
||||
"Icon": "imgs/actions/color/color",
|
||||
"Tooltip": "Set BusyLight displayed color",
|
||||
"PropertyInspectorPath": "ui/color-config.html",
|
||||
"Controllers": [
|
||||
"Keypad"
|
||||
],
|
||||
"States": [
|
||||
{
|
||||
"Image": "imgs/actions/color/color",
|
||||
"TitleAlignment": "bottom"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"Category": "iGoX BusyLight",
|
||||
|
|
|
|||
|
|
@ -0,0 +1,33 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head lang="en">
|
||||
<title>Configure your BusyLight</title>
|
||||
<meta charset="utf-8" />
|
||||
<script src="https://sdpi-components.dev/releases/v3/sdpi-components.js"></script>
|
||||
<script>
|
||||
function getGlobalSettings() {
|
||||
const { streamDeckClient } = SDPIComponents;
|
||||
const settings = streamDeckClient.getGlobalSettings();
|
||||
return settings.url || 'http://busylight-esp32.local';
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<!--
|
||||
Learn more about property inspector components at https://sdpi-components.dev/docs/components
|
||||
-->
|
||||
<sdpi-item label="URL or IP">
|
||||
<sdpi-textfield
|
||||
setting="url"
|
||||
placeholder="http://busylight-esp32.local"
|
||||
global="true"
|
||||
value="getGlobalSettings()">
|
||||
</sdpi-textfield>
|
||||
</sdpi-item>
|
||||
<sdpi-item label="Color">
|
||||
<sdpi-color
|
||||
setting="color"></sdpi-color>
|
||||
</sdpi-item>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -14,9 +14,6 @@
|
|||
</head>
|
||||
|
||||
<body>
|
||||
<script>
|
||||
|
||||
</script>
|
||||
<!--
|
||||
Learn more about property inspector components at https://sdpi-components.dev/docs/components
|
||||
-->
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ export class SetBrightness extends SingletonAction<BrightnessSettings> {
|
|||
|
||||
override async onKeyDown(ev: KeyDownEvent<BrightnessSettings>): Promise<void> {
|
||||
|
||||
streamDeck.logger.trace(`>>> Received KeyDownEvent. Settings: ${JSON.stringify(ev.payload.settings)} <<<`);
|
||||
streamDeck.logger.debug(`>>> Received KeyDownEvent. Settings: ${JSON.stringify(ev.payload.settings)} <<<`);
|
||||
|
||||
const { settings } = ev.payload;
|
||||
settings.brightness ??= 40;
|
||||
|
|
@ -14,14 +14,14 @@ export class SetBrightness extends SingletonAction<BrightnessSettings> {
|
|||
|
||||
override onWillAppear(ev: WillAppearEvent<BrightnessSettings>): void | Promise<void> {
|
||||
|
||||
streamDeck.logger.trace(`>>> Received WillAppearEvent. Settings: ${JSON.stringify(ev.payload.settings)} <<<`);
|
||||
streamDeck.logger.debug(`>>> Received WillAppearEvent. Settings: ${JSON.stringify(ev.payload.settings)} <<<`);
|
||||
|
||||
return ev.action.setTitle(`${ev.payload.settings.brightness ?? 40}%`);
|
||||
}
|
||||
|
||||
override async onDidReceiveSettings(ev: DidReceiveSettingsEvent<BrightnessSettings>): Promise<void> {
|
||||
|
||||
streamDeck.logger.trace(`>>> Received onDidReceiveSettings. Settings: ${JSON.stringify(ev.payload.settings)} <<<`);
|
||||
streamDeck.logger.debug(`>>> Received onDidReceiveSettings. Settings: ${JSON.stringify(ev.payload.settings)} <<<`);
|
||||
|
||||
const { settings } = ev.payload;
|
||||
await ev.action.setSettings(settings);
|
||||
|
|
@ -33,7 +33,7 @@ async function setBrightness(brightness: number) {
|
|||
const settings = await streamDeck.settings.getGlobalSettings();
|
||||
const url = settings.url;
|
||||
|
||||
streamDeck.logger.trace(`>>> Sending brightness: ${brightness} to ${url} <<<`);
|
||||
streamDeck.logger.debug(`>>> Sending brightness: ${brightness} to ${url} <<<`);
|
||||
|
||||
fetch(`${url}/api/brightness`,
|
||||
{
|
||||
|
|
@ -44,7 +44,7 @@ async function setBrightness(brightness: number) {
|
|||
body: JSON.stringify({"brightness": brightness/100})
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(data => streamDeck.logger.trace(data));
|
||||
.then(data => streamDeck.logger.debug(data));
|
||||
}
|
||||
|
||||
type BrightnessSettings = {
|
||||
|
|
|
|||
51
streamdeck-plugin/busylight/src/actions/set-color.ts
Normal file
51
streamdeck-plugin/busylight/src/actions/set-color.ts
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
import streamDeck, { action, JsonObject, KeyDownEvent, DidReceiveSettingsEvent, SingletonAction } from "@elgato/streamdeck";
|
||||
|
||||
@action({ UUID: "org.igox.busylight.color.set" })
|
||||
export class SetColor extends SingletonAction {
|
||||
override async onKeyDown(ev: KeyDownEvent<ColorSettings>): Promise<void> {
|
||||
|
||||
streamDeck.logger.debug(`>>> Received KeyDownEvent. Settings: ${JSON.stringify(ev.payload.settings)} <<<`);
|
||||
|
||||
const { settings } = ev.payload;
|
||||
settings.color ??= '#FFFFFF';
|
||||
setColor(hexToRgb(settings.color));
|
||||
}
|
||||
|
||||
override async onDidReceiveSettings(ev: DidReceiveSettingsEvent<ColorSettings>): Promise<void> {
|
||||
|
||||
streamDeck.logger.debug(`>>> Received onDidReceiveSettings. Settings: ${JSON.stringify(ev.payload.settings)} <<<`);
|
||||
|
||||
const { settings } = ev.payload;
|
||||
await ev.action.setSettings(settings);
|
||||
}
|
||||
}
|
||||
|
||||
function hexToRgb(hex: string): { r: number, g: number, b: number } {
|
||||
const hexNumber = parseInt(hex.replace('#', ''), 16);
|
||||
const r = (hexNumber >> 16) & 255;
|
||||
const g = (hexNumber >> 8) & 255;
|
||||
const b = hexNumber & 255;
|
||||
return { r, g, b };
|
||||
}
|
||||
|
||||
async function setColor(color: JsonObject) {
|
||||
const settings = await streamDeck.settings.getGlobalSettings();
|
||||
const url = settings.url;
|
||||
|
||||
streamDeck.logger.debug(`>>> Sending color: ${JSON.stringify({"r": color.r, "g": color.g, "b": color.b})} to ${url} <<<`);
|
||||
|
||||
fetch(`${url}/api/color`,
|
||||
{
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json"
|
||||
},
|
||||
body: JSON.stringify({"r": color.r, "g": color.g, "b": color.b})
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(data => streamDeck.logger.debug(data));
|
||||
}
|
||||
|
||||
type ColorSettings = {
|
||||
color?: string;
|
||||
};
|
||||
|
|
@ -32,7 +32,7 @@ async function setStatus(status: string) {
|
|||
const settings = await streamDeck.settings.getGlobalSettings();
|
||||
const url = settings.url;
|
||||
|
||||
streamDeck.logger.trace(`>>> Sending status: ${status} to ${url} <<<`);
|
||||
streamDeck.logger.debug(`>>> Sending status: ${status} to ${url} <<<`);
|
||||
|
||||
fetch(`${url}/api/status/${status}`,
|
||||
{
|
||||
|
|
@ -42,5 +42,5 @@ async function setStatus(status: string) {
|
|||
}
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(data => streamDeck.logger.trace(data));
|
||||
.then(data => streamDeck.logger.debug(data));
|
||||
}
|
||||
|
|
@ -3,6 +3,7 @@ import streamDeck, { LogLevel, SingletonAction, action, type DidReceiveSettingsE
|
|||
//import { IncrementCounter } from "./actions/increment-counter";
|
||||
import { SetStatusAvailable, SetStatusBusy, SetStatusAway, SetStatusOff } from "./actions/set-status";
|
||||
import { SetBrightness } from "./actions/set-brightness";
|
||||
import { SetColor } from "./actions/set-color";
|
||||
|
||||
// We can enable "trace" logging so that all messages between the Stream Deck, and the plugin are recorded. When storing sensitive information
|
||||
streamDeck.logger.setLevel(LogLevel.INFO);
|
||||
|
|
@ -13,6 +14,7 @@ streamDeck.actions.registerAction(new SetStatusBusy());
|
|||
streamDeck.actions.registerAction(new SetStatusAway());
|
||||
streamDeck.actions.registerAction(new SetStatusOff());
|
||||
streamDeck.actions.registerAction(new SetBrightness());
|
||||
streamDeck.actions.registerAction(new SetColor());
|
||||
|
||||
// Finally, connect to the Stream Deck.
|
||||
streamDeck.connect();
|
||||
|
|
|
|||
Binary file not shown.
BIN
streamdeck-plugin/img/v0.2.0.0.png
Normal file
BIN
streamdeck-plugin/img/v0.2.0.0.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 125 KiB |
Loading…
Add table
Add a link
Reference in a new issue