summaryrefslogtreecommitdiff
path: root/drivers/sensors/pmw3320.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/sensors/pmw3320.c')
-rw-r--r--drivers/sensors/pmw3320.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/sensors/pmw3320.c b/drivers/sensors/pmw3320.c
index a4648ef425..69a584f4e1 100644
--- a/drivers/sensors/pmw3320.c
+++ b/drivers/sensors/pmw3320.c
@@ -178,7 +178,7 @@ uint16_t pmw3320_get_cpi(void) {
}
void pmw3320_set_cpi(uint16_t cpi) {
- uint8_t cpival = constrain((cpi / PMW3320_CPI_STEP) - 1U, 0, (PMW3320_CPI_MAX / PMW3320_CPI_STEP) - 1U);
+ uint8_t cpival = constrain((cpi / PMW3320_CPI_STEP), (PMW3320_CPI_MIN / PMW3320_CPI_STEP), (PMW3320_CPI_MAX / PMW3320_CPI_STEP)) - 1U;
// Fifth bit is probably a control bit.
// PMW3320 datasheet don't have any info on this, so this is a pure guess.
pmw3320_write_reg(REG_Resolution, 0x20 | cpival);