aboutsummaryrefslogtreecommitdiff
path: root/keyboards/ploopyco/trackball_mini/trackball_mini.c
diff options
context:
space:
mode:
Diffstat (limited to 'keyboards/ploopyco/trackball_mini/trackball_mini.c')
-rw-r--r--keyboards/ploopyco/trackball_mini/trackball_mini.c38
1 files changed, 21 insertions, 17 deletions
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 @@
18 */ 18 */
19 19
20#include "trackball_mini.h" 20#include "trackball_mini.h"
21#include "wait.h"
22#include "debug.h"
21 23
22#ifndef OPT_DEBOUNCE 24#ifndef OPT_DEBOUNCE
23# define OPT_DEBOUNCE 5 // (ms) Time between scroll events 25# define OPT_DEBOUNCE 5 // (ms) Time between scroll events
@@ -35,16 +37,8 @@
35# define OPT_SCALE 1 // Multiplier for wheel 37# define OPT_SCALE 1 // Multiplier for wheel
36#endif 38#endif
37 39
38#ifndef PLOOPY_DPI_OPTIONS 40#define PLOOPY_DPI_OPTIONS { CPI375, CPI750, CPI1375 }
39# define PLOOPY_DPI_OPTIONS { CPI375, CPI750, CPI1375 } 41#define PLOOPY_DPI_DEFAULT 2
40# ifndef PLOOPY_DPI_DEFAULT
41# define PLOOPY_DPI_DEFAULT 2
42# endif
43#endif
44
45#ifndef PLOOPY_DPI_DEFAULT
46# define PLOOPY_DPI_DEFAULT 1
47#endif
48 42
49// Transformation constants for delta-X and delta-Y 43// Transformation constants for delta-X and delta-Y
50const static float ADNS_X_TRANSFORM = -1.0; 44const static float ADNS_X_TRANSFORM = -1.0;
@@ -173,7 +167,7 @@ bool process_record_kb(uint16_t keycode, keyrecord_t* record) {
173void keyboard_pre_init_kb(void) { 167void keyboard_pre_init_kb(void) {
174 // debug_enable = true; 168 // debug_enable = true;
175 // debug_matrix = true; 169 // debug_matrix = true;
176 debug_mouse = true; 170 // debug_mouse = true;
177 // debug_encoder = true; 171 // debug_encoder = true;
178 172
179 setPinInput(OPT_ENC1); 173 setPinInput(OPT_ENC1);
@@ -198,6 +192,22 @@ void keyboard_pre_init_kb(void) {
198void pointing_device_init(void) { 192void pointing_device_init(void) {
199 adns_init(); 193 adns_init();
200 opt_encoder_init(); 194 opt_encoder_init();
195
196 // reboot the adns.
197 // if the adns hasn't initialized yet, this is harmless.
198 adns_write_reg(REG_CHIP_RESET, 0x5a);
199
200 // wait maximum time before adns is ready.
201 // this ensures that the adns is actuall ready after reset.
202 wait_ms(55);
203
204 // read a burst from the adns and then discard it.
205 // gets the adns ready for write commands
206 // (for example, setting the dpi).
207 adns_read_burst();
208
209 // set the DPI.
210 adns_set_cpi(dpi_array[keyboard_config.dpi_config]);
201} 211}
202 212
203void pointing_device_task(void) { 213void pointing_device_task(void) {
@@ -223,9 +233,3 @@ void matrix_init_kb(void) {
223 } 233 }
224 matrix_init_user(); 234 matrix_init_user();
225} 235}
226
227void keyboard_post_init_kb(void) {
228 adns_set_cpi(dpi_array[keyboard_config.dpi_config]);
229
230 keyboard_post_init_user();
231}