From e818259b5bfde1315ec8f9920ed82003cf38b9ae Mon Sep 17 00:00:00 2001 From: cubee Date: Fri, 22 Nov 2024 17:36:35 +1100 Subject: [PATCH] default to -1 if a device has no battery level. this is just to make sure the unwrap() doesn't crash; -1 (or any negative value) is used as the "disconnected" value. --- src/backend/osc.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/backend/osc.rs b/src/backend/osc.rs index 1840554..f792076 100644 --- a/src/backend/osc.rs +++ b/src/backend/osc.rs @@ -100,8 +100,8 @@ impl OscSender { for device in &app.input_state.devices { - // i believe soc is the battery level, based on input.rs (status.charge) - let level = device.soc.unwrap(); + // soc is the battery level (set to device status.charge) + let level = device.soc.unwrap_or(-1.0); let mut parameter = ""; match device.role {