From 57e689439e91e106e0ca2b6a91ca3e756597ba6f Mon Sep 17 00:00:00 2001 From: K Date: Thu, 20 Jul 2023 15:26:10 +0200 Subject: [PATCH] battery level --- barani-meteo-wind-2023.js | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/barani-meteo-wind-2023.js b/barani-meteo-wind-2023.js index 46e413d..681ffc4 100644 --- a/barani-meteo-wind-2023.js +++ b/barani-meteo-wind-2023.js @@ -64,12 +64,22 @@ function Decoder(fPort, bytes, variables) { Index = bitShift(8) * 1; + Battery_t = bitShift(1); + if ((Index % 10) <= 4) { - bitShift(1); // is 9th bit useless? - Battery = (Index % 10) * 0.2 + 3.3; + Battery_voltage = (Index % 10) * 0.2 + 3.3; + if (Battery_t) { + Battery = "> " + Battery_voltage; + } else { + Battery = "< " + Battery_voltage; + } } else { - bitShift(1); // is 9th bit useless? - Battery = (Index % 10) * 0.2 + 3.3 - 1; + Battery_voltage = (Index % 10) * 0.2 + 3.3 - 1; + if (Battery_t) { + Battery = "> " + Battery_voltage; + } else { + Battery = "< " + Battery_voltage; + } } Hz_avg = bitShift(12) * 0.02; @@ -133,4 +143,3 @@ function decodeUplink(input) { // console.log("Testing decoder with sample data 0x0B80520C1C001F399C852001: ") // console.table(Decoder(1,hexToBytes("0B80520C1C001F399C852001"),1)) -// console.log("Done!")