Skip to content

Commit 6a2be9b

Browse files
committed
Trill: removed unused variables warnings and signed/unsigned
comparisons, added definition for __try/__catch which were failing the CI
1 parent 9093a12 commit 6a2be9b

File tree

5 files changed

+17
-11
lines changed

5 files changed

+17
-11
lines changed

src/dev/trill/CentroidDetection.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,7 @@ class CentroidDetection::CalculateCentroids
1616
#include "calculateCentroids.h"
1717
void processCentroids(WORD *wVCentroid, WORD *wVCentroidSize, BYTE MAX_NUM_CENTROIDS, BYTE FIRST_SENSOR_V, BYTE LAST_SENSOR_V, BYTE numSensors) {
1818
long temp;
19-
signed char firstActiveSensor;
20-
signed char lastActiveSensor;
21-
BOOL bActivityDetected;
19+
BYTE lastActiveSensor;
2220
BYTE counter;
2321
WORD posEndOfLoop = (LAST_SENSOR_V - FIRST_SENSOR_V) << SLIDER_BITS;
2422
#include "processCentroids.h"
@@ -85,7 +83,6 @@ void CentroidDetection::process(const DATA_T* rawData)
8583
cc->CSD_waSnsDiff = data.data();
8684
cc->processCentroids(centroidBuffer.data(), sizeBuffer.data(), maxNumCentroids, 0, order.size(), num_sensors);
8785

88-
unsigned int locations = 0;
8986
// Look for 1st instance of 0xFFFF (no touch) in the buffer
9087
unsigned int i;
9188
for(i = 0; i < centroidBuffer.size(); ++i)

src/dev/trill/Trill.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,18 @@
33
#include <vector>
44
#include <string.h>
55

6+
#ifndef __try
7+
#if __cpp_exceptions
8+
# define __try try
9+
# define __catch(X) catch(X)
10+
# define __throw_exception_again throw
11+
#else
12+
# define __try if (true)
13+
# define __catch(X) if (false)
14+
# define __throw_exception_again
15+
#endif
16+
#endif // !__try
17+
618
constexpr uint8_t Trill::speedValues[4];
719
#define MAX_TOUCH_1D_OR_2D (((device_type_ == SQUARE || device_type_ == HEX) ? kMaxTouchNum2D : kMaxTouchNum1D))
820

src/dev/trill/Trill.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ class Trill : public I2c
7373
std::vector<uint8_t> dataBuffer;
7474
uint16_t commandSleepTime = 1000;
7575
size_t currentReadOffset = -1;
76-
bool shouldReadFrameId = false;
7776
unsigned int numBits;
7877
unsigned int transmissionWidth = 16;
7978
unsigned int transmissionRightShift = 0;

src/dev/trill/calculateCentroids.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
// returns a WORD packing two signed chars. The high bytes is the last active sensor in the last centroid,
22
// while the low byte is the first active sensor of the last centroid
33
WORD calculateCentroids(WORD *centroidBuffer, WORD *sizeBuffer, BYTE maxNumCentroids, BYTE minSensor, BYTE maxSensor, BYTE numSensors) {
4-
signed char lastActiveSensor = -1;
4+
BYTE lastActiveSensor = 255;
55
BYTE centroidIndex = 0, sensorIndex, actualHardwareIndex;
66
BYTE wrappedAround = 0;
77
BYTE inCentroid = 0;
88
WORD peakValue = 0, troughDepth = 0;
9-
BYTE counter;
109
long temp;
1110

1211
WORD lastSensorVal, currentSensorVal, currentWeightedSum, currentUnweightedSum;

src/dev/trill/processCentroids.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
temp = calculateCentroids(wVCentroid, wVCentroidSize, MAX_NUM_CENTROIDS, FIRST_SENSOR_V, LAST_SENSOR_V, numSensors); // Vertical centroids
2-
firstActiveSensor = temp & 0xFF;
32
lastActiveSensor = temp >> 8;
4-
bActivityDetected = lastActiveSensor >= 0;
53

64
temp = lastActiveSensor - (LAST_SENSOR_V - FIRST_SENSOR_V );// retrieve the (wrapped) index
75
//check for activity in the wraparound area
86
// IF the last centroid ended after wrapping around ...
97
// AND the first centroid was located before the end of the last ...
10-
if(lastActiveSensor >= LAST_SENSOR_V - FIRST_SENSOR_V
11-
&& (((BYTE)temp) << SLIDER_BITS) >= wVCentroid[0] )
8+
if(lastActiveSensor != 255 // 255 means no active sensor
9+
&& lastActiveSensor >= LAST_SENSOR_V - FIRST_SENSOR_V
10+
&& ((unsigned)temp) << SLIDER_BITS >= wVCentroid[0] )
1211
{
1312
// THEN the last touch is used to replace the first one
1413
for(counter = MAX_NUM_CENTROIDS - 1; counter >= 1; counter--) {

0 commit comments

Comments
 (0)