MagnetometerService.cpp Example File
bpstoqml/src/MagnetometerService.cpp
#include "MagnetometerService.hpp"
#include <iostream>
namespace bb {
namespace cascades {
namespace bps {
MagnetometerService::MagnetometerService(QObject *parent)
: AbstractSensorService(SENSOR_TYPE_MAGNETOMETER, parent)
{
}
MagnetometerService::~MagnetometerService() {
}
void MagnetometerService::handleEvent(bps_event_t *event) {
uint16_t code = bps_event_get_code(event);
if (code == SENSOR_MAGNETOMETER_READING) {
float x, y, z;
sensor_event_get_xyz(event, &x, &y, &z);
unsigned long long timestamp = getTimestamp(event);
SensorAccuracy accuracy = getAccuracy(event);
Q_EMIT magnetometerData(x, y, z, timestamp, accuracy);
}
}
}
}
}