mirror of
https://github.com/CharaChorder/DeviceManager.git
synced 2026-01-04 09:02:50 +00:00
feat: charachorder lite brightness & color settings
This commit is contained in:
@@ -2,9 +2,12 @@ import type { Action } from "svelte/action";
|
|||||||
import { changes, ChangeType, settings } from "$lib/undo-redo";
|
import { changes, ChangeType, settings } from "$lib/undo-redo";
|
||||||
|
|
||||||
export const setting: Action<
|
export const setting: Action<
|
||||||
HTMLInputElement,
|
HTMLInputElement | HTMLSelectElement,
|
||||||
{ id: number; inverse?: number; scale?: number }
|
{ id: number; inverse?: number; scale?: number }
|
||||||
> = function (node: HTMLInputElement, { id, inverse, scale }) {
|
> = function (
|
||||||
|
node: HTMLInputElement | HTMLSelectElement,
|
||||||
|
{ 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";
|
||||||
const min = node.hasAttribute("min")
|
const min = node.hasAttribute("min")
|
||||||
@@ -17,7 +20,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") {
|
if (type === "number" || node instanceof HTMLSelectElement) {
|
||||||
node.value = (
|
node.value = (
|
||||||
inverse !== undefined
|
inverse !== undefined
|
||||||
? inverse / value
|
? inverse / value
|
||||||
@@ -41,7 +44,7 @@ export const setting: Action<
|
|||||||
|
|
||||||
async function listener() {
|
async function listener() {
|
||||||
let value: number;
|
let value: number;
|
||||||
if (type === "number") {
|
if (type === "number" || node instanceof HTMLSelectElement) {
|
||||||
value = Number(node.value);
|
value = Number(node.value);
|
||||||
if (Number.isNaN(value)) return;
|
if (Number.isNaN(value)) return;
|
||||||
value = Math.floor(
|
value = Math.floor(
|
||||||
|
|||||||
@@ -254,10 +254,28 @@
|
|||||||
{#if $serialPort.device === "LITE"}
|
{#if $serialPort.device === "LITE"}
|
||||||
<fieldset>
|
<fieldset>
|
||||||
<legend><label><input type="checkbox" />RGB</label></legend>
|
<legend><label><input type="checkbox" />RGB</label></legend>
|
||||||
<label>Brightness<input type="range" min="0" max="50" step="1" /></label
|
<label
|
||||||
|
>Brightness<input
|
||||||
|
use:setting={{ id: 0x81 }}
|
||||||
|
type="range"
|
||||||
|
min="0"
|
||||||
|
max="50"
|
||||||
|
step="1"
|
||||||
|
/></label
|
||||||
>
|
>
|
||||||
Color
|
<select use:setting={{ id: 0x82 }}>
|
||||||
<label>Reactive Keys<input type="checkbox" /></label>
|
<option value="0">White</option>
|
||||||
|
<option value="1">Red</option>
|
||||||
|
<option value="2">Orange</option>
|
||||||
|
<option value="3">Yellow</option>
|
||||||
|
<option value="4">Lime</option>
|
||||||
|
<option value="5">Green</option>
|
||||||
|
<option value="7">Cyan</option>
|
||||||
|
<option value="9">Blue</option>
|
||||||
|
<option value="10">Violet</option>
|
||||||
|
<option value="11">Pink</option>
|
||||||
|
<option value="10">Multicolor</option>
|
||||||
|
</select>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
{/if}
|
{/if}
|
||||||
</form>
|
</form>
|
||||||
|
|||||||
Reference in New Issue
Block a user