Pimoroni Trackball Integration
Adding the Pimoroni trackball to QMK-compatible keyboards
[ Updated 09-29-21 | Created 09-29-21 ]
Table of Contents
Pro Micro
Two SparkFun Qwiic Pro Micro C will be used.
The trackball will connect to the master half of the board. The 5V and VCC pads must be bridged.
The slave half must have the 5V pad broken which can be carefully cut with an Xacto knife or similar.
In order to flash the left half, the RAW and 5V pins must be bridged. A trace wire can be soldered to the RAW pin (pictured above) to conveniently hold against the 5V pin when flashing. Ensure the wire does not make any connections when powered on and in use.
Trackball
One Pimoroni Trackball Breakout will be used. It will connect to the Pro Micro C via the Qwiic Cable Kit. All that is necessary is one Quiic connection cable, not the entire kit, but it’s nice to have extra. The trackball rests in place of the OLED display via a 3D-printed cover.
The Quiic cable is soldered to the bottom of the Pimoroni.
GND | INT | SCL | SDA | 3-5V |
---|---|---|---|---|
BLACK | (NONE) | YELLOW | BLUE | RED |
Cut the wires short enough to prevent them from bunching up under the cover.
Place a layer of electrical tape between the microcontroller and the trackball unit to prevent the screws and nuts from contacting the pins.
Presto!
Firmware
config.h
#define EE_HANDS
#define PIMORONI_TRACKBALL_ROTATE
#define PIMORONI_TRACKBALL_INVERT_X
rules.mk
PIMORONI_TRACKBALL_ENABLE = yes
ifeq ($(strip $(PIMORONI_TRACKBALL_ENABLE)), yes)
POINTING_DEVICE_ENABLE = yes
SRC += drivers/sensors/pimoroni_trackball.c
QUANTUM_LIB_SRC += i2c_master.c
endif
keymap.c
#ifdef PIMORONI_TRACKBALL_ENABLE
#include "drivers/sensors/pimoroni_trackball.h"
#endif
enum trackball_keycodes {
BALL_SCR
};
uint8_t MOUSE_BUTTONS;
#ifdef PIMORONI_TRACKBALL_ENABLE
void pointing_device_task() {
report_mouse_t mouse_report = pointing_device_get_report();
mouse_report.buttons = MOUSE_BUTTONS;
if (is_keyboard_master()) {
process_mouse(&mouse_report);
}
case BALL_SCR:
if(record->event.pressed){
trackball_set_scrolling(true);
} else{
trackball_set_scrolling(false);
}
pointing_device_set_report(mouse_report);
pointing_device_send();
}
#endif
BALL_SCR (scrolling in general) is not working for me.
Map KC_BTN(1-5) for mouse buttons.
Flashing
Each hand will be flashed with an indivdual EEPROM. The Pro Micro C uses the Caterina bootloader and will be can be flashed using avrdude.
In the qmk_firmware
directory:
make crkbd:<keymap>:avrdude-split-<hand>
where <keymap>
is the name of the keymap and <hand>
is the hand being flashed (left, right).
To put the Pro Micro C into a writeable state, the reset button must be pushed quickly twice, not once.
Before flashing the left hand, bridge the RAW and 5V pins (see above).
Resources
Below are the guides I referenced and servers I asked in to get my trackball working.
foureight84 - sofle-keyboard-pimoroni
greyhatmiddleman - crkbd-pimoroni-trackball
QMK Discord - #help-firmare, #help-hardware
Boardsource Discord - #firmware
~~~
-medwa
Tagged: Keyboards