diff options
Diffstat (limited to 'hw/hank/emisar-d3aa/hwdef.c')
| -rw-r--r-- | hw/hank/emisar-d3aa/hwdef.c | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/hw/hank/emisar-d3aa/hwdef.c b/hw/hank/emisar-d3aa/hwdef.c index 36c6fed..be673e1 100644 --- a/hw/hank/emisar-d3aa/hwdef.c +++ b/hw/hank/emisar-d3aa/hwdef.c @@ -101,13 +101,11 @@ bool gradual_tick_main(uint8_t gt) { #ifdef USE_VOLTAGE_DIVIDER uint8_t voltage_raw2cooked(uint16_t measurement) { // In : 65535 * BATTLVL / 1.024V - // Out: uint8_t: Vbat * 40 + // Out: uint8_t: Vbat * 50 // BATTLVL = Vbat * (100.0/(330+100)) = Vbat / 4.3 - // So, Out = In * 4.3 / 1600 - // (plus a bit of fudging to fix the slope and offset, - // based on measuring actual hardware) + // So, Out = In * 4.3 / 1280 uint8_t result = (uint32_t)(measurement + (65535 * 4 / 1024)) - * 43 / 16000; + * 43 / 12800; return result; } #endif |
