AccelerometerService.cpp Example File
bpstoqml/src/AccelerometerService.cpp
#include "AccelerometerService.hpp"
#include <iostream>
namespace bb {
namespace cascades {
namespace bps {
AccelerometerService::AccelerometerService(QObject *parent)
: AbstractSensorService(SENSOR_TYPE_ACCELEROMETER, parent)
{
}
AccelerometerService::~AccelerometerService() {
}
void AccelerometerService::handleEvent(bps_event_t *event) {
uint16_t code = bps_event_get_code(event);
if (code == SENSOR_ACCELEROMETER_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 accelerometerData(x, y, z, timestamp, accuracy);
}
}
}
}
}