mirror of
https://github.com/qmk/qmk_firmware.git
synced 2025-07-18 21:52:02 +00:00
16 lines
6.1 KiB
JavaScript
16 lines
6.1 KiB
JavaScript
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('<h1 id="battery-driver" tabindex="-1">Battery Driver <a class="header-anchor" href="#battery-driver" aria-label="Permalink to "Battery Driver""></a></h1><p>This driver provides support for sampling battery level.</p><h2 id="usage" tabindex="-1">Usage <a class="header-anchor" href="#usage" aria-label="Permalink to "Usage""></a></h2><p>To use this driver, add the following to your <code>rules.mk</code>:</p><div class="language-make vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">make</span><pre class="shiki shiki-themes github-light github-dark vp-code"><code><span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">BATTERY_DRIVER_REQUIRED = yes</span></span></code></pre></div><h2 id="basic-configuration" tabindex="-1">Basic Configuration <a class="header-anchor" href="#basic-configuration" aria-label="Permalink to "Basic Configuration {#basic-configuration}""></a></h2><p>Add the following to your <code>config.h</code>:</p><table><thead><tr><th>Define</th><th>Default</th><th>Description</th></tr></thead><tbody><tr><td><code>BATTERY_SAMPLE_INTERVAL</code></td><td><code>30000</code></td><td>The time between battery samples in milliseconds.</td></tr></tbody></table><h2 id="driver-configuration" tabindex="-1">Driver Configuration <a class="header-anchor" href="#driver-configuration" aria-label="Permalink to "Driver Configuration {#driver-configuration}""></a></h2><p>Driver selection can be configured in <code>rules.mk</code> as <code>BATTERY_DRIVER</code>. Valid values are <code>adc</code> (default), <code>vendor</code>, or <code>custom</code>. See below for information on individual drivers.</p><h3 id="adc-driver" tabindex="-1">ADC Driver <a class="header-anchor" href="#adc-driver" aria-label="Permalink to "ADC Driver {#adc-driver}""></a></h3><p>This is the default battery driver. The default configuration assumes the battery is connected to a ADC capable pin through a voltage divider.</p><div class="language-make vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">make</span><pre class="shiki shiki-themes github-light github-dark vp-code"><code><span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">BATTERY_DRIVER = adc</span></span></code></pre></div><p>The following <code>#define</code>s apply only to the <code>adc</code> driver:</p><table><thead><tr><th>Define</th><th>Default</th><th>Description</th></tr></thead><tbody><tr><td><code>BATTERY_PIN</code></td><td><em>Not defined</em></td><td>The GPIO pin connected to the voltage divider.</td></tr><tr><td><code>BATTERY_REF_VOLTAGE_MV</code></td><td><code>3300</code></td><td>The ADC reverence voltage, in millivolts.</td></tr><tr><td><code>BATTERY_VOLTAGE_DIVIDER_R1</code></td><td><code>100</code></td><td>The voltage divider resistance, in kOhm. Set to 0 to disable.</td></tr><tr><td><code>BATTERY_VOLTAGE_DIVIDER_R2</code></td><td><code>100</code></td><td>The voltage divider resistance, in kOhm. Set to 0 to disable.</td></tr><tr><td><code>BATTERY_ADC_RESOLUTION</code></td><td><code>10</code></td><td>The ADC resolution configured for the ADC Driver.</td></tr></tbody></table><h2 id="functions" tabindex="-1">Functions <a class="header-anchor" href="#functions" aria-label="Permalink to "Functions""></a></h2><h3 id="api-battery-get-percent" tabindex="-1"><code>uint8_t battery_get_percent(void)</code> <a class="header-anchor" href="#api-battery-get-percent" aria-label="Permalink to "`uint8_t battery_get_percent(void)` {#api-battery-get-percent}""></a></h3><p>Sample battery level.</p><h4 id="api-battery-get-percent-return" tabindex="-1">Return Value <a class="header-anchor" href="#api-battery-get-percent-return" aria-label="Permalink to "Return Value {#api-battery-get-percent-return}""></a></h4><p>The battery percentage, in the range 0-100.</p><h2 id="callbacks" tabindex="-1">Callbacks <a class="header-anchor" href="#callbacks" aria-label="Permalink to "Callbacks""></a></h2><h3 id="api-battery-percent-changed-user" tabindex="-1"><code>void battery_percent_changed_user(uint8_t level)</code> <a class="header-anchor" href="#api-battery-percent-changed-user" aria-label="Permalink to "`void battery_percent_changed_user(uint8_t level)` {#api-battery-percent-changed-user}""></a></h3><p>User hook called when battery level changed.</p><h3 id="api-battery-percent-changed-user-arguments" tabindex="-1">Arguments <a class="header-anchor" href="#api-battery-percent-changed-user-arguments" aria-label="Permalink to "Arguments {#api-battery-percent-changed-user-arguments}""></a></h3><ul><li><code>uint8_t level</code><br> The battery percentage, in the range 0-100.</li></ul><hr><h3 id="api-battery-percent-changed-kb" tabindex="-1"><code>void battery_percent_changed_kb(uint8_t level)</code> <a class="header-anchor" href="#api-battery-percent-changed-kb" aria-label="Permalink to "`void battery_percent_changed_kb(uint8_t level)` {#api-battery-percent-changed-kb}""></a></h3><p>Keyboard hook called when battery level changed.</p><h3 id="api-battery-percent-changed-kb-arguments" tabindex="-1">Arguments <a class="header-anchor" href="#api-battery-percent-changed-kb-arguments" aria-label="Permalink to "Arguments {#api-battery-percent-changed-kb-arguments}""></a></h3><ul><li><code>uint8_t level</code><br> The battery percentage, in the range 0-100.</li></ul>', 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
|
||
};
|