Check battery charging status

This snippet will let you check if the device battery is charging.
#include <device/battery.h>
#include <dlog.h> //for logging purposes

bool battery_charging = false;
if (device_battery_is_charging(&battery_charging) == DEVICE_ERROR_NONE)
{
    if (battery_charging == true)
    {
        LOGI("Battery is charging");
    }
    else
    {
        LOGI("Battery is not charging");
    }
}

Responses

0 Replies