From 8b7f53940bfbcba8bf7fc1953255f09a4f711492 Mon Sep 17 00:00:00 2001 From: Thys de Wet Date: Mon, 27 Sep 2021 14:35:39 +0100 Subject: [PATCH] More tidying --- keyboards/tkw/grandiceps/config.h | 10 +- keyboards/tkw/grandiceps/pimoroni_trackball.c | 151 ------------------ keyboards/tkw/grandiceps/pimoroni_trackball.h | 35 ---- keyboards/tkw/grandiceps/readme.md | 15 ++ keyboards/tkw/grandiceps/rev2/config.h | 24 +++ keyboards/tkw/grandiceps/rev2/rules.mk | 5 + keyboards/tkw/grandiceps/rules.mk | 7 - lib/chibios | 2 +- lib/chibios-contrib | 2 +- lib/googletest | 2 +- lib/lufa | 2 +- 11 files changed, 50 insertions(+), 205 deletions(-) delete mode 100644 keyboards/tkw/grandiceps/pimoroni_trackball.c delete mode 100644 keyboards/tkw/grandiceps/pimoroni_trackball.h create mode 100644 keyboards/tkw/grandiceps/rev2/config.h create mode 100644 keyboards/tkw/grandiceps/rev2/rules.mk diff --git a/keyboards/tkw/grandiceps/config.h b/keyboards/tkw/grandiceps/config.h index ebe89d44a3b6..e51c9ab2235e 100644 --- a/keyboards/tkw/grandiceps/config.h +++ b/keyboards/tkw/grandiceps/config.h @@ -17,22 +17,17 @@ #include "config_common.h" - /* USB Device descriptor parameter */ #define VENDOR_ID 0xFEED #define PRODUCT_ID 0x7812 -#define DEVICE_VER 0x0002 +#define DEVICE_VER 0x0001 #define MANUFACTURER tkw -#define PRODUCT Grandiceps Split rev2 +#define PRODUCT Grandiceps Split /* key matrix size */ #define MATRIX_ROWS 10 #define MATRIX_COLS 6 -#define SPLIT_HAND_PIN B3 - -#define EEPROM_I2C_24LC64 - #define MATRIX_COL_PINS { B0, A7, A3, A5, A4, A2 } #define MATRIX_ROW_PINS { B12, A6, B13, B9, B8 } #define MATRIX_COL_PINS_RIGHT { B0, A7, A3, A5, A4, A2 } @@ -64,7 +59,6 @@ /* Debounce reduces chatter (unintended double-presses) - set 0 if debouncing is not needed */ #define DEBOUNCE 5 - /* disable these deprecated features by default */ #define NO_ACTION_MACRO #define NO_ACTION_FUNCTION diff --git a/keyboards/tkw/grandiceps/pimoroni_trackball.c b/keyboards/tkw/grandiceps/pimoroni_trackball.c deleted file mode 100644 index 9ae094c05ab5..000000000000 --- a/keyboards/tkw/grandiceps/pimoroni_trackball.c +++ /dev/null @@ -1,151 +0,0 @@ -/* Copyright 2020 Christopher Courtney, aka Drashna Jael're (@drashna) - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#include "pimoroni_trackball.h" -#include "i2c_master.h" - -static uint8_t scrolling = 0; -static int16_t x_offset = 0; -static int16_t y_offset = 0; -static int16_t h_offset = 0; -static int16_t v_offset = 0; -static float precisionSpeed = 1; - -#ifndef I2C_TIMEOUT -# define I2C_TIMEOUT 100 -#endif -#ifndef MOUSE_DEBOUNCE -# define MOUSE_DEBOUNCE 5 -#endif - -void trackball_set_rgbw(uint8_t red, uint8_t green, uint8_t blue, uint8_t white) { - uint8_t data[] = {0x00, red, green, blue, white}; - i2c_transmit(TRACKBALL_WRITE, data, sizeof(data), I2C_TIMEOUT); -} - -int16_t mouse_offset(uint8_t positive, uint8_t negative, int16_t scale) { - int16_t offset = (int16_t)positive - (int16_t)negative; - int16_t magnitude = (int16_t)(scale * offset * offset * precisionSpeed); - return offset < 0 ? -magnitude : magnitude; -} - -void update_member(int8_t* member, int16_t* offset) { - if (*offset > 127) { - *member = 127; - *offset -= 127; - } else if (*offset < -127) { - *member = -127; - *offset += 127; - } else { - *member = *offset; - *offset = 0; - } -} - -__attribute__((weak)) void trackball_check_click(bool pressed, report_mouse_t* mouse) { - if (pressed) { - mouse->buttons |= MOUSE_BTN1; - } else { - mouse->buttons &= ~MOUSE_BTN1; - } -} - -void trackball_register_button(bool pressed, enum mouse_buttons button) { - report_mouse_t currentReport = pointing_device_get_report(); - if (pressed) { - currentReport.buttons |= button; - } else { - currentReport.buttons &= ~button; - } - pointing_device_set_report(currentReport); -} - -float trackball_get_precision(void) { return precisionSpeed; } -void trackball_set_precision(float precision) { precisionSpeed = precision; } -bool trackball_is_scrolling(void) { return scrolling; } -void trackball_set_scrolling(bool scroll) { scrolling = scroll; } - -bool has_report_changed (report_mouse_t first, report_mouse_t second) { - return !( - (!first.buttons && first.buttons == second.buttons) && - (!first.x && first.x == second.x) && - (!first.y && first.y == second.y) && - (!first.h && first.h == second.h) && - (!first.v && first.v == second.v) ); -} - - -__attribute__((weak)) void pointing_device_init(void) { trackball_set_rgbw(0x00, 0x00, 0x00, 0x4F); } - -void pointing_device_task(void) { - static bool debounce; - static uint16_t debounce_timer; - uint8_t state[5] = {}; - if (i2c_readReg(TRACKBALL_WRITE, 0x04, state, 5, I2C_TIMEOUT) == I2C_STATUS_SUCCESS) { - if (!state[4] && !debounce) { - if (scrolling) { -#ifdef PIMORONI_TRACKBALL_INVERT_X - h_offset += mouse_offset(state[2], state[3], 1); -#else - h_offset -= mouse_offset(state[2], state[3], 1); -#endif -#ifdef PIMORONI_TRACKBALL_INVERT_Y - v_offset += mouse_offset(state[1], state[0], 1); -#else - v_offset -= mouse_offset(state[1], state[0], 1); -#endif - } else { -#ifdef PIMORONI_TRACKBALL_INVERT_X - x_offset -= mouse_offset(state[2], state[3], 5); -#else - x_offset += mouse_offset(state[2], state[3], 5); -#endif -#ifdef PIMORONI_TRACKBALL_INVERT_Y - y_offset -= mouse_offset(state[1], state[0], 5); -#else - y_offset += mouse_offset(state[1], state[0], 5); -#endif - } - } else { - if (state[4]) { - debounce = true; - debounce_timer = timer_read(); - } - } - } - - if (timer_elapsed(debounce_timer) > MOUSE_DEBOUNCE) debounce = false; - - report_mouse_t mouse = pointing_device_get_report(); - - trackball_check_click(state[4] & (1 << 7), &mouse); - -#ifndef PIMORONI_TRACKBALL_ROTATE - update_member(&mouse.x, &x_offset); - update_member(&mouse.y, &y_offset); - update_member(&mouse.h, &h_offset); - update_member(&mouse.v, &v_offset); -#else - update_member(&mouse.x, &y_offset); - update_member(&mouse.y, &x_offset); - update_member(&mouse.h, &v_offset); - update_member(&mouse.v, &h_offset); -#endif - pointing_device_set_report(mouse); - if (has_report_changed(mouse, pointing_device_get_report())) { - pointing_device_send(); - } -} diff --git a/keyboards/tkw/grandiceps/pimoroni_trackball.h b/keyboards/tkw/grandiceps/pimoroni_trackball.h deleted file mode 100644 index a85384191454..000000000000 --- a/keyboards/tkw/grandiceps/pimoroni_trackball.h +++ /dev/null @@ -1,35 +0,0 @@ -/* Copyright 2020 Christopher Courtney, aka Drashna Jael're (@drashna) - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#pragma once - -#include "quantum.h" -#include "pointing_device.h" - -#ifndef TRACKBALL_ADDRESS -# define TRACKBALL_ADDRESS 0x0A -#endif -#define TRACKBALL_WRITE ((TRACKBALL_ADDRESS << 1) | 0x00) -#define TRACKBALL_READ ((TRACKBALL_ADDRESS << 1) | 0x01) - -void trackball_set_rgbw(uint8_t red, uint8_t green, uint8_t blue, uint8_t white); -void trackball_check_click(bool pressed, report_mouse_t *mouse); -void trackball_register_button(bool pressed, enum mouse_buttons button); - -float trackball_get_precision(void); -void trackball_set_precision(float precision); -bool trackball_is_scrolling(void); -void trackball_set_scrolling(bool scroll); diff --git a/keyboards/tkw/grandiceps/readme.md b/keyboards/tkw/grandiceps/readme.md index 894f1c8d7aad..bdd4e22afa6b 100644 --- a/keyboards/tkw/grandiceps/readme.md +++ b/keyboards/tkw/grandiceps/readme.md @@ -8,12 +8,27 @@ ARM split keyboard with RGB underglow and encoders. * Hardware Supported: f411 blackpill * Hardware Availability: [grandiceps](https://github.com/vattern/grandiceps) +There are two versions of the Grandiceps. Please use the appropriate firmware for your board. + +* Revision 2 has I2C eeprom and support for a Pimoroni trackball. + Make example for this keyboard (after setting up your build environment): make tkw/grandiceps:default + make tkw/grandiceps/rev2:default + Flashing example for this keyboard: make tkw/grandiceps:default:flash + make tkw/grandiceps/rev2:default:flash See the [build environment setup](https://docs.qmk.fm/#/getting_started_build_tools) and the [make instructions](https://docs.qmk.fm/#/getting_started_make_guide) for more information. Brand new to QMK? Start with our [Complete Newbs Guide](https://docs.qmk.fm/#/newbs). + +## Bootloader + +Enter the bootloader in 3 ways: + +* **Bootmagic reset**: Hold down the key at (0,0) in the matrix (usually the top left key or Escape) and plug in the keyboard +* **Physical reset button**: Briefly press the button on the back of the PCB - some may have pads you must short instead +* **Keycode in layout**: Press the key mapped to `RESET` if it is available diff --git a/keyboards/tkw/grandiceps/rev2/config.h b/keyboards/tkw/grandiceps/rev2/config.h new file mode 100644 index 000000000000..98b762087e84 --- /dev/null +++ b/keyboards/tkw/grandiceps/rev2/config.h @@ -0,0 +1,24 @@ +/* Copyright 2021 Thys de Wet + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +#pragma once + +#undef DEVICE_VER +#define DEVICE_VER 0x0002 +#undef PRODUCT +#define PRODUCT Grandiceps Split rev2 + +#define SPLIT_HAND_PIN B3 +#define EEPROM_I2C_24LC64 diff --git a/keyboards/tkw/grandiceps/rev2/rules.mk b/keyboards/tkw/grandiceps/rev2/rules.mk new file mode 100644 index 000000000000..c8f3f05bdd78 --- /dev/null +++ b/keyboards/tkw/grandiceps/rev2/rules.mk @@ -0,0 +1,5 @@ +EEPROM_DRIVER = i2c + +POINTING_DEVICE_ENABLE = yes +SRC += drivers/sensors/pimoroni_trackball.c +QUANTUM_LIB_SRC += i2c_master.c diff --git a/keyboards/tkw/grandiceps/rules.mk b/keyboards/tkw/grandiceps/rules.mk index 521443788df5..08a12d114efe 100644 --- a/keyboards/tkw/grandiceps/rules.mk +++ b/keyboards/tkw/grandiceps/rules.mk @@ -28,10 +28,3 @@ OLED_ENABLE = yes OLED_DRIVER = SSD1306 WS2812_DRIVER = pwm OPT_DEFS += -DSTM32_DMA_REQUIRED=TRUE - -EEPROM_DRIVER = i2c - -POINTING_DEVICE_ENABLE = yes -OPT_DEFS += -DPIMORONI_TRACKBALL_ENABLE -SRC += pimoroni_trackball.c -QUANTUM_LIB_SRC += i2c_master.c diff --git a/lib/chibios b/lib/chibios index ffe54d63cb10..413e39c5681d 160000 --- a/lib/chibios +++ b/lib/chibios @@ -1 +1 @@ -Subproject commit ffe54d63cb10a355add318f8e922e39f1c3d4bfd +Subproject commit 413e39c5681d181720440f2a8b7391f581788d7b diff --git a/lib/chibios-contrib b/lib/chibios-contrib index 61baa6b03613..4568901a91e9 160000 --- a/lib/chibios-contrib +++ b/lib/chibios-contrib @@ -1 +1 @@ -Subproject commit 61baa6b036138c155f7cfc5646d833d9423f3243 +Subproject commit 4568901a91e9bef78ea96a7a83e8150fe1f7353a diff --git a/lib/googletest b/lib/googletest index ec44c6c1675c..e2239ee6043f 160000 --- a/lib/googletest +++ b/lib/googletest @@ -1 +1 @@ -Subproject commit ec44c6c1675c25b9827aacd08c02433cccde7780 +Subproject commit e2239ee6043f73722e7aa812a459f54a28552929 diff --git a/lib/lufa b/lib/lufa index ce10f7642b04..19a5d533f02a 160000 --- a/lib/lufa +++ b/lib/lufa @@ -1 +1 @@ -Subproject commit ce10f7642b0459e409839b23cc91498945119b4d +Subproject commit 19a5d533f02a7b46eeadca99cc9699659cef7a60