From 138c7d49f0d6d546d75630b09c20abd8453d7598 Mon Sep 17 00:00:00 2001 From: Hans Christian Olaussen <41271048+klutvott123@users.noreply.github.com> Date: Sun, 13 Nov 2022 16:21:40 +0100 Subject: [PATCH] Handle signed values --- src/SCRIPTS/BF/ui.lua | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/SCRIPTS/BF/ui.lua b/src/SCRIPTS/BF/ui.lua index 97a2c74..42db07f 100644 --- a/src/SCRIPTS/BF/ui.lua +++ b/src/SCRIPTS/BF/ui.lua @@ -121,6 +121,10 @@ local function processMspReply(cmd,rx_buf) raw_val = bit32.lshift(raw_val, (idx-1)*8) f.value = bit32.bor(f.value, raw_val) end + local bits = #f.vals * 8 + if f.min < 0 and bit32.btest(f.value, bit32.lshift(1, bits - 1)) then + f.value = f.value - (2 ^ bits) + end f.value = f.value/(f.scale or 1) end end