aboutsummaryrefslogtreecommitdiff
path: root/spaghetti-monster/fsm-adc.c
diff options
context:
space:
mode:
authorSelene ToyKeeper2017-09-22 07:22:16 -0600
committerSelene ToyKeeper2017-09-22 07:22:16 -0600
commite4634255795f04a1d859aa691fbc6e729973b14d (patch)
tree40ee093fecb61ea6907cbb3abc50495b55293eed /spaghetti-monster/fsm-adc.c
parentAdded FW3A driver support to FSM and Anduril. (diff)
downloadanduril-e4634255795f04a1d859aa691fbc6e729973b14d.tar.gz
anduril-e4634255795f04a1d859aa691fbc6e729973b14d.tar.bz2
anduril-e4634255795f04a1d859aa691fbc6e729973b14d.zip
Slightly increased resolution of VOLTAGE_FUDGE_FACTOR.
My lights seemed to measure just a bit low, so hopefully this will help. It bumps up reported values by 0.05V.
Diffstat (limited to 'spaghetti-monster/fsm-adc.c')
-rw-r--r--spaghetti-monster/fsm-adc.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/spaghetti-monster/fsm-adc.c b/spaghetti-monster/fsm-adc.c
index 02fd8c2..5be3061 100644
--- a/spaghetti-monster/fsm-adc.c
+++ b/spaghetti-monster/fsm-adc.c
@@ -108,7 +108,8 @@ ISR(ADC_vect) {
// calculate actual voltage: volts * 10
// ADC = 1.1 * 1024 / volts
// volts = 1.1 * 1024 / ADC
- voltage = (uint16_t)(1.1*1024*10)/measurement + VOLTAGE_FUDGE_FACTOR;
+ //voltage = (uint16_t)(1.1*1024*10)/measurement + VOLTAGE_FUDGE_FACTOR;
+ voltage = ((uint16_t)(2*1.1*1024*10)/measurement + VOLTAGE_FUDGE_FACTOR) >> 1;
#endif
// if low, callback EV_voltage_low / EV_voltage_critical
// (but only if it has been more than N ticks since last call)