version>=29 使用了新的重命名接口、EQ 排序功能
This commit is contained in:
+41
-13
@@ -207,6 +207,20 @@ export interface PeqApplyPayload {
|
||||
peqApply: PeqPresetBody;
|
||||
}
|
||||
|
||||
/** POST body for `/dev/info.cgi` — rename an existing PEQ preset (firmware build 29+). */
|
||||
export interface PeqRenamePayload {
|
||||
peqRename: {
|
||||
oldName: string;
|
||||
newName: string;
|
||||
};
|
||||
}
|
||||
|
||||
/** POST body for `/dev/info.cgi` — reorder PEQ presets (firmware build 29+). */
|
||||
export interface PeqSoftPayload {
|
||||
peqSoft: string[];
|
||||
peqSelect: number;
|
||||
}
|
||||
|
||||
// ============================================================
|
||||
// Input/Output Labels
|
||||
// ============================================================
|
||||
@@ -333,6 +347,32 @@ export class LuxsinAPI {
|
||||
});
|
||||
}
|
||||
|
||||
/** Rename a headphone PEQ profile (firmware build 29+). */
|
||||
async renamePeq(oldName: string, newName: string): Promise<void> {
|
||||
const payload: PeqRenamePayload = { peqRename: { oldName, newName } };
|
||||
const encoded = encodeCustomBase64(JSON.stringify(payload));
|
||||
const form = new URLSearchParams();
|
||||
form.set("json", encoded);
|
||||
await fetch(`${this.baseUrl}/dev/info.cgi`, {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8" },
|
||||
body: form.toString(),
|
||||
});
|
||||
}
|
||||
|
||||
/** Reorder headphone PEQ profiles (firmware build 29+). */
|
||||
async sortPeq(names: string[], peqSelect: number): Promise<void> {
|
||||
const payload: PeqSoftPayload = { peqSoft: names, peqSelect };
|
||||
const encoded = encodeCustomBase64(JSON.stringify(payload));
|
||||
const form = new URLSearchParams();
|
||||
form.set("json", encoded);
|
||||
await fetch(`${this.baseUrl}/dev/info.cgi`, {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8" },
|
||||
body: form.toString(),
|
||||
});
|
||||
}
|
||||
|
||||
setVolume(volume: number) { return this.setSetting({ volume }); }
|
||||
setInput(input: number) { return this.setSetting({ input }); }
|
||||
setOutput(output: number) { return this.setSetting({ output }); }
|
||||
@@ -390,18 +430,6 @@ export function formatFirmwareVersionDisplay(version: unknown): string {
|
||||
return `1.0.0.${raw}`;
|
||||
}
|
||||
|
||||
/** Max `bootSound` index available for the current firmware. */
|
||||
export function getBootSoundMaxIndex(firmwareVersion: number): number {
|
||||
return firmwareVersion >= 26 ? 10 : 6;
|
||||
}
|
||||
|
||||
/** Ambient LED block on System page (firmware build 28+). */
|
||||
export const AMBIENT_LED_MIN_FIRMWARE_VERSION = 28;
|
||||
|
||||
export function supportsAmbientLed(firmwareVersion: number): boolean {
|
||||
return firmwareVersion >= AMBIENT_LED_MIN_FIRMWARE_VERSION;
|
||||
}
|
||||
|
||||
export function clampLedChannel(value: unknown): number {
|
||||
const n = typeof value === "number" ? value : Number(value);
|
||||
if (!Number.isFinite(n)) return 0;
|
||||
@@ -417,7 +445,7 @@ export function normalizeBootSound(value: unknown): number {
|
||||
|
||||
export function readBootSoundFromState(state: DeviceState | null | undefined): number {
|
||||
if (!state) return 0;
|
||||
const raw = state.bootSound ?? (state as Record<string, unknown>).bootsound;
|
||||
const raw = state.bootSound ?? (state as unknown as Record<string, unknown>).bootsound;
|
||||
return normalizeBootSound(raw);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user