mirror of
https://github.com/CharaChorder/DeviceManager.git
synced 2025-12-11 13:26:16 +00:00
fix: lite rgb
This commit is contained in:
@@ -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(
|
||||
|
||||
@@ -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}
|
||||
|
||||
Reference in New Issue
Block a user