Hackster is hosting Hackster Holidays, Ep. 6: Livestream & Giveaway Drawing. Watch previous episodes or stream live on Monday!Stream Hackster Holidays, Ep. 6 on Monday!
yswallow
Published © GPL3+

Kidoairaku Swallowtail: a cute butterfly-shaped keyboard

A butterfly-shaped, shining, 54key keyboard challenging to Seeed Studio XIAO pins limitation.

IntermediateShowcase (no instructions)3 days1,880
Kidoairaku Swallowtail: a cute butterfly-shaped keyboard

Things used in this project

Hardware components

Seeed XIAO RP2040
Seeed Studio Seeed XIAO RP2040
×1
1N4148W
×63
SK6803MINI-E
×162
Kailh Choc Silver Crystal
×54
MoErgo POM MCC-Profile Keycap
×54
MOSFET Transistor, P Channel
MOSFET Transistor, P Channel
To control powering to LEDs
×1
Logic Level FET N-Channel
Logic Level FET N-Channel
To control powering LEDs
×1
Resistor 10k ohm
Resistor 10k ohm
To control powering LEDs
×2

Software apps and online services

KiCad
KiCad
PRK Firmware

Story

Read more

Custom parts and enclosures

PCB

Schematics

Schematic

Code

keymap.rb

Ruby
Keyboard definition for PRK Firmware
np_en = 26
np = 27
p1 = 28
p2 = 29
p3 = 6
p4 = 7
p5 = 0
p6 = 1
p7 = 2
p8 = 4

kbd = Keyboard.new

kbd.init_matrix_pins(
[
    [     nil, [p5,p7], [p5,p6], [p5,p4], [p5,p3], [p5,p2],     nil,     nil, [p1,p3], [p1,p4], [p1,p5], [p1,p6], [p1,p7],     nil ],
    [ [p6,p8], [p6,p7], [p6,p5], [p6,p4], [p6,p3], [p6,p2],     nil,     nil, [p2,p3], [p2,p4], [p2,p5], [p2,p6], [p2,p7], [p2,p8] ],
    [ [p7,p8], [p7,p6], [p7,p5], [p7,p4], [p7,p3], [p7,p2],     nil,     nil, [p3,p2], [p3,p4], [p3,p5], [p3,p6], [p3,p7], [p3,p8] ],
    [ [p8,p7], [p8,p6], [p8,p5], [p8,p4], [p8,p3], [p8,p2], [p5,p1], [p1,p2], [p4,p2], [p4,p3], [p4,p5], [p4,p6], [p4,p7], [p4,p8] ],
    [     nil,     nil,     nil,     nil, [p8,p1], [p7,p1], [p6,p1], [p2,p1], [p3,p1], [p4,p1],     nil,     nil,     nil,    nil  ]
]
)


kbd.add_layer :default, %i| 
        KC_Q KC_W KC_E KC_R KC_T                    KC_Y KC_U KC_I KC_O KC_P
KC_ESC  KC_Q KC_W KC_E KC_R KC_G                    KC_H KC_U KC_I KC_O KC_P KC_RALT
KC_LCTL KC_A KC_S KC_D KC_F KC_B                    KC_N KC_J KC_K KC_L KC_MINUS KC_RCTL
KC_LSFT KC_Z KC_X KC_C KC_V KC_B KC_ESC  KC_BSPC KC_N KC_M KC_COMM KC_DOT KC_DEL KC_RSFT
             LOWER KC_TAB KC_SPACE    KC_ENTER KC_BSPC RAISE
|

kbd.add_layer :lower, %i|
        KC_F1   KC_F2 KC_F3   KC_F4   KC_F5                 KC_F8   KC_F9 KC_F10   KC_F11  KC_F12
KC_LALT KC_EXLM KC_AT KC_HASH KC_DLR  KC_PERC               KC_CIRC KC_AMPR KC_ASTER KC_LPRN KC_RPRN KC_RALT
KC_LCTL KC_1    KC_2  KC_3    KC_4    KC_5                  KC_6    KC_7    KC_8     KC_9    KC_0    KC_RCTL
KC_LSFT KC_F2 KC_HOME KC_PGDN KC_PGUP KC_END KC_F6 KC_HOME KC_LEFT KC_DOWN KC_UP   KC_RIGHT KC_END  KC_RSFT
                        LOWER KC_LGUI KC_SPACE    KC_NO  KC_DEL  KC_RGUI
|

kbd.add_layer :raise, %i|
        KC_F1 KC_F2 KC_F3    KC_F4    KC_F5                  KC_NO   KC_NO     KC_INS  KC_NO   KC_PSCREEN
KC_LALT KC_NO KC_NO KC_TILD  KC_PLUS  KC_LCBR                KC_RCBR KC_COLON  KC_DQUO KC_QUES KC_PIPE KC_RALT
KC_LCTL KC_NO KC_NO KC_GRAVE KC_EQUAL KC_LBRC                KC_RBRC KC_SCOLON KC_QUOT KC_SLSH KC_BSLS KC_RCTL
KC_LSFT KC_F6 KC_F7 KC_F8    KC_F9    KC_F10 RGB_VAI    KC_NO KC_F11   KC_F12     KC_NO   KC_NO   KC_NO   KC_RSFT
                             KC_LGUI  KC_NO RGB_VAD    KC_ENTER KC_DEL RAISE 
|


kbd.define_mode_key :CTRL_ESC, [:KC_ESC, :KC_LCTL, 200, nil]
#kbd.define_mode_key :ARROW_TAB, [:KC_TAB, :arrow, 200, nil]
kbd.define_mode_key :LOWER, [nil, :lower, nil, nil]
kbd.define_mode_key :RAISE, [nil, :raise, nil, nil]
kbd.define_mode_key :BOOTSEL, [ Proc.new { kbd.bootsel! }, nil, 200, nil]

gpio_init(np_en)
gpio_set_dir(np_en, Keyboard::GPIO_OUT_HI)

rgb = RGB.new(np,162,0,false)

rgb_matrix = [ [97, 41], [124, 41], 
    [24, 0], [32, 1], [41, 0], [48, 1], [57, 0], [65, 0], [157, 1], [164, 0], [173, 1], [180, 0], [190, 1], [197, 0], 
    [31, 7], [48, 7], [64, 6], [71, 7], [78, 8], [143, 8], [150, 7], [165, 5], [182, 5], [200, 5], 
    [6, 8], [13, 9], [22, 11], [29, 11], [37, 10], [45, 11], [54, 10], [61, 11], [78, 13], [85, 14], [93, 16], [129, 16], [136, 15], [153, 13], [160, 11], [168, 10], [176, 11], [184, 10], [193, 12], [200, 10], [209, 9], [215, 8], 
    [12, 15], [28, 18], [44, 17], [60, 17], [68, 17], [75, 18], [92, 21], [138, 20], [146, 18], [153, 18], [169, 15], [185, 15], [201, 16], [217, 13], 
    [3, 18], [11, 19], [18, 21], [26, 22], [34, 21], [42, 21], [50, 20], [58, 21], [75, 24], [82, 25], [89, 26], [132, 26], [139, 25], [156, 23], [163, 22], [170, 20], [179, 21], [186, 21], [196, 22], [203, 21], [212, 20], [219, 18], 
    [9, 25], [25, 27], [41, 27], [57, 27], [66, 28], [73, 29], [89, 31], [141, 30], [149, 29], [156, 28], [173, 26], [189, 26], [205, 26], [220, 23], 
    [0, 29], [7, 30], [15, 31], [23, 32], [31, 31], [38, 31], [47, 31], [55, 31], [72, 34], [79, 35], [86, 36], [135, 36], [142, 35], [159, 33], [166, 32], [174, 31], [182, 31], [190, 31], [199, 32], [206, 31], [214, 30], [222, 29], 
    [6, 36], [22, 38], [38, 37], [54, 37], [62, 38], [70, 39], [85, 42], [145, 41], [152, 39], [159, 38], [175, 36], [192, 36], [209, 36], [224, 34], 
    [68, 45], [76, 45], [83, 46], [91, 48], [98, 48], [123, 49], [130, 47], [138, 46], [145, 45], [161, 43], 
    [82, 52], [98, 54], [132, 53], [147, 50], 
    [57, 54], [64, 54], [72, 56], [80, 57], [88, 59], [96, 59], [126, 59], [133, 59], [141, 57], [149, 56], [157, 55], [164, 54], 
    [63, 61], [79, 63], [135, 63], [151, 61] 
]

rgb.plot_matrix(rgb_matrix)
rgb.effect = :circle
rgb.value = 24

kbd.append rgb

kbd.start!

Credits

yswallow

yswallow

1 project • 3 followers

Comments