61 lines
2.6 KiB
TypeScript
61 lines
2.6 KiB
TypeScript
/**
|
||
* Firmware version gates for UI features.
|
||
*
|
||
* Versions are compared using `parseFirmwareVersion` (e.g. 2007 → 2.0.0.7).
|
||
* Adjust thresholds here instead of hardcoding in page components.
|
||
*/
|
||
export const FIRMWARE_FEATURE_MIN_VERSION = {
|
||
/** Boot sound: indices 7–10 (-35…-50 dB); legacy firmware caps at index 6. */
|
||
bootSoundExtendedSteps: 26,
|
||
/** Subwoofer LPF/HPF full-range toggles on the Effects page. */
|
||
subwooferFullRange: 2001,
|
||
/** Hearing compensation section on the Effects page. */
|
||
hearingCompensation: 2007,
|
||
/** PEQ preset rename (peqRename) and reorder (peqSoft) in manage dialog. */
|
||
peqPresetRenameAndSort: 2008,
|
||
/** Audio 页面耳机最大音量和耳机启动音量设置。 */
|
||
hpVolumeSettings: 2011,
|
||
/** EQ 单个滤波器的 Bypass 开关(旁通时下发 type=10)。 */
|
||
peqBandBypass: 2012,
|
||
/** 设备语言扩展到 LangType 全枚举(12 种);低于此版本仅前 3 种(0/1/2)可下发设备。 */
|
||
extendedDeviceLanguages: 2012,
|
||
/** System 页屏幕亮度改为 10 档拖动条(screenLight 下发 0–9);低于此版本保持三档选择列表。 */
|
||
screenBrightnessSlider: 2012,
|
||
} as const;
|
||
|
||
export type FirmwareFeatureKey = keyof typeof FIRMWARE_FEATURE_MIN_VERSION;
|
||
|
||
export function isFirmwareFeatureAvailable(
|
||
feature: FirmwareFeatureKey,
|
||
firmwareVersion: number,
|
||
): boolean {
|
||
return firmwareVersion >= FIRMWARE_FEATURE_MIN_VERSION[feature];
|
||
}
|
||
|
||
/** Max `bootSound` select index (0–6 legacy, 0–10 when extended steps are supported). */
|
||
export function getBootSoundMaxIndex(firmwareVersion: number): number {
|
||
return isFirmwareFeatureAvailable("bootSoundExtendedSteps", firmwareVersion) ? 10 : 6;
|
||
}
|
||
|
||
export function supportsPeqPresetRenameAndSort(firmwareVersion: number): boolean {
|
||
return isFirmwareFeatureAvailable("peqPresetRenameAndSort", firmwareVersion);
|
||
}
|
||
|
||
export function supportsHpVolumeSettings(firmwareVersion: number): boolean {
|
||
return isFirmwareFeatureAvailable("hpVolumeSettings", firmwareVersion);
|
||
}
|
||
|
||
export function supportsPeqBandBypass(firmwareVersion: number): boolean {
|
||
return isFirmwareFeatureAvailable("peqBandBypass", firmwareVersion);
|
||
}
|
||
|
||
/** 固件是否支持把扩展设备语言(索引 3..11)下发到设备。 */
|
||
export function supportsExtendedDeviceLanguages(firmwareVersion: number): boolean {
|
||
return isFirmwareFeatureAvailable("extendedDeviceLanguages", firmwareVersion);
|
||
}
|
||
|
||
/** 固件是否支持屏幕亮度 10 档拖动条(screenLight 0–9,数值越大越亮)。 */
|
||
export function supportsScreenBrightnessSlider(firmwareVersion: number): boolean {
|
||
return isFirmwareFeatureAvailable("screenBrightnessSlider", firmwareVersion);
|
||
}
|