diff options
| author | Selene ToyKeeper | 2024-03-27 07:13:26 -0600 |
|---|---|---|
| committer | Selene ToyKeeper | 2024-03-27 07:13:26 -0600 |
| commit | 7b49797be1da97f54e9df3a1b0342ab20d7f02d5 (patch) | |
| tree | 1aab20b6979c781419fc61c8be73facf332ad8e2 /fsm/adc.c | |
| parent | fixed inaccurate comment (thanks to xikteny for spotting it) (diff) | |
| download | anduril-7b49797be1da97f54e9df3a1b0342ab20d7f02d5.tar.gz anduril-7b49797be1da97f54e9df3a1b0342ab20d7f02d5.tar.bz2 anduril-7b49797be1da97f54e9df3a1b0342ab20d7f02d5.zip | |
increased voltage precision from 0.025V to 0.02V
(so 0 to 255 now goes from 0.00V to 5.10V)
Diffstat (limited to '')
| -rw-r--r-- | fsm/adc.c | 58 |
1 files changed, 29 insertions, 29 deletions
@@ -209,8 +209,8 @@ static void ADC_voltage_handler() { #endif else measurement = adc_smooth[0]; - // convert raw ADC value to FSM voltage units: Volts * 40 - // 0 .. 200 = 0.0V .. 5.0V + // convert raw ADC value to FSM voltage units: Volts * 50 + // 0 .. 250 = 0.0V .. 5.0V voltage = voltage_raw2cooked(measurement) + (VOLTAGE_FUDGE_FACTOR << 1) #ifdef USE_VOLTAGE_CORRECTION @@ -392,46 +392,46 @@ static void ADC_temperature_handler() { #ifdef USE_BATTCHECK #ifdef BATTCHECK_4bars PROGMEM const uint8_t voltage_blinks[] = { - 4*30, - 4*35, - 4*38, - 4*40, - 4*42, - 255, + 30*dV, + 35*dV, + 38*dV, + 40*dV, + 42*dV, + 255, }; #endif #ifdef BATTCHECK_6bars PROGMEM const uint8_t voltage_blinks[] = { - 4*30, - 4*34, - 4*36, - 4*38, - 4*40, - 4*41, - 4*43, - 255, + 30*dV, + 34*dV, + 36*dV, + 38*dV, + 40*dV, + 41*dV, + 43*dV, + 255, }; #endif #ifdef BATTCHECK_8bars PROGMEM const uint8_t voltage_blinks[] = { - 4*30, - 4*33, - 4*35, - 4*37, - 4*38, - 4*39, - 4*40, - 4*41, - 4*42, - 255, + 30*dV, + 33*dV, + 35*dV, + 37*dV, + 38*dV, + 39*dV, + 40*dV, + 41*dV, + 42*dV, + 255, }; #endif void battcheck() { #ifdef BATTCHECK_VpT - blink_num(voltage / 4); + blink_num(voltage / dV); #ifdef USE_EXTRA_BATTCHECK_DIGIT - // 0 1 2 3 --> 0 2 5 7, representing x.x00 x.x25 x.x50 x.x75 - blink_num(((voltage % 4)<<1) + ((voltage % 4)>>1)); + // 0.02V precision, 0 1 2 3 4 remainder -> .00 .02 .04 .06 .08V + blink_num((voltage % dV) * (10/dV)); #endif #else uint8_t i; |
