Skip to content

Commit ca91a36

Browse files
committed
Compensate for newer firmware
1 parent 7570e41 commit ca91a36

File tree

3 files changed

+43
-10
lines changed

3 files changed

+43
-10
lines changed

src/CirquePinnacle.cpp

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
#include <cstring> // memcpy(), memset()
2323
#endif
2424

25-
PinnacleTouch::PinnacleTouch(pinnacle_gpio_t dataReadyPin) : _dataReady(dataReadyPin)
25+
PinnacleTouch::PinnacleTouch(pinnacle_gpio_t dataReadyPin) : _dataReady(dataReadyPin), _rev2025(false)
2626
{
2727
PINNACLE_USE_ARDUINO_API
2828
pinMode(_dataReady, INPUT);
@@ -34,7 +34,8 @@ bool PinnacleTouch::begin()
3434
delay(100);
3535
uint8_t buffer[3] = {0}; // index 2 is relative mode defaults
3636
rapReadBytes(PINNACLE_FIRMWARE_ID, buffer, 2);
37-
if (buffer[0] == 7 || buffer[1] == 0x3A) {
37+
_rev2025 = buffer[0] == 0x0E && buffer[1] == 0x75;
38+
if (_rev2025 || (buffer[0] == 7 && buffer[1] == 0x3A)) {
3839
_dataMode = PINNACLE_RELATIVE;
3940
buffer[0] = 0; // config power (defaults) and disable anymeas flags
4041
buffer[1] = 0; // config absolute mode defaults and disable feed
@@ -123,6 +124,11 @@ PinnacleDataMode PinnacleTouch::getDataMode()
123124
return _dataMode;
124125
}
125126

127+
bool PinnacleTouch::isRev2025()
128+
{
129+
return _rev2025;
130+
}
131+
126132
bool PinnacleTouch::isHardConfigured()
127133
{
128134
if (_dataMode <= PINNACLE_ABSOLUTE) {
@@ -254,7 +260,7 @@ bool PinnacleTouch::isShutdown()
254260
void PinnacleTouch::setSampleRate(uint16_t value)
255261
{
256262
if (_dataMode == PINNACLE_ABSOLUTE || _dataMode == PINNACLE_RELATIVE) {
257-
if (value == 200 || value == 300) {
263+
if (!_rev2025 && (value == 200 || value == 300)) {
258264
// disable palm & noise compensations
259265
rapWrite(PINNACLE_FEED_CONFIG_3, 10);
260266
uint8_t reloadTimer = value == 300 ? 6 : 9;
@@ -264,7 +270,9 @@ void PinnacleTouch::setSampleRate(uint16_t value)
264270
else {
265271
// enable palm & noise compensations
266272
rapWrite(PINNACLE_FEED_CONFIG_3, 0);
267-
eraWriteBytes(0x019E, 0x13, 2);
273+
if (!_rev2025) {
274+
eraWriteBytes(0x019E, 0x13, 2);
275+
}
268276
}
269277
// bad input values interpreted as 100 by Pinnacle
270278
rapWrite(PINNACLE_SAMPLE_RATE, (uint8_t)value);
@@ -276,7 +284,7 @@ uint16_t PinnacleTouch::getSampleRate()
276284
if (_dataMode == PINNACLE_ABSOLUTE || _dataMode == PINNACLE_RELATIVE) {
277285
uint8_t temp = 0;
278286
rapRead(PINNACLE_SAMPLE_RATE, &temp);
279-
if (temp == 0) {
287+
if (!_rev2025 && temp == 0) {
280288
eraRead(0x019E, &temp);
281289
return temp == 6 ? 300 : 200;
282290
}
@@ -290,7 +298,7 @@ uint16_t PinnacleTouch::getSampleRate()
290298

291299
void PinnacleTouch::detectFingerStylus(bool enableFinger, bool enableStylus, uint16_t sampleRate)
292300
{
293-
if (_dataMode == PINNACLE_ABSOLUTE || _dataMode == PINNACLE_RELATIVE) {
301+
if (!_rev2025 && (_dataMode == PINNACLE_ABSOLUTE || _dataMode == PINNACLE_RELATIVE)) {
294302
setSampleRate(sampleRate);
295303
uint8_t fingerStylus = 0;
296304
eraRead(0x00EB, &fingerStylus);
@@ -322,7 +330,7 @@ bool PinnacleTouch::calibrate(bool run, bool tap, bool trackError, bool nerd, bo
322330

323331
void PinnacleTouch::setCalibrationMatrix(int16_t* matrix, uint8_t len)
324332
{
325-
if (_dataMode <= PINNACLE_ABSOLUTE) {
333+
if (!_rev2025 && _dataMode <= PINNACLE_ABSOLUTE) {
326334
bool prevFeedState = isFeedEnabled();
327335
if (prevFeedState)
328336
feedEnabled(false); // this will save time on subsequent eraWrite calls
@@ -343,7 +351,7 @@ void PinnacleTouch::setCalibrationMatrix(int16_t* matrix, uint8_t len)
343351

344352
void PinnacleTouch::getCalibrationMatrix(int16_t* matrix)
345353
{
346-
if (_dataMode <= PINNACLE_ABSOLUTE) {
354+
if (!_rev2025 && _dataMode <= PINNACLE_ABSOLUTE) {
347355
// must use sequential read of 92 bytes; individual reads return inaccurate data
348356
eraReadBytes(0x01DF, reinterpret_cast<uint8_t*>(matrix), 92);
349357
for (uint8_t i = 0; i < 46; ++i) {
@@ -355,7 +363,7 @@ void PinnacleTouch::getCalibrationMatrix(int16_t* matrix)
355363

356364
void PinnacleTouch::setAdcGain(uint8_t sensitivity)
357365
{
358-
if (_dataMode <= PINNACLE_ABSOLUTE) {
366+
if (!_rev2025 && _dataMode <= PINNACLE_ABSOLUTE) {
359367
if (sensitivity >= 4)
360368
sensitivity = 0; // faulty input defaults to highest sensitivity
361369
uint8_t temp = 0;
@@ -366,7 +374,7 @@ void PinnacleTouch::setAdcGain(uint8_t sensitivity)
366374

367375
void PinnacleTouch::tuneEdgeSensitivity(uint8_t xAxisWideZMin, uint8_t yAxisWideZMin)
368376
{
369-
if (_dataMode <= PINNACLE_ABSOLUTE) {
377+
if (!_rev2025 && _dataMode <= PINNACLE_ABSOLUTE) {
370378
eraWrite(0x0149, xAxisWideZMin);
371379
eraWrite(0x0168, yAxisWideZMin);
372380
}

src/CirquePinnacle.h

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,28 @@ class PinnacleTouch
342342
* initialize the trackpad)
343343
*/
344344
PinnacleDataMode getDataMode();
345+
/**
346+
* Is the trackpad using a newer firmware revision?
347+
*
348+
* .. note::
349+
* The value returned is only valid after calling `begin()`.
350+
*
351+
* This function describes if the Pinnacle ASIC uses a firmware revision
352+
* that was deployed on or around 2025. Consequently, some advanced configuration
353+
* is not possible with this undocumented firmware revision.
354+
* Thus, the following functionality is affected on the trackpads when this
355+
* function returns ``True``:
356+
*
357+
* - `setSampleRate()` accepted value shall exceed ``100``
358+
* - `detectFingerStylus()` is non-operational
359+
* - `tuneEdgeSensitivity()` is non-operational
360+
* - `setAdcGain()` is non-operational
361+
* - `setCalibrationMatrix()` is non-operational
362+
* - `getCalibrationMatrix()` is non-operational
363+
*
364+
* .. versionadded:: 2.0.0
365+
*/
366+
bool isRev2025();
345367
/**
346368
* This function can be used to inform applications about the factory
347369
* customized hardware configuration.
@@ -791,6 +813,7 @@ class PinnacleTouch
791813
void eraReadBytes(uint16_t, uint8_t*, uint8_t);
792814
PinnacleDataMode _dataMode;
793815
bool _intellimouse;
816+
bool _rev2025;
794817
const pinnacle_gpio_t _dataReady;
795818
virtual void rapWriteCmd(uint8_t*, uint8_t) = 0;
796819
virtual void rapWrite(uint8_t, uint8_t) = 0;

src/py_bindings.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,8 @@ PYBIND11_MODULE(cirque_pinnacle, m)
212212
pinnacleTouch.def("feedEnabled", &PinnacleTouch::feedEnabled);
213213
pinnacleTouch.def_property_readonly("is_hard_configured", &PinnacleTouch::isHardConfigured);
214214
pinnacleTouch.def("isHardConfigured", &PinnacleTouch::isHardConfigured);
215+
pinnacleTouch.def_property_readonly("rev2025", &PinnacleTouch::isRev2025);
216+
pinnacleTouch.def("isRev2025", &PinnacleTouch::isRev2025);
215217
pinnacleTouch.def("available", &PinnacleTouch::available);
216218
pinnacleTouch.def("absolute_mode_config", &PinnacleTouch::absoluteModeConfig,
217219
py::arg("z_idle_count") = 30, py::arg("invert_x") = false, py::arg("invert_x") = false);

0 commit comments

Comments
 (0)