aboutsummaryrefslogtreecommitdiff
path: root/fsm/adc.c
diff options
context:
space:
mode:
authorSelene ToyKeeper2024-03-29 08:21:24 -0600
committerSelene ToyKeeper2024-03-29 08:21:24 -0600
commit849bc5951b27f3f6296d28e8f62f2077e811e2ad (patch)
tree96939f9b03267c410bb211427f5ca346dc75df04 /fsm/adc.c
parentd3aa weak battery test: blink 3x instead of 2x, and omit number readout (diff)
parentuse smooth steps in lockout mode, if enabled (diff)
downloadanduril-849bc5951b27f3f6296d28e8f62f2077e811e2ad.tar.gz
anduril-849bc5951b27f3f6296d28e8f62f2077e811e2ad.tar.bz2
anduril-849bc5951b27f3f6296d28e8f62f2077e811e2ad.zip
Merge branch 'trunk' into emisar-d3aa
FIXME: The d3aa's voltage calculator needs to be fixed after this merge. * trunk: use smooth steps in lockout mode, if enabled fixed Tactical Mode's strobes when Momentary Mode not enabled increased voltage precision from 0.025V to 0.02V (so 0 to 255 now goes from 0.00V to 5.10V) fixed inaccurate comment (thanks to xikteny for spotting it) Allow manually running GitHub actions workflows Bugfix: Prevent switching channel modes when in tactical mode Bugfix: Tactical mode has a dependency on momentary mode
Diffstat (limited to 'fsm/adc.c')
-rw-r--r--fsm/adc.c58
1 files changed, 29 insertions, 29 deletions
diff --git a/fsm/adc.c b/fsm/adc.c
index fbe84a1..e0bacb6 100644
--- a/fsm/adc.c
+++ b/fsm/adc.c
@@ -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;