aboutsummaryrefslogtreecommitdiffhomepage
path: root/app/drivers/sensor/battery/battery_common.h
blob: 3e16ceed145f106a27cff35cb76c4e8379da4b12 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
/*
 * Copyright (c) 2021 The ZMK Contributors
 *
 * SPDX-License-Identifier: MIT
 */

#pragma once

#include <zephyr/drivers/sensor.h>
#include <stdint.h>

struct battery_value {
    uint16_t adc_raw;
    uint16_t millivolts;
    uint8_t state_of_charge;
};

int battery_channel_get(const struct battery_value *value, enum sensor_channel chan,
                        struct sensor_value *val_out);

uint8_t lithium_ion_mv_to_pct(int16_t bat_mv);