Changed the zmk,battery-voltage-divider and zmk,battery-nrf-vddh drivers to support only SENSOR_CHAN_VOLTAGE, and changed the default battery fetch mode to ZMK_BATTERY_REPORTING_FETCH_MODE_LITHIUM_VOLTAGE. This allowed for removing the copy of lithium_ion_mv_to_pct() from the driver code, leaving only the version in battery.c. Custom boards/shields that use a fuel gauge driver instead of a voltage sensor, will need the following added to their Kconfig.defconfig: choice ZMK_BATTERY_REPORTING_FETCH_MODE default ZMK_BATTERY_REPORTING_FETCH_MODE_STATE_OF_CHARGE endchoice Alternatively, add the following to the _defconfig file: ZMK_BATTERY_REPORTING_FETCH_MODE_STATE_OF_CHARGE=y
18 lines
370 B
C
18 lines
370 B
C
/*
|
|
* 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;
|
|
};
|
|
|
|
int battery_channel_get(const struct battery_value *value, enum sensor_channel chan,
|
|
struct sensor_value *val_out);
|