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('
This driver provides support for sampling battery level.
To use this driver, add the following to your rules.mk
:
BATTERY_DRIVER_REQUIRED = yes
Add the following to your config.h
:
Define | Default | Description |
---|---|---|
BATTERY_SAMPLE_INTERVAL | 30000 | The time between battery samples in milliseconds. |
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.
This is the default battery driver. The default configuration assumes the battery is connected to a ADC capable pin through a voltage divider.
BATTERY_DRIVER = adc
The following #define
s apply only to the adc
driver:
Define | Default | Description |
---|---|---|
BATTERY_PIN | Not defined | The GPIO pin connected to the voltage divider. |
BATTERY_REF_VOLTAGE_MV | 3300 | The ADC reverence voltage, in millivolts. |
BATTERY_VOLTAGE_DIVIDER_R1 | 100 | The voltage divider resistance, in kOhm. Set to 0 to disable. |
BATTERY_VOLTAGE_DIVIDER_R2 | 100 | The voltage divider resistance, in kOhm. Set to 0 to disable. |
BATTERY_ADC_RESOLUTION | 10 | The ADC resolution configured for the ADC Driver. |
uint8_t battery_get_percent(void)
Sample battery level.
The battery percentage, in the range 0-100.
void battery_percent_changed_user(uint8_t level)
User hook called when battery level changed.
uint8_t level
void battery_percent_changed_kb(uint8_t level)
Keyboard hook called when battery level changed.
uint8_t level