diff options
author | Riku Isokoski <riksu9000@gmail.com> | 2021-08-01 16:19:09 +0300 |
---|---|---|
committer | Riku Isokoski <riksu9000@gmail.com> | 2021-08-01 16:19:09 +0300 |
commit | 09aaa5871071857dbcd955ce8ea8e33e95960678 (patch) | |
tree | 584153f049a56c41df769844a8ccf99a03648660 /src | |
parent | 79ee65bfd53d31dd282dbbb7952296cc6f1212eb (diff) |
Remove floating point calculation
Diffstat (limited to 'src')
-rw-r--r-- | src/components/battery/BatteryController.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/components/battery/BatteryController.cpp b/src/components/battery/BatteryController.cpp index e334eeac..f8a64ecd 100644 --- a/src/components/battery/BatteryController.cpp +++ b/src/components/battery/BatteryController.cpp @@ -61,9 +61,9 @@ void Battery::SaadcEventHandler(nrfx_saadc_evt_t const* p_event) { // A hardware voltage divider divides the battery voltage by 2 // ADC gain is 1/4 // thus adc_voltage = battery_voltage / 2 * gain = battery_voltage / 8 - // reference_voltage is 0.6V + // reference_voltage is 600mV // p_event->data.done.p_buffer[0] = (adc_voltage / reference_voltage) * 1024 - voltage = p_event->data.done.p_buffer[0] * (0.6 * 8 * 1000) / 1024; + voltage = p_event->data.done.p_buffer[0] * (8 * 600) / 1024; if (voltage > battery_max) { percentRemaining = 100; |