diff options
| author | Selene ToyKeeper | 2022-10-21 08:53:10 -0600 |
|---|---|---|
| committer | Selene ToyKeeper | 2022-10-21 08:53:10 -0600 |
| commit | 1447932067ca39d50c204ad5df5f9cbc1e35ef6d (patch) | |
| tree | 78a8b2d1388526068be9fbfd465a5ed06f4ac204 /spaghetti-monster/fsm-adc.c | |
| parent | allow supporting single-color and RGB side button in the same build (diff) | |
| download | anduril-1447932067ca39d50c204ad5df5f9cbc1e35ef6d.tar.gz anduril-1447932067ca39d50c204ad5df5f9cbc1e35ef6d.tar.bz2 anduril-1447932067ca39d50c204ad5df5f9cbc1e35ef6d.zip | |
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)
Diffstat (limited to '')
| -rw-r--r-- | spaghetti-monster/fsm-adc.c | 4 |
1 files 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 |
