Quickpin initial support

This commit is contained in:
Kyle Brown 2022-10-01 17:21:40 -07:00 committed by xs5871
parent 03c8a61ed0
commit 9431ce5ec1
8 changed files with 222 additions and 42 deletions

View File

@ -1,12 +1,12 @@
import board
from kmk.kmk_keyboard import KMKKeyboard as _KMKKeyboard
from kmk.quickpin.pro_micro.boardsource_blok import pinout as pins
from kmk.scanners import DiodeOrientation
class KMKKeyboard(_KMKKeyboard):
row_pins = (board.P1_15, board.P0_02, board.P0_29)
col_pins = (board.P0_09, board.P0_10, board.P1_11, board.P1_13)
row_pins = (pins[16], pins[17], pins[18])
col_pins = (pins[12], pins[13], pins[14], pins[15])
diode_orientation = DiodeOrientation.COLUMNS
i2c = board.I2C
powersave_pin = board.P0_13

View File

@ -1,30 +1,35 @@
import board
from kmk.kmk_keyboard import KMKKeyboard as _KMKKeyboard
from kmk.quickpin.pro_micro.boardsource_blok import pinout as pins
from kmk.scanners import DiodeOrientation
class KMKKeyboard(_KMKKeyboard):
col_pins = (
board.P0_31,
board.P0_29,
board.P0_02,
board.P1_15,
board.P1_13,
board.P1_11,
pins[19],
pins[18],
pins[17],
pins[16],
pins[15],
pins[14],
)
row_pins = (
pins[6],
pins[7],
pins[8],
pins[9],
)
row_pins = (board.P0_22, board.P0_24, board.P1_00, board.P0_11)
diode_orientation = DiodeOrientation.COLUMNS
data_pin = board.P0_08
rgb_pixel_pin = board.P0_06
data_pin = pins[1]
rgb_pixel_pin = pins[0]
i2c = board.I2C
powersave_pin = board.P0_13
# flake8: noqa
# fmt: off
coord_mapping = [
0, 1, 2, 3, 4, 5, 29, 28, 27, 26, 25, 24,
6, 7, 8, 9, 10, 11, 35, 34, 33, 32, 31, 30,
12, 13, 14, 15, 16, 17, 41, 40, 39, 38, 37, 36,
21, 22, 23, 47, 46, 45,
]

View File

@ -1,28 +0,0 @@
import board
from kmk.kmk_keyboard import KMKKeyboard as _KMKKeyboard
from kmk.scanners import DiodeOrientation
class KMKKeyboard(_KMKKeyboard):
col_pins = (
board.A3,
board.A2,
board.A1,
board.A0,
board.SCK,
board.MISO,
)
row_pins = (board.D4, board.D5, board.D6, board.D7)
diode_orientation = DiodeOrientation.COLUMNS
data_pin = board.RX
rgb_pixel_pin = board.D0
i2c = board.I2C
# flake8: noqa
coord_mapping = [
0, 1, 2, 3, 4, 5, 29, 28, 27, 26, 25, 24,
6, 7, 8, 9, 10, 11, 35, 34, 33, 32, 31, 30,
12, 13, 14, 15, 16, 17, 41, 40, 39, 38, 37, 36,
21, 22, 23, 47, 46, 45,
]

99
docs/quickpin.md Normal file
View File

@ -0,0 +1,99 @@
# Quickpin
Quickpin helps devs quickly translate pinouts between boards of similar pinouts.
This lets you write a single `kb.py` that can be swapped between
microcontrollers with only a single line change and less mistakes.
## Supported footprints/boards
- Pro micro footprint
- Sparkfun Pro micro RP2040
- Boardsource Blok
- Nice!nano
## Example
In this example, we are converting a Boardsource 3x4 from a hard pinned
nice!nano to a controller agnostic pinout.
```python
row_pins = (board.P1_15, board.P0_02, board.P0_29)
col_pins = (board.P0_09, board.P0_10, board.P1_11, board.P1_13)
```
Converts to the following. Notice that `nice_nano` can be subbed for
`boardsource_blok` or `sparkfun_promicro_rp2040`, or any other board sharing
this pinout.
```python
from kmk.quickpin.pro_micro.nice_nano import pinout as pins
row_pins = (pins[16], pins[17], pins[18])
col_pins = (pins[12], pins[13], pins[14], pins[15])
```
## Porting from AVR pro micro
An additional added convenience for translating from other firmwares with AVR
pro micros has also been added to speed up porting.
```python
from kmk.quickpin.pro_micro.nice_nano import pinout as pins
from kmk.quickpin.pro_Micro.avr_promicro import avr
row_pins = (
pins[avr['F7']],
pins[avr['F6']],
pins[avr['F5']],
)
col_pins = (
pins[avr['B6']],
pins[avr['B2']],
pins[avr['B3']],
pins[avr['B1']],
)
```
## Adding boards to quickpin support
Quickpin format is simply a list of pins in order of all through hole pins,
going anticlockwise starting at the top left. The orientation should be with the
chips facing toward you, with USB facing the top. If this isn't appliable, or
otherwise is not true, it should be stated in a comment in the file. Any pin
that is not addressable in software should be left as `None` to fill the space,
and align pins correctly for all boards. All boards should be stored in
`kmk/quickpin/<footprint>/boardname.py`
Pro Micro RP2040 shown as an example
```python
import board
pinout = [
board.TX,
board.RX,
None, # GND
None, # GND
board.D2,
board.D3,
board.D4,
board.D5,
board.D6,
board.D7,
board.D8,
board.D9,
board.D21,
board.MOSI,
board.MISO,
board.SCK,
board.D26,
board.D27,
board.D28,
board.D29,
None, # 3.3v
None, # RST
None, # GND
None, # RAW
]
```

View File

@ -0,0 +1,20 @@
translate = {
'D3': 0,
'D2': 1,
'D1': 4,
'D0': 5,
'D4': 6,
'C6': 7,
'D7': 8,
'E6': 9,
'B4': 10,
'B5': 11,
'B6': 12,
'B2': 13,
'B3': 14,
'B1': 15,
'F7': 16,
'F6': 17,
'F5': 18,
'F4': 19,
}

View File

@ -0,0 +1,28 @@
import board
pinout = [
board.TX,
board.RX,
None, # GND
None, # GND
board.SDA,
board.SCL,
board.GP04,
board.GP05,
board.GP06,
board.GP07,
board.GP08,
board.GP09,
board.GP21,
board.GP23,
board.GP20,
board.GP22,
board.GP26,
board.GP27,
board.GP28,
board.GP29,
None, # 3.3v
None, # RST
None, # GND
None, # RAW
]

View File

@ -0,0 +1,28 @@
import board
pinout = [
board.TX,
board.RX,
None, # GND
None, # GND
board.SDA,
board.SCL,
board.P0_22,
board.P0_24,
board.P1_00,
board.P0_11,
board.P1_04,
board.P1_06,
board.P0_09,
board.P0_10,
board.P1_11,
board.P1_13,
board.P1_15,
board.P0_02,
board.P0_29,
board.P0_31,
None, # 3.3v
None, # RST
None, # GND
None, # Battery+
]

View File

@ -0,0 +1,28 @@
import board
pinout = [
board.TX,
board.RX,
None, # GND
None, # GND
board.D2,
board.D3,
board.D4,
board.D5,
board.D6,
board.D7,
board.D8,
board.D9,
board.D21,
board.MOSI,
board.MISO,
board.SCK,
board.D26,
board.D27,
board.D28,
board.D29,
None, # 3.3v
None, # RST
None, # GND
None, # RAW
]