mirror of
https://github.com/qmk/qmk_firmware.git
synced 2025-02-27 01:56:43 +00:00
16 lines
14 KiB
JavaScript
16 lines
14 KiB
JavaScript
|
import { _ as _export_sfc, c as createElementBlock, o as openBlock, a8 as createStaticVNode } from "./chunks/framework.DyMmIvSC.js";
|
|||
|
const __pageData = JSON.parse('{"title":"Custom Matrix","description":"","frontmatter":{},"headers":[],"relativePath":"custom_matrix.md","filePath":"custom_matrix.md"}');
|
|||
|
const _sfc_main = { name: "custom_matrix.md" };
|
|||
|
const _hoisted_1 = /* @__PURE__ */ createStaticVNode('<h1 id="custom-matrix" tabindex="-1">Custom Matrix <a class="header-anchor" href="#custom-matrix" aria-label="Permalink to "Custom Matrix""></a></h1><p>QMK provides a mechanism to supplement or replace the default matrix scanning routine with your own code.</p><p>The reasons to use this feature include:</p><ul><li>Extra hardware between the keyboard's switches and MCU pins <ul><li>I/O multiplexer</li><li>Line decoder</li></ul></li><li>Irregular switch matrix <ul><li>Simultaneous use of <code>COL2ROW</code> and <code>ROW2COL</code></li></ul></li></ul><h2 id="prerequisites" tabindex="-1">Prerequisites <a class="header-anchor" href="#prerequisites" aria-label="Permalink to "Prerequisites""></a></h2><p>Implementing custom matrix usually involves compilation of an additional source file. It is recommended that for consistency, this file is called <code>matrix.c</code>.</p><p>Add a new file to your keyboard directory:</p><div class="language- vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang"></span><pre class="shiki shiki-themes github-light github-dark vp-code"><code><span class="line"><span>keyboards/<keyboard>/matrix.c</span></span></code></pre></div><p>And to configure compilation for the new file, add 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;">SRC += matrix.c</span></span></code></pre></div><h2 id="lite" tabindex="-1">'lite' <a class="header-anchor" href="#lite" aria-label="Permalink to "'lite'""></a></h2><p>Provides a default implementation for various scanning functions, reducing the boilerplate code when implementing custom matrix. To configure it, add 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;">CUSTOM_MATRIX = lite</span></span></code></pre></div><p>And implement the following functions in a <code>matrix.c</code> file in your keyboard folder:</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;">void</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> matrix_init_custom</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;"> // TODO: initialize hardware 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;">bool</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> matrix_scan_custom</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">matrix_row_t</span><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;"> current_matrix</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">[]</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) {</span></span>\n<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> bool</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> matrix_has_changed </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-l
|
|||
|
const _hoisted_23 = [
|
|||
|
_hoisted_1
|
|||
|
];
|
|||
|
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|||
|
return openBlock(), createElementBlock("div", null, _hoisted_23);
|
|||
|
}
|
|||
|
const custom_matrix = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
|
|||
|
export {
|
|||
|
__pageData,
|
|||
|
custom_matrix as default
|
|||
|
};
|