Skip to content

Commit 2551791

Browse files
committed
Trill: removed warnings and signed/unsigned comparisons
1 parent 9093a12 commit 2551791

File tree

3 files changed

+5
-10
lines changed

3 files changed

+5
-10
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/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)