Skip to content

Commit

Permalink
- Removed some magicnumber #defines
Browse files Browse the repository at this point in the history
 - Removed deprecated headers
  • Loading branch information
Antti Virtanen committed Dec 10, 2010
1 parent 81a0cc6 commit 8a48c93
Show file tree
Hide file tree
Showing 12 changed files with 20 additions and 214 deletions.
8 changes: 4 additions & 4 deletions filters/coordinatealignfilter/coordinatealignfilter.h
Expand Up @@ -30,12 +30,12 @@
#include "sensord/filter.h"
#include "sensord/filterproperty.h"

#define DIM 3

/**
* TMatrix holds a transformation matrix.
*/
class TMatrix {
private:
static const int DIM = 3;

public:
TMatrix() {
Expand All @@ -55,7 +55,7 @@ class TMatrix {
}
return data_[i][j];
};

void setMatrix(const double m[DIM][DIM]) {
memcpy(data_, m, sizeof(double[DIM][DIM]));
}
Expand All @@ -66,7 +66,7 @@ Q_DECLARE_METATYPE(TMatrix);

/**
* @brief Coordinate alignment filter.
*
*
* Performs three dimensional coordinate transformations.
* Transformation is described by transformation matrix which is set through
* \c TMatrix property. Matrix must be of size 3x3. Default TMatrix is
Expand Down
26 changes: 0 additions & 26 deletions filters/genericdata.h

This file was deleted.

26 changes: 0 additions & 26 deletions filters/orientationdata.h

This file was deleted.

26 changes: 0 additions & 26 deletions filters/posedata.h

This file was deleted.

34 changes: 12 additions & 22 deletions filters/rotationfilter/rotationfilter.cpp
Expand Up @@ -21,15 +21,11 @@
You should have received a copy of the GNU Lesser General Public
License along with Sensord. If not, see <http://www.gnu.org/licenses/>.
</p>
*/
*/

#include "rotationfilter.h"

#include <QVariant>
#include <math.h>

#define RADIANS_TO_DEGREES 180/M_PI

RotationFilter::RotationFilter() :
accelerometerDataSink_(this, &RotationFilter::interpret),
compassDataSink_(this, &RotationFilter::updateZvalue),
Expand All @@ -42,29 +38,23 @@ RotationFilter::RotationFilter() :

void RotationFilter::interpret(unsigned, const TimedXyzData* data)
{
const int RADIANS_TO_DEGREES = 180/M_PI;

rotation_.timestamp_ = data->timestamp_;

/// X-Rotation
//~ if (data->x_ == 0 && data->z_ == 0) {
//~ rotation_.x_ = 0;
//~ } else {
rotation_.x_ = round(atan((double)data->y_ / sqrt(data->x_*data->x_ + data->z_*data->z_)) * RADIANS_TO_DEGREES);
rotation_.x_ = -rotation_.x_;
//~ }
// X-Rotation
rotation_.x_ = round(atan((double)data->y_ / sqrt(data->x_ * data->x_ + data->z_ * data->z_)) * RADIANS_TO_DEGREES);
rotation_.x_ = -rotation_.x_;

/// Y-rotation
// Y-rotation
if (data->x_ == 0 && data->y_ == 0 && data->z_ > 0) {
rotation_.y_ = 180;
} else if (data->x_ == 0 && data->z_ == 0) {
rotation_.y_ = 0;
} else {
//~ if (data->y_ == 0 && data->z_ == 0) {
//~ rotation_.y_ = 0;
//~ } else {
rotation_.y_ = round(atan((double)data->x_ / sqrt(data->y_*data->y_ + data->z_*data->z_)) * RADIANS_TO_DEGREES);
//~ }
rotation_.y_ = round(atan((double)data->x_ / sqrt(data->y_ * data->y_ + data->z_ * data->z_)) * RADIANS_TO_DEGREES);

qreal theta = atan(sqrt(data->x_*data->x_ + data->y_*data->y_) / data->z_) * RADIANS_TO_DEGREES;
qreal theta = atan(sqrt(data->x_ * data->x_ + data->y_ * data->y_) / data->z_) * RADIANS_TO_DEGREES;
if (theta > 0) {
if (rotation_.y_ >= 0)
rotation_.y_ = 180 - rotation_.y_;
Expand All @@ -78,7 +68,7 @@ void RotationFilter::interpret(unsigned, const TimedXyzData* data)

double RotationFilter::vectorLength(const TimedXyzData& data)
{
return sqrt(data.x_*data.x_ + data.y_*data.y_ + data.z_*data.z_);
return sqrt(data.x_ * data.x_ + data.y_ * data.y_ + data.z_ * data.z_);
}

void RotationFilter::updateZvalue(unsigned, const CompassData* data)
Expand All @@ -87,7 +77,7 @@ void RotationFilter::updateZvalue(unsigned, const CompassData* data)

/// Z-rotation
/// Compass output is [0, 360), rotation is (-180, 180]
rotation_.z_ = -1*(data->degrees_ - 180);
rotation_.z_ = -1 * (data->degrees_ - 180);

source_.propagate(1, &rotation_);
}
6 changes: 2 additions & 4 deletions filters/rotationfilter/rotationfilter.h
Expand Up @@ -21,7 +21,7 @@
You should have received a copy of the GNU Lesser General Public
License along with Sensord. If not, see <http://www.gnu.org/licenses/>.
</p>
*/
*/

#ifndef ROTATIONFILTER_H
#define ROTATIONFILTER_H
Expand All @@ -31,8 +31,6 @@
#include "orientationdata.h"
#include "sensord/filter.h"

#define DEFAULT_THRESHOLD 50

/**
* @brief Filter for calculating device axis rotations.
*
Expand Down Expand Up @@ -74,7 +72,7 @@ class RotationFilter : public QObject, public FilterBase
void updateZvalue(unsigned, const CompassData*);

inline int dotProduct(TimedXyzData a, TimedXyzData b) const {
return (a.x_*b.x_)+(a.y_*b.y_)+(a.z_*b.z_);
return (a.x_ * b.x_) + (a.y_ * b.y_) + (a.z_ * b.z_);
}

TimedXyzData rotation_;
Expand Down
26 changes: 0 additions & 26 deletions filters/tapdata.h

This file was deleted.

26 changes: 0 additions & 26 deletions filters/timedunsigned.h

This file was deleted.

26 changes: 0 additions & 26 deletions filters/touchdata.h

This file was deleted.

Empty file removed filters/utils.cpp
Empty file.
26 changes: 0 additions & 26 deletions filters/utils.h

This file was deleted.

4 changes: 2 additions & 2 deletions sensord/inputdevadaptor.cpp
Expand Up @@ -38,8 +38,6 @@
#include <QDir>
#include <QString>

#define MAX_EVENT_DEV 16

InputDevAdaptor::InputDevAdaptor(const QString& id, int maxDeviceCount) :
SysfsAdaptor(id, SysfsAdaptor::SelectMode, false),
deviceCount_(0),
Expand Down Expand Up @@ -89,6 +87,8 @@ int InputDevAdaptor::getInputDevices(QString matchString)
}
else
{
const int MAX_EVENT_DEV = 16;

// No configuration for this device, try find the device from the device system path
while (deviceNumber < MAX_EVENT_DEV && deviceCount_ < maxDeviceCount_) {
deviceName = deviceSysPathString_.arg(deviceNumber);
Expand Down

0 comments on commit 8a48c93

Please sign in to comment.