react-native-nitro-compass 1.0.9 → 1.2.0
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/README.md +166 -20
- package/android/src/main/java/com/margelo/nitro/nitrocompass/HybridNitroCompass.kt +718 -105
- package/ios/HybridNitroCompass.swift +119 -6
- package/lib/commonjs/hook.js +102 -11
- package/lib/commonjs/hook.js.map +1 -1
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/multiplex.js +23 -2
- package/lib/commonjs/multiplex.js.map +1 -1
- package/lib/module/hook.js +103 -12
- package/lib/module/hook.js.map +1 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/multiplex.js +23 -2
- package/lib/module/multiplex.js.map +1 -1
- package/lib/typescript/src/hook.d.ts +49 -1
- package/lib/typescript/src/hook.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +2 -2
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/multiplex.d.ts.map +1 -1
- package/lib/typescript/src/specs/NitroCompass.nitro.d.ts +158 -18
- package/lib/typescript/src/specs/NitroCompass.nitro.d.ts.map +1 -1
- package/nitrogen/generated/android/c++/JCompassSample.hpp +7 -3
- package/nitrogen/generated/android/c++/JDebugInfo.hpp +85 -0
- package/nitrogen/generated/android/c++/JHybridNitroCompassSpec.cpp +21 -0
- package/nitrogen/generated/android/c++/JHybridNitroCompassSpec.hpp +4 -0
- package/nitrogen/generated/android/c++/JSensorKind.hpp +6 -3
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrocompass/CompassSample.kt +9 -4
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrocompass/DebugInfo.kt +86 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrocompass/HybridNitroCompassSpec.kt +16 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrocompass/SensorKind.kt +4 -3
- package/nitrogen/generated/ios/NitroCompass-Swift-Cxx-Bridge.hpp +12 -0
- package/nitrogen/generated/ios/NitroCompass-Swift-Cxx-Umbrella.hpp +3 -0
- package/nitrogen/generated/ios/c++/HybridNitroCompassSpecSwift.hpp +29 -0
- package/nitrogen/generated/ios/swift/CompassSample.swift +7 -2
- package/nitrogen/generated/ios/swift/DebugInfo.swift +64 -0
- package/nitrogen/generated/ios/swift/HybridNitroCompassSpec.swift +4 -0
- package/nitrogen/generated/ios/swift/HybridNitroCompassSpec_cxx.swift +45 -0
- package/nitrogen/generated/ios/swift/SensorKind.swift +8 -4
- package/nitrogen/generated/shared/c++/CompassSample.hpp +6 -2
- package/nitrogen/generated/shared/c++/DebugInfo.hpp +111 -0
- package/nitrogen/generated/shared/c++/HybridNitroCompassSpec.cpp +4 -0
- package/nitrogen/generated/shared/c++/HybridNitroCompassSpec.hpp +7 -0
- package/nitrogen/generated/shared/c++/SensorKind.hpp +10 -6
- package/package.json +2 -2
- package/src/hook.ts +161 -12
- package/src/index.ts +2 -0
- package/src/multiplex.ts +23 -2
- package/src/specs/NitroCompass.nitro.ts +164 -18
|
@@ -23,7 +23,10 @@ data class CompassSample(
|
|
|
23
23
|
val heading: Double,
|
|
24
24
|
@DoNotStrip
|
|
25
25
|
@Keep
|
|
26
|
-
val accuracy: Double
|
|
26
|
+
val accuracy: Double,
|
|
27
|
+
@DoNotStrip
|
|
28
|
+
@Keep
|
|
29
|
+
val fieldStrengthMicroTesla: Double
|
|
27
30
|
) {
|
|
28
31
|
/* primary constructor */
|
|
29
32
|
|
|
@@ -32,12 +35,14 @@ data class CompassSample(
|
|
|
32
35
|
if (other !is CompassSample) return false
|
|
33
36
|
return Objects.deepEquals(this.heading, other.heading)
|
|
34
37
|
&& Objects.deepEquals(this.accuracy, other.accuracy)
|
|
38
|
+
&& Objects.deepEquals(this.fieldStrengthMicroTesla, other.fieldStrengthMicroTesla)
|
|
35
39
|
}
|
|
36
40
|
|
|
37
41
|
override fun hashCode(): Int {
|
|
38
42
|
return arrayOf(
|
|
39
43
|
heading,
|
|
40
|
-
accuracy
|
|
44
|
+
accuracy,
|
|
45
|
+
fieldStrengthMicroTesla
|
|
41
46
|
).contentDeepHashCode()
|
|
42
47
|
}
|
|
43
48
|
|
|
@@ -49,8 +54,8 @@ data class CompassSample(
|
|
|
49
54
|
@Keep
|
|
50
55
|
@Suppress("unused")
|
|
51
56
|
@JvmStatic
|
|
52
|
-
private fun fromCpp(heading: Double, accuracy: Double): CompassSample {
|
|
53
|
-
return CompassSample(heading, accuracy)
|
|
57
|
+
private fun fromCpp(heading: Double, accuracy: Double, fieldStrengthMicroTesla: Double): CompassSample {
|
|
58
|
+
return CompassSample(heading, accuracy, fieldStrengthMicroTesla)
|
|
54
59
|
}
|
|
55
60
|
}
|
|
56
61
|
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// DebugInfo.kt
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
package com.margelo.nitro.nitrocompass
|
|
9
|
+
|
|
10
|
+
import androidx.annotation.Keep
|
|
11
|
+
import com.facebook.proguard.annotations.DoNotStrip
|
|
12
|
+
import java.util.Objects
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Represents the JavaScript object/struct "DebugInfo".
|
|
17
|
+
*/
|
|
18
|
+
@DoNotStrip
|
|
19
|
+
@Keep
|
|
20
|
+
data class DebugInfo(
|
|
21
|
+
@DoNotStrip
|
|
22
|
+
@Keep
|
|
23
|
+
val interferenceActive: Boolean,
|
|
24
|
+
@DoNotStrip
|
|
25
|
+
@Keep
|
|
26
|
+
val msSinceLastBiasJump: Double,
|
|
27
|
+
@DoNotStrip
|
|
28
|
+
@Keep
|
|
29
|
+
val expectedFieldMicroTesla: Double,
|
|
30
|
+
@DoNotStrip
|
|
31
|
+
@Keep
|
|
32
|
+
val lastFieldMicroTesla: Double,
|
|
33
|
+
@DoNotStrip
|
|
34
|
+
@Keep
|
|
35
|
+
val fusedYawDeg: Double,
|
|
36
|
+
@DoNotStrip
|
|
37
|
+
@Keep
|
|
38
|
+
val lastYawRateDegPerS: Double,
|
|
39
|
+
@DoNotStrip
|
|
40
|
+
@Keep
|
|
41
|
+
val hasGameRotationVector: Boolean,
|
|
42
|
+
@DoNotStrip
|
|
43
|
+
@Keep
|
|
44
|
+
val usingUncalibratedMag: Boolean
|
|
45
|
+
) {
|
|
46
|
+
/* primary constructor */
|
|
47
|
+
|
|
48
|
+
override fun equals(other: Any?): Boolean {
|
|
49
|
+
if (this === other) return true
|
|
50
|
+
if (other !is DebugInfo) return false
|
|
51
|
+
return Objects.deepEquals(this.interferenceActive, other.interferenceActive)
|
|
52
|
+
&& Objects.deepEquals(this.msSinceLastBiasJump, other.msSinceLastBiasJump)
|
|
53
|
+
&& Objects.deepEquals(this.expectedFieldMicroTesla, other.expectedFieldMicroTesla)
|
|
54
|
+
&& Objects.deepEquals(this.lastFieldMicroTesla, other.lastFieldMicroTesla)
|
|
55
|
+
&& Objects.deepEquals(this.fusedYawDeg, other.fusedYawDeg)
|
|
56
|
+
&& Objects.deepEquals(this.lastYawRateDegPerS, other.lastYawRateDegPerS)
|
|
57
|
+
&& Objects.deepEquals(this.hasGameRotationVector, other.hasGameRotationVector)
|
|
58
|
+
&& Objects.deepEquals(this.usingUncalibratedMag, other.usingUncalibratedMag)
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
override fun hashCode(): Int {
|
|
62
|
+
return arrayOf(
|
|
63
|
+
interferenceActive,
|
|
64
|
+
msSinceLastBiasJump,
|
|
65
|
+
expectedFieldMicroTesla,
|
|
66
|
+
lastFieldMicroTesla,
|
|
67
|
+
fusedYawDeg,
|
|
68
|
+
lastYawRateDegPerS,
|
|
69
|
+
hasGameRotationVector,
|
|
70
|
+
usingUncalibratedMag
|
|
71
|
+
).contentDeepHashCode()
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
companion object {
|
|
75
|
+
/**
|
|
76
|
+
* Constructor called from C++
|
|
77
|
+
*/
|
|
78
|
+
@DoNotStrip
|
|
79
|
+
@Keep
|
|
80
|
+
@Suppress("unused")
|
|
81
|
+
@JvmStatic
|
|
82
|
+
private fun fromCpp(interferenceActive: Boolean, msSinceLastBiasJump: Double, expectedFieldMicroTesla: Double, lastFieldMicroTesla: Double, fusedYawDeg: Double, lastYawRateDegPerS: Double, hasGameRotationVector: Boolean, usingUncalibratedMag: Boolean): DebugInfo {
|
|
83
|
+
return DebugInfo(interferenceActive, msSinceLastBiasJump, expectedFieldMicroTesla, lastFieldMicroTesla, fusedYawDeg, lastYawRateDegPerS, hasGameRotationVector, usingUncalibratedMag)
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrocompass/HybridNitroCompassSpec.kt
CHANGED
|
@@ -50,10 +50,18 @@ abstract class HybridNitroCompassSpec: HybridObject() {
|
|
|
50
50
|
@Keep
|
|
51
51
|
abstract fun setFilter(degrees: Double): Unit
|
|
52
52
|
|
|
53
|
+
@DoNotStrip
|
|
54
|
+
@Keep
|
|
55
|
+
abstract fun setSmoothing(alpha: Double): Unit
|
|
56
|
+
|
|
53
57
|
@DoNotStrip
|
|
54
58
|
@Keep
|
|
55
59
|
abstract fun getDiagnostics(): SensorDiagnostics?
|
|
56
60
|
|
|
61
|
+
@DoNotStrip
|
|
62
|
+
@Keep
|
|
63
|
+
abstract fun getDebugInfo(): DebugInfo
|
|
64
|
+
|
|
57
65
|
@DoNotStrip
|
|
58
66
|
@Keep
|
|
59
67
|
abstract fun hasCompass(): Boolean
|
|
@@ -66,6 +74,10 @@ abstract class HybridNitroCompassSpec: HybridObject() {
|
|
|
66
74
|
@Keep
|
|
67
75
|
abstract fun setDeclination(degrees: Double): Unit
|
|
68
76
|
|
|
77
|
+
@DoNotStrip
|
|
78
|
+
@Keep
|
|
79
|
+
abstract fun setLocation(latitude: Double, longitude: Double): Unit
|
|
80
|
+
|
|
69
81
|
abstract fun setOnCalibrationNeeded(onChange: (quality: AccuracyQuality) -> Unit): Unit
|
|
70
82
|
|
|
71
83
|
@DoNotStrip
|
|
@@ -88,6 +100,10 @@ abstract class HybridNitroCompassSpec: HybridObject() {
|
|
|
88
100
|
@Keep
|
|
89
101
|
abstract fun setPauseOnBackground(enabled: Boolean): Unit
|
|
90
102
|
|
|
103
|
+
@DoNotStrip
|
|
104
|
+
@Keep
|
|
105
|
+
abstract fun recalibrate(): Unit
|
|
106
|
+
|
|
91
107
|
@DoNotStrip
|
|
92
108
|
@Keep
|
|
93
109
|
abstract fun getPermissionStatus(): PermissionStatus
|
|
@@ -16,9 +16,10 @@ import com.facebook.proguard.annotations.DoNotStrip
|
|
|
16
16
|
@DoNotStrip
|
|
17
17
|
@Keep
|
|
18
18
|
enum class SensorKind(@DoNotStrip @Keep val value: Int) {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
MAGNETOMETER(0),
|
|
20
|
+
CORELOCATION(1),
|
|
21
|
+
ROTATIONVECTOR(2),
|
|
22
|
+
GEOMAGNETICROTATIONVECTOR(3);
|
|
22
23
|
|
|
23
24
|
companion object
|
|
24
25
|
}
|
|
@@ -12,6 +12,8 @@
|
|
|
12
12
|
namespace margelo::nitro::nitrocompass { enum class AccuracyQuality; }
|
|
13
13
|
// Forward declaration of `CompassSample` to properly resolve imports.
|
|
14
14
|
namespace margelo::nitro::nitrocompass { struct CompassSample; }
|
|
15
|
+
// Forward declaration of `DebugInfo` to properly resolve imports.
|
|
16
|
+
namespace margelo::nitro::nitrocompass { struct DebugInfo; }
|
|
15
17
|
// Forward declaration of `HybridNitroCompassSpec` to properly resolve imports.
|
|
16
18
|
namespace margelo::nitro::nitrocompass { class HybridNitroCompassSpec; }
|
|
17
19
|
// Forward declaration of `PermissionStatus` to properly resolve imports.
|
|
@@ -28,6 +30,7 @@ namespace NitroCompass { class HybridNitroCompassSpec_cxx; }
|
|
|
28
30
|
// Include C++ defined types
|
|
29
31
|
#include "AccuracyQuality.hpp"
|
|
30
32
|
#include "CompassSample.hpp"
|
|
33
|
+
#include "DebugInfo.hpp"
|
|
31
34
|
#include "HybridNitroCompassSpec.hpp"
|
|
32
35
|
#include "PermissionStatus.hpp"
|
|
33
36
|
#include "SensorDiagnostics.hpp"
|
|
@@ -237,6 +240,15 @@ namespace margelo::nitro::nitrocompass::bridge::swift {
|
|
|
237
240
|
return Result<std::optional<SensorDiagnostics>>::withError(error);
|
|
238
241
|
}
|
|
239
242
|
|
|
243
|
+
// pragma MARK: Result<DebugInfo>
|
|
244
|
+
using Result_DebugInfo_ = Result<DebugInfo>;
|
|
245
|
+
inline Result_DebugInfo_ create_Result_DebugInfo_(const DebugInfo& value) noexcept {
|
|
246
|
+
return Result<DebugInfo>::withValue(value);
|
|
247
|
+
}
|
|
248
|
+
inline Result_DebugInfo_ create_Result_DebugInfo_(const std::exception_ptr& error) noexcept {
|
|
249
|
+
return Result<DebugInfo>::withError(error);
|
|
250
|
+
}
|
|
251
|
+
|
|
240
252
|
// pragma MARK: Result<std::optional<CompassSample>>
|
|
241
253
|
using Result_std__optional_CompassSample__ = Result<std::optional<CompassSample>>;
|
|
242
254
|
inline Result_std__optional_CompassSample__ create_Result_std__optional_CompassSample__(const std::optional<CompassSample>& value) noexcept {
|
|
@@ -12,6 +12,8 @@
|
|
|
12
12
|
namespace margelo::nitro::nitrocompass { enum class AccuracyQuality; }
|
|
13
13
|
// Forward declaration of `CompassSample` to properly resolve imports.
|
|
14
14
|
namespace margelo::nitro::nitrocompass { struct CompassSample; }
|
|
15
|
+
// Forward declaration of `DebugInfo` to properly resolve imports.
|
|
16
|
+
namespace margelo::nitro::nitrocompass { struct DebugInfo; }
|
|
15
17
|
// Forward declaration of `HybridNitroCompassSpec` to properly resolve imports.
|
|
16
18
|
namespace margelo::nitro::nitrocompass { class HybridNitroCompassSpec; }
|
|
17
19
|
// Forward declaration of `PermissionStatus` to properly resolve imports.
|
|
@@ -24,6 +26,7 @@ namespace margelo::nitro::nitrocompass { enum class SensorKind; }
|
|
|
24
26
|
// Include C++ defined types
|
|
25
27
|
#include "AccuracyQuality.hpp"
|
|
26
28
|
#include "CompassSample.hpp"
|
|
29
|
+
#include "DebugInfo.hpp"
|
|
27
30
|
#include "HybridNitroCompassSpec.hpp"
|
|
28
31
|
#include "PermissionStatus.hpp"
|
|
29
32
|
#include "SensorDiagnostics.hpp"
|
|
@@ -18,6 +18,8 @@ namespace margelo::nitro::nitrocompass { struct CompassSample; }
|
|
|
18
18
|
namespace margelo::nitro::nitrocompass { struct SensorDiagnostics; }
|
|
19
19
|
// Forward declaration of `SensorKind` to properly resolve imports.
|
|
20
20
|
namespace margelo::nitro::nitrocompass { enum class SensorKind; }
|
|
21
|
+
// Forward declaration of `DebugInfo` to properly resolve imports.
|
|
22
|
+
namespace margelo::nitro::nitrocompass { struct DebugInfo; }
|
|
21
23
|
// Forward declaration of `AccuracyQuality` to properly resolve imports.
|
|
22
24
|
namespace margelo::nitro::nitrocompass { enum class AccuracyQuality; }
|
|
23
25
|
// Forward declaration of `PermissionStatus` to properly resolve imports.
|
|
@@ -28,6 +30,7 @@ namespace margelo::nitro::nitrocompass { enum class PermissionStatus; }
|
|
|
28
30
|
#include "SensorDiagnostics.hpp"
|
|
29
31
|
#include <optional>
|
|
30
32
|
#include "SensorKind.hpp"
|
|
33
|
+
#include "DebugInfo.hpp"
|
|
31
34
|
#include "AccuracyQuality.hpp"
|
|
32
35
|
#include "PermissionStatus.hpp"
|
|
33
36
|
#include <NitroModules/Promise.hpp>
|
|
@@ -108,6 +111,12 @@ namespace margelo::nitro::nitrocompass {
|
|
|
108
111
|
std::rethrow_exception(__result.error());
|
|
109
112
|
}
|
|
110
113
|
}
|
|
114
|
+
inline void setSmoothing(double alpha) override {
|
|
115
|
+
auto __result = _swiftPart.setSmoothing(std::forward<decltype(alpha)>(alpha));
|
|
116
|
+
if (__result.hasError()) [[unlikely]] {
|
|
117
|
+
std::rethrow_exception(__result.error());
|
|
118
|
+
}
|
|
119
|
+
}
|
|
111
120
|
inline std::optional<SensorDiagnostics> getDiagnostics() override {
|
|
112
121
|
auto __result = _swiftPart.getDiagnostics();
|
|
113
122
|
if (__result.hasError()) [[unlikely]] {
|
|
@@ -116,6 +125,14 @@ namespace margelo::nitro::nitrocompass {
|
|
|
116
125
|
auto __value = std::move(__result.value());
|
|
117
126
|
return __value;
|
|
118
127
|
}
|
|
128
|
+
inline DebugInfo getDebugInfo() override {
|
|
129
|
+
auto __result = _swiftPart.getDebugInfo();
|
|
130
|
+
if (__result.hasError()) [[unlikely]] {
|
|
131
|
+
std::rethrow_exception(__result.error());
|
|
132
|
+
}
|
|
133
|
+
auto __value = std::move(__result.value());
|
|
134
|
+
return __value;
|
|
135
|
+
}
|
|
119
136
|
inline bool hasCompass() override {
|
|
120
137
|
auto __result = _swiftPart.hasCompass();
|
|
121
138
|
if (__result.hasError()) [[unlikely]] {
|
|
@@ -138,6 +155,12 @@ namespace margelo::nitro::nitrocompass {
|
|
|
138
155
|
std::rethrow_exception(__result.error());
|
|
139
156
|
}
|
|
140
157
|
}
|
|
158
|
+
inline void setLocation(double latitude, double longitude) override {
|
|
159
|
+
auto __result = _swiftPart.setLocation(std::forward<decltype(latitude)>(latitude), std::forward<decltype(longitude)>(longitude));
|
|
160
|
+
if (__result.hasError()) [[unlikely]] {
|
|
161
|
+
std::rethrow_exception(__result.error());
|
|
162
|
+
}
|
|
163
|
+
}
|
|
141
164
|
inline void setOnCalibrationNeeded(const std::function<void(AccuracyQuality /* quality */)>& onChange) override {
|
|
142
165
|
auto __result = _swiftPart.setOnCalibrationNeeded(onChange);
|
|
143
166
|
if (__result.hasError()) [[unlikely]] {
|
|
@@ -156,6 +179,12 @@ namespace margelo::nitro::nitrocompass {
|
|
|
156
179
|
std::rethrow_exception(__result.error());
|
|
157
180
|
}
|
|
158
181
|
}
|
|
182
|
+
inline void recalibrate() override {
|
|
183
|
+
auto __result = _swiftPart.recalibrate();
|
|
184
|
+
if (__result.hasError()) [[unlikely]] {
|
|
185
|
+
std::rethrow_exception(__result.error());
|
|
186
|
+
}
|
|
187
|
+
}
|
|
159
188
|
inline PermissionStatus getPermissionStatus() override {
|
|
160
189
|
auto __result = _swiftPart.getPermissionStatus();
|
|
161
190
|
if (__result.hasError()) [[unlikely]] {
|
|
@@ -18,8 +18,8 @@ public extension CompassSample {
|
|
|
18
18
|
/**
|
|
19
19
|
* Create a new instance of `CompassSample`.
|
|
20
20
|
*/
|
|
21
|
-
init(heading: Double, accuracy: Double) {
|
|
22
|
-
self.init(heading, accuracy)
|
|
21
|
+
init(heading: Double, accuracy: Double, fieldStrengthMicroTesla: Double) {
|
|
22
|
+
self.init(heading, accuracy, fieldStrengthMicroTesla)
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
@inline(__always)
|
|
@@ -31,4 +31,9 @@ public extension CompassSample {
|
|
|
31
31
|
var accuracy: Double {
|
|
32
32
|
return self.__accuracy
|
|
33
33
|
}
|
|
34
|
+
|
|
35
|
+
@inline(__always)
|
|
36
|
+
var fieldStrengthMicroTesla: Double {
|
|
37
|
+
return self.__fieldStrengthMicroTesla
|
|
38
|
+
}
|
|
34
39
|
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// DebugInfo.swift
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
import NitroModules
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Represents an instance of `DebugInfo`, backed by a C++ struct.
|
|
12
|
+
*/
|
|
13
|
+
public typealias DebugInfo = margelo.nitro.nitrocompass.DebugInfo
|
|
14
|
+
|
|
15
|
+
public extension DebugInfo {
|
|
16
|
+
private typealias bridge = margelo.nitro.nitrocompass.bridge.swift
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Create a new instance of `DebugInfo`.
|
|
20
|
+
*/
|
|
21
|
+
init(interferenceActive: Bool, msSinceLastBiasJump: Double, expectedFieldMicroTesla: Double, lastFieldMicroTesla: Double, fusedYawDeg: Double, lastYawRateDegPerS: Double, hasGameRotationVector: Bool, usingUncalibratedMag: Bool) {
|
|
22
|
+
self.init(interferenceActive, msSinceLastBiasJump, expectedFieldMicroTesla, lastFieldMicroTesla, fusedYawDeg, lastYawRateDegPerS, hasGameRotationVector, usingUncalibratedMag)
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
@inline(__always)
|
|
26
|
+
var interferenceActive: Bool {
|
|
27
|
+
return self.__interferenceActive
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
@inline(__always)
|
|
31
|
+
var msSinceLastBiasJump: Double {
|
|
32
|
+
return self.__msSinceLastBiasJump
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
@inline(__always)
|
|
36
|
+
var expectedFieldMicroTesla: Double {
|
|
37
|
+
return self.__expectedFieldMicroTesla
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
@inline(__always)
|
|
41
|
+
var lastFieldMicroTesla: Double {
|
|
42
|
+
return self.__lastFieldMicroTesla
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
@inline(__always)
|
|
46
|
+
var fusedYawDeg: Double {
|
|
47
|
+
return self.__fusedYawDeg
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
@inline(__always)
|
|
51
|
+
var lastYawRateDegPerS: Double {
|
|
52
|
+
return self.__lastYawRateDegPerS
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
@inline(__always)
|
|
56
|
+
var hasGameRotationVector: Bool {
|
|
57
|
+
return self.__hasGameRotationVector
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
@inline(__always)
|
|
61
|
+
var usingUncalibratedMag: Bool {
|
|
62
|
+
return self.__usingUncalibratedMag
|
|
63
|
+
}
|
|
64
|
+
}
|
|
@@ -17,13 +17,17 @@ public protocol HybridNitroCompassSpec_protocol: HybridObject {
|
|
|
17
17
|
func stop() throws -> Void
|
|
18
18
|
func isStarted() throws -> Bool
|
|
19
19
|
func setFilter(degrees: Double) throws -> Void
|
|
20
|
+
func setSmoothing(alpha: Double) throws -> Void
|
|
20
21
|
func getDiagnostics() throws -> SensorDiagnostics?
|
|
22
|
+
func getDebugInfo() throws -> DebugInfo
|
|
21
23
|
func hasCompass() throws -> Bool
|
|
22
24
|
func getCurrentHeading() throws -> CompassSample?
|
|
23
25
|
func setDeclination(degrees: Double) throws -> Void
|
|
26
|
+
func setLocation(latitude: Double, longitude: Double) throws -> Void
|
|
24
27
|
func setOnCalibrationNeeded(onChange: @escaping (_ quality: AccuracyQuality) -> Void) throws -> Void
|
|
25
28
|
func setOnInterferenceDetected(onChange: @escaping (_ interferenceDetected: Bool) -> Void) throws -> Void
|
|
26
29
|
func setPauseOnBackground(enabled: Bool) throws -> Void
|
|
30
|
+
func recalibrate() throws -> Void
|
|
27
31
|
func getPermissionStatus() throws -> PermissionStatus
|
|
28
32
|
func requestPermission() throws -> Promise<PermissionStatus>
|
|
29
33
|
}
|
|
@@ -174,6 +174,17 @@ open class HybridNitroCompassSpec_cxx {
|
|
|
174
174
|
}
|
|
175
175
|
}
|
|
176
176
|
|
|
177
|
+
@inline(__always)
|
|
178
|
+
public final func setSmoothing(alpha: Double) -> bridge.Result_void_ {
|
|
179
|
+
do {
|
|
180
|
+
try self.__implementation.setSmoothing(alpha: alpha)
|
|
181
|
+
return bridge.create_Result_void_()
|
|
182
|
+
} catch (let __error) {
|
|
183
|
+
let __exceptionPtr = __error.toCpp()
|
|
184
|
+
return bridge.create_Result_void_(__exceptionPtr)
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
|
|
177
188
|
@inline(__always)
|
|
178
189
|
public final func getDiagnostics() -> bridge.Result_std__optional_SensorDiagnostics__ {
|
|
179
190
|
do {
|
|
@@ -192,6 +203,18 @@ open class HybridNitroCompassSpec_cxx {
|
|
|
192
203
|
}
|
|
193
204
|
}
|
|
194
205
|
|
|
206
|
+
@inline(__always)
|
|
207
|
+
public final func getDebugInfo() -> bridge.Result_DebugInfo_ {
|
|
208
|
+
do {
|
|
209
|
+
let __result = try self.__implementation.getDebugInfo()
|
|
210
|
+
let __resultCpp = __result
|
|
211
|
+
return bridge.create_Result_DebugInfo_(__resultCpp)
|
|
212
|
+
} catch (let __error) {
|
|
213
|
+
let __exceptionPtr = __error.toCpp()
|
|
214
|
+
return bridge.create_Result_DebugInfo_(__exceptionPtr)
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
|
|
195
218
|
@inline(__always)
|
|
196
219
|
public final func hasCompass() -> bridge.Result_bool_ {
|
|
197
220
|
do {
|
|
@@ -233,6 +256,17 @@ open class HybridNitroCompassSpec_cxx {
|
|
|
233
256
|
}
|
|
234
257
|
}
|
|
235
258
|
|
|
259
|
+
@inline(__always)
|
|
260
|
+
public final func setLocation(latitude: Double, longitude: Double) -> bridge.Result_void_ {
|
|
261
|
+
do {
|
|
262
|
+
try self.__implementation.setLocation(latitude: latitude, longitude: longitude)
|
|
263
|
+
return bridge.create_Result_void_()
|
|
264
|
+
} catch (let __error) {
|
|
265
|
+
let __exceptionPtr = __error.toCpp()
|
|
266
|
+
return bridge.create_Result_void_(__exceptionPtr)
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
|
|
236
270
|
@inline(__always)
|
|
237
271
|
public final func setOnCalibrationNeeded(onChange: bridge.Func_void_AccuracyQuality) -> bridge.Result_void_ {
|
|
238
272
|
do {
|
|
@@ -276,6 +310,17 @@ open class HybridNitroCompassSpec_cxx {
|
|
|
276
310
|
}
|
|
277
311
|
}
|
|
278
312
|
|
|
313
|
+
@inline(__always)
|
|
314
|
+
public final func recalibrate() -> bridge.Result_void_ {
|
|
315
|
+
do {
|
|
316
|
+
try self.__implementation.recalibrate()
|
|
317
|
+
return bridge.create_Result_void_()
|
|
318
|
+
} catch (let __error) {
|
|
319
|
+
let __exceptionPtr = __error.toCpp()
|
|
320
|
+
return bridge.create_Result_void_(__exceptionPtr)
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
|
|
279
324
|
@inline(__always)
|
|
280
325
|
public final func getPermissionStatus() -> bridge.Result_PermissionStatus_ {
|
|
281
326
|
do {
|
|
@@ -17,12 +17,14 @@ public extension SensorKind {
|
|
|
17
17
|
*/
|
|
18
18
|
init?(fromString string: String) {
|
|
19
19
|
switch string {
|
|
20
|
+
case "magnetometer":
|
|
21
|
+
self = .magnetometer
|
|
22
|
+
case "coreLocation":
|
|
23
|
+
self = .corelocation
|
|
20
24
|
case "rotationVector":
|
|
21
25
|
self = .rotationvector
|
|
22
26
|
case "geomagneticRotationVector":
|
|
23
27
|
self = .geomagneticrotationvector
|
|
24
|
-
case "coreLocation":
|
|
25
|
-
self = .corelocation
|
|
26
28
|
default:
|
|
27
29
|
return nil
|
|
28
30
|
}
|
|
@@ -33,12 +35,14 @@ public extension SensorKind {
|
|
|
33
35
|
*/
|
|
34
36
|
var stringValue: String {
|
|
35
37
|
switch self {
|
|
38
|
+
case .magnetometer:
|
|
39
|
+
return "magnetometer"
|
|
40
|
+
case .corelocation:
|
|
41
|
+
return "coreLocation"
|
|
36
42
|
case .rotationvector:
|
|
37
43
|
return "rotationVector"
|
|
38
44
|
case .geomagneticrotationvector:
|
|
39
45
|
return "geomagneticRotationVector"
|
|
40
|
-
case .corelocation:
|
|
41
|
-
return "coreLocation"
|
|
42
46
|
}
|
|
43
47
|
}
|
|
44
48
|
}
|
|
@@ -41,10 +41,11 @@ namespace margelo::nitro::nitrocompass {
|
|
|
41
41
|
public:
|
|
42
42
|
double heading SWIFT_PRIVATE;
|
|
43
43
|
double accuracy SWIFT_PRIVATE;
|
|
44
|
+
double fieldStrengthMicroTesla SWIFT_PRIVATE;
|
|
44
45
|
|
|
45
46
|
public:
|
|
46
47
|
CompassSample() = default;
|
|
47
|
-
explicit CompassSample(double heading, double accuracy): heading(heading), accuracy(accuracy) {}
|
|
48
|
+
explicit CompassSample(double heading, double accuracy, double fieldStrengthMicroTesla): heading(heading), accuracy(accuracy), fieldStrengthMicroTesla(fieldStrengthMicroTesla) {}
|
|
48
49
|
|
|
49
50
|
public:
|
|
50
51
|
friend bool operator==(const CompassSample& lhs, const CompassSample& rhs) = default;
|
|
@@ -61,13 +62,15 @@ namespace margelo::nitro {
|
|
|
61
62
|
jsi::Object obj = arg.asObject(runtime);
|
|
62
63
|
return margelo::nitro::nitrocompass::CompassSample(
|
|
63
64
|
JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "heading"))),
|
|
64
|
-
JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "accuracy")))
|
|
65
|
+
JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "accuracy"))),
|
|
66
|
+
JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "fieldStrengthMicroTesla")))
|
|
65
67
|
);
|
|
66
68
|
}
|
|
67
69
|
static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::nitrocompass::CompassSample& arg) {
|
|
68
70
|
jsi::Object obj(runtime);
|
|
69
71
|
obj.setProperty(runtime, PropNameIDCache::get(runtime, "heading"), JSIConverter<double>::toJSI(runtime, arg.heading));
|
|
70
72
|
obj.setProperty(runtime, PropNameIDCache::get(runtime, "accuracy"), JSIConverter<double>::toJSI(runtime, arg.accuracy));
|
|
73
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "fieldStrengthMicroTesla"), JSIConverter<double>::toJSI(runtime, arg.fieldStrengthMicroTesla));
|
|
71
74
|
return obj;
|
|
72
75
|
}
|
|
73
76
|
static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
|
|
@@ -80,6 +83,7 @@ namespace margelo::nitro {
|
|
|
80
83
|
}
|
|
81
84
|
if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "heading")))) return false;
|
|
82
85
|
if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "accuracy")))) return false;
|
|
86
|
+
if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "fieldStrengthMicroTesla")))) return false;
|
|
83
87
|
return true;
|
|
84
88
|
}
|
|
85
89
|
};
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// DebugInfo.hpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#pragma once
|
|
9
|
+
|
|
10
|
+
#if __has_include(<NitroModules/JSIConverter.hpp>)
|
|
11
|
+
#include <NitroModules/JSIConverter.hpp>
|
|
12
|
+
#else
|
|
13
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
14
|
+
#endif
|
|
15
|
+
#if __has_include(<NitroModules/NitroDefines.hpp>)
|
|
16
|
+
#include <NitroModules/NitroDefines.hpp>
|
|
17
|
+
#else
|
|
18
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
19
|
+
#endif
|
|
20
|
+
#if __has_include(<NitroModules/JSIHelpers.hpp>)
|
|
21
|
+
#include <NitroModules/JSIHelpers.hpp>
|
|
22
|
+
#else
|
|
23
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
24
|
+
#endif
|
|
25
|
+
#if __has_include(<NitroModules/PropNameIDCache.hpp>)
|
|
26
|
+
#include <NitroModules/PropNameIDCache.hpp>
|
|
27
|
+
#else
|
|
28
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
29
|
+
#endif
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
namespace margelo::nitro::nitrocompass {
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* A struct which can be represented as a JavaScript object (DebugInfo).
|
|
39
|
+
*/
|
|
40
|
+
struct DebugInfo final {
|
|
41
|
+
public:
|
|
42
|
+
bool interferenceActive SWIFT_PRIVATE;
|
|
43
|
+
double msSinceLastBiasJump SWIFT_PRIVATE;
|
|
44
|
+
double expectedFieldMicroTesla SWIFT_PRIVATE;
|
|
45
|
+
double lastFieldMicroTesla SWIFT_PRIVATE;
|
|
46
|
+
double fusedYawDeg SWIFT_PRIVATE;
|
|
47
|
+
double lastYawRateDegPerS SWIFT_PRIVATE;
|
|
48
|
+
bool hasGameRotationVector SWIFT_PRIVATE;
|
|
49
|
+
bool usingUncalibratedMag SWIFT_PRIVATE;
|
|
50
|
+
|
|
51
|
+
public:
|
|
52
|
+
DebugInfo() = default;
|
|
53
|
+
explicit DebugInfo(bool interferenceActive, double msSinceLastBiasJump, double expectedFieldMicroTesla, double lastFieldMicroTesla, double fusedYawDeg, double lastYawRateDegPerS, bool hasGameRotationVector, bool usingUncalibratedMag): interferenceActive(interferenceActive), msSinceLastBiasJump(msSinceLastBiasJump), expectedFieldMicroTesla(expectedFieldMicroTesla), lastFieldMicroTesla(lastFieldMicroTesla), fusedYawDeg(fusedYawDeg), lastYawRateDegPerS(lastYawRateDegPerS), hasGameRotationVector(hasGameRotationVector), usingUncalibratedMag(usingUncalibratedMag) {}
|
|
54
|
+
|
|
55
|
+
public:
|
|
56
|
+
friend bool operator==(const DebugInfo& lhs, const DebugInfo& rhs) = default;
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
} // namespace margelo::nitro::nitrocompass
|
|
60
|
+
|
|
61
|
+
namespace margelo::nitro {
|
|
62
|
+
|
|
63
|
+
// C++ DebugInfo <> JS DebugInfo (object)
|
|
64
|
+
template <>
|
|
65
|
+
struct JSIConverter<margelo::nitro::nitrocompass::DebugInfo> final {
|
|
66
|
+
static inline margelo::nitro::nitrocompass::DebugInfo fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
|
67
|
+
jsi::Object obj = arg.asObject(runtime);
|
|
68
|
+
return margelo::nitro::nitrocompass::DebugInfo(
|
|
69
|
+
JSIConverter<bool>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "interferenceActive"))),
|
|
70
|
+
JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "msSinceLastBiasJump"))),
|
|
71
|
+
JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "expectedFieldMicroTesla"))),
|
|
72
|
+
JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "lastFieldMicroTesla"))),
|
|
73
|
+
JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "fusedYawDeg"))),
|
|
74
|
+
JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "lastYawRateDegPerS"))),
|
|
75
|
+
JSIConverter<bool>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "hasGameRotationVector"))),
|
|
76
|
+
JSIConverter<bool>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "usingUncalibratedMag")))
|
|
77
|
+
);
|
|
78
|
+
}
|
|
79
|
+
static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::nitrocompass::DebugInfo& arg) {
|
|
80
|
+
jsi::Object obj(runtime);
|
|
81
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "interferenceActive"), JSIConverter<bool>::toJSI(runtime, arg.interferenceActive));
|
|
82
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "msSinceLastBiasJump"), JSIConverter<double>::toJSI(runtime, arg.msSinceLastBiasJump));
|
|
83
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "expectedFieldMicroTesla"), JSIConverter<double>::toJSI(runtime, arg.expectedFieldMicroTesla));
|
|
84
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "lastFieldMicroTesla"), JSIConverter<double>::toJSI(runtime, arg.lastFieldMicroTesla));
|
|
85
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "fusedYawDeg"), JSIConverter<double>::toJSI(runtime, arg.fusedYawDeg));
|
|
86
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "lastYawRateDegPerS"), JSIConverter<double>::toJSI(runtime, arg.lastYawRateDegPerS));
|
|
87
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "hasGameRotationVector"), JSIConverter<bool>::toJSI(runtime, arg.hasGameRotationVector));
|
|
88
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "usingUncalibratedMag"), JSIConverter<bool>::toJSI(runtime, arg.usingUncalibratedMag));
|
|
89
|
+
return obj;
|
|
90
|
+
}
|
|
91
|
+
static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
|
|
92
|
+
if (!value.isObject()) {
|
|
93
|
+
return false;
|
|
94
|
+
}
|
|
95
|
+
jsi::Object obj = value.getObject(runtime);
|
|
96
|
+
if (!nitro::isPlainObject(runtime, obj)) {
|
|
97
|
+
return false;
|
|
98
|
+
}
|
|
99
|
+
if (!JSIConverter<bool>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "interferenceActive")))) return false;
|
|
100
|
+
if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "msSinceLastBiasJump")))) return false;
|
|
101
|
+
if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "expectedFieldMicroTesla")))) return false;
|
|
102
|
+
if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "lastFieldMicroTesla")))) return false;
|
|
103
|
+
if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "fusedYawDeg")))) return false;
|
|
104
|
+
if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "lastYawRateDegPerS")))) return false;
|
|
105
|
+
if (!JSIConverter<bool>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "hasGameRotationVector")))) return false;
|
|
106
|
+
if (!JSIConverter<bool>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "usingUncalibratedMag")))) return false;
|
|
107
|
+
return true;
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
} // namespace margelo::nitro
|