aboutsummaryrefslogtreecommitdiff
path: root/spaghetti-monster
diff options
context:
space:
mode:
authorSelene ToyKeeper2020-03-16 04:13:55 -0600
committerSelene ToyKeeper2020-03-16 04:13:55 -0600
commit227b54b1095e47ae9d0ab4b4c2a49862fd708559 (patch)
tree721f7bfce0a0c310ea0cff79b73e720aee692368 /spaghetti-monster
parentmerged fsm branch (to get adc-rework branch with new thermal regulation) (diff)
downloadanduril-227b54b1095e47ae9d0ab4b4c2a49862fd708559.tar.gz
anduril-227b54b1095e47ae9d0ab4b4c2a49862fd708559.tar.bz2
anduril-227b54b1095e47ae9d0ab4b4c2a49862fd708559.zip
fixed calc_voltage_divider() (use 10-bit calibration values, not 8-bit)
Diffstat (limited to 'spaghetti-monster')
-rw-r--r--spaghetti-monster/fsm-adc.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/spaghetti-monster/fsm-adc.c b/spaghetti-monster/fsm-adc.c
index 7880238..e7b7feb 100644
--- a/spaghetti-monster/fsm-adc.c
+++ b/spaghetti-monster/fsm-adc.c
@@ -112,7 +112,7 @@ inline void ADC_off() {
#ifdef USE_VOLTAGE_DIVIDER
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<<7) - (ADC_22<<7)) / (44-22);
+ 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) + VOLTAGE_FUDGE_FACTOR;
return result;
If you find this content useful please consider a small donation via bitcoin: bitcoin:1mxKyQsHHugqRxPKgwaA7wUwJEGCNthn2?amount=0.001&message=Donation Scraping git contents via cgit is very resource intensive. The continued hosting of these git repositories is entirely financed by your bitcoin contributions. For donations of a least 1 mBTC you include your IP address in the message of your bitcoin donation. This will remove this message in the future for requests from your IP, which will significantly reduce token usage. In any case, any contributions to bitcoin address 1mxKyQsHHugqRxPKgwaA7wUwJEGCNthn2 are very welcome. Thanks in advance for you contribution to a self-sustaining ecosystem.