Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[iioadaptor] Handle edge case for inverted IIO proximity sensor. Fixe…
…s MER#2076.
  • Loading branch information
DylanVanAssche committed Jan 20, 2020
1 parent 4f97982 commit b49a908
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion adaptors/iioadaptor/iioadaptor.cpp
Expand Up @@ -56,6 +56,7 @@
// Proximity sensor
#define PROXIMITY_DEFAULT_THRESHOLD 250
#define PROXIMITY_NEAR_VALUE 0
#define PROXIMITY_FAR_VALUE 100

/* Conversion of acceleration data to SI units (m/s^2) */
#define CONVERT_A_X(x) ((float(x) / 1000) * (GRAVITY * -1.0))
Expand Down Expand Up @@ -459,11 +460,12 @@ void IioAdaptor::processSample(int fileId, int fd)
bool near = false;
int proximityValue = (result + iioDevice.offset) * iioDevice.scale;
proximityData = proximityBuffer_->nextSlot();
// IIO proximity sensors are inverted in comparison to Hybris proximity sensors
if (proximityValue >= proximityThreshold) {
near = true;
}
proximityData->withinProximity_ = near;
proximityData->value_ = near ? PROXIMITY_NEAR_VALUE : proximityValue;
proximityData->value_ = near ? PROXIMITY_NEAR_VALUE : PROXIMITY_FAR_VALUE;
}
break;
default:
Expand Down

0 comments on commit b49a908

Please sign in to comment.