mirror of
https://github.com/CharaChorder/DeviceManager.git
synced 2026-01-07 02:22:52 +00:00
fix: lite rgb
This commit is contained in:
@@ -9,7 +9,9 @@ export const setting: Action<
|
|||||||
{ id, inverse, scale },
|
{ id, inverse, scale },
|
||||||
) {
|
) {
|
||||||
node.setAttribute("disabled", "");
|
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")
|
const min = node.hasAttribute("min")
|
||||||
? Number(node.getAttribute("min"))
|
? Number(node.getAttribute("min"))
|
||||||
: undefined;
|
: undefined;
|
||||||
@@ -20,7 +22,7 @@ export const setting: Action<
|
|||||||
const unsubscribe = settings.subscribe(async (settings) => {
|
const unsubscribe = settings.subscribe(async (settings) => {
|
||||||
if (id in settings) {
|
if (id in settings) {
|
||||||
const { value, isApplied } = settings[id]!;
|
const { value, isApplied } = settings[id]!;
|
||||||
if (type === "number" || node instanceof HTMLSelectElement) {
|
if (isNumeric) {
|
||||||
node.value = (
|
node.value = (
|
||||||
inverse !== undefined
|
inverse !== undefined
|
||||||
? inverse / value
|
? inverse / value
|
||||||
@@ -44,7 +46,7 @@ export const setting: Action<
|
|||||||
|
|
||||||
async function listener() {
|
async function listener() {
|
||||||
let value: number;
|
let value: number;
|
||||||
if (type === "number" || node instanceof HTMLSelectElement) {
|
if (isNumeric) {
|
||||||
value = Number(node.value);
|
value = Number(node.value);
|
||||||
if (Number.isNaN(value)) return;
|
if (Number.isNaN(value)) return;
|
||||||
value = Math.floor(
|
value = Math.floor(
|
||||||
|
|||||||
@@ -253,11 +253,14 @@
|
|||||||
|
|
||||||
{#if $serialPort.device === "LITE"}
|
{#if $serialPort.device === "LITE"}
|
||||||
<fieldset>
|
<fieldset>
|
||||||
<legend><label><input type="checkbox" />RGB</label></legend>
|
<legend
|
||||||
|
><label><input type="checkbox" use:setting={{ id: 0x84 }} />RGB</label
|
||||||
|
></legend
|
||||||
|
>
|
||||||
<label
|
<label
|
||||||
>Brightness<input
|
>Brightness<input
|
||||||
use:setting={{ id: 0x81 }}
|
use:setting={{ id: 0x81 }}
|
||||||
type="range"
|
type="number"
|
||||||
min="0"
|
min="0"
|
||||||
max="50"
|
max="50"
|
||||||
step="1"
|
step="1"
|
||||||
@@ -274,7 +277,7 @@
|
|||||||
<option value="9">Blue</option>
|
<option value="9">Blue</option>
|
||||||
<option value="10">Violet</option>
|
<option value="10">Violet</option>
|
||||||
<option value="11">Pink</option>
|
<option value="11">Pink</option>
|
||||||
<option value="10">Multicolor</option>
|
<option value="13">Multicolor</option>
|
||||||
</select>
|
</select>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
{/if}
|
{/if}
|
||||||
|
|||||||
Reference in New Issue
Block a user