summaryrefslogtreecommitdiff
path: root/drivers/sensors/pmw3389.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/sensors/pmw3389.c')
-rw-r--r--drivers/sensors/pmw3389.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/sensors/pmw3389.c b/drivers/sensors/pmw3389.c
index c5781a5ffe..10e578edac 100644
--- a/drivers/sensors/pmw3389.c
+++ b/drivers/sensors/pmw3389.c
@@ -22,7 +22,7 @@ void pmw33xx_set_cpi(uint8_t sensor, uint16_t cpi) {
return;
}
- uint16_t cpival = CONSTRAIN((cpi / PMW33XX_CPI_STEP) - 1, 0, (PMW33XX_CPI_MAX / PMW33XX_CPI_STEP) - 1U);
+ uint16_t cpival = CONSTRAIN((cpi / PMW33XX_CPI_STEP), (PMW33XX_CPI_MIN / PMW33XX_CPI_STEP), (PMW33XX_CPI_MAX / PMW33XX_CPI_STEP)) - 1U;
// Sets upper byte first for more consistent setting of cpi
pmw33xx_write(sensor, REG_Resolution_H, (cpival >> 8) & 0xFF);
pmw33xx_write(sensor, REG_Resolution_L, cpival & 0xFF);