diff options
Diffstat (limited to 'docs')
28 files changed, 832 insertions, 307 deletions
diff --git a/docs/_summary.md b/docs/_summary.md index 5af0046ab3..acbfcfaeda 100644 --- a/docs/_summary.md +++ b/docs/_summary.md @@ -133,11 +133,13 @@ * [Compatible Microcontrollers](compatible_microcontrollers.md) * [Drivers](hardware_drivers.md) * [ADC Driver](adc_driver.md) + * [Audio Driver](audio_driver.md) * [I2C Driver](i2c_driver.md) * [SPI Driver](spi_driver.md) * [WS2812 Driver](ws2812_driver.md) * [EEPROM Driver](eeprom_driver.md) * ['serial' Driver](serial_driver.md) + * [UART Driver](uart_driver.md) * [GPIO Controls](internals_gpio_control.md) * [Keyboard Guidelines](hardware_keyboard_guidelines.md) @@ -159,6 +161,7 @@ * [Contributing to QMK](contributing.md) * [Translating the QMK Docs](translating.md) * [Config Options](config_options.md) + * [Data Driven Configuration](data_driven_config.md) * [Make Documentation](getting_started_make_guide.md) * [Documentation Best Practices](documentation_best_practices.md) * [Documentation Templates](documentation_templates.md) diff --git a/docs/audio_driver.md b/docs/audio_driver.md new file mode 100644 index 0000000000..7cd5a98d9f --- /dev/null +++ b/docs/audio_driver.md @@ -0,0 +1,221 @@ +# Audio Driver :id=audio-driver + +The [Audio feature](feature_audio.md) breaks the hardware specifics out into separate, exchangeable driver units, with a common interface to the audio-"core" - which itself handles playing songs and notes while tracking their progress in an internal state, initializing/starting/stopping the driver as needed. + +Not all MCUs support every available driver, either the platform-support is not there (yet?) or the MCU simply does not have the required hardware peripheral. + + +## AVR :id=avr + +Boards built around an Atmega32U4 can use two sets of PWM capable pins, each driving a separate speaker. +The possible configurations are: + +| | Timer3 | Timer1 | +|--------------|-------------|--------------| +| one speaker | C4,C5 or C6 | | +| one speaker | | B4, B5 or B7 | +| two speakers | C4,C5 or C6 | B4, B5 or B7 | + +Currently there is only one/default driver for AVR based boards, which is automatically configured to: + +```make +AUDIO_DRIVER = pwm_hardware +``` + + +## ARM :id=arm + +For Arm based boards, QMK depends on ChibiOS - hence any MCU supported by the later is likely usable, as long as certain hardware peripherals are available. + +Supported wiring configurations, with their ChibiOS/MCU peripheral requirement are listed below; +piezo speakers are marked with :one: for the first/primary and :two: for the secondary. + + | driver | GPTD6<br>Tim6 | GPTD7<br>Tim7 | GPTD8<br>Tim8 | PWMD1<sup>1</sup><br>Tim1_Ch1 | + |--------------|------------------------------------------|------------------------|---------------|-------------------------------| + | dac_basic | A4+DACD1 = :one: | A5+DACD2 = :one: | state | | + | | A4+DACD1 = :one: + Gnd | A5+DACD2 = :two: + Gnd | state | | + | | A4+DACD1 = :two: + Gnd | A5+DACD2 = :one: + Gnd | state | | + | | A4+DACD1 = :one: + Gnd | | state | | + | | | A5+DACD2 = :one: + Gnd | state | | + | dac_additive | A4+DACD1 = :one: + Gnd | | | | + | | A5+DACD2 = :one: + Gnd | | | | + | | A4+DACD1 + A5+DACD2 = :one: <sup>2</sup> | | | | + | pwm_software | state-update | | | any = :one: | + | pwm hardware | state-update | | | A8 = :one: <sup>3</sup> | + + +<sup>1</sup>: the routing and alternate functions for PWM differ sometimes between STM32 MCUs, if in doubt consult the data-sheet +<sup>2</sup>: one piezo connected to A4 and A5, with AUDIO_PIN_ALT_AS_NEGATIVE set +<sup>3</sup>: TIM1_CH1 = A8 on STM32F103C8, other combinations are possible, see Data-sheet. configured with: AUDIO_PWM_DRIVER and AUDIO_PWM_CHANNEL + + + +### DAC basic :id=dac-basic + +The default driver for ARM boards, in absence of an overriding configuration. +This driver needs one Timer per enabled/used DAC channel, to trigger conversion; and a third timer to trigger state updates with the audio-core. + +Additionally, in the board config, you'll want to make changes to enable the DACs, GPT for Timers 6, 7 and 8: + +``` c +//halconf.h: +#define HAL_USE_DAC TRUE +#define HAL_USE_GPT TRUE +#include_next <halconf.h> +``` + +``` c +// mcuconf.h: +#include_next <mcuconf.h> +#undef STM32_DAC_USE_DAC1_CH1 +#define STM32_DAC_USE_DAC1_CH1 TRUE +#undef STM32_DAC_USE_DAC1_CH2 +#define STM32_DAC_USE_DAC1_CH2 TRUE +#undef STM32_GPT_USE_TIM6 +#define STM32_GPT_USE_TIM6 TRUE +#undef STM32_GPT_USE_TIM7 +#define STM32_GPT_USE_TIM7 TRUE +#undef STM32_GPT_USE_TIM8 +#define STM32_GPT_USE_TIM8 TRUE +``` + +?> Note: DAC1 (A4) uses TIM6, DAC2 (A5) uses TIM7, and the audio state timer uses TIM8 (configurable). + +You can also change the timer used for the overall audio state by defining the driver. For instance: + +```c +#define AUDIO_STATE_TIMER GPTD9 +``` + +### DAC additive :id=dac-additive + +only needs one timer (GPTD6, Tim6) to trigger the DAC unit to do a conversion; the audio state updates are in turn triggered during the DAC callback. + +Additionally, in the board config, you'll want to make changes to enable the DACs, GPT for Timer 6: + +``` c +//halconf.h: +#define HAL_USE_DAC TRUE +#define HAL_USE_GPT TRUE +#include_next <halconf.h> +``` + +``` c +// mcuconf.h: +#include_next <mcuconf.h> +#undef STM32_DAC_USE_DAC1_CH1 +#define STM32_DAC_USE_DAC1_CH1 TRUE +#undef STM32_DAC_USE_DAC1_CH2 +#define STM32_DAC_USE_DAC1_CH2 TRUE +#undef STM32_GPT_USE_TIM6 +#define STM32_GPT_USE_TIM6 TRUE +``` + +### DAC Config + +| Define | Defaults | Description --------------------------------------------------------------------------------------------- | +| `AUDIO_DAC_SAMPLE_MAX` | `4095U` | Highest value allowed. Lower value means lower volume. And 4095U is the upper limit, since this is limited to a 12 bit value. Only effects non-pregenerated samples. | +| `AUDIO_DAC_OFF_VALUE` | `AUDIO_DAC_SAMPLE_MAX / 2` | The value of the DAC when notplaying anything. Some setups may require a high (`AUDIO_DAC_SAMPLE_MAX`) or low (`0`) value here. | +| `AUDIO_MAX_SIMULTANEOUS_TONES` | __see next table__ | The number of tones that can be played simultaneously. A value that is too high may freeze the controller or glitch out when too many tones are being played. | +| `AUDIO_DAC_SAMPLE_RATE` | __see next table__ | Effective bit rate of the DAC (in hertz), higher limits simultaneous tones, and lower sacrifices quality. | + +There are a number of predefined quality settings that you can use, with "sane minimum" being the default. You can use custom values by simply defining the sample rate and number of simultaneous tones, instead of using one of the listed presets. + +| Define | Sample Rate | Simultaneous tones | +| `AUDIO_DAC_QUALITY_VERY_LOW` | `11025U` | `8` | +| `AUDIO_DAC_QUALITY_LOW` | `22040U` | `4` | +| `AUDIO_DAC_QUALITY_HIGH` | `44100U` | `2` | +| `AUDIO_DAC_QUALITY_VERY_HIGH` | `88200U` | `1` | +| `AUDIO_DAC_QUALITY_SANE_MINIMUM` | `16384U` | `8` | + + +```c + /* zero crossing (or approach, whereas zero == DAC_OFF_VALUE, which can be configured to anything from 0 to DAC_SAMPLE_MAX) + * ============================*=*========================== AUDIO_DAC_SAMPLE_MAX + * * * + * * * + * --------------------------------------------------------- + * * * } AUDIO_DAC_SAMPLE_MAX/100 + * --------------------------------------------------------- AUDIO_DAC_OFF_VALUE + * * * } AUDIO_DAC_SAMPLE_MAX/100 + * --------------------------------------------------------- + * * + * * * + * * * + * =====*=*================================================= 0x0 + */ +``` + + +### PWM hardware :id=pwm-hardware + +This driver uses the ChibiOS-PWM system to produce a square-wave on specific output pins that are connected to the PWM hardware. +The hardware directly toggles the pin via its alternate function. See your MCU's data-sheet for which pin can be driven by what timer - looking for TIMx_CHy and the corresponding alternate function. + +A configuration example for the STM32F103C8 would be: +``` c +//halconf.h: +#define HAL_USE_PWM TRUE +#define HAL_USE_PAL TRUE +#define HAL_USE_GPT TRUE +#include_next <halconf.h> +``` + +``` c +// mcuconf.h: +#include_next <mcuconf.h> +#undef STM32_PWM_USE_TIM1 +#define STM32_PWM_USE_TIM1 TRUE +#undef STM32_GPT_USE_TIM4 +#define STM32_GPT_USE_TIM4 TRUE +``` + +If we now target pin A8, looking through the data-sheet of the STM32F103C8, for the timers and alternate functions +- TIM1_CH1 = PA8 <- alternate0 +- TIM1_CH2 = PA9 +- TIM1_CH3 = PA10 +- TIM1_CH4 = PA11 + +with all this information, the configuration would contain these lines: +``` c +//config.h: +#define AUDIO_PIN A8 +#define AUDIO_PWM_DRIVER PWMD1 +#define AUDIO_PWM_CHANNEL 1 +#define AUDIO_STATE_TIMER GPTD4 +``` + +ChibiOS uses GPIOv1 for the F103, which only knows of one alternate function. +On 'larger' STM32s, GPIOv2 or GPIOv3 are used; with them it is also necessary to configure `AUDIO_PWM_PAL_MODE` to the correct alternate function for the selected pin, timer and timer-channel. + + +### PWM software :id=pwm-software + +This driver uses the PWM callbacks from PWMD1 with TIM1_CH1 to toggle the selected AUDIO_PIN in software. +During the same callback, with AUDIO_PIN_ALT_AS_NEGATIVE set, the AUDIO_PIN_ALT is toggled inversely to AUDIO_PIN. This is useful for setups that drive a piezo from two pins (instead of one and Gnd). + +You can also change the timer used for software PWM by defining the driver. For instance: + +```c +#define AUDIO_STATE_TIMER GPTD8 +``` + + +### Testing Notes :id=testing-notes + +While not an exhaustive list, the following table provides the scenarios that have been partially validated: + +| | DAC basic | DAC additive | PWM hardware | PWM software | +|--------------------------|--------------------|--------------------|--------------------|--------------------| +| Atmega32U4 | :o: | :o: | :heavy_check_mark: | :o: | +| STM32F103C8 (bluepill) | :x: | :x: | :heavy_check_mark: | :heavy_check_mark: | +| STM32F303CCT6 (proton-c) | :heavy_check_mark: | :heavy_check_mark: | ? | :heavy_check_mark: | +| STM32F405VG | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | +| L0xx | :x: (no Tim8) | ? | ? | ? | + + +:heavy_check_mark: : works and was tested +:o: : does not apply +:x: : not supported by MCU + +*Other supported ChibiOS boards and/or pins may function, it will be highly chip and configuration dependent.* diff --git a/docs/compatible_microcontrollers.md b/docs/compatible_microcontrollers.md index 1bf7072246..47a4844e7f 100644 --- a/docs/compatible_microcontrollers.md +++ b/docs/compatible_microcontrollers.md @@ -9,6 +9,7 @@ The following use [LUFA](https://www.fourwalledcubicle.com/LUFA.php) as the USB * [ATmega16U2](https://www.microchip.com/wwwproducts/en/ATmega16U2) / [ATmega32U2](https://www.microchip.com/wwwproducts/en/ATmega32U2) * [ATmega16U4](https://www.microchip.com/wwwproducts/en/ATmega16U4) / [ATmega32U4](https://www.microchip.com/wwwproducts/en/ATmega32U4) * [AT90USB64](https://www.microchip.com/wwwproducts/en/AT90USB646) / [AT90USB128](https://www.microchip.com/wwwproducts/en/AT90USB1286) +* [AT90USB162](https://www.microchip.com/wwwproducts/en/AT90USB162) Certain MCUs which do not have native USB will use [V-USB](https://www.obdev.at/products/vusb/index.html) instead: @@ -25,6 +26,10 @@ You can also use any ARM chip with USB that [ChibiOS](https://www.chibios.org) s * [STM32F0x2](https://www.st.com/en/microcontrollers-microprocessors/stm32f0x2.html) * [STM32F103](https://www.st.com/en/microcontrollers-microprocessors/stm32f103.html) * [STM32F303](https://www.st.com/en/microcontrollers-microprocessors/stm32f303.html) + * [STM32F401](https://www.st.com/en/microcontrollers-microprocessors/stm32f401.html) + * [STM32F411](https://www.st.com/en/microcontrollers-microprocessors/stm32f411.html) + * [STM32G431](https://www.st.com/en/microcontrollers-microprocessors/stm32g4x1.html) + * [STM32G474](https://www.st.com/en/microcontrollers-microprocessors/stm32g4x4.html) ### NXP (Kinetis) diff --git a/docs/config_options.md b/docs/config_options.md index a3262b418b..aeaaf47aaf 100644 --- a/docs/config_options.md +++ b/docs/config_options.md @@ -67,16 +67,22 @@ This is a C header file that is one of the first things included, and will persi * turns on the alternate audio voices (to cycle through) * `#define C4_AUDIO` * enables audio on pin C4 + * Deprecated. Use `#define AUDIO_PIN C4` * `#define C5_AUDIO` * enables audio on pin C5 + * Deprecated. Use `#define AUDIO_PIN C5` * `#define C6_AUDIO` * enables audio on pin C6 + * Deprecated. Use `#define AUDIO_PIN C6` * `#define B5_AUDIO` - * enables audio on pin B5 (duophony is enables if one of B[5-7]\_AUDIO is enabled along with one of C[4-6]\_AUDIO) + * enables audio on pin B5 (duophony is enabled if one of B pins is enabled along with one of C pins) + * Deprecated. Use `#define AUDIO_PIN B5`, or use `#define AUDIO_PIN_ALT B5` if a `C` pin is enabled with `AUDIO_PIN` * `#define B6_AUDIO` - * enables audio on pin B6 (duophony is enables if one of B[5-7]\_AUDIO is enabled along with one of C[4-6]\_AUDIO) + * enables audio on pin B5 (duophony is enabled if one of B pins is enabled along with one of C pins) + * Deprecated. Use `#define AUDIO_PIN B6`, or use `#define AUDIO_PIN_ALT B6` if a `C` pin is enabled with `AUDIO_PIN` * `#define B7_AUDIO` - * enables audio on pin B7 (duophony is enables if one of B[5-7]\_AUDIO is enabled along with one of C[4-6]\_AUDIO) + * enables audio on pin B5 (duophony is enabled if one of B pins is enabled along with one of C pins) + * Deprecated. Use `#define AUDIO_PIN B7`, or use `#define AUDIO_PIN_ALT B7` if a `C` pin is enabled with `AUDIO_PIN` * `#define BACKLIGHT_PIN B7` * pin of the backlight * `#define BACKLIGHT_LEVELS 3` @@ -97,6 +103,8 @@ This is a C header file that is one of the first things included, and will persi * sets the maximum power (in mA) over USB for the device (default: 500) * `#define USB_POLLING_INTERVAL_MS 10` * sets the USB polling rate in milliseconds for the keyboard, mouse, and shared (NKRO/media keys) interfaces +* `#define USB_SUSPEND_WAKEUP_DELAY 200` + * set the number of milliseconde to pause after sending a wakeup packet * `#define F_SCL 100000L` * sets the I2C clock rate speed for keyboards using I2C. The default is `400000L`, except for keyboards using `split_common`, where the default is `100000L`. diff --git a/docs/data_driven_config.md b/docs/data_driven_config.md new file mode 100644 index 0000000000..c2ad4fed8f --- /dev/null +++ b/docs/data_driven_config.md @@ -0,0 +1,91 @@ +# Data Driven Configuration + +This page describes how QMK's data driven JSON configuration system works. It is aimed at developers who want to work on QMK itself. + +## History + +Historically QMK has been configured through a combination of two mechanisms- `rules.mk` and `config.h`. While this worked well when QMK was only a handful of keyboards we've grown to encompass nearly 1500 supported keyboards. That extrapolates out to 6000 configuration files under `keyboards/` alone! The freeform nature of these files and the unique patterns people have used to avoid duplication have made ongoing maintenance a challenge, and a large number of our keyboards follow patterns that are outdated and sometimes harder to understand. + +We have also been working on bringing the power of QMK to people who aren't comformable with a CLI, and other projects such as VIA are working to make using QMK as easy as installing a program. These tools need information about how a keyboard is laid out or what pins and features are available so that users can take full advantage of QMK. We introduced `info.json` as a first step towards this. The QMK API is an effort to combine these 3 sources of information- `config.h`, `rules.mk`, and `info.json`- into a single source of truth that end-user tools can use. + +Now we have support for generating `rules.mk` and `config.h` values from `info.json`, allowing us to have a single source of truth. This will allow us to use automated tooling to maintain keyboards saving a lot of time and maintenance work. + +## Overview + +On the C side of things nothing changes. When you need to create a new rule or define you follow the same process: + +1. Add it to `docs/config_options.md` +1. Set a default in the appropriate core file +1. Add your ifdef statements as needed + +You will then need to add support for your new configuration to `info.json`. The basic process is: + +1. Add it to the schema in `data/schemas/keyboards.jsonschema` +1. Add a mapping in `data/maps` +1. (optional and discoraged) Add code to extract/generate it to: + * `lib/python/qmk/info.py` + * `lib/python/qmk/cli/generate/config_h.py` + * `lib/python/qmk/cli/generate/rules_mk.py` + +## Adding an option to info.json + +This section describes adding support for a `config.h`/`rules.mk` value to info.json. + +### Add it to the schema + +QMK maintains [jsonschema](https://json-schema.org/) files in `data/schemas`. The values that go into keyboard-specific `info.json` files are kept in `keyboard.jsonschema`. Any value you want to make available to end users to edit must go in here. + +In some cases you can simply add a new top-level key. Some examples to follow are `keyboard_name`, `maintainer`, `processor`, and `url`. This is appropriate when your option is self-contained and not directly related to other options. + +In other cases you should group like options together in an `object`. This is particularly true when adding support for a feature. Some examples to follow for this are `indicators`, `matrix_pins`, and `rgblight`. If you are not sure how to integrate your new option(s) [open an issue](https://github.com/qmk/qmk_firmware/issues/new?assignees=&labels=cli%2C+python&template=other_issues.md&title=) or [join #cli on Discord](https://discord.gg/heQPAgy) and start a conversation there. + +### Add a mapping + +In most cases you can add a simple mapping. These are maintained as JSON files in `data/mappings/info_config.json` and `data/mappings/info_rules.json`, and control mapping for `config.h` and `rules.mk`, respectively. Each mapping is keyed by the `config.h` or `rules.mk` variable, and the value is a hash with the following keys: + +* `info_key`: (required) The location within `info.json` for this value. See below. +* `value_type`: (optional) Default `str`. The format for this variable's value. See below. +* `to_json`: (optional) Default `true`. Set to `false` to exclude this mapping from info.json +* `to_c`: (optional) Default `true`. Set to `false` to exclude this mapping from config.h +* `warn_duplicate`: (optional) Default `true`. Set to `false` to turn off warning when a value exists in both places + +#### Info Key + +We use JSON dot notation to address variables within info.json. For example, to access `info_json["rgblight"]["split_count"]` I would specify `rgblight.split_count`. This allows you to address deeply nested keys with a simple string. + +Under the hood we use [Dotty Dict](https://dotty-dict.readthedocs.io/en/latest/), you can refer to that documentation for how these strings are converted to object access. + +#### Value Types + +By default we treat all values as simple strings. If your value is more complex you can use one of these types to intelligently parse the data: + +* `array`: A comma separated array of strings +* `array.int`: A comma separated array of integers +* `int`: An integer +* `hex`: A number formatted as hex +* `list`: A space separate array of strings +* `mapping`: A hash of key/value pairs + +### Add code to extract it + +Most use cases can be solved by the mapping files described above. If yours can't you can instead write code to extract your config values. + +Whenever QMK generates a complete `info.json` it extracts information from `config.h` and `rules.mk`. You will need to add code for your new config value to `lib/python/qmk/info.py`. Typically this means adding a new `_extract_<feature>()` function and then calling your function in either `_extract_config_h()` or `_extract_rules_mk()`. + +If you are not sure how to edit this file or are not comfortable with Python [open an issue](https://github.com/qmk/qmk_firmware/issues/new?assignees=&labels=cli%2C+python&template=other_issues.md&title=) or [join #cli on Discord](https://discord.gg/heQPAgy) and someone can help you with this part. + +### Add code to generate it + +The final piece of the puzzle is providing your new option to the build system. This is done by generating two files: + +* `.build/obj_<keyboard>/src/info_config.h` +* `.build/obj_<keyboard>/src/rules.mk` + +These two files are generated by the code here: + +* `lib/python/qmk/cli/generate/config_h.py` +* `lib/python/qmk/cli/generate/rules_mk.py` + +For `config.h` values you'll need to write a function for your rule(s) and call that function in `generate_config_h()`. + +If you have a new top-level `info.json` key for `rules.mk` you can simply add your keys to `info_to_rules` at the top of `lib/python/qmk/cli/generate/rules_mk.py`. Otherwise you'll need to create a new if block for your feature in `generate_rules_mk()`. diff --git a/docs/feature_audio.md b/docs/feature_audio.md index 5132dfe971..9e7ba75f52 100644 --- a/docs/feature_audio.md +++ b/docs/feature_audio.md @@ -1,21 +1,117 @@ # Audio -Your keyboard can make sounds! If you've got a Planck, Preonic, or basically any AVR keyboard that allows access to certain PWM-capable pins, 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. +Your keyboard can make sounds! If you'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. -Up to two simultaneous audio voices are supported, one driven by timer 1 and another driven by timer 3. The following pins can be defined as audio outputs in config.h: +To activate this feature, add `AUDIO_ENABLE = yes` to your `rules.mk`. -Timer 1: -`#define B5_AUDIO` -`#define B6_AUDIO` -`#define B7_AUDIO` +## AVR based boards +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. -Timer 3: -`#define C4_AUDIO` -`#define C5_AUDIO` -`#define C6_AUDIO` +The following pins can be configured as audio outputs in `config.h` - for one speaker set eiter one out of: -If you add `AUDIO_ENABLE = yes` to your `rules.mk`, there's a couple different sounds that will automatically be enabled without any other configuration: +* `#define AUDIO_PIN C4` +* `#define AUDIO_PIN C5` +* `#define AUDIO_PIN C6` +* `#define AUDIO_PIN B5` +* `#define AUDIO_PIN B6` +* `#define AUDIO_PIN B7` +and *optionally*, for a second speaker, one of: +* `#define AUDIO_PIN_ALT B5` +* `#define AUDIO_PIN_ALT B6` +* `#define AUDIO_PIN_ALT B7` + +### Wiring +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. + + +## ARM based boards +for more technical details, see the notes on [Audio driver](audio_driver.md). + +<!-- because I'm not sure where to fit this in: https://waveeditonline.com/ --> +### DAC (basic) +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 `AUDIO_DRIVER = dac_basic` to `rules.mk` and set in `config.h` either: + +`#define AUDIO_PIN A4` or `#define AUDIO_PIN A5` + +the other DAC channel can optionally be used with a secondary speaker, just set: + +`#define AUDIO_PIN_ALT A4` or `#define AUDIO_PIN_ALT A5` + +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. + +#### Wiring: +for two piezos, for example configured as `AUDIO_PIN A4` and `AUDIO_PIN_ALT A5` would be: red lead to A4 and black to Ground, and similarly with the second one: A5 = red, and Ground = black + +another alternative is to drive *one* piezo with both DAC pins - for an extra "push". +wiring red to A4 and black to A5 (or the other way round) and add `#define AUDIO_PIN_ALT_AS_NEGATIVE` to `config.h` + +##### Proton-C Example: +The Proton-C comes (optionally) with one 'builtin' piezo, which is wired to A4+A5. +For this board `config.h` would include these defines: + +```c +#define AUDIO_PIN A5 +#define AUDIO_PIN_ALT A4 +#define AUDIO_PIN_ALT_AS_NEGATIVE +``` + +### DAC (additive) +Another option, besides dac_basic (which produces sound through a square-wave), is to use the DAC to do additive wave synthesis. +With a number of predefined wave-forms or by providing your own implementation to generate samples on the fly. +To use this feature set `AUDIO_DRIVER = dac_additive` in your `rules.mk`, and select in `config.h` EITHER `#define AUDIO_PIN A4` or `#define AUDIO_PIN A5`. + +The used waveform *defaults* to sine, but others can be selected by adding one of the following defines to `config.h`: + +* `#define AUDIO_DAC_SAMPLE_WAVEFORM_SINE` +* `#define AUDIO_DAC_SAMPLE_WAVEFORM_TRIANGLE` +* `#define AUDIO_DAC_SAMPLE_WAVEFORM_TRAPEZOID` +* `#define AUDIO_DAC_SAMPLE_WAVEFORM_SQUARE` + +Should you rather choose to generate and use your own sample-table with the DAC unit, implement `uint16_t dac_value_generate(void)` with your keyboard - for an example implementation see keyboards/planck/keymaps/synth_sample or keyboards/planck/keymaps/synth_wavetable + + +### PWM (software) +if the DAC pins are unavailable (or the MCU has no usable DAC at all, like STM32F1xx); PWM can be an alternative. +Note that there is currently only one speaker/pin supported. + +set in `rules.mk`: + +`AUDIO_DRIVER = pwm_software` and in `config.h`: +`#define AUDIO_PIN C13` (can be any pin) to have the selected pin output a pwm signal, generated from a timer callback which toggles the pin in software. + +#### Wiring +the usual piezo wiring: red goes to the selected AUDIO_PIN, black goes to ground. + +OR if you can chose to drive one piezo with two pins, for example `#define AUDIO_PIN B1`, `#define AUDIO_PIN_ALT B2` in `config.h`, with `#define AUDIO_PIN_ALT_AS_NEGATIVE` - then the red lead could go to B1, the black to B2. + +### PWM (hardware) +STM32F1xx have to fall back to using PWM, but can do so in hardware; but again on currently only one speaker/pin. + +`AUDIO_DRIVER = pwm_hardware` in `rules.mk`, and in `config.h`: +`#define AUDIO_PIN A8` +`#define AUDIO_PWM_DRIVER PWMD1` +`#define AUDIO_PWM_CHANNEL 1` +(as well as `#define AUDIO_PWM_PAL_MODE 42` if you are on STM32F2 or larger) +which will use Timer 1 to directly drive pin PA8 through the PWM hardware (TIM1_CH1 = PA8). +Should you want to use the pwm-hardware on another pin and timer - be ready to dig into the STM32 data-sheet to pick the right TIMx_CHy and pin-alternate function. + + +## Tone Multiplexing +Since most drivers can only render one tone per speaker at a time (with the one exception: arm dac-additive) there also exists a "workaround-feature" that does time-slicing/multiplexing - which does what the name implies: cycle through a set of active tones (e.g. when playing chords in Music Mode) at a given rate, and put one tone at a time out through the one/few speakers that are available. + +To enable this feature, and configure a starting-rate, add the following defines to `config.h`: +```c +#define AUDIO_ENABLE_TONE_MULTIPLEXING +#define AUDIO_TONE_MULTIPLEXING_RATE_DEFAULT 10 +``` + +The audio core offers interface functions to get/set/change the tone multiplexing rate from within `keymap.c`. + + +## Songs +There's a couple of different sounds that will automatically be enabled without any other configuration: ``` STARTUP_SONG // plays when the keyboard starts up (audio.c) GOODBYE_SONG // plays when you press the RESET key (quantum.c) @@ -67,15 +163,34 @@ The available keycodes for audio are: * `AU_OFF` - Turn Audio Feature off * `AU_TOG` - Toggle Audio Feature state -!> These keycodes turn all of the audio functionality on and off. Turning it off means that audio feedback, audio clicky, music mode, etc. are disabled, completely. +!> These keycodes turn all of the audio functionality on and off. Turning it off means that audio feedback, audio clicky, music mode, etc. are disabled, completely. + +## Tempo +the 'speed' at which SONGs are played is dictated by the set Tempo, which is measured in beats-per-minute. Note lenghts are defined relative to that. +The initial/default tempo is set to 120 bpm, but can be configured by setting `TEMPO_DEFAULT` in `config.c`. +There is also a set of functions to modify the tempo from within the user/keymap code: +```c +void audio_set_tempo(uint8_t tempo); +void audio_increase_tempo(uint8_t tempo_change); +void audio_decrease_tempo(uint8_t tempo_change); +``` ## ARM Audio Volume -For ARM devices, you can adjust the DAC sample values. If your board is too loud for you or your coworkers, you can set the max using `DAC_SAMPLE_MAX` in your `config.h`: +For ARM devices, you can adjust the DAC sample values. If your board is too loud for you or your coworkers, you can set the max using `AUDIO_DAC_SAMPLE_MAX` in your `config.h`: ```c -#define DAC_SAMPLE_MAX 65535U +#define AUDIO_DAC_SAMPLE_MAX 4095U ``` +the DAC usually runs in 12Bit mode, hence a volume of 100% = 4095U + +Note: this only adjusts the volume aka 'works' if you stick to WAVEFORM_SQUARE, since its samples are generated on the fly - any other waveform uses a hardcoded/precomputed sample-buffer. + +## Voices +Aka "audio effects", different ones can be enabled by setting in `config.h` these defines: +`#define AUDIO_VOICES` to enable the feature, and `#define AUDIO_VOICE_DEFAULT something` to select a specific effect +for details see quantum/audio/voices.h and .c + ## Music Mode @@ -215,12 +330,6 @@ This is still a WIP, but check out `quantum/process_keycode/process_midi.c` to s AU_OFF, AU_TOG, - #ifdef FAUXCLICKY_ENABLE - FC_ON, - FC_OFF, - FC_TOG, - #endif - // Music mode on/off/toggle MU_ON, MU_OFF, diff --git a/docs/feature_backlight.md b/docs/feature_backlight.md index a558af64e1..2adb16e4a8 100644 --- a/docs/feature_backlight.md +++ b/docs/feature_backlight.md @@ -93,18 +93,18 @@ BACKLIGHT_DRIVER = pwm On AVR boards, QMK automatically decides which driver to use according to the following table: -|Backlight Pin|AT90USB64/128|ATmega16/32U4|ATmega16/32U2|ATmega32A|ATmega328/P| -|-------------|-------------|-------------|-------------|---------|-----------| -|`B1` | | | | |Timer 1 | -|`B2` | | | | |Timer 1 | -|`B5` |Timer 1 |Timer 1 | | | | -|`B6` |Timer 1 |Timer 1 | | | | -|`B7` |Timer 1 |Timer 1 |Timer 1 | | | -|`C4` |Timer 3 | | | | | -|`C5` |Timer 3 | |Timer 1 | | | -|`C6` |Timer 3 |Timer 3 |Timer 1 | | | -|`D4` | | | |Timer 1 | | -|`D5` | | | |Timer 1 | | +|Backlight Pin|AT90USB64/128|AT90USB162|ATmega16/32U4|ATmega16/32U2|ATmega32A|ATmega328/P| +|-------------|-------------|----------|-------------|-------------|---------|-----------| +|`B1` | | | | | |Timer 1 | +|`B2` | | | | | |Timer 1 | +|`B5` |Timer 1 | |Timer 1 | | | | +|`B6` |Timer 1 | |Timer 1 | | | | +|`B7` |Timer 1 |Timer 1 |Timer 1 |Timer 1 | | | +|`C4` |Timer 3 | | | | | | +|`C5` |Timer 3 |Timer 1 | |Timer 1 | | | +|`C6` |Timer 3 |Timer 1 |Timer 3 |Timer 1 | | | +|`D4` | | | | |Timer 1 | | +|`D5` | | | | |Timer 1 | | All other pins will use timer-assisted software PWM: diff --git a/docs/feature_macros.md b/docs/feature_macros.md index 36fa761d21..6e69ad642c 100644 --- a/docs/feature_macros.md +++ b/docs/feature_macros.md @@ -4,7 +4,7 @@ Macros allow you to send multiple keystrokes when pressing just one key. QMK has !> **Security Note**: While it is possible to use macros to send passwords, credit card numbers, and other sensitive information it is a supremely bad idea to do so. Anyone who gets a hold of your keyboard will be able to access that information by opening a text editor. -## The New Way: `SEND_STRING()` & `process_record_user` +## `SEND_STRING()` & `process_record_user` Sometimes you want a key to type out words or phrases. For the most common situations, we've provided `SEND_STRING()`, which will type out a string (i.e. a sequence of characters) for you. All ASCII characters that are easily translatable to a keycode are supported (e.g. `qmk 123\n\t`). @@ -233,9 +233,15 @@ Parallel to `register_code` function, this sends the `<kc>` keyup event to the c ### `tap_code(<kc>);` -This will send `register_code(<kc>)` and then `unregister_code(<kc>)`. This is useful if you want to send both the press and release events ("tap" the key, rather than hold it). +Sends `register_code(<kc>)` and then `unregister_code(<kc>)`. This is useful if you want to send both the press and release events ("tap" the key, rather than hold it). -If you're having issues with taps (un)registering, you can add a delay between the register and unregister events by setting `#define TAP_CODE_DELAY 100` in your `config.h` file. The value is in milliseconds. +If `TAP_CODE_DELAY` is defined (default 0), this function waits that many milliseconds before calling `unregister_code(<kc>)`. This can be useful when you are having issues with taps (un)registering. + +If the keycode is `KC_CAPS`, it waits `TAP_HOLD_CAPS_DELAY` milliseconds instead (default 80), as macOS prevents accidental Caps Lock activation by waiting for the key to be held for a certain amount of time. + +### `tap_code_delay(<kc>, <delay>);` + +Like `tap_code(<kc>)`, but with a `delay` parameter for specifying arbitrary intervals before sending the unregister event. ### `register_code16(<kc>);`, `unregister_code16(<kc>);` and `tap_code16(<kc>);` @@ -262,15 +268,15 @@ This will clear all keys besides the mods currently pressed. This macro will register `KC_LALT` and tap `KC_TAB`, then wait for 1000ms. If the key is tapped again, it will send another `KC_TAB`; if there is no tap, `KC_LALT` will be unregistered, thus allowing you to cycle through windows. ```c -bool is_alt_tab_active = false; # ADD this near the begining of keymap.c -uint16_t alt_tab_timer = 0; # we will be using them soon. +bool is_alt_tab_active = false; // ADD this near the begining of keymap.c +uint16_t alt_tab_timer = 0; // we will be using them soon. -enum custom_keycodes { # Make sure have the awesome keycode ready +enum custom_keycodes { // Make sure have the awesome keycode ready ALT_TAB = SAFE_RANGE, }; bool process_record_user(uint16_t keycode, keyrecord_t *record) { - switch (keycode) { # This will do most of the grunt work with the keycodes. + switch (keycode) { // This will do most of the grunt work with the keycodes. case ALT_TAB: if (record->event.pressed) { if (!is_alt_tab_active) { @@ -287,7 +293,7 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) { return true; } -void matrix_scan_user(void) { # The very important timer. +void matrix_scan_user(void) { // The very important timer. if (is_alt_tab_active) { if (timer_elapsed(alt_tab_timer) > 1000) { unregister_code(KC_LALT); @@ -296,104 +302,3 @@ void matrix_scan_user(void) { # The very important timer. } } ``` - ---- - -## **(DEPRECATED)** The Old Way: `MACRO()` & `action_get_macro` - -!> This is inherited from TMK, and hasn't been updated - it's recommended that you use `SEND_STRING` and `process_record_user` instead. - -By default QMK assumes you don't have any macros. To define your macros you create an `action_get_macro()` function. For example: - -```c -const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) { - if (record->event.pressed) { - switch(id) { - case 0: - return MACRO(D(LSFT), T(H), U(LSFT), T(I), D(LSFT), T(1), U(LSFT), END); - case 1: - return MACRO(D(LSFT), T(B), U(LSFT), T(Y), T(E), D(LSFT), T(1), U(LSFT), END); - } - } - return MACRO_NONE; -}; -``` - -This defines two macros which will be run when the key they are assigned to is pressed. If instead you'd like them to run when the key is released you can change the if statement: - - if (!record->event.pressed) { - -### Macro Commands - -A macro can include the following commands: - -* I() change interval of stroke in milliseconds. -* D() press key. -* U() release key. -* T() type key(press and release). -* W() wait (milliseconds). -* END end mark. - -### Mapping a Macro to a Key - -Use the `M()` function within your keymap to call a macro. For example, here is the keymap for a 2-key keyboard: - -```c -const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { - [0] = LAYOUT( - M(0), M(1) - ), -}; - -const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) { - if (record->event.pressed) { - switch(id) { - case 0: - return MACRO(D(LSFT), T(H), U(LSFT), T(I), D(LSFT), T(1), U(LSFT), END); - case 1: - return MACRO(D(LSFT), T(B), U(LSFT), T(Y), T(E), D(LSFT), T(1), U(LSFT), END); - } - } - return MACRO_NONE; -}; -``` - -When you press the key on the left it will type "Hi!" and when you press the key on the right it will type "Bye!". - -### Naming Your Macros - -If you have a bunch of macros you want to refer to from your keymap while keeping the keymap easily readable you can name them using `#define` at the top of your file. - -```c -#define M_HI M(0) -#define M_BYE M(1) - -const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { - [0] = LAYOUT( - M_HI, M_BYE - ), -}; -``` - - -## Advanced Example: - -### Single-Key Copy/Paste - -This example defines a macro which sends `Ctrl-C` when pressed down, and `Ctrl-V` when released. - -```c -const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) { - switch(id) { - case 0: { - if (record->event.pressed) { - return MACRO( D(LCTL), T(C), U(LCTL), END ); - } else { - return MACRO( D(LCTL), T(V), U(LCTL), END ); - } - break; - } - } - return MACRO_NONE; -}; -``` diff --git a/docs/feature_mouse_keys.md b/docs/feature_mouse_keys.md index ffde133892..8e2a3a4cd1 100644 --- a/docs/feature_mouse_keys.md +++ b/docs/feature_mouse_keys.md @@ -29,6 +29,9 @@ In your keymap you can use the following keycodes to map key presses to mouse ac |`KC_MS_BTN3` |`KC_BTN3`|Press button 3 | |`KC_MS_BTN4` |`KC_BTN4`|Press button 4 | |`KC_MS_BTN5` |`KC_BTN5`|Press button 5 | +|`KC_MS_BTN6` |`KC_BTN6`|Press button 6 | +|`KC_MS_BTN7` |`KC_BTN7`|Press button 7 | +|`KC_MS_BTN8` |`KC_BTN8`|Press button 8 | |`KC_MS_WH_UP` |`KC_WH_U`|Move wheel up | |`KC_MS_WH_DOWN` |`KC_WH_D`|Move wheel down | |`KC_MS_WH_LEFT` |`KC_WH_L`|Move wheel left | @@ -42,6 +45,7 @@ In your keymap you can use the following keycodes to map key presses to mouse ac Mouse keys supports three different modes to move the cursor: * **Accelerated (default):** Holding movement keys accelerates the cursor until it reaches its maximum speed. +* **Kinetic:** Holding movement keys accelerates the cursor with its speed following a quadratic curve until it reaches its maximum speed. * **Constant:** Holding movement keys moves the cursor at constant speeds. * **Combined:** Holding movement keys accelerates the cursor until it reaches its maximum speed, but holding acceleration and movement keys simultaneously moves the cursor at constant speeds. @@ -56,7 +60,8 @@ This is the default mode. You can adjust the cursor and scrolling acceleration u |Define |Default|Description | |----------------------------|-------|---------------------------------------------------------| |`MOUSEKEY_DELAY` |300 |Delay between pressing a movement key and cursor movement| -|`MOUSEKEY_INTERVAL` |50 |Time between cursor movements | +|`MOUSEKEY_INTERVAL` |50 |Time between cursor movements in milliseconds | +|`MOUSEKEY_MOVE_DELTA` |5 |Step size | |`MOUSEKEY_MAX_SPEED` |10 |Maximum cursor speed at which acceleration stops | |`MOUSEKEY_TIME_TO_MAX` |20 |Time until maximum cursor speed is reached | |`MOUSEKEY_WHEEL_DELAY` |300 |Delay between pressing a wheel key and wheel movement | @@ -73,6 +78,30 @@ Tips: Cursor acceleration uses the same algorithm as the X Window System MouseKeysAccel feature. You can read more about it [on Wikipedia](https://en.wikipedia.org/wiki/Mouse_keys). +### Kinetic Mode + +This is an extension of the accelerated mode. The kinetic mode uses a quadratic curve on the cursor speed which allows precise movements at the beginning and allows to cover large distances by increasing cursor speed quickly thereafter. You can adjust the cursor and scrolling acceleration using the following settings in your keymap’s `config.h` file: + +|Define |Default |Description | +|--------------------------------------|---------|---------------------------------------------------------------| +|`MK_KINETIC_SPEED` |undefined|Enable kinetic mode | +|`MOUSEKEY_DELAY` |8 |Delay between pressing a movement key and cursor movement | +|`MOUSEKEY_INTERVAL` |8 |Time between cursor movements in milliseconds | +|`MOUSEKEY_MOVE_DELTA` |25 |Step size for accelerating from initial to base speed | +|`MOUSEKEY_INITIAL_SPEED` |100 |Initial speed of the cursor in pixel per second | +|`MOUSEKEY_BASE_SPEED` |1000 |Maximum cursor speed at which acceleration stops | +|`MOUSEKEY_DECELERATED_SPEED` |400 |Decelerated cursor speed | +|`MOUSEKEY_ACCELERATED_SPEED` |3000 |Accelerated cursor speed | +|`MOUSEKEY_WHEEL_INITIAL_MOVEMENTS` |16 |Initial number of movements of the mouse wheel | +|`MOUSEKEY_WHEEL_BASE_MOVEMENTS` |32 |Maximum number of movements at which acceleration stops | +|`MOUSEKEY_WHEEL_ACCELERATED_MOVEMENTS`|48 |Accelerated wheel movements | +|`MOUSEKEY_WHEEL_DECELERATED_MOVEMENTS`|8 |Decelerated wheel movements | + +Tips: + +* The smoothness of the cursor movement depends on the `MOUSEKEY_INTERVAL` setting. The shorter the interval is set the smoother the movement will be. Setting the value too low makes the cursor unresponsive. Lower settings are possible if the micro processor is fast enough. For example: At an interval of `8` milliseconds, `125` movements per second will be initiated. With a base speed of `1000` each movement will move the cursor by `8` pixels. +* Mouse wheel movements are implemented differently from cursor movements. While it's okay for the cursor to move multiple pixels at once for the mouse wheel this would lead to jerky movements. Instead, the mouse wheel operates at step size `1`. Setting mouse wheel speed is done by adjusting the number of wheel movements per second. + ### Constant mode In this mode you can define multiple different speeds for both the cursor and the mouse wheel. There is no acceleration. `KC_ACL0`, `KC_ACL1` and `KC_ACL2` change the cursor and scroll speed to their respective setting. diff --git a/docs/feature_pointing_device.md b/docs/feature_pointing_device.md index 37edac5e6b..905c2a8f95 100644 --- a/docs/feature_pointing_device.md +++ b/docs/feature_pointing_device.md @@ -19,7 +19,7 @@ Keep in mind that a report_mouse_t (here "mouseReport") has the following proper * `mouseReport.y` - this is a signed int from -127 to 127 (not 128, this is defined in USB HID spec) representing movement (+ upward, - downward) on the y axis. * `mouseReport.v` - this is a signed int from -127 to 127 (not 128, this is defined in USB HID spec) representing vertical scrolling (+ upward, - downward). * `mouseReport.h` - this is a signed int from -127 to 127 (not 128, this is defined in USB HID spec) representing horizontal scrolling (+ right, - left). -* `mouseReport.buttons` - this is a uint8_t in which the last 5 bits are used. These bits represent the mouse button state - bit 3 is mouse button 5, and bit 7 is mouse button 1. +* `mouseReport.buttons` - this is a uint8_t in which all 8 bits are used. These bits represent the mouse button state - bit 0 is mouse button 1, and bit 7 is mouse button 8. Once you have made the necessary changes to the mouse report, you need to send it: diff --git a/docs/feature_rgb_matrix.md b/docs/feature_rgb_matrix.md index f5abd327c5..fd866bd571 100644 --- a/docs/feature_rgb_matrix.md +++ b/docs/feature_rgb_matrix.md @@ -129,6 +129,28 @@ Configure the hardware via your `config.h`: --- +### APA102 :id=apa102 + +There is basic support for APA102 based addressable LED strands. To enable it, add this to your `rules.mk`: + +```makefile +RGB_MATRIX_ENABLE = yes +RGB_MATRIX_DRIVER = APA102 +``` + +Configure the hardware via your `config.h`: + +```c +// The pin connected to the data pin of the LEDs +#define RGB_DI_PIN D7 +// The pin connected to the clock pin of the LEDs +#define RGB_CI_PIN D6 +// The number of LEDs connected +#define DRIVER_LED_TOTAL 70 +``` + +--- + From this point forward the configuration is the same for all the drivers. The `led_config_t` struct provides a key electrical matrix to led index lookup table, what the physical position of each LED is on the board, and what type of key or usage the LED if the LED represents. Here is a brief example: ```c diff --git a/docs/feature_rgblight.md b/docs/feature_rgblight.md index 755fd769e6..d2612a6d1b 100644 --- a/docs/feature_rgblight.md +++ b/docs/feature_rgblight.md @@ -10,6 +10,7 @@ Currently QMK supports the following addressable LEDs (however, the white LED in * WS2811, WS2812, WS2812B, WS2812C, etc. * SK6812, SK6812MINI, SK6805 + * APA102 These LEDs are called "addressable" because instead of using a wire per color, each LED contains a small microchip that understands a special protocol sent over a single wire. The chip passes on the remaining data to the next LED, allowing them to be chained together. In this way, you can easily control the color of the individual LEDs. @@ -21,11 +22,19 @@ On keyboards with onboard RGB LEDs, it is usually enabled by default. If it is n RGBLIGHT_ENABLE = yes ``` -At minimum you must define the data pin your LED strip is connected to, and the number of LEDs in the strip, in your `config.h`. If your keyboard has onboard RGB LEDs, and you are simply creating a keymap, you usually won't need to modify these. +For APA102 LEDs, add the following to your `rules.mk`: + +```make +RGBLIGHT_ENABLE = yes +RGBLIGHT_DRIVER = APA102 +``` + +At minimum you must define the data pin your LED strip is connected to, and the number of LEDs in the strip, in your `config.h`. For APA102 LEDs, you must also define the clock pin. If your keyboard has onboard RGB LEDs, and you are simply creating a keymap, you usually won't need to modify these. |Define |Description | |---------------|---------------------------------------------------------------------------------------------------------| |`RGB_DI_PIN` |The pin connected to the data pin of the LEDs | +|`RGB_CI_PIN` |The pin connected to the clock pin of the LEDs (APA102 only) | |`RGBLED_NUM` |The number of LEDs connected | |`RGBLED_SPLIT` |(Optional) For split keyboards, the number of LEDs connected on each half directly wired to `RGB_DI_PIN` | @@ -73,15 +82,20 @@ Changing the **Value** sets the overall brightness.<br> Your RGB lighting can be configured by placing these `#define`s in your `config.h`: -|Define |Default |Description | -|---------------------|-------------|-----------------------------------------------------------------------------| -|`RGBLIGHT_HUE_STEP` |`10` |The number of steps to cycle through the hue by | -|`RGBLIGHT_SAT_STEP` |`17` |The number of steps to increment the saturation by | -|`RGBLIGHT_VAL_STEP` |`17` |The number of steps to increment the brightness by | -|`RGBLIGHT_LIMIT_VAL` |`255` |The maximum brightness level | -|`RGBLIGHT_SLEEP` |*Not defined*|If defined, the RGB lighting will be switched off when the host goes to sleep| -|`RGBLIGHT_SPLIT` |*Not defined*|If defined, synchronization functionality for split keyboards is added| -|`RGBLIGHT_DISABLE_KEYCODES`|*not defined*|If defined, disables the ability to control RGB Light from the keycodes. You must use code functions to control the feature| +|Define |Default |Description | +|---------------------------|----------------------------|---------------------------------------------------------------------------------------------------------------------------| +|`RGBLIGHT_HUE_STEP` |`10` |The number of steps to cycle through the hue by | +|`RGBLIGHT_SAT_STEP` |`17` |The number of steps to increment the saturation by | +|`RGBLIGHT_VAL_STEP` |`17` |The number of steps to increment the brightness by | +|`RGBLIGHT_LIMIT_VAL` |`255` |The maximum brightness level | +|`RGBLIGHT_SLEEP` |*Not defined* |If defined, the RGB lighting will be switched off when the host goes to sleep | +|`RGBLIGHT_SPLIT` |*Not defined* |If defined, synchronization functionality for split keyboards is added | +|`RGBLIGHT_DISABLE_KEYCODES`|*Not defined* |If defined, disables the ability to control RGB Light from the keycodes. You must use code functions to control the feature| +|`RGBLIGHT_DEFAULT_MODE` |`RGBLIGHT_MODE_STATIC_LIGHT`|The default mode to use upon clearing the EEPROM | +|`RGBLIGHT_DEFAULT_HUE` |`0` (red) |The default hue to use upon clearing the EEPROM | +|`RGBLIGHT_DEFAULT_SAT` |`UINT8_MAX` (255) |The default saturation to use upon clearing the EEPROM | +|`RGBLIGHT_DEFAULT_VAL` |`RGBLIGHT_LIMIT_VAL` |The default value (brightness) to use upon clearing the EEPROM | +|`RGBLIGHT_DEFAULT_SPD` |`0` |The default speed to use upon clearing the EEPROM | ## Effects and Animations @@ -139,7 +153,7 @@ The following options are used to tweak the various animations: |`RGBLIGHT_EFFECT_KNIGHT_OFFSET` |`0` |The number of LEDs to start the "Knight" animation from the start of the strip by | |`RGBLIGHT_RAINBOW_SWIRL_RANGE` |`255` |Range adjustment for the rainbow swirl effect to get different swirls | |`RGBLIGHT_EFFECT_SNAKE_LENGTH` |`4` |The number of LEDs to light up for the "Snake" animation | -|`RGBLIGHT_EFFECT_TWINKLE_LIFE` |`75` |Adjusts how quickly each LED brightens and dims when twinkling (in animation steps) | +|`RGBLIGHT_EFFECT_TWINKLE_LIFE` |`200` |Adjusts how quickly each LED brightens and dims when twinkling (in animation steps) | |`RGBLIGHT_EFFECT_TWINKLE_PROBABILITY`|`1/127` |Adjusts how likely each LED is to twinkle (on each animation step) | ### Example Usage to Reduce Memory Footprint diff --git a/docs/feature_split_keyboard.md b/docs/feature_split_keyboard.md index b234114200..90af3930f9 100644 --- a/docs/feature_split_keyboard.md +++ b/docs/feature_split_keyboard.md @@ -181,6 +181,22 @@ If you're having issues with serial communication, you can change this value, as * **`4`**: about 26kbps * **`5`**: about 20kbps +```c +#define SPLIT_MODS_ENABLE +``` + +This enables transmitting modifier state (normal, weak and oneshot) to the non +primary side of the split keyboard. This adds a few bytes of data to the split +communication protocol and may impact the matrix scan speed when enabled. +The purpose of this feature is to support cosmetic use of modifer state (e.g. +displaying status on an OLED screen). + +```c +#define SPLIT_TRANSPORT_MIRROR +``` + +This mirrors the master side matrix to the slave side for features that react or require knowledge of master side key presses on the slave side. This adds a few bytes of data to the split communication protocol and may impact the matrix scan speed when enabled. The purpose of this feature is to support cosmetic use of key events (e.g. RGB reacting to Keypresses). + ### Hardware Configuration Options There are some settings that you may need to configure, based on how the hardware is set up. diff --git a/docs/getting_started_make_guide.md b/docs/getting_started_make_guide.md index ad63a1c2ec..7198576e3a 100644 --- a/docs/getting_started_make_guide.md +++ b/docs/getting_started_make_guide.md @@ -121,10 +121,6 @@ For further details, as well as limitations, see the [Unicode page](feature_unic This allows you output audio on the C6 pin (needs abstracting). See the [audio page](feature_audio.md) for more information. -`FAUXCLICKY_ENABLE` - -Uses buzzer to emulate clicky switches. A cheap imitation of the Cherry blue switches. By default, uses the C6 pin, same as `AUDIO_ENABLE`. - `VARIABLE_TRACE` Use this to debug changes to variable values, see the [tracing variables](unit_testing.md#tracing-variables) section of the Unit Testing page for more information. diff --git a/docs/ja/compatible_microcontrollers.md b/docs/ja/compatible_microcontrollers.md index 48b07aaec4..fdd11f14fa 100644 --- a/docs/ja/compatible_microcontrollers.md +++ b/docs/ja/compatible_microcontrollers.md @@ -14,6 +14,7 @@ QMK は十分な容量のフラッシュメモリを備えた USB 対応 AVR ま * [ATmega16U2](https://www.microchip.com/wwwproducts/en/ATmega16U2) / [ATmega32U2](https://www.microchip.com/wwwproducts/en/ATmega32U2) * [ATmega16U4](https://www.microchip.com/wwwproducts/en/ATmega16U4) / [ATmega32U4](https://www.microchip.com/wwwproducts/en/ATmega32U4) * [AT90USB64](https://www.microchip.com/wwwproducts/en/AT90USB646) / [AT90USB128](https://www.microchip.com/wwwproducts/en/AT90USB1286) +* [AT90USB162](https://www.microchip.com/wwwproducts/en/AT90USB162) 組み込みの USB インターフェースを持たない、いくつかの MCU は代わりに [V-USB](https://www.obdev.at/products/vusb/index.html) を使います: @@ -30,6 +31,10 @@ QMK は十分な容量のフラッシュメモリを備えた USB 対応 AVR ま * [STM32F0x2](https://www.st.com/en/microcontrollers-microprocessors/stm32f0x2.html) * [STM32F103](https://www.st.com/en/microcontrollers-microprocessors/stm32f103.html) * [STM32F303](https://www.st.com/en/microcontrollers-microprocessors/stm32f303.html) +* [STM32F401](https://www.st.com/en/microcontrollers-microprocessors/stm32f401.html) +* [STM32F411](https://www.st.com/en/microcontrollers-microprocessors/stm32f411.html) +* [STM32G431](https://www.st.com/en/microcontrollers-microprocessors/stm32g4x1.html) +* [STM32G474](https://www.st.com/en/microcontrollers-microprocessors/stm32g4x4.html) ### NXP (Kinetis) diff --git a/docs/ja/feature_audio.md b/docs/ja/feature_audio.md index 2d13c3f7cc..ca7820e3c4 100644 --- a/docs/ja/feature_audio.md +++ b/docs/ja/feature_audio.md @@ -220,12 +220,6 @@ const uint8_t music_map[MATRIX_ROWS][MATRIX_COLS] = LAYOUT_ortho_4x12( AU_OFF, AU_TOG, - #ifdef FAUXCLICKY_ENABLE - FC_ON, - FC_OFF, - FC_TOG, - #endif - // Music mode on/off/toggle MU_ON, MU_OFF, diff --git a/docs/ja/feature_macros.md b/docs/ja/feature_macros.md index 14a58ad244..c42a61b5fb 100644 --- a/docs/ja/feature_macros.md +++ b/docs/ja/feature_macros.md @@ -9,7 +9,7 @@ !> **セキュリティの注意**: マクロを使って、パスワード、クレジットカード番号、その他の機密情報のいずれも送信することが可能ですが、それは非常に悪い考えです。あなたのキーボードを手に入れた人は誰でもテキストエディタを開いてその情報にアクセスすることができます。 -## 新しい方法: `SEND_STRING()` と `process_record_user` +## `SEND_STRING()` と `process_record_user` 単語またはフレーズを入力するキーが欲しい時があります。最も一般的な状況のために `SEND_STRING()` を提供しています。これは文字列(つまり、文字のシーケンス)を入力します。簡単にキーコードに変換することができる全ての ASCII 文字がサポートされています (例えば、`qmk 123\n\t`)。 @@ -267,15 +267,15 @@ SEND_STRING(".."SS_TAP(X_END)); このマクロは `KC_LALT` を登録し、`KC_TAB` をタップして、1000ms 待ちます。キーが再度タップされると、別の `KC_TAB` が送信されます; タップが無い場合、`KC_LALT` が登録解除され、ウィンドウを切り替えることができます。 ```c -bool is_alt_tab_active = false; # keymap.c の先頭付近にこれを追加します -uint16_t alt_tab_timer = 0; # すぐにそれらを使います +bool is_alt_tab_active = false; // keymap.c の先頭付近にこれを追加します +uint16_t alt_tab_timer = 0; // すぐにそれらを使います -enum custom_keycodes { # 素晴らしいキーコードを用意してください +enum custom_keycodes { // 素晴らしいキーコードを用意してください ALT_TAB = SAFE_RANGE, }; bool process_record_user(uint16_t keycode, keyrecord_t *record) { - switch (keycode) { # これはキーコードを利用したつまらない作業のほとんどを行います。 + switch (keycode) { // これはキーコードを利用したつまらない作業のほとんどを行います。 case ALT_TAB: if (record->event.pressed) { if (!is_alt_tab_active) { @@ -292,7 +292,7 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) { return true; } -void matrix_scan_user(void) { # とても重要なタイマー +void matrix_scan_user(void) { // とても重要なタイマー if (is_alt_tab_active) { if (timer_elapsed(alt_tab_timer) > 1000) { unregister_code(KC_LALT); @@ -301,104 +301,3 @@ void matrix_scan_user(void) { # とても重要なタイマー } } ``` - ---- - -## **(非推奨)** 古い方法: `MACRO()` と `action_get_macro` - -!> これは TMK から継承されており、更新されていません - 代わりに `SEND_STRING` と `process_record_user` を使うことをお勧めします。 - -デフォルトでは、QMK はマクロが無いことを前提としています。マクロを定義するには、`action_get_macro()` 関数を作成します。例えば: - -```c -const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) { - if (record->event.pressed) { - switch(id) { - case 0: - return MACRO(D(LSFT), T(H), U(LSFT), T(I), D(LSFT), T(1), U(LSFT), END); - case 1: - return MACRO(D(LSFT), T(B), U(LSFT), T(Y), T(E), D(LSFT), T(1), U(LSFT), END); - } - } - return MACRO_NONE; -}; -``` - -これは割り当てられているキーが押された時に実行される2つのマクロを定義します。キーが放された時にそれらを実行したい場合は、if 文を変更することができます。 - - if (!record->event.pressed) { - -### マクロコマンド - -マクロは以下のコマンドを含めることができます: - -* I() はストロークの間隔をミリ秒単位で変更します。 -* D() はキーを押します。 -* U() はキーを放します。 -* T() はキーをタイプ(押して放す)します。 -* W() は待ちます (ミリ秒)。 -* END 終了マーク。 - -### マクロをキーにマッピングする - -マクロを呼び出すにはキーマップ内で `M()` 関数を使います。例えば、2キーのキーボードのキーマップは以下の通りです: - -```c -const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { - [0] = LAYOUT( - M(0), M(1) - ), -}; - -const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) { - if (record->event.pressed) { - switch(id) { - case 0: - return MACRO(D(LSFT), T(H), U(LSFT), T(I), D(LSFT), T(1), U(LSFT), END); - case 1: - return MACRO(D(LSFT), T(B), U(LSFT), T(Y), T(E), D(LSFT), T(1), U(LSFT), END); - } - } - return MACRO_NONE; -}; -``` - -左側のキーを押すと、"Hi!" を入力し、右側のキーを押すと "Bye!" を入力します。 - -### マクロに名前を付ける - -キーマップを読みやすくしながらキーマップから参照したいマクロがたくさんある場合は、ファイルの先頭で `#define` を使って名前を付けることができます。 - -```c -#define M_HI M(0) -#define M_BYE M(1) - -const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { - [0] = LAYOUT( - M_HI, M_BYE - ), -}; -``` - - -## 高度な例: - -### 単一キーのコピーと貼り付け - -この例は、押された時に `Ctrl-C` を送信し、放される時に `Ctrl-V` を送信するマクロを定義します。 - -```c -const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) { - switch(id) { - case 0: { - if (record->event.pressed) { - return MACRO( D(LCTL), T(C), U(LCTL), END ); - } else { - return MACRO( D(LCTL), T(V), U(LCTL), END ); - } - break; - } - } - return MACRO_NONE; -}; -``` diff --git a/docs/ja/feature_mouse_keys.md b/docs/ja/feature_mouse_keys.md index 74b09e939b..e4fa9dfb45 100644 --- a/docs/ja/feature_mouse_keys.md +++ b/docs/ja/feature_mouse_keys.md @@ -34,6 +34,9 @@ MOUSEKEY_ENABLE = yes | `KC_MS_BTN3` | `KC_BTN3` | ボタン3を押す | | `KC_MS_BTN4` | `KC_BTN4` | ボタン4を押す | | `KC_MS_BTN5` | `KC_BTN5` | ボタン5を押す | +| `KC_MS_BTN6` | `KC_BTN6` | ボタン6を押す | +| `KC_MS_BTN7` | `KC_BTN7` | ボタン7を押す | +| `KC_MS_BTN8` | `KC_BTN8` | ボタン8を押す | | `KC_MS_WH_UP` | `KC_WH_U` | ホイールを向こう側に回転 | | `KC_MS_WH_DOWN` | `KC_WH_D` | ホイールを手前側に回転 | | `KC_MS_WH_LEFT` | `KC_WH_L` | ホイールを左に倒す | diff --git a/docs/ja/getting_started_make_guide.md b/docs/ja/getting_started_make_guide.md index 08005877e7..45284a0b9f 100644 --- a/docs/ja/getting_started_make_guide.md +++ b/docs/ja/getting_started_make_guide.md @@ -110,10 +110,6 @@ make コマンド自体にもいくつかの追加オプションがあります C6 ピン(抽象化が必要)でオーディオ出力できます。詳細は[オーディオページ](ja/feature_audio.md)を見てください。 -`FAUXCLICKY_ENABLE` - -クリック音のあるスイッチをエミュレートするためにブザーを使います。Cherry社製の青軸スイッチの安っぽい模倣です。デフォルトでは、`AUDIO_ENABLE` と同じように C6 ピンを使います。 - `VARIABLE_TRACE` これを使って変数の値の変更をデバッグします。詳細についてはユニットテストのページの[変数のトレース](ja/unit_testing.md#tracing-variables)のセクションを見てください。 diff --git a/docs/ja/proton_c_conversion.md b/docs/ja/proton_c_conversion.md index 6e4f7dcb66..e7c07413ce 100644 --- a/docs/ja/proton_c_conversion.md +++ b/docs/ja/proton_c_conversion.md @@ -51,6 +51,7 @@ Proton C には1つのオンボード LED(C13)しかなく、デフォルトで� ``` MCU = STM32F303 +BOARD = QMK_PROTON_C ``` 次の変数が存在する場合は削除します。 diff --git a/docs/ja/understanding_qmk.md b/docs/ja/understanding_qmk.md index 74b37398f8..ab860a6096 100644 --- a/docs/ja/understanding_qmk.md +++ b/docs/ja/understanding_qmk.md @@ -147,7 +147,6 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { * [`bool process_haptic(uint16_t keycode, keyrecord_t *record)`](https://github.com/qmk/qmk_firmware/blob/2cee371bf125a6ec541dd7c5a809573facc7c456/drivers/haptic/haptic.c#L216) * [`bool process_record_kb(uint16_t keycode, keyrecord_t *record)`](https://github.com/qmk/qmk_firmware/blob/e1203a222bb12ab9733916164a000ef3ac48da93/keyboards/clueboard/card/card.c#L20) * [`bool process_record_user(uint16_t keycode, keyrecord_t *record)`](https://github.com/qmk/qmk_firmware/blob/e1203a222bb12ab9733916164a000ef3ac48da93/keyboards/clueboard/card/keymaps/default/keymap.c#L58) - * [`bool process_rgb_matrix(uint16_t keycode, keyrecord_t *record)`](https://github.com/qmk/qmk_firmware/blob/e1203a222bb12ab9733916164a000ef3ac48da93/quantum/rgb_matrix.c#L139) * [`bool process_midi(uint16_t keycode, keyrecord_t *record)`](https://github.com/qmk/qmk_firmware/blob/e1203a222bb12ab9733916164a000ef3ac48da93/quantum/process_keycode/process_midi.c#L81) * [`bool process_audio(uint16_t keycode, keyrecord_t *record)`](https://github.com/qmk/qmk_firmware/blob/e1203a222bb12ab9733916164a000ef3ac48da93/quantum/process_keycode/process_audio.c#L19) * [`bool process_steno(uint16_t keycode, keyrecord_t *record)`](https://github.com/qmk/qmk_firmware/blob/e1203a222bb12ab9733916164a000ef3ac48da93/quantum/process_keycode/process_steno.c#L160) diff --git a/docs/proton_c_conversion.md b/docs/proton_c_conversion.md index 1b5e496e74..47511e1b1e 100644 --- a/docs/proton_c_conversion.md +++ b/docs/proton_c_conversion.md @@ -44,6 +44,7 @@ To use the Proton C natively, without having to specify `CTPC=yes`, you need to ``` MCU = STM32F303 +BOARD = QMK_PROTON_C ``` Remove these variables if they exist: diff --git a/docs/reference_info_json.md b/docs/reference_info_json.md index 67c189d786..30d813e93a 100644 --- a/docs/reference_info_json.md +++ b/docs/reference_info_json.md @@ -19,8 +19,20 @@ The `info.json` file is a JSON formatted dictionary with the following keys avai * Width of the board in Key Units * `height` * Height of the board in Key Units +* `debounce` + * How many milliseconds (ms) to wait for debounce to happen. (Default: 5) +* `diode_direction` + * The direction diodes face. See [`DIRECT_PINS` in the hardware configuration](https://docs.qmk.fm/#/config_options?id=hardware-options) for more details. +* `layout_aliases` + * A dictionary containing layout aliases. The key is the alias and the value is a layout in `layouts` it maps to. * `layouts` - * Physical Layout representations. See the next section for more detail. + * Physical Layout representations. See the [Layout Format](#layout_format) section for more detail. +* `matrix_pins` + * Configure the pins corresponding to columns and rows, or direct pins. See [Matrix Pins](#matrix_pins) for more detail. +* `rgblight` + * Configure the [RGB Lighting feature](feature_rgblight.md). See the [RGB Lighting](#rgb_lighting) section for more detail. +* `usb` + * Configure USB VID, PID, and other parameters. See [USB](#USB) for more detail. ### Layout Format @@ -49,25 +61,129 @@ All key positions and rotations are specified in relation to the top-left corner * The width of the key, in Key Units. Ignored if `ks` is provided. Default: `1` * `h` * The height of the key, in Key Units. Ignored if `ks` is provided. Default: `1` -* `r` - * How many degrees clockwise to rotate the key. -* `rx` - * The absolute position of the point to rotate the key around in the horizontal axis. Default: `x` -* `ry` - * The absolute position of the point to rotate the key around in the vertical axis. Default: `y` -* `ks` - * Key Shape: define a polygon by providing a list of points, in Key Units. - * **Important**: These are relative to the top-left of the key, not absolute. - * Example ISO Enter: `[ [0,0], [1.5,0], [1.5,2], [0.25,2], [0.25,1], [0,1], [0,0] ]` * `label` * What to name this position in the matrix. - * This should usually be the same name as what is silkscreened on the PCB at this location. - -## How is the Metadata Exposed? - -This metadata is primarily used in two ways: - -* To allow web-based configurators to dynamically generate UI -* To support the new `make keyboard:keymap:qmk` target, which bundles this metadata up with the firmware to allow QMK Toolbox to be smarter. - -Configurator authors can see the [QMK Compiler](https://docs.api.qmk.fm/using-the-api) docs for more information on using the JSON API. + * This should usually correspond to the keycode for the first layer of the default keymap. +* `matrix` + * A 2 item list describing the row and column location for this key. + +### Matrix Pins + +Currently QMK supports connecting switches either directly to GPIO pins or via a switch matrix. At this time you can not combine these, they are mutually exclusive. + +#### Switch Matrix + +Most keyboards use a switch matrix to connect keyswitches to the MCU. You can define your pin columns and rows to configure your switch matrix. When defining switch matrices you should also define your `diode_direction`. + +Example: + +```json +{ + "diode_direction": "COL2ROW", + "matrix_pins": { + "cols": ["F4", "E6", "B1", "D2"], + "rows": ["B0", "D3", "D5", "D4", "D6"] + } +} +``` + +#### Direct Pins + +Direct pins are when you connect one side of the switch to GND and the other side to a GPIO pin on your MCU. No diode is required, but there is a 1:1 mapping between switches and pins. + +When specifying direct pins you need to arrange them in nested arrays. The outer array consists of rows, while the inner array is a text string corresponding to a pin. You can use `null` to indicate an empty spot in the matrix. + +Example: + +```json +{ + "matrix_pins": { + "direct": [ + ["A10", "A9"], + ["A0", "B8"], + [null, "B11"], + ["B9", "A8"], + ["A7", "B1"], + [null, "B2"] + ] + } +} +``` + +### RGB Lighting + +This section controls the legacy WS2812 support in QMK. This should not be confused with the RGB Matrix feature, which can be used to control both WS2812 and ISSI RGB LEDs. + +The following items can be set. Not every value is required. + +* `led_count` + * The number of LEDs in your strip +* `pin` + * The GPIO pin that your LED strip is connected to +* `animations` + * A dictionary that lists enabled and disabled animations. See [RGB Light Animations](#rgb_light_animations) below. +* `sleep` + * Set to `true` to enable lighting during host sleep +* `split` + * Set to `true` to enable synchronization functionality between split halves +* `split_count` + * For split keyboards, the number of LEDs on each side +* `max_brightness` + * (0-255) What the maxmimum brightness (value) level is +* `hue_steps` + * How many steps of adjustment to have for hue +* `saturation_steps` + * How many steps of adjustment to have for saturation +* `brightness_steps` + * How many steps of adjustment to have for brightness (value) + +Example: + +```json +{ + "rgblight": { + "led_count": 4, + "pin": "F6", + "hue_steps": 10, + "saturation_steps": 17, + "brightness_steps": 17, + "animations": { + "all": true + } + } +} +``` + +#### RGB Light Animations + +The following animations can be enabled: + +| Key | Description | +|-----|-------------| +| `all` | Enable all additional animation modes. | +| `alternating` | Enable alternating animation mode. | +| `breathing` | Enable breathing animation mode. | +| `christmas` | Enable christmas animation mode. | +| `knight` | Enable knight animation mode. | +| `rainbow_mood` | Enable rainbow mood animation mode. | +| `rainbow_swirl` | Enable rainbow swirl animation mode. | +| `rgb_test` | Enable RGB test animation mode. | +| `snake` | Enable snake animation mode. | +| `static_gradient` | Enable static gradient mode. | +| `twinkle` | Enable twinkle animation mode. | + +### USB + +Every USB keyboard needs to have its USB parmaters defined. At a minimum you need to set vid, pid, and device version. + +Example: + +```json +{ + "usb": { + "vid": "0xC1ED", + "pid": "0x23B0", + "device_ver": "0x0001" + } +} +``` diff --git a/docs/reference_keymap_extras.md b/docs/reference_keymap_extras.md index f2abb4e596..40a1956844 100644 --- a/docs/reference_keymap_extras.md +++ b/docs/reference_keymap_extras.md @@ -18,7 +18,9 @@ To use these, simply `#include` the corresponding [header file](https://github.c |Dutch (Belgium) |`keymap_belgian.h` | |English (Ireland) |`keymap_irish.h` | |English (UK) |`keymap_uk.h` | +|English (US Extended) |`keymap_us_extended.h` | |English (US International) |`keymap_us_international.h` | +|English (US International, Linux)|`keymap_us_international_linux.h`| |Estonian |`keymap_estonian.h` | |Finnish |`keymap_finnish.h` | |French |`keymap_french.h` | diff --git a/docs/serial_driver.md b/docs/serial_driver.md index bc376b6ddd..c98f4c1176 100644 --- a/docs/serial_driver.md +++ b/docs/serial_driver.md @@ -60,6 +60,7 @@ Configure the hardware via your config.h: // 5: about 19200 baud #define SERIAL_USART_DRIVER SD1 // USART driver of TX pin. default: SD1 #define SERIAL_USART_TX_PAL_MODE 7 // Pin "alternate function", see the respective datasheet for the appropriate values for your MCU. default: 7 +#define SERIAL_USART_TIMEOUT 100 // USART driver timeout. default 100 ``` You must also enable the ChibiOS `SERIAL` feature: diff --git a/docs/spi_driver.md b/docs/spi_driver.md index 16fe1d803f..a27a3a13d0 100644 --- a/docs/spi_driver.md +++ b/docs/spi_driver.md @@ -6,12 +6,12 @@ The SPI Master drivers used in QMK have a set of common functions to allow porta No special setup is required - just connect the `SS`, `SCK`, `MOSI` and `MISO` pins of your SPI devices to the matching pins on the MCU: -|MCU |`SS`|`SCK`|`MOSI`|`MISO`| -|---------------|----|-----|------|------| -|ATmega16/32U2/4|`B0`|`B1` |`B2` |`B3` | -|AT90USB64/128 |`B0`|`B1` |`B2` |`B3` | -|ATmega32A |`B4`|`B7` |`B5` |`B6` | -|ATmega328/P |`B2`|`B5` |`B3` |`B4` | +|MCU |`SS`|`SCK`|`MOSI`|`MISO`| +|-----------------|----|-----|------|------| +|ATmega16/32U2/4 |`B0`|`B1` |`B2` |`B3` | +|AT90USB64/128/162|`B0`|`B1` |`B2` |`B3` | +|ATmega32A |`B4`|`B7` |`B5` |`B6` | +|ATmega328/P |`B2`|`B5` |`B3` |`B4` | You may use more than one slave select pin, not just the `SS` pin. This is useful when you have multiple devices connected and need to communicate with them individually. `SPI_SS_PIN` can be passed to `spi_start()` to refer to `SS`. diff --git a/docs/uart_driver.md b/docs/uart_driver.md new file mode 100644 index 0000000000..4d1716975f --- /dev/null +++ b/docs/uart_driver.md @@ -0,0 +1,90 @@ +# UART Driver + +The UART drivers used in QMK have a set of common functions to allow portability between MCUs. + +Currently, this driver does not support enabling hardware flow control (the `RTS` and `CTS` pins) if available, but may do so in future. + +## AVR Configuration + +No special setup is required - just connect the `RX` and `TX` pins of your UART device to the opposite pins on the MCU: + +|MCU |`TX`|`RX`|`CTS`|`RTS`| +|-------------|----|----|-----|-----| +|ATmega16/32U2|`D3`|`D2`|`D7` |`D6` | +|ATmega16/32U4|`D3`|`D2`|`D5` |`B7` | +|AT90USB64/128|`D3`|`D2`|*n/a*|*n/a*| +|ATmega32A |`D1`|`D0`|*n/a*|*n/a*| +|ATmega328/P |`D1`|`D0`|*n/a*|*n/a*| + +## ChibiOS/ARM Configuration + +You'll need to determine which pins can be used for UART -- as an example, STM32 parts generally have multiple UART peripherals, labeled USART1, USART2, USART3 etc. + +To enable UART, modify your board's `halconf.h` to enable the serial driver: + +```c +#define HAL_USE_SERIAL TRUE +``` + +Then, modify your board's `mcuconf.h` to enable the peripheral you've chosen, for example: + +```c +#undef STM32_SERIAL_USE_USART2 +#define STM32_SERIAL_USE_USART2 TRUE +``` + +Configuration-wise, you'll need to set up the peripheral as per your MCU's datasheet -- the defaults match the pins for a Proton-C, i.e. STM32F303. + +|`config.h` override |Description |Default Value| +|--------------------------|---------------------------------------------------------------|-------------| +|`#define SERIAL_DRIVER` |USART peripheral to use - USART1 -> `SD1`, USART2 -> `SD2` etc.|`SD1` | +|`#define SD1_TX_PIN` |The pin to use for TX |`A9` | +|`#define SD1_TX_PAL_MODE` |The alternate function mode for TX |`7` | +|`#define SD1_RX_PIN` |The pin to use for RX |`A10` | +|`#define SD1_RX_PAL_MODE` |The alternate function mode for RX |`7` | +|`#define SD1_CTS_PIN` |The pin to use for CTS |`A11` | +|`#define SD1_CTS_PAL_MODE`|The alternate function mode for CTS |`7` | +|`#define SD1_RTS_PIN` |The pin to use for RTS |`A12` | +|`#define SD1_RTS_PAL_MODE`|The alternate function mode for RTS |`7` | + +## Functions + +### `void uart_init(uint32_t baud)` + +Initialize the UART driver. This function must be called only once, before any of the below functions can be called. + +#### Arguments + + - `uint32_t baud` + The baud rate to transmit and receive at. This may depend on the device you are communicating with. Common values are 1200, 2400, 4800, 9600, 19200, 38400, 57600, and 115200. + +--- + +### `void uart_putchar(uint8_t c)` + +Transmit a single byte. + +#### Arguments + + - `uint8_t c` + The byte (character) to send, from 0 to 255. + +--- + +### `uint8_t uart_getchar(void)` + +Receive a single byte. + +#### Return Value + +The byte read from the receive buffer. + +--- + +### `bool uart_available(void)` + +Return whether the receive buffer contains data. Call this function to determine if `uart_getchar()` will return meaningful data. + +#### Return Value + +`true` if the receive buffer length is non-zero. diff --git a/docs/understanding_qmk.md b/docs/understanding_qmk.md index 9396424258..331b1c893c 100644 --- a/docs/understanding_qmk.md +++ b/docs/understanding_qmk.md @@ -142,7 +142,6 @@ The `process_record()` function itself is deceptively simple, but hidden within * [`bool process_haptic(uint16_t keycode, keyrecord_t *record)`](https://github.com/qmk/qmk_firmware/blob/2cee371bf125a6ec541dd7c5a809573facc7c456/drivers/haptic/haptic.c#L216) * [`bool process_record_kb(uint16_t keycode, keyrecord_t *record)`](https://github.com/qmk/qmk_firmware/blob/e1203a222bb12ab9733916164a000ef3ac48da93/keyboards/clueboard/card/card.c#L20) * [`bool process_record_user(uint16_t keycode, keyrecord_t *record)`](https://github.com/qmk/qmk_firmware/blob/e1203a222bb12ab9733916164a000ef3ac48da93/keyboards/clueboard/card/keymaps/default/keymap.c#L58) - * [`bool process_rgb_matrix(uint16_t keycode, keyrecord_t *record)`](https://github.com/qmk/qmk_firmware/blob/e1203a222bb12ab9733916164a000ef3ac48da93/quantum/rgb_matrix.c#L139) * [`bool process_midi(uint16_t keycode, keyrecord_t *record)`](https://github.com/qmk/qmk_firmware/blob/e1203a222bb12ab9733916164a000ef3ac48da93/quantum/process_keycode/process_midi.c#L81) * [`bool process_audio(uint16_t keycode, keyrecord_t *record)`](https://github.com/qmk/qmk_firmware/blob/e1203a222bb12ab9733916164a000ef3ac48da93/quantum/process_keycode/process_audio.c#L19) * [`bool process_steno(uint16_t keycode, keyrecord_t *record)`](https://github.com/qmk/qmk_firmware/blob/e1203a222bb12ab9733916164a000ef3ac48da93/quantum/process_keycode/process_steno.c#L160) |