qmk_firmware/assets/drivers_battery.md.rnOtPi7n.js

16 lines
6.1 KiB
JavaScript
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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 &quot;Battery Driver&quot;"></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 &quot;Usage&quot;"></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 &quot;Basic Configuration {#basic-configuration}&quot;"></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 &quot;Driver Configuration {#driver-configuration}&quot;"></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 &quot;ADC Driver {#adc-driver}&quot;"></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 &quot;Functions&quot;"></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 &quot;`uint8_t battery_get_percent(void)` {#api-battery-get-percent}&quot;"></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 &quot;Return Value {#api-battery-get-percent-return}&quot;"></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 &quot;Callbacks&quot;"></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 &quot;`void battery_percent_changed_user(uint8_t level)` {#api-battery-percent-changed-user}&quot;"></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 &quot;Arguments {#api-battery-percent-changed-user-arguments}&quot;"></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 &quot;`void battery_percent_changed_kb(uint8_t level)` {#api-battery-percent-changed-kb}&quot;"></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 &quot;Arguments {#api-battery-percent-changed-kb-arguments}&quot;"></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
};