2024-09-24 08:56:37 +00:00
|
|
|
|
import { _ as _export_sfc, c as createElementBlock, o as openBlock, a8 as createStaticVNode } from "./chunks/framework.B9AX-CPi.js";
|
2024-08-31 03:45:17 +00:00
|
|
|
|
const __pageData = JSON.parse('{"title":"Joystick","description":"","frontmatter":{},"headers":[],"relativePath":"features/joystick.md","filePath":"features/joystick.md"}');
|
|
|
|
|
const _sfc_main = { name: "features/joystick.md" };
|
|
|
|
|
const _hoisted_1 = /* @__PURE__ */ createStaticVNode('<h1 id="joystick" tabindex="-1">Joystick <a class="header-anchor" href="#joystick" aria-label="Permalink to "Joystick {#joystick}""></a></h1><p>This feature provides game controller input as a joystick device supporting up to 6 axes and 32 buttons. Axes can be read either from an <a href="./../drivers/adc">ADC-capable input pin</a>, or can be virtual, so that its value is provided by your code.</p><p>An analog device such as a <a href="https://en.wikipedia.org/wiki/Potentiometer" target="_blank" rel="noreferrer">potentiometer</a> found on an analog joystick's axes is based on a voltage divider, where adjusting the movable wiper controls the output voltage which can then be read by the microcontroller's ADC.</p><h2 id="usage" tabindex="-1">Usage <a class="header-anchor" href="#usage" aria-label="Permalink to "Usage {#usage}""></a></h2><p>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;">JOYSTICK_ENABLE = yes</span></span></code></pre></div><p>By default the joystick driver is <code>analog</code>, but you can change this with:</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;">JOYSTICK_DRIVER = digital</span></span></code></pre></div><p>When using <code>analog</code> with ARM, <a href="./../drivers/adc">you must use 3.3v with your Joystick</a>. Although ARM boards such as the <a href="https://keeb.supply/products/0xcb-helios" target="_blank" rel="noreferrer">Helios</a> have 5v pin output, the ADC driver does not support it.</p><h2 id="configuration" tabindex="-1">Configuration <a class="header-anchor" href="#configuration" aria-label="Permalink to "Configuration {#configuration}""></a></h2><p>By default, two axes and eight buttons are defined, with a reported resolution of 8 bits (-127 to +127). This can be changed in 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:#6A737D;--shiki-dark:#6A737D;">// Min 0, max 32</span></span>\n<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">#define</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> JOYSTICK_BUTTON_COUNT</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> 16</span></span>\n<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// Min 0, max 6: X, Y, Z, Rx, Ry, Rz</span></span>\n<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">#define</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> JOYSTICK_AXIS_COUNT</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> 3</span></span>\n<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// Min 8, max 16</span></span>\n<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">#define</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> JOYSTICK_AXIS_RESOLUTION</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> 10</span></span></code></pre></div><div class="tip custom-block"><p class="custom-block-title">TIP</p><p>You must define at least one button or axis. Also note that the maximum ADC resolution of the supported AVR MCUs is 10-bit, and 12-bit for most STM32 MCUs.</p></div><h3 id="axes" tabindex="-1">Axes <a class="header-anchor" href="#axes" aria-label="Permalink to "Axes {#axes}""></a></h3><p>When defining axes for your joys
|
|
|
|
|
const _hoisted_60 = [
|
|
|
|
|
_hoisted_1
|
|
|
|
|
];
|
|
|
|
|
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
|
|
return openBlock(), createElementBlock("div", null, _hoisted_60);
|
|
|
|
|
}
|
|
|
|
|
const joystick = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
|
|
|
|
|
export {
|
|
|
|
|
__pageData,
|
|
|
|
|
joystick as default
|
|
|
|
|
};
|