1
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
import { clamp, numberValue, type ParameterSnapshot } from '../parameterState'
|
||||
export const mattressFirmnessOptions = ['最软', '很软', '稍软', '稍硬', '很硬', '最硬']
|
||||
export const mattressModeOptions = ['无', '瑜伽助眠', '智能适配', '智能腰托']
|
||||
export const massagePartOptions = ['无', '背部', '腰部', '牵引', '腿部', '全身']
|
||||
export const mattressFirmnessZones = [
|
||||
{ key: 'left_shoulder', label: '左肩' }, { key: 'right_shoulder', label: '右肩' },
|
||||
{ key: 'left_back', label: '左背' }, { key: 'right_back', label: '右背' },
|
||||
{ key: 'left_waist', label: '左腰' }, { key: 'right_waist', label: '右腰' },
|
||||
{ key: 'left_lumbar', label: '左腰椎' }, { key: 'right_lumbar', label: '右腰椎' },
|
||||
{ key: 'left_hip', label: '左臀' }, { key: 'right_hip', label: '右臀' },
|
||||
{ key: 'left_leg', label: '左腿' }, { key: 'right_leg', label: '右腿' }
|
||||
]
|
||||
export const defaults = { mattressLeftHeating: 0, mattressRightHeating: 0, mattressLeftMode: '智能适配',
|
||||
mattressRightMode: '智能适配', mattressFirmness: {} as Record<string, string>, mattressMassageLeftPart: '无',
|
||||
mattressMassageRightPart: '无', mattressMassageLevel: '轻柔' }
|
||||
export const labels = { mattress_left_heating: '床垫左侧加热', mattress_right_heating: '床垫右侧加热',
|
||||
mattress_left_mode: '床垫左侧承托模式', mattress_right_mode: '床垫右侧承托模式',
|
||||
mattress_massage_left_part: '左侧按摩部位', mattress_massage_right_part: '右侧按摩部位', mattress_massage_level: '按摩力度' }
|
||||
export function sync(state: typeof defaults, controls: ParameterSnapshot) {
|
||||
for (const [parameter, property] of [['mattress_left_heating', 'mattressLeftHeating'],
|
||||
['mattress_right_heating', 'mattressRightHeating']] as const) {
|
||||
const value = numberValue(controls[parameter]?.state)
|
||||
if (controls[parameter]?.available && value !== undefined) state[property] = clamp(value, 0, 4)
|
||||
}
|
||||
for (const zone of mattressFirmnessZones) {
|
||||
const control = controls['mattress_firmness_' + zone.key]
|
||||
if (control?.available && mattressFirmnessOptions.includes(control.state)) state.mattressFirmness[zone.key] = control.state
|
||||
}
|
||||
for (const [parameter, property] of [['mattress_massage_left_part', 'mattressMassageLeftPart'],
|
||||
['mattress_massage_right_part', 'mattressMassageRightPart']] as const) {
|
||||
const control = controls[parameter]
|
||||
if (control?.available && massagePartOptions.includes(control.state)) state[property] = control.state
|
||||
}
|
||||
const level = controls.mattress_massage_level
|
||||
if (level?.available && ['轻柔', '强劲'].includes(level.state)) state.mattressMassageLevel = level.state
|
||||
}
|
||||
Reference in New Issue
Block a user