summaryrefslogtreecommitdiffstats
path: root/drivers/sensors/cirque_pinnacle.h
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/sensors/cirque_pinnacle.h')
-rw-r--r--drivers/sensors/cirque_pinnacle.h62
1 files changed, 45 insertions, 17 deletions
diff --git a/drivers/sensors/cirque_pinnacle.h b/drivers/sensors/cirque_pinnacle.h
index c8cb360e03..1c9bf06fd3 100644
--- a/drivers/sensors/cirque_pinnacle.h
+++ b/drivers/sensors/cirque_pinnacle.h
@@ -2,26 +2,23 @@
#pragma once
+#include "cirque_pinnacle_regdefs.h"
#include <stdint.h>
#include <stdbool.h>
-// Convenient way to store and access measurements
-typedef struct {
- uint16_t xValue;
- uint16_t yValue;
- uint16_t zValue;
- uint8_t buttonFlags;
- bool touchDown;
-} pinnacle_data_t;
+#ifndef CIRQUE_PINNACLE_TIMEOUT
+# define CIRQUE_PINNACLE_TIMEOUT 20 // I2C timeout in milliseconds
+#endif
-void cirque_pinnacle_init(void);
-pinnacle_data_t cirque_pinnacle_read_data(void);
-void cirque_pinnacle_scale_data(pinnacle_data_t* coordinates, uint16_t xResolution, uint16_t yResolution);
-uint16_t cirque_pinnacle_get_scale(void);
-void cirque_pinnacle_set_scale(uint16_t scale);
+#define CIRQUE_PINNACLE_ABSOLUTE_MODE 1
+#define CIRQUE_PINNACLE_RELATIVE_MODE 0
+#ifndef CIRQUE_PINNACLE_POSITION_MODE
+# define CIRQUE_PINNACLE_POSITION_MODE CIRQUE_PINNACLE_ABSOLUTE_MODE
+#endif
-#ifndef CIRQUE_PINNACLE_TIMEOUT
-# define CIRQUE_PINNACLE_TIMEOUT 20
+#define CIRQUE_PINNACLE_DEFAULT_SCALE 1024
+#ifndef CIRQUE_PINNACLE_DIAMETER_MM
+# define CIRQUE_PINNACLE_DIAMETER_MM 40
#endif
// Coordinate scaling values
@@ -43,12 +40,14 @@ void cirque_pinnacle_set_scale(uint16_t scale);
#ifndef CIRQUE_PINNACLE_Y_RANGE
# define CIRQUE_PINNACLE_Y_RANGE (CIRQUE_PINNACLE_Y_UPPER - CIRQUE_PINNACLE_Y_LOWER)
#endif
-
+#if !defined(POINTING_DEVICE_TASK_THROTTLE_MS)
+# define POINTING_DEVICE_TASK_THROTTLE_MS 10 // Cirque Pinnacle in normal operation produces data every 10ms. Advanced configuration for pen/stylus usage might require lower values.
+#endif
#if defined(POINTING_DEVICE_DRIVER_cirque_pinnacle_i2c)
# include "i2c_master.h"
// Cirque's 7-bit I2C Slave Address
# ifndef CIRQUE_PINNACLE_ADDR
-# define CIRQUE_PINNACLE_ADDR 0x2A
+# define CIRQUE_PINNACLE_ADDR I2C_ADDRESS_DEFAULT
# endif
#elif defined(POINTING_DEVICE_DRIVER_cirque_pinnacle_spi)
# include "spi_master.h"
@@ -72,3 +71,32 @@ void cirque_pinnacle_set_scale(uint16_t scale);
# endif
# endif
#endif
+
+#define DIVIDE_UNSIGNED_ROUND(numerator, denominator) (((numerator) + ((denominator) / 2)) / (denominator))
+#define CIRQUE_PINNACLE_INCH_TO_PX(inch) (DIVIDE_UNSIGNED_ROUND((inch) * (uint32_t)CIRQUE_PINNACLE_DIAMETER_MM * 10, 254))
+#define CIRQUE_PINNACLE_PX_TO_INCH(px) (DIVIDE_UNSIGNED_ROUND((px) * (uint32_t)254, CIRQUE_PINNACLE_DIAMETER_MM * 10))
+
+// Convenient way to store and access measurements
+typedef struct {
+ bool valid; // true if valid data was read, false if no data was ready
+#if CIRQUE_PINNACLE_POSITION_MODE
+ uint16_t xValue;
+ uint16_t yValue;
+ uint16_t zValue;
+ uint8_t buttonFlags;
+ bool touchDown;
+#else
+ uint8_t xDelta;
+ uint8_t yDelta;
+ uint8_t wheelCount;
+ uint8_t buttons;
+#endif
+} pinnacle_data_t;
+
+void cirque_pinnacle_init(void);
+void cirque_pinnacle_calibrate(void);
+void cirque_pinnacle_cursor_smoothing(bool enable);
+pinnacle_data_t cirque_pinnacle_read_data(void);
+void cirque_pinnacle_scale_data(pinnacle_data_t* coordinates, uint16_t xResolution, uint16_t yResolution);
+uint16_t cirque_pinnacle_get_scale(void);
+void cirque_pinnacle_set_scale(uint16_t scale);