Adjusts LF ADC raw data processing

Adjusts the bit shift for ADC raw data conversion to refine the value range.
This commit is contained in:
Oleg Moiseenko
2025-10-09 09:42:43 +03:00
parent e2c6bfc9e1
commit f5bed3c5b1
2 changed files with 2 additions and 2 deletions
@@ -45,7 +45,7 @@ bool raw_read_to_buffer(uint8_t *data, size_t maxlen, uint32_t timeout_ms, size_
while (NO_TIMEOUT_1MS(p_at, timeout_ms) && *outlen < maxlen) {
uint16_t val = 0;
while (cb_pop_front(&cb, &val) && *outlen < maxlen) {
val = val >> 6; // 14 bit ADC to 8 bit value
val = val >> 5; // 14 bit ADC to 8 bit value and /2 range
data[*outlen] = val > 0xff ? 0xff : val;
++(*outlen);
}
+1 -1
View File
@@ -3267,7 +3267,7 @@ class LFADCGenericRead(ReaderRequiredUnit):
for i in range(0, len(resp), width):
chunk = resp[i : i + width]
hexpart = " ".join(f"{b:02x}" for b in chunk)
binpart = "".join('1' if b >= 0x5f else '0' for b in chunk)
binpart = "".join('1' if b >= 0xbf else '0' for b in chunk)
print(f"{i:04x} {hexpart:<{width * 3}} {binpart}")
avg = 0