import { _ as _export_sfc, c as createElementBlock, o as openBlock, a8 as createStaticVNode } from "./chunks/framework.Cauyuiy8.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" }; const _hoisted_1 = /* @__PURE__ */ createStaticVNode('

Battery Driver

This driver provides support for sampling battery level.

Usage

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

make
BATTERY_DRIVER_REQUIRED = yes

Basic Configuration

Add the following to your config.h:

DefineDefaultDescription
BATTERY_SAMPLE_INTERVAL30000The time between battery samples in milliseconds.

Driver Configuration

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

ADC Driver

This is the default battery 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_PINNot definedThe GPIO pin connected to the voltage divider.
BATTERY_REF_VOLTAGE_MV3300The ADC reverence voltage, in millivolts.
BATTERY_VOLTAGE_DIVIDER_R1100The voltage divider resistance, in kOhm. Set to 0 to disable.
BATTERY_VOLTAGE_DIVIDER_R2100The voltage divider resistance, in kOhm. Set to 0 to disable.
BATTERY_ADC_RESOLUTION10The ADC resolution configured for the ADC Driver.

Functions

uint8_t battery_get_percent(void)

Sample battery level.

Return Value

The battery percentage, in the range 0-100.

Callbacks

void battery_percent_changed_user(uint8_t level)

User hook called when battery level changed.

Arguments


void battery_percent_changed_kb(uint8_t level)

Keyboard hook called when battery level changed.

Arguments

', 30); const _hoisted_31 = [ _hoisted_1 ]; function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) { return openBlock(), createElementBlock("div", null, _hoisted_31); } const battery = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]); export { __pageData, battery as default };