| 12345678910111213 |
- 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('<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 directly 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" tabindex="0"><code><span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">BATTERY_DRIVER_REQUIRED = yes</span></span></code></pre></div><div class="info custom-block"><p class="custom-block-title">Note</p><p>This is already configured for you if you are using the <a href="./../features/battery">Battery</a> feature.</p></div><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>, <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>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" tabindex="0"><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 tabindex="0"><thead><tr><th>Define</th><th>Default</th><th>Description</th></tr></thead><tbody><tr><td><code>BATTERY_ADC_PIN</code></td><td><em>Not defined</em></td><td>The GPIO pin connected to the voltage divider.</td></tr><tr><td><code>BATTERY_ADC_REF_VOLTAGE_MV</code></td><td><code>3300</code></td><td>The ADC reverence voltage, in millivolts.</td></tr><tr><td><code>BATTERY_ADC_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_ADC_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><h3 id="custom-driver" tabindex="-1">Custom Driver <a class="header-anchor" href="#custom-driver" aria-label="Permalink to "Custom Driver {#custom-driver}""></a></h3><p>A custom driver is expected to implement the following interface:</p><div class="language-c vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">c</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">void</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> battery_driver_init</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">void</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) {</span></span>\n<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"> // Perform any initialisation here</span></span>\n<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">}</span></span>\n<span class="line"></span>\n<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">uint8_t</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> battery_driver_sample_percent</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">void</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) {</span></span>\n<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"> // Read and return current state here</span></span>\n<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> return</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> value;</span></span>\n<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">}</span></span></code></pre></div>', 16)
- ])]);
- }
- const battery = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
- export {
- __pageData,
- battery as default
- };
|