Commit b49a908c authored by DylanVanAssche's avatar DylanVanAssche

[iioadaptor] Handle edge case for inverted IIO proximity sensor. Fixes MER#2076.

parent 4f97982d
...@@ -56,6 +56,7 @@ ...@@ -56,6 +56,7 @@
// Proximity sensor // Proximity sensor
#define PROXIMITY_DEFAULT_THRESHOLD 250 #define PROXIMITY_DEFAULT_THRESHOLD 250
#define PROXIMITY_NEAR_VALUE 0 #define PROXIMITY_NEAR_VALUE 0
#define PROXIMITY_FAR_VALUE 100
/* Conversion of acceleration data to SI units (m/s^2) */ /* Conversion of acceleration data to SI units (m/s^2) */
#define CONVERT_A_X(x) ((float(x) / 1000) * (GRAVITY * -1.0)) #define CONVERT_A_X(x) ((float(x) / 1000) * (GRAVITY * -1.0))
...@@ -459,11 +460,12 @@ void IioAdaptor::processSample(int fileId, int fd) ...@@ -459,11 +460,12 @@ void IioAdaptor::processSample(int fileId, int fd)
bool near = false; bool near = false;
int proximityValue = (result + iioDevice.offset) * iioDevice.scale; int proximityValue = (result + iioDevice.offset) * iioDevice.scale;
proximityData = proximityBuffer_->nextSlot(); proximityData = proximityBuffer_->nextSlot();
// IIO proximity sensors are inverted in comparison to Hybris proximity sensors
if (proximityValue >= proximityThreshold) { if (proximityValue >= proximityThreshold) {
near = true; near = true;
} }
proximityData->withinProximity_ = near; proximityData->withinProximity_ = near;
proximityData->value_ = near ? PROXIMITY_NEAR_VALUE : proximityValue; proximityData->value_ = near ? PROXIMITY_NEAR_VALUE : PROXIMITY_FAR_VALUE;
} }
break; break;
default: default:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment