fix: trackball cpi boundaries, restore user set default cpi at boot
Some checks failed
Build firmware / build-firmware (default) (push) Has been cancelled
Build firmware / build-firmware (oryx) (push) Has been cancelled

This commit is contained in:
Florian Didron
2025-09-02 16:51:28 +07:00
parent 2ec6a09d59
commit 91d29fe418
2 changed files with 4 additions and 31 deletions

View File

@@ -192,6 +192,7 @@ void navigator_trackball_device_init(void) {
}
trackball_init = 1;
restore_cpi(current_cpi);
if (!callback_token) {
// Register the callback to read the trackball motion
callback_token = defer_exec(NAVIGATOR_TRACKBALL_READ, sci18is606_read_callback, NULL);
@@ -217,20 +218,17 @@ uint16_t navigator_trackball_get_cpi(void) {
void restore_cpi(uint8_t cpi) {
current_cpi = cpi;
paw3805ek_set_cpi();
printf("restored cpi: %d\n", current_cpi);
}
void navigator_trackball_set_cpi(uint16_t cpi) {
if (cpi == 0) { // Decrease one tick
if (current_cpi > NAVIGATOR_TRACKBALL_CPI_TICK) {
current_cpi -= NAVIGATOR_TRACKBALL_CPI_TICK;
printf("decreased cpi: %d\n", current_cpi);
paw3805ek_set_cpi();
}
} else {
if (current_cpi < 255 - NAVIGATOR_TRACKBALL_CPI_TICK) {
if (current_cpi <= NAVIGATOR_TRACKBALL_CPI_MAX - NAVIGATOR_TRACKBALL_CPI_TICK) {
current_cpi += NAVIGATOR_TRACKBALL_CPI_TICK;
printf("increased cpi: %d\n", current_cpi);
paw3805ek_set_cpi();
}
}

View File

@@ -18,6 +18,8 @@
# define NAVIGATOR_TRACKBALL_CPI_TICK 5
#endif
#define NAVIGATOR_TRACKBALL_CPI_MAX 125
#ifndef NAVIGATOR_TRACKBALL_TIMEOUT
# define NAVIGATOR_TRACKBALL_TIMEOUT 100
#endif
@@ -36,33 +38,6 @@
#define SCI18IS606_GET_ID 0xFE
#define WRITE_REG_BIT 0x80
/*
The PAW3805EK datasheet suggests the following CPI values for the X and Y axes:
CPI X-axis Y-axis
800 0x1F 0x22
1000 0x26 0x2A
1200 0x2E 0x32
1600 0x3C 0x43
2000 0x4C 0x54
2400 0x5B 0x64
3000 0x70 0x7B
*/
#define CPI_TICKS 7
#define DEFAULT_CPI_TICK 1
#define CPI_X_800 0x1F
#define CPI_Y_800 0x22
#define CPI_X_1000 0x26
#define CPI_Y_1000 0x2A
#define CPI_X_1200 0x2E
#define CPI_Y_1200 0x32
#define CPI_X_1600 0x3C
#define CPI_Y_1600 0x43
#define CPI_X_2000 0x4C
#define CPI_Y_2000 0x54
#define CPI_X_2400 0x5B
#define CPI_Y_2400 0x64
#define CPI_X_3000 0x70
#define CPI_Y_3000 0x7B
typedef struct {
uint8_t reg;