import { _ as _export_sfc, o as openBlock, c as createElementBlock, al as createStaticVNode } from "./chunks/framework.8zKZLKO7.js"; const __pageData = JSON.parse('{"title":"Battery Driver","description":"","frontmatter":{},"headers":[],"relativePath":"drivers/battery.md","filePath":"drivers/battery.md","lastUpdated":null}'); const _sfc_main = { name: "drivers/battery.md" }; function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) { return openBlock(), createElementBlock("div", null, [..._cache[0] || (_cache[0] = [ createStaticVNode('

Battery Driver ​

This driver provides support for directly sampling battery level.

Usage ​

To use this driver, add the following to your rules.mk:

make
BATTERY_DRIVER_REQUIRED = yes

Note

This is already configured for you if you are using the Battery feature.

Driver Configuration ​

Driver selection can be configured in rules.mk as BATTERY_DRIVER. Valid values are adc, vendor, or custom. See below for information on individual drivers.

ADC Driver ​

The default configuration assumes the battery is connected to a ADC capable pin through a voltage divider.

make
BATTERY_DRIVER = adc

The following #defines apply only to the adc driver:

DefineDefaultDescription
BATTERY_ADC_PINNot definedThe GPIO pin connected to the voltage divider.
BATTERY_ADC_REF_VOLTAGE_MV3300The ADC reverence voltage, in millivolts.
BATTERY_ADC_VOLTAGE_DIVIDER_R1100The voltage divider resistance, in kOhm. Set to 0 to disable.
BATTERY_ADC_VOLTAGE_DIVIDER_R2100The voltage divider resistance, in kOhm. Set to 0 to disable.
BATTERY_ADC_RESOLUTION10The ADC resolution configured for the ADC Driver.

Custom Driver ​

A custom driver is expected to implement the following interface:

c
void battery_driver_init(void) {\n    // Perform any initialisation here\n}\n\nuint8_t battery_driver_sample_percent(void) {\n    // Read and return current state here\n    return value;\n}
', 16) ])]); } const battery = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]); export { __pageData, battery as default };