From 2e1a2f98f22ab71292183d0f858d65db6f59083d Mon Sep 17 00:00:00 2001 From: jess Date: Thu, 2 Apr 2026 18:19:51 -0700 Subject: [PATCH] add cl_factor protocol support to desktop cue --- cue/src/protocol.rs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/cue/src/protocol.rs b/cue/src/protocol.rs index 9ab45d6..58d2a0b 100644 --- a/cue/src/protocol.rs +++ b/cue/src/protocol.rs @@ -26,6 +26,7 @@ pub const RSP_REF_LP_RANGE: u8 = 0x21; pub const RSP_REFS_DONE: u8 = 0x22; pub const RSP_CELL_K: u8 = 0x11; pub const RSP_REF_STATUS: u8 = 0x23; +pub const RSP_CL_FACTOR: u8 = 0x24; /* Cue → ESP32 */ pub const CMD_SET_SWEEP: u8 = 0x10; @@ -44,6 +45,8 @@ pub const CMD_START_PH: u8 = 0x24; pub const CMD_START_CLEAN: u8 = 0x25; pub const CMD_SET_CELL_K: u8 = 0x28; pub const CMD_GET_CELL_K: u8 = 0x29; +pub const CMD_SET_CL_FACTOR: u8 = 0x33; +pub const CMD_GET_CL_FACTOR: u8 = 0x34; pub const CMD_START_REFS: u8 = 0x30; pub const CMD_GET_REFS: u8 = 0x31; pub const CMD_CLEAR_REFS: u8 = 0x32; @@ -258,6 +261,7 @@ pub enum EisMessage { RefsDone, RefStatus { has_refs: bool }, CellK(f32), + ClFactor(f32), } fn decode_u16(data: &[u8]) -> u16 { @@ -413,6 +417,10 @@ pub fn parse_sysex(data: &[u8]) -> Option { let p = &data[2..]; Some(EisMessage::CellK(decode_float(&p[0..5]))) } + RSP_CL_FACTOR if data.len() >= 7 => { + let p = &data[2..]; + Some(EisMessage::ClFactor(decode_float(&p[0..5]))) + } _ => None, } } @@ -527,3 +535,14 @@ pub fn build_sysex_set_cell_k(k: f32) -> Vec { pub fn build_sysex_get_cell_k() -> Vec { vec![0xF0, SYSEX_MFR, CMD_GET_CELL_K, 0xF7] } + +pub fn build_sysex_set_cl_factor(f: f32) -> Vec { + let mut sx = vec![0xF0, SYSEX_MFR, CMD_SET_CL_FACTOR]; + sx.extend_from_slice(&encode_float(f)); + sx.push(0xF7); + sx +} + +pub fn build_sysex_get_cl_factor() -> Vec { + vec![0xF0, SYSEX_MFR, CMD_GET_CL_FACTOR, 0xF7] +}