qmk_firmware/assets/features_encoders.md.Cw1N3hGV.js

16 lines
28 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":"Encoders","description":"","frontmatter":{},"headers":[],"relativePath":"features/encoders.md","filePath":"features/encoders.md"}');
const _sfc_main = { name: "features/encoders.md" };
const _hoisted_1 = /* @__PURE__ */ createStaticVNode('<h1 id="encoders" tabindex="-1">Encoders <a class="header-anchor" href="#encoders" aria-label="Permalink to &quot;Encoders&quot;"></a></h1><p>Basic (EC11 compatible) encoders are supported by adding this 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;">ENCODER_ENABLE = yes</span></span></code></pre></div><p>and this to your <code>config.h</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;">#define</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> ENCODER_A_PINS</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> { B12 }</span></span>\n<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">#define</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> ENCODER_B_PINS</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> { B13 }</span></span></code></pre></div><p>Each PAD_A/B variable defines an array so multiple encoders can be defined, e.g.:</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;">#define</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> ENCODER_A_PINS</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> { encoder1a, encoder2a }</span></span>\n<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">#define</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> ENCODER_B_PINS</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> { encoder1b, encoder2b }</span></span></code></pre></div><p>If your encoder&#39;s clockwise directions are incorrect, you can swap the A &amp; B pad definitions. They can also be flipped with a define:</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;">#define</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> ENCODER_DIRECTION_FLIP</span></span></code></pre></div><p>Additionally, the resolution, which defines how many pulses the encoder registers between each detent, can be defined with:</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;">#define</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> ENCODER_RESOLUTION</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> 4</span></span></code></pre></div><p>It can also be defined per-encoder, by instead defining:</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;">#define</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> ENCODER_RESOLUTIONS</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> { </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">4</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">2</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> }</spa
const _hoisted_49 = [
_hoisted_1
];
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
return openBlock(), createElementBlock("div", null, _hoisted_49);
}
const encoders = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
export {
__pageData,
encoders as default
};