Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Lorn Potter
committed
Aug 21, 2013
1 parent
d3ccfc9
commit 287f09a
Showing
35 changed files
with
1,951 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
TARGET = hybrisaccelerometeradaptor | ||
|
||
HEADERS += hybrisaccelerometeradaptor.h \ | ||
hybrisaccelerometeradaptorplugin.h | ||
|
||
SOURCES += hybrisaccelerometeradaptor.cpp \ | ||
hybrisaccelerometeradaptorplugin.cpp | ||
|
||
include( ../adaptor-config.pri ) |
75 changes: 75 additions & 0 deletions
75
adaptors/hybrisaccelerometer/hybrisaccelerometeradaptor.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
/**************************************************************************** | ||
** | ||
** Copyright (C) 2013 Jolla Ltd | ||
** Contact: lorn.potter@jollamobile.com | ||
** | ||
** | ||
** $QT_BEGIN_LICENSE:LGPL$ | ||
** | ||
** GNU Lesser General Public License Usage | ||
** Alternatively, this file may be used under the terms of the GNU Lesser | ||
** General Public License version 2.1 as published by the Free Software | ||
** Foundation and appearing in the file LICENSE.LGPL included in the | ||
** packaging of this file. Please review the following information to | ||
** ensure the GNU Lesser General Public License version 2.1 requirements | ||
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. | ||
** | ||
** $QT_END_LICENSE$ | ||
** | ||
****************************************************************************/ | ||
|
||
#include "hybrisaccelerometeradaptor.h" | ||
#include "logging.h" | ||
#include "datatypes/utils.h" | ||
#include <android/hardware/sensors.h> | ||
|
||
HybrisAccelerometerAdaptor::HybrisAccelerometerAdaptor(const QString& id) : | ||
HybrisAdaptor(id,SENSOR_TYPE_ACCELEROMETER) | ||
{ | ||
buffer = new DeviceAdaptorRingBuffer<AccelerationData>(1); | ||
setAdaptedSensor("accelerometer", "Internal accelerometer coordinates", buffer); | ||
|
||
setDescription("Hybris accelerometer"); | ||
// setDefaultInterval(50); | ||
} | ||
|
||
HybrisAccelerometerAdaptor::~HybrisAccelerometerAdaptor() | ||
{ | ||
delete buffer; | ||
} | ||
|
||
bool HybrisAccelerometerAdaptor::startSensor() | ||
{ | ||
if (!(HybrisAdaptor::startSensor())) | ||
return false; | ||
|
||
sensordLogD() << "Hybris AccelAdaptor start\n"; | ||
return true; | ||
} | ||
|
||
void HybrisAccelerometerAdaptor::stopSensor() | ||
{ | ||
HybrisAdaptor::stopSensor(); | ||
sensordLogD() << "Hybris AccelAdaptor stop\n"; | ||
} | ||
|
||
void HybrisAccelerometerAdaptor::processSample(const sensors_event_t& data) | ||
{ | ||
|
||
AccelerationData *d = buffer->nextSlot(); | ||
d->timestamp_ = quint64(data.timestamp * .001); | ||
// sensorfw wants milli-G' | ||
d->x_ = -(data.data[0] / 9.80665 * 1000); | ||
d->y_ = -(data.data[1] / 9.80665 * 1000); | ||
d->z_ = -(data.data[2] / 9.80665 * 1000); | ||
// qt's sensorfw plugin expects G == 9.81286, but it should be | ||
//9.80665 | ||
buffer->commit(); | ||
buffer->wakeUpReaders(); | ||
} | ||
|
||
//void HybrisAccelerometerAdaptor::init() | ||
//{ | ||
//// introduceAvailableDataRange(DataRange(-HybrisAdaptor::maxRange, HybrisAdaptor::maxRange , 1)); | ||
//// introduceAvailableInterval(DataRange(10, 586, 0)); | ||
//} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/**************************************************************************** | ||
** | ||
** Copyright (C) 2013 Jolla Ltd | ||
** Contact: lorn.potter@jollamobile.com | ||
** | ||
** | ||
** $QT_BEGIN_LICENSE:LGPL$ | ||
** | ||
** GNU Lesser General Public License Usage | ||
** Alternatively, this file may be used under the terms of the GNU Lesser | ||
** General Public License version 2.1 as published by the Free Software | ||
** Foundation and appearing in the file LICENSE.LGPL included in the | ||
** packaging of this file. Please review the following information to | ||
** ensure the GNU Lesser General Public License version 2.1 requirements | ||
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. | ||
** | ||
** $QT_END_LICENSE$ | ||
** | ||
****************************************************************************/ | ||
|
||
#ifndef HYBRISACCELEROMETERADPTOR_H | ||
#define HYBRISACCELEROMETERADPTOR_H | ||
|
||
#include "hybrisadaptor.h" | ||
|
||
#include <QString> | ||
#include <QStringList> | ||
#include "deviceadaptorringbuffer.h" | ||
#include "datatypes/orientationdata.h" | ||
|
||
class HybrisAccelerometerAdaptor : public HybrisAdaptor | ||
{ | ||
Q_OBJECT | ||
|
||
public: | ||
static DeviceAdaptor* factoryMethod(const QString& id) { | ||
return new HybrisAccelerometerAdaptor(id); | ||
} | ||
HybrisAccelerometerAdaptor(const QString& id); | ||
~HybrisAccelerometerAdaptor(); | ||
|
||
bool startSensor(); | ||
void stopSensor(); | ||
|
||
protected: | ||
void processSample(const sensors_event_t& data); | ||
// void init(); | ||
|
||
private: | ||
DeviceAdaptorRingBuffer<AccelerationData>* buffer; | ||
int sensorType; | ||
|
||
}; | ||
#endif |
35 changes: 35 additions & 0 deletions
35
adaptors/hybrisaccelerometer/hybrisaccelerometeradaptorplugin.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/**************************************************************************** | ||
** | ||
** Copyright (C) 2013 Jolla Ltd | ||
** Contact: lorn.potter@jollamobile.com | ||
** | ||
** | ||
** $QT_BEGIN_LICENSE:LGPL$ | ||
** | ||
** GNU Lesser General Public License Usage | ||
** Alternatively, this file may be used under the terms of the GNU Lesser | ||
** General Public License version 2.1 as published by the Free Software | ||
** Foundation and appearing in the file LICENSE.LGPL included in the | ||
** packaging of this file. Please review the following information to | ||
** ensure the GNU Lesser General Public License version 2.1 requirements | ||
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. | ||
** | ||
** $QT_END_LICENSE$ | ||
** | ||
****************************************************************************/ | ||
|
||
#include "hybrisaccelerometeradaptorplugin.h" | ||
#include "hybrisaccelerometeradaptor.h" | ||
#include "sensormanager.h" | ||
#include "logging.h" | ||
|
||
void HybrisAccelerometerAdaptorPlugin::Register(class Loader&) | ||
{ | ||
sensordLogD() << "registering hybrisaccelerometeradaptor"; | ||
SensorManager& sm = SensorManager::instance(); | ||
sm.registerDeviceAdaptor<HybrisAccelerometerAdaptor>("accelerometeradaptor"); | ||
} | ||
|
||
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) | ||
Q_EXPORT_PLUGIN2(hybrisaccelerometeradaptor, HybrisAccelerometerAdaptorPlugin) | ||
#endif |
37 changes: 37 additions & 0 deletions
37
adaptors/hybrisaccelerometer/hybrisaccelerometeradaptorplugin.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/**************************************************************************** | ||
** | ||
** Copyright (C) 2013 Jolla Ltd | ||
** Contact: lorn.potter@jollamobile.com | ||
** | ||
** | ||
** $QT_BEGIN_LICENSE:LGPL$ | ||
** | ||
** GNU Lesser General Public License Usage | ||
** Alternatively, this file may be used under the terms of the GNU Lesser | ||
** General Public License version 2.1 as published by the Free Software | ||
** Foundation and appearing in the file LICENSE.LGPL included in the | ||
** packaging of this file. Please review the following information to | ||
** ensure the GNU Lesser General Public License version 2.1 requirements | ||
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. | ||
** | ||
** $QT_END_LICENSE$ | ||
** | ||
****************************************************************************/ | ||
|
||
#ifndef HYBRISACCELEROMETERADAPTORPLUGIN_H | ||
#define HYBRISACCELEROMETERADAPTORPLUGIN_H | ||
|
||
#include "plugin.h" | ||
|
||
class HybrisAccelerometerAdaptorPlugin : public Plugin | ||
{ | ||
Q_OBJECT | ||
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) | ||
Q_PLUGIN_METADATA(IID "com.nokia.SensorService.Plugin/1.0") | ||
#endif | ||
|
||
private: | ||
void Register(class Loader& l); | ||
}; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
/**************************************************************************** | ||
** | ||
** Copyright (C) 2013 Jolla Ltd | ||
** Contact: lorn.potter@jollamobile.com | ||
** | ||
** | ||
** $QT_BEGIN_LICENSE:LGPL$ | ||
** | ||
** GNU Lesser General Public License Usage | ||
** Alternatively, this file may be used under the terms of the GNU Lesser | ||
** General Public License version 2.1 as published by the Free Software | ||
** Foundation and appearing in the file LICENSE.LGPL included in the | ||
** packaging of this file. Please review the following information to | ||
** ensure the GNU Lesser General Public License version 2.1 requirements | ||
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. | ||
** | ||
** $QT_END_LICENSE$ | ||
** | ||
****************************************************************************/ | ||
|
||
#include "hybrisalsadaptor.h" | ||
#include "logging.h" | ||
#include "datatypes/utils.h" | ||
#include <android/hardware/sensors.h> | ||
|
||
HybrisAlsAdaptor::HybrisAlsAdaptor(const QString& id) : | ||
HybrisAdaptor(id,SENSOR_TYPE_LIGHT) | ||
{ | ||
buffer = new DeviceAdaptorRingBuffer<TimedUnsigned>(1); | ||
setAdaptedSensor("als", "Internal ambient light sensor lux values", buffer); | ||
// setDefaultInterval(50); | ||
setDescription("Hybris als"); | ||
} | ||
|
||
HybrisAlsAdaptor::~HybrisAlsAdaptor() | ||
{ | ||
delete buffer; | ||
} | ||
|
||
bool HybrisAlsAdaptor::startSensor() | ||
{ | ||
if (!(HybrisAdaptor::startSensor())) | ||
return false; | ||
|
||
sensordLogD() << "Hybris HybrisAlsAdaptor start\n"; | ||
return true; | ||
} | ||
|
||
void HybrisAlsAdaptor::stopSensor() | ||
{ | ||
HybrisAdaptor::stopSensor(); | ||
sensordLogD() << "Hybris HybrisAlsAdaptor stop\n"; | ||
} | ||
|
||
void HybrisAlsAdaptor::processSample(const sensors_event_t& data) | ||
{ | ||
TimedUnsigned *d = buffer->nextSlot(); | ||
d->timestamp_ = quint64(data.timestamp * .0001); | ||
d->value_ = data.light; | ||
|
||
buffer->commit(); | ||
buffer->wakeUpReaders(); | ||
} | ||
|
||
void HybrisAlsAdaptor::init() | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/**************************************************************************** | ||
** | ||
** Copyright (C) 2013 Jolla Ltd | ||
** Contact: lorn.potter@jollamobile.com | ||
** | ||
** | ||
** $QT_BEGIN_LICENSE:LGPL$ | ||
** | ||
** GNU Lesser General Public License Usage | ||
** Alternatively, this file may be used under the terms of the GNU Lesser | ||
** General Public License version 2.1 as published by the Free Software | ||
** Foundation and appearing in the file LICENSE.LGPL included in the | ||
** packaging of this file. Please review the following information to | ||
** ensure the GNU Lesser General Public License version 2.1 requirements | ||
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. | ||
** | ||
** $QT_END_LICENSE$ | ||
** | ||
****************************************************************************/ | ||
|
||
#ifndef HYBRISALSADAPTOR_H | ||
#define HYBRISALSADAPTOR_H | ||
#include "hybrisadaptor.h" | ||
|
||
#include <QString> | ||
#include <QStringList> | ||
#include <linux/input.h> | ||
#include "deviceadaptorringbuffer.h" | ||
#include "datatypes/orientationdata.h" | ||
#include <QTime> | ||
|
||
class HybrisAlsAdaptor : public HybrisAdaptor | ||
{ | ||
Q_OBJECT | ||
|
||
public: | ||
static DeviceAdaptor* factoryMethod(const QString& id) { | ||
return new HybrisAlsAdaptor(id); | ||
} | ||
HybrisAlsAdaptor(const QString& id); | ||
~HybrisAlsAdaptor(); | ||
|
||
bool startSensor(); | ||
void stopSensor(); | ||
|
||
protected: | ||
void processSample(const sensors_event_t& data); | ||
void init(); | ||
|
||
private: | ||
DeviceAdaptorRingBuffer<TimedUnsigned>* buffer; | ||
|
||
|
||
}; | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
TARGET = hybrisalsadaptor | ||
|
||
HEADERS += hybrisalsadaptor.h \ | ||
hybrisalsadaptorplugin.h | ||
|
||
SOURCES += hybrisalsadaptor.cpp \ | ||
hybrisalsadaptorplugin.cpp | ||
|
||
include(../adaptor-config.pri ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/**************************************************************************** | ||
** | ||
** Copyright (C) 2013 Jolla Ltd | ||
** Contact: lorn.potter@jollamobile.com | ||
** | ||
** | ||
** $QT_BEGIN_LICENSE:LGPL$ | ||
** | ||
** GNU Lesser General Public License Usage | ||
** Alternatively, this file may be used under the terms of the GNU Lesser | ||
** General Public License version 2.1 as published by the Free Software | ||
** Foundation and appearing in the file LICENSE.LGPL included in the | ||
** packaging of this file. Please review the following information to | ||
** ensure the GNU Lesser General Public License version 2.1 requirements | ||
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. | ||
** | ||
** $QT_END_LICENSE$ | ||
** | ||
****************************************************************************/ | ||
|
||
#include "hybrisalsadaptorplugin.h" | ||
#include "hybrisalsadaptor.h" | ||
#include "sensormanager.h" | ||
#include "logging.h" | ||
|
||
void HybrisAlsAdaptorPlugin::Register(class Loader&) | ||
{ | ||
sensordLogD() << "registering hybrisalsadaptor"; | ||
SensorManager& sm = SensorManager::instance(); | ||
sm.registerDeviceAdaptor<HybrisAlsAdaptor>("alsadaptor"); | ||
} | ||
|
||
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) | ||
Q_EXPORT_PLUGIN2(hybrisalsadaptor, HybrisAlsAdaptorPlugin) | ||
#endif |
Oops, something went wrong.