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: Fixes for Ploopy devices (#13144) Co-authored-by: Drashna Jael're --- keyboards/ploopyco/trackball_nano/trackball_nano.c | 27 +++++++++++++++------- 1 file changed, 19 insertions(+), 8 deletions(-) (limited to 'keyboards/ploopyco/trackball_nano') diff --git a/keyboards/ploopyco/trackball_nano/trackball_nano.c b/keyboards/ploopyco/trackball_nano/trackball_nano.c index 17cdedac7a..9bcfa59ef8 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(); -} -- cgit v1.2.3