From 6b52c6d83dafc80c65719947e307ee3795bd619c Mon Sep 17 00:00:00 2001 From: JohSchneider Date: Sat, 13 Jan 2024 08:28:09 +0000 Subject: [PATCH] Cirque reachable calibration aide (#22803) Co-authored-by: Stefan Kerkmann Co-authored-by: Johannes --- docs/feature_pointing_device.md | 13 +++++++------ drivers/sensors/cirque_pinnacle.c | 9 +++++++++ 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/docs/feature_pointing_device.md b/docs/feature_pointing_device.md index c18eb52aab..b091dec08b 100644 --- a/docs/feature_pointing_device.md +++ b/docs/feature_pointing_device.md @@ -217,12 +217,13 @@ Also see the `POINTING_DEVICE_TASK_THROTTLE_MS`, which defaults to 10ms when usi #### Absolute mode settings -| Setting | Description | Default | -| -------------------------------- | ---------------------------------------------------------- | ------------------ | -| `CIRQUE_PINNACLE_X_LOWER` | (Optional) The minimum reachable X value on the sensor. | `127` | -| `CIRQUE_PINNACLE_X_UPPER` | (Optional) The maximum reachable X value on the sensor. | `1919` | -| `CIRQUE_PINNACLE_Y_LOWER` | (Optional) The minimum reachable Y value on the sensor. | `63` | -| `CIRQUE_PINNACLE_Y_UPPER` | (Optional) The maximum reachable Y value on the sensor. | `1471` | +| Setting | Description | Default | +|-----------------------------------------|-------------------------------------------------------------------------|-------------| +| `CIRQUE_PINNACLE_X_LOWER` | (Optional) The minimum reachable X value on the sensor. | `127` | +| `CIRQUE_PINNACLE_X_UPPER` | (Optional) The maximum reachable X value on the sensor. | `1919` | +| `CIRQUE_PINNACLE_Y_LOWER` | (Optional) The minimum reachable Y value on the sensor. | `63` | +| `CIRQUE_PINNACLE_Y_UPPER` | (Optional) The maximum reachable Y value on the sensor. | `1471` | +| `CIRQUE_PINNACLE_REACHABLE_CALIBRATION` | (Optional) Enable console messages to aide in calibrating above values. | not defined | #### Absolute mode gestures diff --git a/drivers/sensors/cirque_pinnacle.c b/drivers/sensors/cirque_pinnacle.c index b5c1abdebc..38e1fae3e3 100644 --- a/drivers/sensors/cirque_pinnacle.c +++ b/drivers/sensors/cirque_pinnacle.c @@ -331,6 +331,15 @@ pinnacle_data_t cirque_pinnacle_read_data(void) { result.wheelCount = ((int8_t*)data)[3]; #endif +#ifdef CIRQUE_PINNACLE_REACHABLE_CALIBRATION + static uint16_t xMin = UINT16_MAX, yMin = UINT16_MAX, yMax = 0, xMax = 0; + if (result.xValue < xMin) xMin = result.xValue; + if (result.xValue > xMax) xMax = result.xValue; + if (result.yValue < yMin) yMin = result.yValue; + if (result.yValue > yMax) yMax = result.yValue; + pd_dprintf("%s: xLo=%3d xHi=%3d yLo=%3d yHi=%3d\n", __FUNCTION__, xMin, xMax, yMin, yMax); +#endif + result.valid = true; return result; }