From 005dc0b3e5e0ce6351739daf519a59abc7872385 Mon Sep 17 00:00:00 2001 From: Mike Hojnowski Date: Wed, 3 Jan 2024 05:13:43 -0500 Subject: [PATCH] Modified formula for voltage calculation on dfm17 (#81) --- src/hal/system.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/hal/system.c b/src/hal/system.c index 152f69f..ced3bcf 100644 --- a/src/hal/system.c +++ b/src/hal/system.c @@ -211,7 +211,14 @@ static void dma_adc_init() uint16_t system_get_battery_voltage_millivolts() { +#ifdef RS41 return (uint16_t) (((float) dma_buffer_adc[0]) * 10.0f * 600.0f / 4096.0f); +#else //DFM17 + // Kludge: DFM17 voltage is more than 5 volts, so cut the value in half. + // Changed 600 to 690 to try and get it more accurate to actual voltage + // 690 yields fairly linear, accurate results between 5v6 and 6v6 + return (uint16_t) ( ((float) dma_buffer_adc[0]) * 10.0f * 690.0f / 8192.0f ); +#endif } uint16_t system_get_button_adc_value()