merged
This commit is contained in:
@@ -23,6 +23,8 @@ private:
|
||||
;
|
||||
}
|
||||
|
||||
bool started = false;
|
||||
|
||||
public:
|
||||
|
||||
/** singleton access */
|
||||
@@ -33,26 +35,30 @@ public:
|
||||
|
||||
void start() override {
|
||||
|
||||
if (started) {return;}
|
||||
started = true;
|
||||
|
||||
auto onSensorData = [&] () {
|
||||
AccelerometerData data(acc.reading()->x(), acc.reading()->y(), acc.reading()->z());
|
||||
informListeners(data);
|
||||
};
|
||||
|
||||
// accelerometer is usually verry fast -> limit the maximum data-rate to 200 Hz (5ms)
|
||||
acc.setDataRate(200);
|
||||
|
||||
acc.connect(&acc, &QAccelerometer::readingChanged, onSensorData);
|
||||
acc.start();
|
||||
|
||||
}
|
||||
|
||||
bool isRunning() const override {
|
||||
return acc.isActive();
|
||||
return started;
|
||||
}
|
||||
|
||||
void stop() override {
|
||||
throw "TODO";
|
||||
}
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif // ANDROID
|
||||
|
||||
@@ -22,6 +22,8 @@ private:
|
||||
;
|
||||
}
|
||||
|
||||
bool started = false;
|
||||
|
||||
public:
|
||||
|
||||
/** singleton access */
|
||||
@@ -32,6 +34,9 @@ public:
|
||||
|
||||
void start() override {
|
||||
|
||||
if (started) {return;}
|
||||
started = true;
|
||||
|
||||
auto onSensorData = [&] () {
|
||||
BarometerData data(baro.reading()->pressure() / 100.0f); // convert Pa to hPa
|
||||
informListeners(data);
|
||||
@@ -43,7 +48,7 @@ public:
|
||||
}
|
||||
|
||||
bool isRunning() const override {
|
||||
return baro.isActive();
|
||||
return started;
|
||||
}
|
||||
|
||||
void stop() override {
|
||||
|
||||
@@ -22,6 +22,8 @@ private:
|
||||
;
|
||||
}
|
||||
|
||||
bool started = false;
|
||||
|
||||
public:
|
||||
|
||||
/** singleton access */
|
||||
@@ -36,18 +38,26 @@ public:
|
||||
|
||||
void start() override {
|
||||
|
||||
if (started) {return;}
|
||||
started = true;
|
||||
|
||||
auto onSensorData = [&] () {
|
||||
GyroscopeData data(degToRad(gyro.reading()->x()), degToRad(gyro.reading()->y()), degToRad(gyro.reading()->z()));
|
||||
informListeners(data);
|
||||
// const Timestamp now = Timestamp::fromRunningTime();
|
||||
// Log::add("123", "ts:" + std::to_string(now.ms()));
|
||||
};
|
||||
|
||||
// gyroscope is usually not as fast as the acceleromter -> limiting not needed
|
||||
//gyro.setDataRate(200);
|
||||
|
||||
gyro.connect(&gyro, &QGyroscope::readingChanged, onSensorData);
|
||||
gyro.start();
|
||||
|
||||
}
|
||||
|
||||
bool isRunning() const override {
|
||||
return gyro.isActive();
|
||||
return started;
|
||||
}
|
||||
|
||||
void stop() override {
|
||||
|
||||
@@ -9,6 +9,8 @@
|
||||
#include "../../misc/Debug.h"
|
||||
#include "../WiFiSensor.h"
|
||||
|
||||
#include <Indoor/misc/Debug.h>
|
||||
|
||||
class WiFiSensorAndroid : public WiFiSensor {
|
||||
|
||||
private:
|
||||
@@ -30,11 +32,11 @@ public:
|
||||
|
||||
// do NOT start twice!
|
||||
if (started) {return;}
|
||||
started = true;
|
||||
|
||||
// start scanning
|
||||
int res = QAndroidJniObject::callStaticMethod<int>("indoor/java/WiFi", "start", "()I");
|
||||
if (res != 1337) {throw Exception("error while starting WiFi");}
|
||||
started = true;
|
||||
|
||||
}
|
||||
|
||||
@@ -46,7 +48,11 @@ public:
|
||||
return started;
|
||||
}
|
||||
|
||||
/** called from java. handle the given incoming scan result */
|
||||
/**
|
||||
* called from WiFi.java
|
||||
* handle the given incoming scan result
|
||||
* just a bit curious, thus std::string instead of std::string&
|
||||
*/
|
||||
void handle(const std::string data) {
|
||||
|
||||
// to-be-constructed sensor data
|
||||
@@ -68,6 +74,16 @@ public:
|
||||
// call listeners
|
||||
informListeners(sensorData);
|
||||
|
||||
// interval debug
|
||||
// static Timestamp lastTS;
|
||||
// const Timestamp diff = curTS - lastTS;
|
||||
// Log::add("wifi", std::to_string(diff.ms()));
|
||||
// if (diff.ms() > 650) {
|
||||
// Log::add("wifi", "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
|
||||
// }
|
||||
// lastTS = curTS;
|
||||
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user