Fixes for Ploopy devices (#13144)

Co-authored-by: Drashna Jael're <drashna@live.com>
master
ploopyco 2021-06-21 15:59:56 -04:00 committed by GitHub
parent 224dcac08f
commit eba3d68394
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 111 additions and 33 deletions

View File

@ -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();
}

View File

@ -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.

View File

@ -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.

View File

@ -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.

View File

@ -0,0 +1,40 @@
/* Copyright 2021 Colin Lam (Ploopy Corporation)
* Copyright 2020 Christopher Courtney, aka Drashna Jael're (@drashna) <drashna@live.com>
* 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 <http://www.gnu.org/licenses/>.
*/
#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 }

View File

@ -0,0 +1 @@
See the main readme for more details. This is just here for when future revisions are released.

View File

@ -0,0 +1,22 @@
/* Copyright 2021 Colin Lam (Ploopy Corporation)
* Copyright 2020 Christopher Courtney, aka Drashna Jael're (@drashna) <drashna@live.com>
* 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 <http://www.gnu.org/licenses/>.
*/
#pragma once
#include "trackball_mini.h"

View File

@ -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();
}

View File

@ -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();
}