add cl_factor protocol support to desktop cue

This commit is contained in:
jess 2026-04-02 18:19:51 -07:00
parent 4c914a5101
commit 2e1a2f98f2
1 changed files with 19 additions and 0 deletions

View File

@ -26,6 +26,7 @@ pub const RSP_REF_LP_RANGE: u8 = 0x21;
pub const RSP_REFS_DONE: u8 = 0x22; pub const RSP_REFS_DONE: u8 = 0x22;
pub const RSP_CELL_K: u8 = 0x11; pub const RSP_CELL_K: u8 = 0x11;
pub const RSP_REF_STATUS: u8 = 0x23; pub const RSP_REF_STATUS: u8 = 0x23;
pub const RSP_CL_FACTOR: u8 = 0x24;
/* Cue → ESP32 */ /* Cue → ESP32 */
pub const CMD_SET_SWEEP: u8 = 0x10; 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_START_CLEAN: u8 = 0x25;
pub const CMD_SET_CELL_K: u8 = 0x28; pub const CMD_SET_CELL_K: u8 = 0x28;
pub const CMD_GET_CELL_K: u8 = 0x29; 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_START_REFS: u8 = 0x30;
pub const CMD_GET_REFS: u8 = 0x31; pub const CMD_GET_REFS: u8 = 0x31;
pub const CMD_CLEAR_REFS: u8 = 0x32; pub const CMD_CLEAR_REFS: u8 = 0x32;
@ -258,6 +261,7 @@ pub enum EisMessage {
RefsDone, RefsDone,
RefStatus { has_refs: bool }, RefStatus { has_refs: bool },
CellK(f32), CellK(f32),
ClFactor(f32),
} }
fn decode_u16(data: &[u8]) -> u16 { fn decode_u16(data: &[u8]) -> u16 {
@ -413,6 +417,10 @@ pub fn parse_sysex(data: &[u8]) -> Option<EisMessage> {
let p = &data[2..]; let p = &data[2..];
Some(EisMessage::CellK(decode_float(&p[0..5]))) 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, _ => None,
} }
} }
@ -527,3 +535,14 @@ pub fn build_sysex_set_cell_k(k: f32) -> Vec<u8> {
pub fn build_sysex_get_cell_k() -> Vec<u8> { pub fn build_sysex_get_cell_k() -> Vec<u8> {
vec![0xF0, SYSEX_MFR, CMD_GET_CELL_K, 0xF7] vec![0xF0, SYSEX_MFR, CMD_GET_CELL_K, 0xF7]
} }
pub fn build_sysex_set_cl_factor(f: f32) -> Vec<u8> {
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<u8> {
vec![0xF0, SYSEX_MFR, CMD_GET_CL_FACTOR, 0xF7]
}