summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJyoti Bhayana <jbhayana@google.com>2020-08-21 11:24:35 -0700
committerJyoti Bhayana <jbhayana@google.com>2020-08-21 13:40:04 -0700
commitea8b73ca844ab32b24a53e3f474bafcb43023f32 (patch)
treee33ec1dc005dda5c083dbb65532ad00ebfb6519e
parentd915bc02647bd4295fb82c7177c8ab189e8fa7f0 (diff)
downloaddevice_google_trout-android11-mainline-media-release.tar.gz
device_google_trout-android11-mainline-media-release.tar.bz2
device_google_trout-android11-mainline-media-release.zip
sensor hal Bug: 163167988 Test: Build, test using KitchenSink Change-Id: I70bd3627110968d7388fc806105fd1310075182a
-rw-r--r--hal/sensors/2.0/Sensor.cpp19
1 files changed, 7 insertions, 12 deletions
diff --git a/hal/sensors/2.0/Sensor.cpp b/hal/sensors/2.0/Sensor.cpp
index a525754..b5288e2 100644
--- a/hal/sensors/2.0/Sensor.cpp
+++ b/hal/sensors/2.0/Sensor.cpp
@@ -122,30 +122,25 @@ Result SensorBase::flush() {
void HWSensorBase::processScanData(uint8_t* data, Event* evt) {
float channelData[NUM_OF_CHANNEL_SUPPORTED - 1];
- int64_t ts;
unsigned int chanIdx;
evt->sensorHandle = mSensorInfo.sensorHandle;
evt->sensorType = mSensorInfo.type;
for (auto i = 0u; i < miio_data.channelInfo.size(); i++) {
chanIdx = miio_data.channelInfo[i].index;
- if (miio_data.channelInfo[i].sign) {
- int64_t val = *reinterpret_cast<int64_t*>(
- data + chanIdx * miio_data.channelInfo[i].storage_bytes);
- if (chanIdx == (miio_data.channelInfo.size() - 1)) {
- ts = val;
- } else {
- channelData[chanIdx] = (static_cast<float>(val) * miio_data.resolution);
- }
+ const int64_t val = *reinterpret_cast<int64_t*>(
+ data + chanIdx * miio_data.channelInfo[i].storage_bytes);
+
+ // If the channel index is the last, it is timestamp
+ // else it is sensor data
+ if (chanIdx == miio_data.channelInfo.size() - 1) {
+ evt->timestamp = val;
} else {
- uint64_t val = *reinterpret_cast<uint64_t*>(
- data + chanIdx * miio_data.channelInfo[i].storage_bytes);
channelData[chanIdx] = (static_cast<float>(val) * miio_data.resolution);
}
}
evt->u.vec3.x = channelData[0];
evt->u.vec3.y = channelData[1];
evt->u.vec3.z = channelData[2];
- evt->timestamp = ts;
evt->u.vec3.status = SensorStatus::ACCURACY_HIGH;
}