@geastack/host 0.1.29 → 0.1.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/host/background.cpp +12 -0
- package/host/imu.cpp +25 -0
- package/include/gea/embedded-host.h +1 -0
- package/include/host/backends.h +4 -0
- package/include/host/background.h +34 -0
- package/include/host/navigator.h +9 -1
- package/package.json +1 -1
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
// Fallbacks for hosts with no background session; a platform that has one
|
|
3
|
+
// (the watchOS target) defines these strongly.
|
|
4
|
+
#include "host/background.h"
|
|
5
|
+
|
|
6
|
+
namespace gea::platform::background {
|
|
7
|
+
|
|
8
|
+
__attribute__((weak)) bool start(const char *) { return false; }
|
|
9
|
+
__attribute__((weak)) void stop() {}
|
|
10
|
+
__attribute__((weak)) const char *state() { return "unsupported"; }
|
|
11
|
+
|
|
12
|
+
} // namespace gea::platform::background
|
package/host/imu.cpp
CHANGED
|
@@ -2,8 +2,33 @@
|
|
|
2
2
|
#include "imu.h"
|
|
3
3
|
#include "gea/embedded-host.h"
|
|
4
4
|
|
|
5
|
+
namespace gea::platform::sensors {
|
|
6
|
+
|
|
7
|
+
__attribute__((weak)) bool attitude(double &, double &, double &, double &) { return false; }
|
|
8
|
+
|
|
9
|
+
} // namespace gea::platform::sensors
|
|
10
|
+
|
|
5
11
|
namespace gea::framework::sensors {
|
|
6
12
|
|
|
13
|
+
namespace {
|
|
14
|
+
|
|
15
|
+
struct Attitude {
|
|
16
|
+
double w = 0, x = 0, y = 0, z = 0;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
Attitude currentAttitude() {
|
|
20
|
+
Attitude q;
|
|
21
|
+
if (!gea::platform::sensors::attitude(q.w, q.x, q.y, q.z)) return Attitude{};
|
|
22
|
+
return q;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
} // namespace
|
|
26
|
+
|
|
27
|
+
double AccelerometerBackend::attitudeX() { return currentAttitude().x; }
|
|
28
|
+
double AccelerometerBackend::attitudeY() { return currentAttitude().y; }
|
|
29
|
+
double AccelerometerBackend::attitudeZ() { return currentAttitude().z; }
|
|
30
|
+
double AccelerometerBackend::attitudeW() { return currentAttitude().w; }
|
|
31
|
+
|
|
7
32
|
void AccelerometerBackend::init() {
|
|
8
33
|
gea::platform::sensors::Accelerometer::init();
|
|
9
34
|
}
|
package/include/host/backends.h
CHANGED
|
@@ -23,6 +23,10 @@ public:
|
|
|
23
23
|
static double gyroscopeX();
|
|
24
24
|
static double gyroscopeY();
|
|
25
25
|
static double gyroscopeZ();
|
|
26
|
+
static double attitudeX();
|
|
27
|
+
static double attitudeY();
|
|
28
|
+
static double attitudeZ();
|
|
29
|
+
static double attitudeW();
|
|
26
30
|
};
|
|
27
31
|
|
|
28
32
|
} // namespace gea::framework::sensors
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
#pragma once
|
|
3
|
+
|
|
4
|
+
#include <string>
|
|
5
|
+
|
|
6
|
+
// Keeping the app running while it is not on screen. On watchOS this is a
|
|
7
|
+
// WKExtendedRuntimeSession; elsewhere the weak defaults in host/background.cpp
|
|
8
|
+
// report "unsupported" and start() returns false.
|
|
9
|
+
namespace gea::platform::background {
|
|
10
|
+
|
|
11
|
+
// type is the platform's session kind ("physical-therapy", "self-care",
|
|
12
|
+
// "mindfulness" or "alarm" on watchOS). Returns false when it cannot start.
|
|
13
|
+
bool start(const char *type);
|
|
14
|
+
void stop();
|
|
15
|
+
// "unsupported", "idle", "starting", "running", "expiring" or "ended".
|
|
16
|
+
const char *state();
|
|
17
|
+
|
|
18
|
+
} // namespace gea::platform::background
|
|
19
|
+
|
|
20
|
+
namespace gea::host {
|
|
21
|
+
|
|
22
|
+
struct BackgroundSessionFacade {
|
|
23
|
+
bool start(const std::string &type) const { return gea::platform::background::start(type.c_str()); }
|
|
24
|
+
void stop() const { gea::platform::background::stop(); }
|
|
25
|
+
std::string state() const { return gea::platform::background::state(); }
|
|
26
|
+
bool active() const {
|
|
27
|
+
const std::string value = gea::platform::background::state();
|
|
28
|
+
return value == "starting" || value == "running" || value == "expiring";
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
inline constexpr BackgroundSessionFacade BackgroundSession{};
|
|
33
|
+
|
|
34
|
+
} // namespace gea::host
|
package/include/host/navigator.h
CHANGED
|
@@ -49,7 +49,11 @@ public:
|
|
|
49
49
|
gea::framework::sensors::AccelerometerBackend::accelerationZ),
|
|
50
50
|
gyroscopeX(gea::framework::sensors::AccelerometerBackend::gyroscopeX),
|
|
51
51
|
gyroscopeY(gea::framework::sensors::AccelerometerBackend::gyroscopeY),
|
|
52
|
-
gyroscopeZ(gea::framework::sensors::AccelerometerBackend::gyroscopeZ)
|
|
52
|
+
gyroscopeZ(gea::framework::sensors::AccelerometerBackend::gyroscopeZ),
|
|
53
|
+
attitudeX(gea::framework::sensors::AccelerometerBackend::attitudeX),
|
|
54
|
+
attitudeY(gea::framework::sensors::AccelerometerBackend::attitudeY),
|
|
55
|
+
attitudeZ(gea::framework::sensors::AccelerometerBackend::attitudeZ),
|
|
56
|
+
attitudeW(gea::framework::sensors::AccelerometerBackend::attitudeW) {}
|
|
53
57
|
|
|
54
58
|
void start() const { gea::framework::sensors::AccelerometerBackend::init(); }
|
|
55
59
|
void init() const { gea::framework::sensors::AccelerometerBackend::init(); }
|
|
@@ -69,6 +73,10 @@ public:
|
|
|
69
73
|
AccelerometerValueProperty gyroscopeX;
|
|
70
74
|
AccelerometerValueProperty gyroscopeY;
|
|
71
75
|
AccelerometerValueProperty gyroscopeZ;
|
|
76
|
+
AccelerometerValueProperty attitudeX;
|
|
77
|
+
AccelerometerValueProperty attitudeY;
|
|
78
|
+
AccelerometerValueProperty attitudeZ;
|
|
79
|
+
AccelerometerValueProperty attitudeW;
|
|
72
80
|
};
|
|
73
81
|
|
|
74
82
|
using IMU = AccelerometerFacade;
|