From afea7ca0d1d670bdee04cfe80a1d8c36efa4fca0 Mon Sep 17 00:00:00 2001 From: Riku Isokoski Date: Sun, 18 Dec 2022 19:14:36 +0200 Subject: Update clang-tidy configuration and fix some warnings (#1474) Don't enable coding conventions from unrelated projects. Only enable generic checks. --- src/components/battery/BatteryController.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'src/components/battery') diff --git a/src/components/battery/BatteryController.cpp b/src/components/battery/BatteryController.cpp index b61f0ce3..dc15612e 100644 --- a/src/components/battery/BatteryController.cpp +++ b/src/components/battery/BatteryController.cpp @@ -16,8 +16,8 @@ Battery::Battery() { } void Battery::ReadPowerState() { - isCharging = !nrf_gpio_pin_read(PinMap::Charging); - isPowerPresent = !nrf_gpio_pin_read(PinMap::PowerPresent); + isCharging = (nrf_gpio_pin_read(PinMap::Charging) == 0); + isPowerPresent = (nrf_gpio_pin_read(PinMap::PowerPresent) == 0); if (isPowerPresent && !isCharging) { isFull = true; @@ -81,10 +81,8 @@ void Battery::SaadcEventHandler(nrfx_saadc_evt_t const* p_event) { // p_event->data.done.p_buffer[0] = (adc_voltage / reference_voltage) * 1024 voltage = p_event->data.done.p_buffer[0] * (8 * 600) / 1024; - uint8_t newPercent; - if (isFull) { - newPercent = 100; - } else { + uint8_t newPercent = 100; + if (!isFull) { newPercent = std::min(aprox.GetValue(voltage), isCharging ? uint8_t {99} : uint8_t {100}); } -- cgit v1.2.3-70-g09d2