summaryrefslogtreecommitdiff
path: root/drivers/sensors
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/sensors')
-rw-r--r--drivers/sensors/analog_joystick.c71
-rw-r--r--drivers/sensors/azoteq_iqs5xx.c37
-rw-r--r--drivers/sensors/cirque_pinnacle.c27
-rw-r--r--drivers/sensors/cirque_pinnacle_i2c.c12
-rw-r--r--drivers/sensors/pimoroni_trackball.c4
5 files changed, 113 insertions, 38 deletions
diff --git a/drivers/sensors/analog_joystick.c b/drivers/sensors/analog_joystick.c
index 12256a8e7a..221625075c 100644
--- a/drivers/sensors/analog_joystick.c
+++ b/drivers/sensors/analog_joystick.c
@@ -22,17 +22,28 @@
#include <stdlib.h>
// Set Parameters
+#ifndef ANALOG_JOYSTICK_AUTO_AXIS
uint16_t minAxisValue = ANALOG_JOYSTICK_AXIS_MIN;
uint16_t maxAxisValue = ANALOG_JOYSTICK_AXIS_MAX;
+#else
+int16_t minAxisValues[2];
+int16_t maxAxisValues[2];
+#endif
uint8_t maxCursorSpeed = ANALOG_JOYSTICK_SPEED_MAX;
uint8_t speedRegulator = ANALOG_JOYSTICK_SPEED_REGULATOR; // Lower Values Create Faster Movement
+#ifdef ANALOG_JOYSTICK_WEIGHTS
+int8_t weights[101] = ANALOG_JOYSTICK_WEIGHTS;
+#endif
+
int16_t xOrigin, yOrigin;
uint16_t lastCursor = 0;
-int16_t axisCoordinate(pin_t pin, uint16_t origin) {
+uint8_t prevValues[2] = {0, 0};
+
+int16_t axisCoordinate(pin_t pin, uint16_t origin, uint8_t axis) {
int8_t direction;
int16_t distanceFromOrigin;
int16_t range;
@@ -43,12 +54,27 @@ int16_t axisCoordinate(pin_t pin, uint16_t origin) {
return 0;
} else if (origin > position) {
distanceFromOrigin = origin - position;
- range = origin - minAxisValue;
- direction = -1;
+#ifdef ANALOG_JOYSTICK_AUTO_AXIS
+ if (position < minAxisValues[axis]) {
+ minAxisValues[axis] = position;
+ }
+ range = origin - minAxisValues[axis];
+#else
+ range = origin - minAxisValue;
+#endif
+ direction = -1;
} else {
distanceFromOrigin = position - origin;
- range = maxAxisValue - origin;
- direction = 1;
+
+#ifdef ANALOG_JOYSTICK_AUTO_AXIS
+ if (position > maxAxisValues[axis]) {
+ maxAxisValues[axis] = position;
+ }
+ range = maxAxisValues[axis] - origin;
+#else
+ range = maxAxisValue - origin;
+#endif
+ direction = 1;
}
float percent = (float)distanceFromOrigin / range;
@@ -62,14 +88,29 @@ int16_t axisCoordinate(pin_t pin, uint16_t origin) {
}
}
-int8_t axisToMouseComponent(pin_t pin, int16_t origin, uint8_t maxSpeed) {
- int16_t coordinate = axisCoordinate(pin, origin);
+int8_t axisToMouseComponent(pin_t pin, int16_t origin, uint8_t maxSpeed, uint8_t axis) {
+ int16_t coordinate = axisCoordinate(pin, origin, axis);
+ int8_t result;
+#ifndef ANALOG_JOYSTICK_WEIGHTS
if (coordinate != 0) {
float percent = (float)coordinate / 100;
- return percent * maxCursorSpeed * (abs(coordinate) / speedRegulator);
+ result = percent * maxCursorSpeed * (abs(coordinate) / speedRegulator);
} else {
return 0;
}
+#else
+ result = weights[abs(coordinate)] * (coordinate < 0 ? -1 : 1) * maxCursorSpeed / speedRegulator;
+#endif
+
+#ifdef ANALOG_JOYSTICK_CUTOFF
+ uint8_t pv = prevValues[axis];
+ prevValues[axis] = abs(result);
+ if (pv > abs(result)) {
+ return 0;
+ }
+#endif
+
+ return result;
}
report_analog_joystick_t analog_joystick_read(void) {
@@ -77,8 +118,8 @@ report_analog_joystick_t analog_joystick_read(void) {
if (timer_elapsed(lastCursor) > ANALOG_JOYSTICK_READ_INTERVAL) {
lastCursor = timer_read();
- report.x = axisToMouseComponent(ANALOG_JOYSTICK_X_AXIS_PIN, xOrigin, maxCursorSpeed);
- report.y = axisToMouseComponent(ANALOG_JOYSTICK_Y_AXIS_PIN, yOrigin, maxCursorSpeed);
+ report.x = axisToMouseComponent(ANALOG_JOYSTICK_X_AXIS_PIN, xOrigin, maxCursorSpeed, 0);
+ report.y = axisToMouseComponent(ANALOG_JOYSTICK_Y_AXIS_PIN, yOrigin, maxCursorSpeed, 1);
}
#ifdef ANALOG_JOYSTICK_CLICK_PIN
report.button = !readPin(ANALOG_JOYSTICK_CLICK_PIN);
@@ -87,10 +128,20 @@ report_analog_joystick_t analog_joystick_read(void) {
}
void analog_joystick_init(void) {
+ setPinInputHigh(ANALOG_JOYSTICK_X_AXIS_PIN);
+ setPinInputHigh(ANALOG_JOYSTICK_Y_AXIS_PIN);
+
#ifdef ANALOG_JOYSTICK_CLICK_PIN
setPinInputHigh(ANALOG_JOYSTICK_CLICK_PIN);
#endif
// Account for drift
xOrigin = analogReadPin(ANALOG_JOYSTICK_X_AXIS_PIN);
yOrigin = analogReadPin(ANALOG_JOYSTICK_Y_AXIS_PIN);
+
+#ifdef ANALOG_JOYSTICK_AUTO_AXIS
+ minAxisValues[0] = xOrigin - 100;
+ minAxisValues[1] = yOrigin - 100;
+ maxAxisValues[0] = xOrigin + 100;
+ maxAxisValues[1] = yOrigin + 100;
+#endif
}
diff --git a/drivers/sensors/azoteq_iqs5xx.c b/drivers/sensors/azoteq_iqs5xx.c
index 521f558b5f..367873eb06 100644
--- a/drivers/sensors/azoteq_iqs5xx.c
+++ b/drivers/sensors/azoteq_iqs5xx.c
@@ -107,18 +107,17 @@ static struct {
i2c_status_t azoteq_iqs5xx_wake(void) {
uint8_t data = 0;
- i2c_status_t status = i2c_readReg16(AZOTEQ_IQS5XX_ADDRESS, AZOTEQ_IQS5XX_REG_PREVIOUS_CYCLE_TIME, (uint8_t *)&data, sizeof(data), 1);
- i2c_stop();
+ i2c_status_t status = i2c_read_register16(AZOTEQ_IQS5XX_ADDRESS, AZOTEQ_IQS5XX_REG_PREVIOUS_CYCLE_TIME, (uint8_t *)&data, sizeof(data), 1);
wait_us(150);
return status;
}
i2c_status_t azoteq_iqs5xx_end_session(void) {
const uint8_t END_BYTE = 1; // any data
- return i2c_writeReg16(AZOTEQ_IQS5XX_ADDRESS, AZOTEQ_IQS5XX_REG_END_COMMS, &END_BYTE, 1, AZOTEQ_IQS5XX_TIMEOUT_MS);
+ return i2c_write_register16(AZOTEQ_IQS5XX_ADDRESS, AZOTEQ_IQS5XX_REG_END_COMMS, &END_BYTE, 1, AZOTEQ_IQS5XX_TIMEOUT_MS);
}
i2c_status_t azoteq_iqs5xx_get_base_data(azoteq_iqs5xx_base_data_t *base_data) {
- i2c_status_t status = i2c_readReg16(AZOTEQ_IQS5XX_ADDRESS, AZOTEQ_IQS5XX_REG_PREVIOUS_CYCLE_TIME, (uint8_t *)base_data, 10, AZOTEQ_IQS5XX_TIMEOUT_MS);
+ i2c_status_t status = i2c_read_register16(AZOTEQ_IQS5XX_ADDRESS, AZOTEQ_IQS5XX_REG_PREVIOUS_CYCLE_TIME, (uint8_t *)base_data, 10, AZOTEQ_IQS5XX_TIMEOUT_MS);
if (status == I2C_STATUS_SUCCESS) {
azoteq_iqs5xx_end_session();
}
@@ -131,7 +130,7 @@ i2c_status_t azoteq_iqs5xx_get_report_rate(azoteq_iqs5xx_report_rate_t *report_r
return I2C_STATUS_ERROR;
}
uint16_t selected_reg = AZOTEQ_IQS5XX_REG_REPORT_RATE_ACTIVE + (2 * mode);
- i2c_status_t status = i2c_readReg16(AZOTEQ_IQS5XX_ADDRESS, selected_reg, (uint8_t *)report_rate, 2, AZOTEQ_IQS5XX_TIMEOUT_MS);
+ i2c_status_t status = i2c_read_register16(AZOTEQ_IQS5XX_ADDRESS, selected_reg, (uint8_t *)report_rate, 2, AZOTEQ_IQS5XX_TIMEOUT_MS);
if (end_session) {
azoteq_iqs5xx_end_session();
}
@@ -147,7 +146,7 @@ i2c_status_t azoteq_iqs5xx_set_report_rate(uint16_t report_rate_ms, azoteq_iqs5x
azoteq_iqs5xx_report_rate_t report_rate = {0};
report_rate.h = (uint8_t)((report_rate_ms >> 8) & 0xFF);
report_rate.l = (uint8_t)(report_rate_ms & 0xFF);
- i2c_status_t status = i2c_writeReg16(AZOTEQ_IQS5XX_ADDRESS, selected_reg, (uint8_t *)&report_rate, 2, AZOTEQ_IQS5XX_TIMEOUT_MS);
+ i2c_status_t status = i2c_write_register16(AZOTEQ_IQS5XX_ADDRESS, selected_reg, (uint8_t *)&report_rate, 2, AZOTEQ_IQS5XX_TIMEOUT_MS);
if (end_session) {
azoteq_iqs5xx_end_session();
}
@@ -156,10 +155,10 @@ i2c_status_t azoteq_iqs5xx_set_report_rate(uint16_t report_rate_ms, azoteq_iqs5x
i2c_status_t azoteq_iqs5xx_set_reati(bool enabled, bool end_session) {
azoteq_iqs5xx_system_config_0_t config = {0};
- i2c_status_t status = i2c_readReg16(AZOTEQ_IQS5XX_ADDRESS, AZOTEQ_IQS5XX_REG_SYSTEM_CONFIG_0, (uint8_t *)&config, sizeof(azoteq_iqs5xx_system_config_0_t), AZOTEQ_IQS5XX_TIMEOUT_MS);
+ i2c_status_t status = i2c_read_register16(AZOTEQ_IQS5XX_ADDRESS, AZOTEQ_IQS5XX_REG_SYSTEM_CONFIG_0, (uint8_t *)&config, sizeof(azoteq_iqs5xx_system_config_0_t), AZOTEQ_IQS5XX_TIMEOUT_MS);
if (status == I2C_STATUS_SUCCESS) {
config.reati = enabled;
- status = i2c_writeReg16(AZOTEQ_IQS5XX_ADDRESS, AZOTEQ_IQS5XX_REG_SYSTEM_CONFIG_0, (uint8_t *)&config, sizeof(azoteq_iqs5xx_system_config_0_t), AZOTEQ_IQS5XX_TIMEOUT_MS);
+ status = i2c_write_register16(AZOTEQ_IQS5XX_ADDRESS, AZOTEQ_IQS5XX_REG_SYSTEM_CONFIG_0, (uint8_t *)&config, sizeof(azoteq_iqs5xx_system_config_0_t), AZOTEQ_IQS5XX_TIMEOUT_MS);
}
if (end_session) {
azoteq_iqs5xx_end_session();
@@ -169,7 +168,7 @@ i2c_status_t azoteq_iqs5xx_set_reati(bool enabled, bool end_session) {
i2c_status_t azoteq_iqs5xx_set_event_mode(bool enabled, bool end_session) {
azoteq_iqs5xx_system_config_1_t config = {0};
- i2c_status_t status = i2c_readReg16(AZOTEQ_IQS5XX_ADDRESS, AZOTEQ_IQS5XX_REG_SYSTEM_CONFIG_1, (uint8_t *)&config, sizeof(azoteq_iqs5xx_system_config_1_t), AZOTEQ_IQS5XX_TIMEOUT_MS);
+ i2c_status_t status = i2c_read_register16(AZOTEQ_IQS5XX_ADDRESS, AZOTEQ_IQS5XX_REG_SYSTEM_CONFIG_1, (uint8_t *)&config, sizeof(azoteq_iqs5xx_system_config_1_t), AZOTEQ_IQS5XX_TIMEOUT_MS);
if (status == I2C_STATUS_SUCCESS) {
config.event_mode = enabled;
config.touch_event = true;
@@ -179,7 +178,7 @@ i2c_status_t azoteq_iqs5xx_set_event_mode(bool enabled, bool end_session) {
config.reati_event = false;
config.alp_prox_event = false;
config.gesture_event = true;
- status = i2c_writeReg16(AZOTEQ_IQS5XX_ADDRESS, AZOTEQ_IQS5XX_REG_SYSTEM_CONFIG_1, (uint8_t *)&config, sizeof(azoteq_iqs5xx_system_config_1_t), AZOTEQ_IQS5XX_TIMEOUT_MS);
+ status = i2c_write_register16(AZOTEQ_IQS5XX_ADDRESS, AZOTEQ_IQS5XX_REG_SYSTEM_CONFIG_1, (uint8_t *)&config, sizeof(azoteq_iqs5xx_system_config_1_t), AZOTEQ_IQS5XX_TIMEOUT_MS);
}
if (end_session) {
azoteq_iqs5xx_end_session();
@@ -189,7 +188,7 @@ i2c_status_t azoteq_iqs5xx_set_event_mode(bool enabled, bool end_session) {
i2c_status_t azoteq_iqs5xx_set_gesture_config(bool end_session) {
azoteq_iqs5xx_gesture_config_t config = {0};
- i2c_status_t status = i2c_readReg16(AZOTEQ_IQS5XX_ADDRESS, AZOTEQ_IQS5XX_REG_SINGLE_FINGER_GESTURES, (uint8_t *)&config, sizeof(azoteq_iqs5xx_gesture_config_t), AZOTEQ_IQS5XX_TIMEOUT_MS);
+ i2c_status_t status = i2c_read_register16(AZOTEQ_IQS5XX_ADDRESS, AZOTEQ_IQS5XX_REG_SINGLE_FINGER_GESTURES, (uint8_t *)&config, sizeof(azoteq_iqs5xx_gesture_config_t), AZOTEQ_IQS5XX_TIMEOUT_MS);
pd_dprintf("azo scroll: %d\n", config.multi_finger_gestures.scroll);
if (status == I2C_STATUS_SUCCESS) {
config.single_finger_gestures.single_tap = AZOTEQ_IQS5XX_TAP_ENABLE;
@@ -211,7 +210,7 @@ i2c_status_t azoteq_iqs5xx_set_gesture_config(bool end_session) {
config.scroll_initial_distance = AZOTEQ_IQS5XX_SWAP_H_L_BYTES(AZOTEQ_IQS5XX_SCROLL_INITIAL_DISTANCE);
config.zoom_initial_distance = AZOTEQ_IQS5XX_SWAP_H_L_BYTES(AZOTEQ_IQS5XX_ZOOM_INITIAL_DISTANCE);
config.zoom_consecutive_distance = AZOTEQ_IQS5XX_SWAP_H_L_BYTES(AZOTEQ_IQS5XX_ZOOM_CONSECUTIVE_DISTANCE);
- status = i2c_writeReg16(AZOTEQ_IQS5XX_ADDRESS, AZOTEQ_IQS5XX_REG_SINGLE_FINGER_GESTURES, (uint8_t *)&config, sizeof(azoteq_iqs5xx_gesture_config_t), AZOTEQ_IQS5XX_TIMEOUT_MS);
+ status = i2c_write_register16(AZOTEQ_IQS5XX_ADDRESS, AZOTEQ_IQS5XX_REG_SINGLE_FINGER_GESTURES, (uint8_t *)&config, sizeof(azoteq_iqs5xx_gesture_config_t), AZOTEQ_IQS5XX_TIMEOUT_MS);
}
if (end_session) {
azoteq_iqs5xx_end_session();
@@ -221,7 +220,7 @@ i2c_status_t azoteq_iqs5xx_set_gesture_config(bool end_session) {
i2c_status_t azoteq_iqs5xx_set_xy_config(bool flip_x, bool flip_y, bool switch_xy, bool palm_reject, bool end_session) {
azoteq_iqs5xx_xy_config_0_t config = {0};
- i2c_status_t status = i2c_readReg16(AZOTEQ_IQS5XX_ADDRESS, AZOTEQ_IQS5XX_REG_XY_CONFIG_0, (uint8_t *)&config, sizeof(azoteq_iqs5xx_xy_config_0_t), AZOTEQ_IQS5XX_TIMEOUT_MS);
+ i2c_status_t status = i2c_read_register16(AZOTEQ_IQS5XX_ADDRESS, AZOTEQ_IQS5XX_REG_XY_CONFIG_0, (uint8_t *)&config, sizeof(azoteq_iqs5xx_xy_config_0_t), AZOTEQ_IQS5XX_TIMEOUT_MS);
if (status == I2C_STATUS_SUCCESS) {
if (flip_x) {
config.flip_x = !config.flip_x;
@@ -233,7 +232,7 @@ i2c_status_t azoteq_iqs5xx_set_xy_config(bool flip_x, bool flip_y, bool switch_x
config.switch_xy_axis = !config.switch_xy_axis;
}
config.palm_reject = palm_reject;
- status = i2c_writeReg16(AZOTEQ_IQS5XX_ADDRESS, AZOTEQ_IQS5XX_REG_XY_CONFIG_0, (uint8_t *)&config, sizeof(azoteq_iqs5xx_xy_config_0_t), AZOTEQ_IQS5XX_TIMEOUT_MS);
+ status = i2c_write_register16(AZOTEQ_IQS5XX_ADDRESS, AZOTEQ_IQS5XX_REG_XY_CONFIG_0, (uint8_t *)&config, sizeof(azoteq_iqs5xx_xy_config_0_t), AZOTEQ_IQS5XX_TIMEOUT_MS);
}
if (end_session) {
azoteq_iqs5xx_end_session();
@@ -243,11 +242,11 @@ i2c_status_t azoteq_iqs5xx_set_xy_config(bool flip_x, bool flip_y, bool switch_x
i2c_status_t azoteq_iqs5xx_reset_suspend(bool reset, bool suspend, bool end_session) {
azoteq_iqs5xx_system_control_1_t config = {0};
- i2c_status_t status = i2c_readReg16(AZOTEQ_IQS5XX_ADDRESS, AZOTEQ_IQS5XX_REG_SYSTEM_CONTROL_1, (uint8_t *)&config, sizeof(azoteq_iqs5xx_system_control_1_t), AZOTEQ_IQS5XX_TIMEOUT_MS);
+ i2c_status_t status = i2c_read_register16(AZOTEQ_IQS5XX_ADDRESS, AZOTEQ_IQS5XX_REG_SYSTEM_CONTROL_1, (uint8_t *)&config, sizeof(azoteq_iqs5xx_system_control_1_t), AZOTEQ_IQS5XX_TIMEOUT_MS);
if (status == I2C_STATUS_SUCCESS) {
config.reset = reset;
config.suspend = suspend;
- status = i2c_writeReg16(AZOTEQ_IQS5XX_ADDRESS, AZOTEQ_IQS5XX_REG_SYSTEM_CONTROL_1, (uint8_t *)&config, sizeof(azoteq_iqs5xx_system_control_1_t), AZOTEQ_IQS5XX_TIMEOUT_MS);
+ status = i2c_write_register16(AZOTEQ_IQS5XX_ADDRESS, AZOTEQ_IQS5XX_REG_SYSTEM_CONTROL_1, (uint8_t *)&config, sizeof(azoteq_iqs5xx_system_control_1_t), AZOTEQ_IQS5XX_TIMEOUT_MS);
}
if (end_session) {
azoteq_iqs5xx_end_session();
@@ -260,14 +259,14 @@ void azoteq_iqs5xx_set_cpi(uint16_t cpi) {
azoteq_iqs5xx_resolution_t resolution = {0};
resolution.x_resolution = AZOTEQ_IQS5XX_SWAP_H_L_BYTES(MIN(azoteq_iqs5xx_device_resolution_t.resolution_x, AZOTEQ_IQS5XX_INCH_TO_RESOLUTION_X(cpi)));
resolution.y_resolution = AZOTEQ_IQS5XX_SWAP_H_L_BYTES(MIN(azoteq_iqs5xx_device_resolution_t.resolution_y, AZOTEQ_IQS5XX_INCH_TO_RESOLUTION_Y(cpi)));
- i2c_writeReg16(AZOTEQ_IQS5XX_ADDRESS, AZOTEQ_IQS5XX_REG_X_RESOLUTION, (uint8_t *)&resolution, sizeof(azoteq_iqs5xx_resolution_t), AZOTEQ_IQS5XX_TIMEOUT_MS);
+ i2c_write_register16(AZOTEQ_IQS5XX_ADDRESS, AZOTEQ_IQS5XX_REG_X_RESOLUTION, (uint8_t *)&resolution, sizeof(azoteq_iqs5xx_resolution_t), AZOTEQ_IQS5XX_TIMEOUT_MS);
}
}
uint16_t azoteq_iqs5xx_get_cpi(void) {
if (azoteq_iqs5xx_product_number != AZOTEQ_IQS5XX_UNKNOWN) {
azoteq_iqs5xx_resolution_t resolution = {0};
- i2c_status_t status = i2c_readReg16(AZOTEQ_IQS5XX_ADDRESS, AZOTEQ_IQS5XX_REG_X_RESOLUTION, (uint8_t *)&resolution, sizeof(azoteq_iqs5xx_resolution_t), AZOTEQ_IQS5XX_TIMEOUT_MS);
+ i2c_status_t status = i2c_read_register16(AZOTEQ_IQS5XX_ADDRESS, AZOTEQ_IQS5XX_REG_X_RESOLUTION, (uint8_t *)&resolution, sizeof(azoteq_iqs5xx_resolution_t), AZOTEQ_IQS5XX_TIMEOUT_MS);
if (status == I2C_STATUS_SUCCESS) {
return AZOTEQ_IQS5XX_RESOLUTION_X_TO_INCH(AZOTEQ_IQS5XX_SWAP_H_L_BYTES(resolution.x_resolution));
}
@@ -276,7 +275,7 @@ uint16_t azoteq_iqs5xx_get_cpi(void) {
}
uint16_t azoteq_iqs5xx_get_product(void) {
- i2c_status_t status = i2c_readReg16(AZOTEQ_IQS5XX_ADDRESS, AZOTEQ_IQS5XX_REG_PRODUCT_NUMBER, (uint8_t *)&azoteq_iqs5xx_product_number, sizeof(uint16_t), AZOTEQ_IQS5XX_TIMEOUT_MS);
+ i2c_status_t status = i2c_read_register16(AZOTEQ_IQS5XX_ADDRESS, AZOTEQ_IQS5XX_REG_PRODUCT_NUMBER, (uint8_t *)&azoteq_iqs5xx_product_number, sizeof(uint16_t), AZOTEQ_IQS5XX_TIMEOUT_MS);
if (status == I2C_STATUS_SUCCESS) {
azoteq_iqs5xx_product_number = AZOTEQ_IQS5XX_SWAP_H_L_BYTES(azoteq_iqs5xx_product_number);
}
diff --git a/drivers/sensors/cirque_pinnacle.c b/drivers/sensors/cirque_pinnacle.c
index 3131805c20..9afc9df804 100644
--- a/drivers/sensors/cirque_pinnacle.c
+++ b/drivers/sensors/cirque_pinnacle.c
@@ -216,6 +216,20 @@ void cirque_pinnacle_cursor_smoothing(bool enable) {
RAP_Write(HOSTREG__FEEDCONFIG3, feedconfig3);
}
+// Check sensor is connected
+bool cirque_pinnacle_connected(void) {
+ uint8_t current_zidle = 0;
+ uint8_t temp_zidle = 0;
+ RAP_ReadBytes(HOSTREG__ZIDLE, &current_zidle, 1);
+ RAP_Write(HOSTREG__ZIDLE, HOSTREG__ZIDLE_DEFVAL);
+ RAP_ReadBytes(HOSTREG__ZIDLE, &temp_zidle, 1);
+ if (temp_zidle == HOSTREG__ZIDLE_DEFVAL) {
+ RAP_Write(HOSTREG__ZIDLE, current_zidle);
+ return true;
+ }
+ return false;
+}
+
/* Pinnacle-based TM040040/TM035035/TM023023 Functions */
void cirque_pinnacle_init(void) {
#if defined(POINTING_DEVICE_DRIVER_cirque_pinnacle_spi)
@@ -274,6 +288,10 @@ void cirque_pinnacle_init(void) {
}
cirque_pinnacle_enable_feed(true);
+
+#ifndef CIRQUE_PINNACLE_SKIP_SENSOR_CHECK
+ touchpad_init = cirque_pinnacle_connected();
+#endif
}
pinnacle_data_t cirque_pinnacle_read_data(void) {
@@ -320,6 +338,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;
}
diff --git a/drivers/sensors/cirque_pinnacle_i2c.c b/drivers/sensors/cirque_pinnacle_i2c.c
index 3c11e5f079..a3622e9d60 100644
--- a/drivers/sensors/cirque_pinnacle_i2c.c
+++ b/drivers/sensors/cirque_pinnacle_i2c.c
@@ -14,12 +14,11 @@ extern bool touchpad_init;
void RAP_ReadBytes(uint8_t address, uint8_t* data, uint8_t count) {
uint8_t cmdByte = READ_MASK | address; // Form the READ command byte
if (touchpad_init) {
- i2c_writeReg(CIRQUE_PINNACLE_ADDR << 1, cmdByte, NULL, 0, CIRQUE_PINNACLE_TIMEOUT);
- if (i2c_readReg(CIRQUE_PINNACLE_ADDR << 1, cmdByte, data, count, CIRQUE_PINNACLE_TIMEOUT) != I2C_STATUS_SUCCESS) {
- pd_dprintf("error cirque_pinnacle i2c_readReg\n");
+ i2c_write_register(CIRQUE_PINNACLE_ADDR << 1, cmdByte, NULL, 0, CIRQUE_PINNACLE_TIMEOUT);
+ if (i2c_read_register(CIRQUE_PINNACLE_ADDR << 1, cmdByte, data, count, CIRQUE_PINNACLE_TIMEOUT) != I2C_STATUS_SUCCESS) {
+ pd_dprintf("error cirque_pinnacle i2c_read_register\n");
touchpad_init = false;
}
- i2c_stop();
}
}
@@ -28,10 +27,9 @@ void RAP_Write(uint8_t address, uint8_t data) {
uint8_t cmdByte = WRITE_MASK | address; // Form the WRITE command byte
if (touchpad_init) {
- if (i2c_writeReg(CIRQUE_PINNACLE_ADDR << 1, cmdByte, &data, sizeof(data), CIRQUE_PINNACLE_TIMEOUT) != I2C_STATUS_SUCCESS) {
- pd_dprintf("error cirque_pinnacle i2c_writeReg\n");
+ if (i2c_write_register(CIRQUE_PINNACLE_ADDR << 1, cmdByte, &data, sizeof(data), CIRQUE_PINNACLE_TIMEOUT) != I2C_STATUS_SUCCESS) {
+ pd_dprintf("error cirque_pinnacle i2c_write_register\n");
touchpad_init = false;
}
- i2c_stop();
}
}
diff --git a/drivers/sensors/pimoroni_trackball.c b/drivers/sensors/pimoroni_trackball.c
index 326e59744f..9c6d26d73d 100644
--- a/drivers/sensors/pimoroni_trackball.c
+++ b/drivers/sensors/pimoroni_trackball.c
@@ -56,13 +56,13 @@ void pimoroni_trackball_set_cpi(uint16_t cpi) {
void pimoroni_trackball_set_rgbw(uint8_t r, uint8_t g, uint8_t b, uint8_t w) {
uint8_t data[4] = {r, g, b, w};
- __attribute__((unused)) i2c_status_t status = i2c_writeReg(PIMORONI_TRACKBALL_ADDRESS << 1, PIMORONI_TRACKBALL_REG_LED_RED, data, sizeof(data), PIMORONI_TRACKBALL_TIMEOUT);
+ __attribute__((unused)) i2c_status_t status = i2c_write_register(PIMORONI_TRACKBALL_ADDRESS << 1, PIMORONI_TRACKBALL_REG_LED_RED, data, sizeof(data), PIMORONI_TRACKBALL_TIMEOUT);
pd_dprintf("Trackball RGBW i2c_status_t: %d\n", status);
}
i2c_status_t read_pimoroni_trackball(pimoroni_data_t* data) {
- i2c_status_t status = i2c_readReg(PIMORONI_TRACKBALL_ADDRESS << 1, PIMORONI_TRACKBALL_REG_LEFT, (uint8_t*)data, sizeof(*data), PIMORONI_TRACKBALL_TIMEOUT);
+ i2c_status_t status = i2c_read_register(PIMORONI_TRACKBALL_ADDRESS << 1, PIMORONI_TRACKBALL_REG_LEFT, (uint8_t*)data, sizeof(*data), PIMORONI_TRACKBALL_TIMEOUT);
#ifdef POINTING_DEVICE_DEBUG
static uint16_t d_timer;