diff options
| author | Selene ToyKeeper | 2024-03-29 08:21:24 -0600 |
|---|---|---|
| committer | Selene ToyKeeper | 2024-03-29 08:21:24 -0600 |
| commit | 849bc5951b27f3f6296d28e8f62f2077e811e2ad (patch) | |
| tree | 96939f9b03267c410bb211427f5ca346dc75df04 /arch/attiny85.c | |
| parent | d3aa weak battery test: blink 3x instead of 2x, and omit number readout (diff) | |
| parent | use smooth steps in lockout mode, if enabled (diff) | |
| download | anduril-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 'arch/attiny85.c')
| -rw-r--r-- | arch/attiny85.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/arch/attiny85.c b/arch/attiny85.c index 9e298cc..4ca4b87 100644 --- a/arch/attiny85.c +++ b/arch/attiny85.c @@ -103,24 +103,24 @@ inline uint16_t mcu_adc_result() { return ADC; } inline uint8_t mcu_vdd_raw2cooked(uint16_t measurement) { // In : 65535 * 1.1 / Vbat - // Out: uint8_t: Vbat * 40 + // Out: uint8_t: Vbat * 50 // 1.1 = ADC Vref // 1024 = how much ADC resolution we're using (10 bits) // (12 bits available, but it costs an extra 84 bytes of ROM to calculate) - uint8_t vbat40 = (uint16_t)(40 * 1.1 * 1024) / (measurement >> 6); - return vbat40; + uint8_t vbat = (uint16_t)(10 * dV * 1.1 * 1024) / (measurement >> 6); + return vbat; } #ifdef USE_VOLTAGE_DIVIDER inline uint8_t mcu_vdivider_raw2cooked(uint16_t measurement) { // In : 4095 * Vdiv / 1.1V - // Out: uint8_t: Vbat * 40 + // Out: uint8_t: Vbat * 50 // Vdiv = Vbat / 4.3 (typically) // 1.1 = ADC Vref const uint16_t adc_per_volt = (((uint16_t)ADC_44 << 4) - ((uint16_t)ADC_22 << 4)) - / (4 * (44-22)); + / (dV * (44-22)); uint8_t result = measurement / adc_per_volt; return result; } |
