From 1447932067ca39d50c204ad5df5f9cbc1e35ef6d Mon Sep 17 00:00:00 2001 From: Selene ToyKeeper Date: Fri, 21 Oct 2022 08:53:10 -0600 Subject: fixed voltage calibration resolution on SP10 Pro and other devices which use a voltage divider (it was 0.1V per step, and is now 0.05V per step) --- spaghetti-monster/fsm-adc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spaghetti-monster/fsm-adc.c b/spaghetti-monster/fsm-adc.c index c5401ea..ce7a31c 100644 --- a/spaghetti-monster/fsm-adc.c +++ b/spaghetti-monster/fsm-adc.c @@ -146,12 +146,12 @@ static inline uint8_t calc_voltage_divider(uint16_t value) { // use 9.7 fixed-point to get sufficient precision uint16_t adc_per_volt = ((ADC_44<<5) - (ADC_22<<5)) / (44-22); // shift incoming value into a matching position - uint8_t result = ((value>>1) / adc_per_volt) + uint8_t result = ((value / adc_per_volt) + VOLTAGE_FUDGE_FACTOR #ifdef USE_VOLTAGE_CORRECTION + voltage_correction - 7 #endif - ; + ) >> 1; return result; } #endif -- cgit v1.2.3