Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[hybrisadaptor] Add binder backend to hybris adaptor. Fixes JB#45163
  • Loading branch information
mlehtima committed Apr 17, 2019
1 parent 3a0e3a7 commit 1dd09c7
Show file tree
Hide file tree
Showing 16 changed files with 854 additions and 118 deletions.
7 changes: 6 additions & 1 deletion adaptors/hybrisaccelerometer/hybrisaccelerometeradaptor.cpp
Expand Up @@ -21,7 +21,6 @@
#include "hybrisaccelerometeradaptor.h"
#include "logging.h"
#include "datatypes/utils.h"
#include <hardware/sensors.h>
#include "config.h"

#define GRAVITY_RECIPROCAL_THOUSANDS 101.971621298
Expand Down Expand Up @@ -66,9 +65,15 @@ void HybrisAccelerometerAdaptor::processSample(const sensors_event_t& data)
d->timestamp_ = quint64(data.timestamp * .001);
// sensorfw wants milli-G'

#ifdef USE_BINDER
d->x_ = data.u.vec3.x * GRAVITY_RECIPROCAL_THOUSANDS;
d->y_ = data.u.vec3.y * GRAVITY_RECIPROCAL_THOUSANDS;
d->z_ = data.u.vec3.z * GRAVITY_RECIPROCAL_THOUSANDS;
#else
d->x_ = data.acceleration.x * GRAVITY_RECIPROCAL_THOUSANDS;
d->y_ = data.acceleration.y * GRAVITY_RECIPROCAL_THOUSANDS;
d->z_ = data.acceleration.z * GRAVITY_RECIPROCAL_THOUSANDS;
#endif

buffer->commit();
buffer->wakeUpReaders();
Expand Down
5 changes: 4 additions & 1 deletion adaptors/hybrisalsadaptor/hybrisalsadaptor.cpp
Expand Up @@ -24,7 +24,6 @@
#include "hybrisalsadaptor.h"
#include "logging.h"
#include "datatypes/utils.h"
#include <hardware/sensors.h>
#include "config.h"

#include <fcntl.h>
Expand Down Expand Up @@ -129,7 +128,11 @@ void HybrisAlsAdaptor::processSample(const sensors_event_t& data)
{
TimedUnsigned *d = buffer->nextSlot();
d->timestamp_ = quint64(data.timestamp * .001);
#ifdef USE_BINDER
d->value_ = data.u.scalar;
#else
d->value_ = data.light;
#endif
lastLightValue = d->value_;
buffer->commit();
buffer->wakeUpReaders();
Expand Down
7 changes: 6 additions & 1 deletion adaptors/hybrisgyroscopeadaptor/hybrisgyroscopeadaptor.cpp
Expand Up @@ -21,7 +21,6 @@
#include "hybrisgyroscopeadaptor.h"
#include "logging.h"
#include "datatypes/utils.h"
#include <hardware/sensors.h>
#include "config.h"
#include <math.h>

Expand Down Expand Up @@ -73,9 +72,15 @@ void HybrisGyroscopeAdaptor::processSample(const sensors_event_t& data)

TimedXyzData *d = buffer->nextSlot();
d->timestamp_ = quint64(data.timestamp * .001);
#ifdef USE_BINDER
d->x_ = (data.u.vec3.x) * RADIANS_TO_DEGREES * 1000;
d->y_ = (data.u.vec3.y) * RADIANS_TO_DEGREES * 1000;
d->z_ = (data.u.vec3.z) * RADIANS_TO_DEGREES * 1000;
#else
d->x_ = (data.gyro.x) * RADIANS_TO_DEGREES * 1000;
d->y_ = (data.gyro.y) * RADIANS_TO_DEGREES * 1000;
d->z_ = (data.gyro.z) * RADIANS_TO_DEGREES * 1000;
#endif
buffer->commit();
buffer->wakeUpReaders();
}
Expand Down
13 changes: 11 additions & 2 deletions adaptors/hybrismagnetometeradaptor/hybrismagnetometeradaptor.cpp
Expand Up @@ -21,7 +21,6 @@
#include "hybrismagnetometeradaptor.h"
#include "logging.h"
#include "datatypes/utils.h"
#include <hardware/sensors.h>
#include "config.h"

HybrisMagnetometerAdaptor::HybrisMagnetometerAdaptor(const QString& id) :
Expand Down Expand Up @@ -68,6 +67,16 @@ void HybrisMagnetometerAdaptor::processSample(const sensors_event_t& data)
{
CalibratedMagneticFieldData *d = buffer->nextSlot();
d->timestamp_ = quint64(data.timestamp * .001);

#ifdef USE_BINDER
d->x_ = data.u.vec3.x * 1000;
d->y_ = data.u.vec3.y * 1000;
d->z_ = data.u.vec3.z * 1000;
d->rx_ = data.u.vec3.x * 1000;
d->ry_ = data.u.vec3.y * 1000;
d->rz_ = data.u.vec3.z * 1000;
d->level_= data.u.vec3.status;
#else
//uT
d->x_ = (data.magnetic.x * 1000);
d->y_ = (data.magnetic.y * 1000);
Expand All @@ -81,7 +90,7 @@ void HybrisMagnetometerAdaptor::processSample(const sensors_event_t& data)
d->rx_ = data.magnetic.x * 1000;
d->ry_ = data.magnetic.y * 1000;
d->rz_ = data.magnetic.z * 1000;

#endif
#endif
buffer->commit();
buffer->wakeUpReaders();
Expand Down
Expand Up @@ -21,7 +21,6 @@
#include "hybrisorientationadaptor.h"
#include "logging.h"
#include "datatypes/utils.h"
#include <hardware/sensors.h>
#include "config.h"

/*
Expand Down Expand Up @@ -84,9 +83,14 @@ void HybrisOrientationAdaptor::processSample(const sensors_event_t& data)
{
CompassData *d = buffer->nextSlot();
d->timestamp_ = quint64(data.timestamp * .001);
#ifdef USE_BINDER
d->degrees_ = data.u.vec3.x; //azimuth
d->level_ = data.u.vec3.status;
#else
d->degrees_ = data.orientation.azimuth; //azimuth
d->rawDegrees_ = d->degrees_;
d->level_ = data.orientation.status;
#endif
d->rawDegrees_ = d->degrees_;

buffer->commit();
buffer->wakeUpReaders();
Expand Down
5 changes: 4 additions & 1 deletion adaptors/hybrispressureadaptor/hybrispressureadaptor.cpp
Expand Up @@ -26,7 +26,6 @@
#include "hybrispressureadaptor.h"
#include "logging.h"
#include "datatypes/utils.h"
#include <hardware/sensors.h>
#include "config.h"

HybrisPressureAdaptor::HybrisPressureAdaptor(const QString& id) :
Expand Down Expand Up @@ -70,7 +69,11 @@ void HybrisPressureAdaptor::processSample(const sensors_event_t& data)
{
TimedUnsigned *d = buffer->nextSlot();
d->timestamp_ = quint64(data.timestamp * .001);
#ifdef USE_BINDER
d->value_ = data.u.scalar * 100;//From hPa to Pa
#else
d->value_ = data.pressure * 100;//From hPa to Pa
#endif
buffer->commit();
buffer->wakeUpReaders();
}
Expand Down
10 changes: 8 additions & 2 deletions adaptors/hybrisproximityadaptor/hybrisproximityadaptor.cpp
Expand Up @@ -25,7 +25,6 @@
#include "hybrisproximityadaptor.h"
#include "logging.h"
#include "datatypes/utils.h"
#include <hardware/sensors.h>
#include "config.h"
#include <fcntl.h>
#include <unistd.h>
Expand Down Expand Up @@ -138,11 +137,18 @@ void HybrisProximityAdaptor::processSample(const sensors_event_t& data)
ProximityData *d = buffer->nextSlot();
d->timestamp_ = quint64(data.timestamp * .001);
bool near = false;
#ifdef USE_BINDER
if (data.u.scalar < maxRange()) {
near = true;
}
d->value_ = data.u.scalar;
#else
if (data.distance < maxRange()) {
near = true;
}
d->withinProximity_ = near;
d->value_ = data.distance;
#endif
d->withinProximity_ = near;

lastNearValue = near;
buffer->commit();
Expand Down
Expand Up @@ -24,7 +24,6 @@
#include "hybrisstepcounteradaptor.h"
#include "logging.h"
#include "datatypes/utils.h"
#include <hardware/sensors.h>
#include "config.h"

#ifndef SENSOR_TYPE_STEP_COUNTER
Expand Down Expand Up @@ -81,12 +80,16 @@ void HybrisStepCounterAdaptor::processSample(const sensors_event_t& data)
{
TimedUnsigned *d = buffer->nextSlot();
d->timestamp_ = quint64(data.timestamp * .001);
#ifdef USE_BINDER
d->value_ = data.u.stepCount;
#else
#ifdef NO_SENSORS_EVENT_U64
uint64_t value = 0;
memcpy(&value, data.data, sizeof value);
d->value_ = value;
#else
d->value_ = data.u64.step_counter;
#endif
#endif
buffer->commit();
buffer->wakeUpReaders();
Expand Down
8 changes: 6 additions & 2 deletions common-config.pri
Expand Up @@ -38,7 +38,11 @@ OTHER_FILES += \

contains(CONFIG,hybris) {
CONFIG += link_pkgconfig
PKGCONFIG += android-headers
PKGCONFIG += libhardware
contains(CONFIG,binder) {
DEFINES += USE_BINDER=1
PKGCONFIG += libgbinder libglibutil gobject-2.0 glib-2.0
} else {
PKGCONFIG += android-headers libhardware
}
}

9 changes: 5 additions & 4 deletions core/hybris.pro
Expand Up @@ -5,9 +5,6 @@ TARGET = hybrissensorfw

include( ../common-config.pri )

CONFIG += link_pkgconfig
PKGCONFIG += android-headers

SENSORFW_INCLUDEPATHS = .. \
../include \
../filters \
Expand All @@ -20,7 +17,11 @@ QMAKE_LIBDIR_FLAGS += -lsensordatatypes-qt5

SOURCES += hybrisadaptor.cpp
HEADERS += hybrisadaptor.h
LIBS += -L/usr/lib -lhybris-common -lhardware -L../datatypes
LIBS += -L/usr/lib -L../datatypes

!contains(CONFIG,binder) {
LIBS += -lhybris-common -lhardware
}

include(../common-install.pri)
target.path = $$SHAREDLIBPATH
Expand Down

0 comments on commit 1dd09c7

Please sign in to comment.