picoruby / prk_firmware

A keyboard firmware platform in PicoRuby
MIT License
573 stars 53 forks source link

Keyball61" with split keyboard and Duplex Matrix key scanning. #178

Closed nuovotaka closed 3 months ago

nuovotaka commented 5 months ago

Operation has been verified with an authorized microcontroller. At that time, all keys were responsive and recognized.

When I described the following in PRK Firmware and checked it, the two rows from the bottom are not recognized on the left hand key (USB connection side). On the right hand side, the third row from the bottom is not recognized. The circuits of the right and left hands are the same, but the circuit of the part with the trackball is different from that of the left hand side.

For some reason, all keys placed on the left hand side (ex. The number 1 to 1) do not respond. They all return the key placed on the right hand side as a response.

Does the firmware not yet support keyboards with different schematics on the left and right?

Below is the code.

# Initialize a Keyboard
kbd = Keyboard.new

# Init split?
kbd.split = true
kbd.split_style = :right_side_flipped_split

# Ruby is so good that you can define your method in keymap.rb
class SPI
  def pmw3360dm_write(*values)
    GPIO.write_at(21, 0)
    write(*values)
    Machine.delay_us 20
    GPIO.write_at(21, 1)
  end
end

# Initialize GPIO pin
r0 = 4
r1 = 5
r2 = 6
r3 = 7
r4 = 8
c0 = 29
c1 = 28
c2 = 27
c3 = 26

# Init duplex matrix
kbd.init_matrix_pins(
  [
    [ [r0, c0], [r0, c1], [r0, c2], [c0, r0], [c1, r0], [c2, r0],      nil,     nil, [c2, r0], [c1, r0], [c0, r0], [r0, c2], [r0, c1], [r0, c0], ],
    [ [r1, c0], [r1, c1], [r1, c2], [c0, r1], [c1, r1], [c2, r1],      nil,      nil, [c2, r1], [c1, r1], [c0, r1], [r1, c2], [r1, c1], [r1, c0], ],
    [ [r2, c0], [r2, c1], [r2, c2], [c0, r2], [c1, r2], [c2, r2],      nil,      nil, [c2, r2], [c1, r2], [c0, r2], [r2, c2], [r2, c1], [r2, c0], ],
    [ [r3, c0], [r3, c1], [r3, c2], [c0, r3], [c1, r3], [c2, r3], [c3, r3], [c3, r3], [c2, r3], [c1, r3], [c0, r3], [r3, c2], [r3, c1], [r3, c0], ],
    [ [r4, c0], [r4, c1], [r4, c2], [c0, r4], [c1, r4], [c2, r4], [c3, r4], [c3, r4], [c2, r4],      nil,      nil,      nil, [r4, c1], [r4, c0], ],
  ]
)

kbd.add_layer :default, %i(
  KC_GRAVE KC_1    KC_2    KC_3    KC_4    KC_5                     KC_6    KC_7    KC_8    KC_9    KC_0    KC_DEL 
  KC_ESC   KC_Q    KC_W    KC_E    KC_R    KC_T                     KC_Y    KC_U    KC_I    KC_O    KC_P    KC_BSLS
  KC_TAB   KC_A    KC_S    KC_D    KC_F    KC_G                     KC_H    KC_J    KC_K    KC_L    KC_SCLN KC_QUOT
  KC_CAPS  KC_Z    KC_X    KC_C    KC_V    KC_B    KC_LBRC  KC_RBRC KC_N    KC_M    KC_COMM KC_DOT  KC_SLSH KC_RSFT
  KC_LSFT  KC_LCTL KC_LALT KC_LGUI Layer1  KC_SPC  Layer2   KC_BSPC KC_ENT                          KE_RALT KC_RGUI
)

kbd.add_layer :Layer1, %i(
  KC_GRAVE KC_F1   KC_F2   KC_F3   KC_F4   KC_F5                       KC_F6      KC_F7      KC_F8     KC_F9      KC_F10     KC_F11 
  KC_ESC   KC_Q    KC_KP_7 KC_KP_8 KC_KP_9 KC_KP_SLASH                 KC_Y       KC_WH_L    KE_WH_U   KE_WH_R    KC_MINS    KC_F12 
  KC_TAB   KC_A    KC_KP_4 KC_KP_5 KC_KP_6 KC_KP_MINUS                 KC_PGUP    KC_MS_BTN1 KC_WH_D   KC_MS_BTN2 KC_MS_BTN3 KC_QUOT
  KC_CAPS  KC_Z    KC_KP_1 KC_KP_2 KC_KP_3 KC_KP_EQUAL KC_LBRC KC_RBRC KC_PGDN    KC_M       KC_COMM   KC_DOT     KC_KP_SLSH KC_RSFT
  KC_LSFT  KC_LCTL KC_KP_0 KC_KP_DOT Layer1  KC_SPC    Layer2  KC_BSPC KC_ENT                                     KC_RALT    KC_RGUI
)
kbd.add_layer :Layer2, %i(
  RGB_TOG  KC_1    KC_2    KC_3    KC_4    KC_5                     KC_6    KC_7    KC_8     KC_9     KC_0    KC_DEL 
  RGB_MOD  RGB_HUI RGB_SAI RGB_VAI KC_R    KC_T                     KC_Y    KC_U    KC_I     KC_O     KC_P    KC_BSLS
  RGB_RMOD RGB_HUD RGB_SAD RGB_VAD KC_F    KC_G                     KC_H    KC_J    KC_K     KC_L     KC_SCLN KC_QUOT
  KC_CAPS  KC_Z    KC_X    KC_C    KC_V    KC_B     BOOTSEL BOOTSEL KC_HOME KC_PGDN KC_PGUP  KC_END   KC_SLSH KC_RSFT
  KC_LSFT  KC_LCTL KC_LEFT KC_DOWN KC_UP   KC_RIGHT Layer2  KC_BSPC KC_ENT                            KC_RALT KC_RGUI
)

kbd.define_mode_key :Layer1, [ :KC_NO, :Layer1, nil, nil ]
kbd.define_mode_key :Layer2, [ :KC_NO, :Layer2, nil, nil ]
kbd.define_mode_key :BOOTSEL, [ Proc.new { kbd.bootsel! }, nil, 200, nil]

kbd.start!