qmk_firmware/assets/drivers_adc.md.CdK8AtnR.js

16 lines
18 KiB
JavaScript
Raw Normal View History

import { _ as _export_sfc, c as createElementBlock, o as openBlock, a8 as createStaticVNode } from "./chunks/framework.B9AX-CPi.js";
const __pageData = JSON.parse('{"title":"ADC Driver","description":"","frontmatter":{},"headers":[],"relativePath":"drivers/adc.md","filePath":"drivers/adc.md"}');
const _sfc_main = { name: "drivers/adc.md" };
const _hoisted_1 = /* @__PURE__ */ createStaticVNode('<h1 id="adc-driver" tabindex="-1">ADC Driver <a class="header-anchor" href="#adc-driver" aria-label="Permalink to &quot;ADC Driver&quot;"></a></h1><p>QMK can leverage the Analog-to-Digital Converter (ADC) on supported MCUs to measure voltages on certain pins. This can be useful for implementing things such as battery level indicators for Bluetooth keyboards, or volume controls using a potentiometer, as opposed to a <a href="./../features/encoders">rotary encoder</a>.</p><p>This driver currently supports both AVR and a limited selection of ARM devices. The values returned are 10-bit integers (0-1023) mapped between 0V and VCC (usually 5V or 3.3V for AVR, 3.3V only for ARM), however on ARM there is more flexibility in control of operation through <code>#define</code>s if you need more precision.</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;">ANALOG_DRIVER_REQUIRED = yes</span></span></code></pre></div><p>Then place this include at the top of your code:</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"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">#include</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;analog.h&quot;</span></span></code></pre></div><h2 id="channels" tabindex="-1">Channels <a class="header-anchor" href="#channels" aria-label="Permalink to &quot;Channels&quot;"></a></h2><h3 id="avr" tabindex="-1">AVR <a class="header-anchor" href="#avr" aria-label="Permalink to &quot;AVR&quot;"></a></h3><table><thead><tr><th>Channel</th><th>AT90USB64/128</th><th>ATmega16/32U4</th><th>ATmega32A</th><th>ATmega328/P</th></tr></thead><tbody><tr><td>0</td><td><code>F0</code></td><td><code>F0</code></td><td><code>A0</code></td><td><code>C0</code></td></tr><tr><td>1</td><td><code>F1</code></td><td><code>F1</code></td><td><code>A1</code></td><td><code>C1</code></td></tr><tr><td>2</td><td><code>F2</code></td><td></td><td><code>A2</code></td><td><code>C2</code></td></tr><tr><td>3</td><td><code>F3</code></td><td></td><td><code>A3</code></td><td><code>C3</code></td></tr><tr><td>4</td><td><code>F4</code></td><td><code>F4</code></td><td><code>A4</code></td><td><code>C4</code></td></tr><tr><td>5</td><td><code>F5</code></td><td><code>F5</code></td><td><code>A5</code></td><td><code>C5</code></td></tr><tr><td>6</td><td><code>F6</code></td><td><code>F6</code></td><td><code>A6</code></td><td>*</td></tr><tr><td>7</td><td><code>F7</code></td><td><code>F7</code></td><td><code>A7</code></td><td>*</td></tr><tr><td>8</td><td></td><td><code>D4</code></td><td></td><td></td></tr><tr><td>9</td><td></td><td><code>D6</code></td><td></td><td></td></tr><tr><td>10</td><td></td><td><code>D7</code></td><td></td><td></td></tr><tr><td>11</td><td></td><td><code>B4</code></td><td></td><td></td></tr><tr><td>12</td><td></td><td><code>B5</code></td><td></td><td></td></tr><tr><td>13</td><td></td><td><code>B6</code></td><td></td><td></td></tr></tbody></table><p><sup>* The ATmega328/P possesses two extra ADC channels; however, they are not present on the DIP pinout, and are not shared with GPIO pins. You can use <code>adc_read()</code> directly to gain access to these.</sup></p><h3 id="arm" tabindex="-1">ARM <a class="header-anchor" href="#arm" aria-label="Permalink to &quot;ARM&quot;"></a></h3><h4 id="stm32" tabindex="-1">STM32 <a class="header-anchor" href="#stm32" aria-label="Permalink to &quot;STM32&quot;"></a></h4><p>Note that some of these pins are doubled-up on ADCs with the same
const _hoisted_33 = [
_hoisted_1
];
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
return openBlock(), createElementBlock("div", null, _hoisted_33);
}
const adc = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
export {
__pageData,
adc as default
};