From eba3d68394ba7bdd15836c0f4f4bb3c44b4e1f91 Mon Sep 17 00:00:00 2001 From: ploopyco <54917504+ploopyco@users.noreply.github.com> Date: Mon, 21 Jun 2021 15:59:56 -0400 Subject: [PATCH] Fixes for Ploopy devices (#13144) Co-authored-by: Drashna Jael're --- keyboards/ploopyco/adns5050.c | 2 +- keyboards/ploopyco/trackball/readme.md | 2 +- keyboards/ploopyco/trackball_mini/readme.md | 10 ++--- .../ploopyco/trackball_mini/rev1_001/config.h | 2 +- .../ploopyco/trackball_mini/rev1_002/config.h | 40 +++++++++++++++++++ .../trackball_mini/rev1_002/readme.md | 1 + .../trackball_mini/rev1_002/rev1_002.h | 22 ++++++++++ .../ploopyco/trackball_mini/rev1_002/rules.mk | 0 .../ploopyco/trackball_mini/trackball_mini.c | 38 ++++++++++-------- .../ploopyco/trackball_nano/trackball_nano.c | 27 +++++++++---- 10 files changed, 111 insertions(+), 33 deletions(-) create mode 100644 keyboards/ploopyco/trackball_mini/rev1_002/config.h create mode 100644 keyboards/ploopyco/trackball_mini/rev1_002/readme.md create mode 100644 keyboards/ploopyco/trackball_mini/rev1_002/rev1_002.h create mode 100644 keyboards/ploopyco/trackball_mini/rev1_002/rules.mk diff --git a/keyboards/ploopyco/adns5050.c b/keyboards/ploopyco/adns5050.c index fcf2f213e..e12e56f20 100644 --- a/keyboards/ploopyco/adns5050.c +++ b/keyboards/ploopyco/adns5050.c @@ -142,7 +142,7 @@ uint8_t adns_read_reg(uint8_t reg_addr) { void adns_write_reg(uint8_t reg_addr, uint8_t data) { adns_cs_select(); - adns_serial_write(reg_addr); + adns_serial_write( 0b10000000 | reg_addr ); adns_serial_write(data); adns_cs_deselect(); } diff --git a/keyboards/ploopyco/trackball/readme.md b/keyboards/ploopyco/trackball/readme.md index f34bbac30..7792c0cc5 100644 --- a/keyboards/ploopyco/trackball/readme.md +++ b/keyboards/ploopyco/trackball/readme.md @@ -19,7 +19,7 @@ See the [build environment setup](https://docs.qmk.fm/#/getting_started_build_to ## Revisions -There are two main revisions for the PloopyCo Tracball, everything up to 1.004, and 1.005. +There are two main revisions for the PloopyCo Tracball, everything up to 1.004, and 1.005-1.006. In the 1.005 revision, button for was changed from pin B5 to B6, and the debug LED pin was changed from F7 to B5. diff --git a/keyboards/ploopyco/trackball_mini/readme.md b/keyboards/ploopyco/trackball_mini/readme.md index 8b8482a38..1858efb6e 100644 --- a/keyboards/ploopyco/trackball_mini/readme.md +++ b/keyboards/ploopyco/trackball_mini/readme.md @@ -12,8 +12,8 @@ It's a DIY, QMK Powered Trackball...Mini! Make example for this trackball (after setting up your build environment): - make ploopyco/trackball_mini/rev1_001:default:flash - make ploopyco/trackball_mini/rev1_001:via:flash + make ploopyco/trackball_mini/rev1_002:default:flash + make ploopyco/trackball_mini/rev1_002:via:flash To jump to the bootloader, hold down "Button 4" (immediate right of the ball) @@ -51,13 +51,13 @@ This should allow you to more heavily customize the behavior. Alternatively, the `process_wheel` and `process_mouse` functions can both be replaced too, to allow for even more functionality. -Additionally, you can change the DPI/CPI or speed of the trackball by calling `adns_set_cpi` at any time. Additionally, there is a `DPI_CONFIG` macro that will cycle through an array of options for the DPI. This is set to 375, 750, and 1375, but can be changed. 750 is the default. +Additionally, you can change the DPI/CPI or speed of the trackball by calling `adns_set_cpi` at any time. Additionally, there is a `DPI_CONFIG` macro that will cycle through an array of options for the DPI. This is set to 375, 750, and 1375, but can be changed. 1375 is the default. To configure/set your own array, there are two defines to use, `PLOOPY_DPI_OPTIONS` to set the array, and `PLOOPY_DPI_DEFAULT`. ```c #define PLOOPY_DPI_OPTIONS { CPI375, CPI750, CPI1375} -#define PLOOPY_DPI_DEFAULT 1 +#define PLOOPY_DPI_DEFAULT 2 ``` The `PLOOPY_DPI_OPTIONS` array sets the values that you want to be able to cycle through, and the order they are in. The "default" define lets the firmware know which of these options is the default and should be loaded by default. @@ -72,4 +72,4 @@ When flashing the bootloader, use the following fuse settings: |----------|-------------| | Low | `0x5E` | | High | `0x99` | -| Extended | `0xC3` | \ No newline at end of file +| Extended | `0xC3` | diff --git a/keyboards/ploopyco/trackball_mini/rev1_001/config.h b/keyboards/ploopyco/trackball_mini/rev1_001/config.h index 3f5941dec..06720b8fd 100644 --- a/keyboards/ploopyco/trackball_mini/rev1_001/config.h +++ b/keyboards/ploopyco/trackball_mini/rev1_001/config.h @@ -31,7 +31,7 @@ */ #define DIRECT_PINS \ { \ - { D4, D2, E6, D7, B6 } \ + { D4, D2, E6, B6, D7 } \ } // These pins are not broken out, and cannot be used normally. diff --git a/keyboards/ploopyco/trackball_mini/rev1_002/config.h b/keyboards/ploopyco/trackball_mini/rev1_002/config.h new file mode 100644 index 000000000..06720b8fd --- /dev/null +++ b/keyboards/ploopyco/trackball_mini/rev1_002/config.h @@ -0,0 +1,40 @@ +/* Copyright 2021 Colin Lam (Ploopy Corporation) + * Copyright 2020 Christopher Courtney, aka Drashna Jael're (@drashna) + * Copyright 2019 Sunjun Kim + * Copyright 2019 Hiroyuki Okada + * + * 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 + +/* + * Keyboard Matrix Assignments + * + * Change this to how you wired your keyboard + * COLS: AVR pins used for columns, left to right + * ROWS: AVR pins used for rows, top to bottom + * DIODE_DIRECTION: COL2ROW = COL = Anode (+), ROW = Cathode (-, marked on diode) + * ROW2COL = ROW = Anode (+), COL = Cathode (-, marked on diode) + * + */ +#define DIRECT_PINS \ + { \ + { D4, D2, E6, B6, D7 } \ + } + +// These pins are not broken out, and cannot be used normally. +// They are set as output and pulled high, by default +#define UNUSED_PINS \ + { B5, C7, D0, D1, D3, D5, D6, F1, F3, F5, F6, F7 } diff --git a/keyboards/ploopyco/trackball_mini/rev1_002/readme.md b/keyboards/ploopyco/trackball_mini/rev1_002/readme.md new file mode 100644 index 000000000..e8a5a918e --- /dev/null +++ b/keyboards/ploopyco/trackball_mini/rev1_002/readme.md @@ -0,0 +1 @@ +See the main readme for more details. This is just here for when future revisions are released. diff --git a/keyboards/ploopyco/trackball_mini/rev1_002/rev1_002.h b/keyboards/ploopyco/trackball_mini/rev1_002/rev1_002.h new file mode 100644 index 000000000..4f34e17dd --- /dev/null +++ b/keyboards/ploopyco/trackball_mini/rev1_002/rev1_002.h @@ -0,0 +1,22 @@ +/* Copyright 2021 Colin Lam (Ploopy Corporation) + * Copyright 2020 Christopher Courtney, aka Drashna Jael're (@drashna) + * Copyright 2019 Sunjun Kim + * Copyright 2019 Hiroyuki Okada + * + * 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 "trackball_mini.h" diff --git a/keyboards/ploopyco/trackball_mini/rev1_002/rules.mk b/keyboards/ploopyco/trackball_mini/rev1_002/rules.mk new file mode 100644 index 000000000..e69de29bb diff --git a/keyboards/ploopyco/trackball_mini/trackball_mini.c b/keyboards/ploopyco/trackball_mini/trackball_mini.c index d6eb61a2b..996c00b22 100644 --- a/keyboards/ploopyco/trackball_mini/trackball_mini.c +++ b/keyboards/ploopyco/trackball_mini/trackball_mini.c @@ -18,6 +18,8 @@ */ #include "trackball_mini.h" +#include "wait.h" +#include "debug.h" #ifndef OPT_DEBOUNCE # define OPT_DEBOUNCE 5 // (ms) Time between scroll events @@ -35,16 +37,8 @@ # define OPT_SCALE 1 // Multiplier for wheel #endif -#ifndef PLOOPY_DPI_OPTIONS -# define PLOOPY_DPI_OPTIONS { CPI375, CPI750, CPI1375 } -# ifndef PLOOPY_DPI_DEFAULT -# define PLOOPY_DPI_DEFAULT 2 -# endif -#endif - -#ifndef PLOOPY_DPI_DEFAULT -# define PLOOPY_DPI_DEFAULT 1 -#endif +#define PLOOPY_DPI_OPTIONS { CPI375, CPI750, CPI1375 } +#define PLOOPY_DPI_DEFAULT 2 // Transformation constants for delta-X and delta-Y const static float ADNS_X_TRANSFORM = -1.0; @@ -173,7 +167,7 @@ bool process_record_kb(uint16_t keycode, keyrecord_t* record) { void keyboard_pre_init_kb(void) { // debug_enable = true; // debug_matrix = true; - debug_mouse = true; + // debug_mouse = true; // debug_encoder = true; setPinInput(OPT_ENC1); @@ -198,6 +192,22 @@ void keyboard_pre_init_kb(void) { void pointing_device_init(void) { adns_init(); opt_encoder_init(); + + // reboot the adns. + // if the adns hasn't initialized yet, this is harmless. + adns_write_reg(REG_CHIP_RESET, 0x5a); + + // wait maximum time before adns is ready. + // this ensures that the adns is actuall ready after reset. + wait_ms(55); + + // read a burst from the adns and then discard it. + // gets the adns ready for write commands + // (for example, setting the dpi). + adns_read_burst(); + + // set the DPI. + adns_set_cpi(dpi_array[keyboard_config.dpi_config]); } void pointing_device_task(void) { @@ -223,9 +233,3 @@ void matrix_init_kb(void) { } matrix_init_user(); } - -void keyboard_post_init_kb(void) { - adns_set_cpi(dpi_array[keyboard_config.dpi_config]); - - keyboard_post_init_user(); -} diff --git a/keyboards/ploopyco/trackball_nano/trackball_nano.c b/keyboards/ploopyco/trackball_nano/trackball_nano.c index 17cdedac7..9bcfa59ef 100644 --- a/keyboards/ploopyco/trackball_nano/trackball_nano.c +++ b/keyboards/ploopyco/trackball_nano/trackball_nano.c @@ -18,6 +18,7 @@ */ #include "trackball_nano.h" +#include "wait.h" #ifndef OPT_DEBOUNCE # define OPT_DEBOUNCE 5 // (ms) Time between scroll events @@ -43,7 +44,7 @@ #endif #ifndef PLOOPY_DPI_DEFAULT -# define PLOOPY_DPI_DEFAULT 1 +# define PLOOPY_DPI_DEFAULT 2 #endif const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { }; @@ -139,7 +140,7 @@ bool process_record_kb(uint16_t keycode, keyrecord_t* record) { void keyboard_pre_init_kb(void) { // debug_enable = true; // debug_matrix = true; - debug_mouse = true; + // debug_mouse = true; // debug_encoder = true; setPinInput(OPT_ENC1); @@ -164,6 +165,22 @@ void keyboard_pre_init_kb(void) { void pointing_device_init(void) { adns_init(); opt_encoder_init(); + + // reboot the adns. + // if the adns hasn't initialized yet, this is harmless. + adns_write_reg(REG_CHIP_RESET, 0x5a); + + // wait maximum time before adns is ready. + // this ensures that the adns is actuall ready after reset. + wait_ms(55); + + // read a burst from the adns and then discard it. + // gets the adns ready for write commands + // (for example, setting the dpi). + adns_read_burst(); + + // set the DPI. + adns_set_cpi(dpi_array[keyboard_config.dpi_config]); } void pointing_device_task(void) { @@ -188,9 +205,3 @@ void matrix_init_kb(void) { } matrix_init_user(); } - -void keyboard_post_init_kb(void) { - adns_set_cpi(dpi_array[keyboard_config.dpi_config]); - - keyboard_post_init_user(); -}