fix: lite rgb

This commit is contained in:
2024-04-06 15:56:02 +02:00
parent 93849f250f
commit a23af9ba9d
2 changed files with 11 additions and 6 deletions

View File

@@ -9,7 +9,9 @@ export const setting: Action<
{ id, inverse, scale },
) {
node.setAttribute("disabled", "");
const type = node.getAttribute("type") as "number" | "checkbox";
const type = node.getAttribute("type") as "number" | "checkbox" | "range";
const isNumeric =
type === "number" || type === "range" || node instanceof HTMLSelectElement;
const min = node.hasAttribute("min")
? Number(node.getAttribute("min"))
: undefined;
@@ -20,7 +22,7 @@ export const setting: Action<
const unsubscribe = settings.subscribe(async (settings) => {
if (id in settings) {
const { value, isApplied } = settings[id]!;
if (type === "number" || node instanceof HTMLSelectElement) {
if (isNumeric) {
node.value = (
inverse !== undefined
? inverse / value
@@ -44,7 +46,7 @@ export const setting: Action<
async function listener() {
let value: number;
if (type === "number" || node instanceof HTMLSelectElement) {
if (isNumeric) {
value = Number(node.value);
if (Number.isNaN(value)) return;
value = Math.floor(

View File

@@ -253,11 +253,14 @@
{#if $serialPort.device === "LITE"}
<fieldset>
<legend><label><input type="checkbox" />RGB</label></legend>
<legend
><label><input type="checkbox" use:setting={{ id: 0x84 }} />RGB</label
></legend
>
<label
>Brightness<input
use:setting={{ id: 0x81 }}
type="range"
type="number"
min="0"
max="50"
step="1"
@@ -274,7 +277,7 @@
<option value="9">Blue</option>
<option value="10">Violet</option>
<option value="11">Pink</option>
<option value="10">Multicolor</option>
<option value="13">Multicolor</option>
</select>
</fieldset>
{/if}