aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSelene ToyKeeper2022-10-21 08:53:10 -0600
committerSelene ToyKeeper2022-10-21 08:53:10 -0600
commit1447932067ca39d50c204ad5df5f9cbc1e35ef6d (patch)
tree78a8b2d1388526068be9fbfd465a5ed06f4ac204
parentallow supporting single-color and RGB side button in the same build (diff)
downloadanduril-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)
-rw-r--r--spaghetti-monster/fsm-adc.c4
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
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.