Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add documentation for the Potentiometer module included with KMK #638

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Update potentiometer.md
updated formatting
NiceManiac committed Nov 1, 2022
commit 006ccc4b4f28b60b66505c7fd03438e2a4fd05d6
14 changes: 8 additions & 6 deletions docs/en/potentiometer.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Potentiometer module
Do you want to add joystick sor faders to your keyboard?
Do you want to add joysticks or faders to your keyboard?

The potentiometer module reads analog signals from you ADC pins and gives you a value in 7 bit base.

@@ -18,15 +18,15 @@ keyboard.modules.append(potentiometer)
## How to use
Here is all you need to use this module in your `main.py` / `code.py` file.

###### 1. Load the module: import the potentiometer handler and add it to keyboard modules.
**1. Load the module: import the potentiometer handler and add it to keyboard modules.**

```python
from kmk.modules.potentiometer import PotentiometerHandler
potentiometer = PotentiometerHandler()
keyboard.modules.append(potentiometer)
```

###### 2. Define the pins for each potentiometer: `pin_a` for the signal pin and `defname` for the name of the controlling defenition. If you want to invert the direction of the potentiometer, set the 3rd (optional) parameter `is_inverted` to `True`.
**2. Define the pins for each potentiometer: `pin_a` for the signal pin and `defname` for the name of the controlling defenition. If you want to invert the direction of the potentiometer, set the 3rd (optional) parameter `is_inverted` to `True`.**

```python
potentiometer.pins = (
@@ -45,10 +45,12 @@ potentiometer.pins = (
)
```

###### 3. Define the mapping of keys to be called.
**3. Define the mapping of keys to be called.**

here we convert the incoming base values into a value 0-127 for ease of use.

This example is for a joystick mapped to WASD with a deadzone in the center. The exact deadzone values might vary depending on the potentiometers used.

*Note: this uses `keyboard.add_key` and `keyboard.remove_key` which could be considered legacy.*

```python
@@ -75,7 +77,7 @@ def potentiometer_2_handler(state):

## Other examples

###### Computer volume
**Computer volume**

You can use a potentiometer to control the system volume easily. Here an example from [ZFR_KBD's RP2.65-F](https://github.com/KMKfw/kmk_firmware/blob/master/user_keymaps/ZFR_KBD/RP2.65-F.py)

@@ -117,7 +119,7 @@ def potentiometer_1_handler(state):
set_sys_vol(state)
```

###### LED brightness
**LED brightness**

You can also use a potentiometer to control the LED brightness of your keyboard. Another example from [ZFR_KBD's RP2.65-F](https://github.com/KMKfw/kmk_firmware/blob/master/user_keymaps/ZFR_KBD/RP2.65-F.py)