From 7b49797be1da97f54e9df3a1b0342ab20d7f02d5 Mon Sep 17 00:00:00 2001 From: Selene ToyKeeper Date: Wed, 27 Mar 2024 07:13:26 -0600 Subject: increased voltage precision from 0.025V to 0.02V (so 0 to 255 now goes from 0.00V to 5.10V) --- fsm/adc.h | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'fsm/adc.h') diff --git a/fsm/adc.h b/fsm/adc.h index f66bf34..5dec6c5 100644 --- a/fsm/adc.h +++ b/fsm/adc.h @@ -4,6 +4,10 @@ #pragma once +// voltage is 0.00V to 5.10V in 0.02V steps, from 0 to 255 +// so one deci-Volt is 5 steps +#define dV 5 + #if defined(USE_LVP) || defined(USE_THERMAL_REGULATION) // use raw value instead of lowpassed value for the next N measurements // (2 = 1 for voltage + 1 for temperature) @@ -15,13 +19,13 @@ volatile uint8_t adc_reset = 2; #ifndef VOLTAGE_WARNING_SECONDS #define VOLTAGE_WARNING_SECONDS 5 #endif -// low-battery threshold in volts * 40 +// low-battery threshold in volts * 50 #ifndef VOLTAGE_LOW -#define VOLTAGE_LOW (4*29) +#define VOLTAGE_LOW (29*dV) #endif // battery is low but not critical #ifndef VOLTAGE_RED -#define VOLTAGE_RED (4*33) +#define VOLTAGE_RED (33*dV) #endif // MCU sees voltage 0.X volts lower than actual, add X/2 to readings #ifndef VOLTAGE_FUDGE_FACTOR -- cgit v1.2.3