qmk_firmware/assets/features_audio.md.DWNYte3W.js

16 lines
44 KiB
JavaScript
Raw Normal View History

import { _ as _export_sfc, c as createElementBlock, o as openBlock, a8 as createStaticVNode } from "./chunks/framework.DyMmIvSC.js";
const __pageData = JSON.parse('{"title":"Audio","description":"","frontmatter":{},"headers":[],"relativePath":"features/audio.md","filePath":"features/audio.md"}');
const _sfc_main = { name: "features/audio.md" };
const _hoisted_1 = /* @__PURE__ */ createStaticVNode('<h1 id="audio" tabindex="-1">Audio <a class="header-anchor" href="#audio" aria-label="Permalink to &quot;Audio&quot;"></a></h1><p>Your keyboard can make sounds! If you&#39;ve got a spare pin you can hook up a simple speaker and make it beep. You can use those beeps to indicate layer transitions, modifiers, special keys, or just to play some funky 8bit tunes.</p><p>To activate this feature, add <code>AUDIO_ENABLE = yes</code> to your <code>rules.mk</code>.</p><h2 id="avr-based-boards" tabindex="-1">AVR based boards <a class="header-anchor" href="#avr-based-boards" aria-label="Permalink to &quot;AVR based boards&quot;"></a></h2><p>On Atmega32U4 based boards, up to two simultaneous tones can be rendered. With one speaker connected to a PWM capable pin on PORTC driven by timer 3 and the other on one of the PWM pins on PORTB driven by timer 1.</p><p>The following pins can be configured as audio outputs in <code>config.h</code> - for one speaker set either one out of:</p><ul><li><code>#define AUDIO_PIN C4</code></li><li><code>#define AUDIO_PIN C5</code></li><li><code>#define AUDIO_PIN C6</code></li><li><code>#define AUDIO_PIN B5</code></li><li><code>#define AUDIO_PIN B6</code></li><li><code>#define AUDIO_PIN B7</code></li></ul><p>and <em>optionally</em>, for a second speaker, one of:</p><ul><li><code>#define AUDIO_PIN_ALT B5</code></li><li><code>#define AUDIO_PIN_ALT B6</code></li><li><code>#define AUDIO_PIN_ALT B7</code></li></ul><h3 id="wiring" tabindex="-1">Wiring <a class="header-anchor" href="#wiring" aria-label="Permalink to &quot;Wiring&quot;"></a></h3><p>per speaker is - for example with a piezo buzzer - the black lead to Ground, and the red lead connected to the selected AUDIO_PIN for the primary; and similarly with AUDIO_PIN_ALT for the secondary.</p><h2 id="arm-based-boards" tabindex="-1">ARM based boards <a class="header-anchor" href="#arm-based-boards" aria-label="Permalink to &quot;ARM based boards&quot;"></a></h2><p>for more technical details, see the notes on <a href="./../drivers/audio">Audio driver</a>.</p><h3 id="dac-basic" tabindex="-1">DAC (basic) <a class="header-anchor" href="#dac-basic" aria-label="Permalink to &quot;DAC (basic)&quot;"></a></h3><p>Most STM32 MCUs have DAC peripherals, with a notable exception of the STM32F1xx series. Generally, the DAC peripheral drives pins A4 or A5. To enable DAC-based audio output on STM32 devices, add <code>AUDIO_DRIVER = dac_basic</code> to <code>rules.mk</code> and set in <code>config.h</code> either:</p><p><code>#define AUDIO_PIN A4</code> or <code>#define AUDIO_PIN A5</code></p><p>the other DAC channel can optionally be used with a secondary speaker, just set:</p><p><code>#define AUDIO_PIN_ALT A4</code> or <code>#define AUDIO_PIN_ALT A5</code></p><p>Do note though that the dac_basic driver is only capable of reproducing one tone per speaker/channel at a time, for more tones simultaneously, try the dac_additive driver.</p><h4 id="wiring-1" tabindex="-1">Wiring: <a class="header-anchor" href="#wiring-1" aria-label="Permalink to &quot;Wiring:&quot;"></a></h4><p>for two piezos, for example configured as <code>AUDIO_PIN A4</code> and <code>AUDIO_PIN_ALT A5</code> would be: red lead to A4 and black to Ground, and similarly with the second one: A5 = red, and Ground = black</p><p>another alternative is to drive <em>one</em> piezo with both DAC pins - for an extra &quot;push&quot;. wiring red to A4 and black to A5 (or the other way round) and add <code>#define AUDIO_PIN_ALT_AS_NEGATIVE</code> to <code>config.h</code></p><h5 id="proton-c-example" tabindex="-1">Proton-C Example: <a class="header-anchor" href="#proton-c-example" aria-label="Permalink to &quot;Proton-C Example:&quot;"></a></h5><p>The Proton-C comes (optionally) with one &#39;builtin&#39; piezo, which is wired to A4+A5. For this board <code>config.h</code> would include these defines:</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 g
const _hoisted_116 = [
_hoisted_1
];
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
return openBlock(), createElementBlock("div", null, _hoisted_116);
}
const audio = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
export {
__pageData,
audio as default
};