capacitor-motioncal 0.0.4 → 0.0.5
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 +316 -70
- package/android/CMakeLists.txt +29 -0
- package/android/build.gradle +4 -4
- package/android/src/main/java/com/denizak/motioncalibration/MotionCalibration.java +14 -43
- package/android/src/main/jni/jni_bridge.c +197 -0
- package/common/imuread.h +1 -15
- package/common/rawdata.c +8 -11
- package/common/serialdata.c +0 -59
- package/dist/docs.json +7 -68
- package/dist/esm/definitions.d.ts +11 -29
- package/dist/esm/web.d.ts +2 -13
- package/dist/esm/web.js +1 -10
- package/dist/esm/web.js.map +1 -1
- package/dist/plugin.cjs.js +1 -10
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.js +1 -10
- package/dist/plugin.js.map +1 -1
- package/ios/Sources/MotionCalibrationPlugin/MotionCalibrationPlugin.swift +7 -43
- package/package.json +3 -2
- package/android/src/main/jniLibs/arm64-v8a/libmotioncalibration.so +0 -0
- package/android/src/main/jniLibs/armeabi-v7a/libmotioncalibration.so +0 -0
- package/android/src/main/jniLibs/x86/libmotioncalibration.so +0 -0
- package/android/src/main/jniLibs/x86_64/libmotioncalibration.so +0 -0
- package/common/motioncalibration.c +0 -7
- package/common/motioncalibration.h +0 -12
|
@@ -6,11 +6,8 @@ public class MotionCalibrationPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
6
6
|
public let identifier = "MotionCalibrationPlugin"
|
|
7
7
|
public let jsName = "MotionCalibration"
|
|
8
8
|
public let pluginMethods: [CAPPluginMethod] = [
|
|
9
|
-
CAPPluginMethod(name: "updateBValue", returnType: CAPPluginReturnPromise),
|
|
10
|
-
CAPPluginMethod(name: "getBValue", returnType: CAPPluginReturnPromise),
|
|
11
9
|
CAPPluginMethod(name: "isSendCalAvailable", returnType: CAPPluginReturnPromise),
|
|
12
|
-
CAPPluginMethod(name: "
|
|
13
|
-
CAPPluginMethod(name: "setResultFilename", returnType: CAPPluginReturnPromise),
|
|
10
|
+
CAPPluginMethod(name: "rawData", returnType: CAPPluginReturnPromise),
|
|
14
11
|
CAPPluginMethod(name: "sendCalibration", returnType: CAPPluginReturnPromise),
|
|
15
12
|
CAPPluginMethod(name: "getQualitySurfaceGapError", returnType: CAPPluginReturnPromise),
|
|
16
13
|
CAPPluginMethod(name: "getQualityMagnitudeVarianceError", returnType: CAPPluginReturnPromise),
|
|
@@ -26,53 +23,20 @@ public class MotionCalibrationPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
26
23
|
CAPPluginMethod(name: "clearDrawPoints", returnType: CAPPluginReturnPromise)
|
|
27
24
|
]
|
|
28
25
|
|
|
29
|
-
public override func load() {
|
|
30
|
-
// Initialize the C struct if needed
|
|
31
|
-
motioncal.B = 0.0
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
@objc func updateBValue(_ call: CAPPluginCall) {
|
|
35
|
-
guard let value = call.getFloat("value") else {
|
|
36
|
-
call.reject("Value is required")
|
|
37
|
-
return
|
|
38
|
-
}
|
|
39
|
-
motioncal.B = value * 2
|
|
40
|
-
call.resolve()
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
@objc func getBValue(_ call: CAPPluginCall) {
|
|
44
|
-
let bValue = motioncal.B
|
|
45
|
-
call.resolve(["value": bValue])
|
|
46
|
-
}
|
|
47
|
-
|
|
48
26
|
@objc func isSendCalAvailable(_ call: CAPPluginCall) {
|
|
49
27
|
let available = is_send_cal_available()
|
|
50
28
|
call.resolve(["available": Int(available)])
|
|
51
29
|
}
|
|
52
30
|
|
|
53
|
-
@objc func
|
|
54
|
-
guard let
|
|
55
|
-
call.reject("
|
|
31
|
+
@objc func rawData(_ call: CAPPluginCall) {
|
|
32
|
+
guard let dataArray = call.getArray("data") as? [NSNumber], dataArray.count == 9 else {
|
|
33
|
+
call.reject("Expected array of 9 numbers")
|
|
56
34
|
return
|
|
57
35
|
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
let result = read_ipc_file_data(fullPath)
|
|
63
|
-
call.resolve(["result": Int(result)])
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
@objc func setResultFilename(_ call: CAPPluginCall) {
|
|
67
|
-
guard let filename = call.getString("filename") else {
|
|
68
|
-
call.reject("Filename is required")
|
|
69
|
-
return
|
|
36
|
+
var rawValues = dataArray.map { Int16(clamping: $0.intValue) }
|
|
37
|
+
rawValues.withUnsafeMutableBufferPointer { ptr in
|
|
38
|
+
raw_data(ptr.baseAddress!)
|
|
70
39
|
}
|
|
71
|
-
|
|
72
|
-
let documentsPath = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true)[0]
|
|
73
|
-
let fullPath = (documentsPath as NSString).appendingPathComponent(filename)
|
|
74
|
-
|
|
75
|
-
set_result_filename(fullPath)
|
|
76
40
|
call.resolve()
|
|
77
41
|
}
|
|
78
42
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "capacitor-motioncal",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.5",
|
|
4
4
|
"description": "Capacitor plugin for motion calibration using magnetometer data",
|
|
5
5
|
"main": "dist/plugin.cjs.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
"files": [
|
|
10
10
|
"android/src/main/",
|
|
11
11
|
"android/build.gradle",
|
|
12
|
+
"android/CMakeLists.txt",
|
|
12
13
|
"dist/",
|
|
13
14
|
"ios/Sources/",
|
|
14
15
|
"common/",
|
|
@@ -43,7 +44,7 @@
|
|
|
43
44
|
"swiftlint": "node-swiftlint",
|
|
44
45
|
"docgen": "docgen --api MotionCalibrationPlugin --output-readme README.md --output-json dist/docs.json",
|
|
45
46
|
"build": "npm run clean && npm run docgen && tsc && rollup -c rollup.config.mjs",
|
|
46
|
-
"clean": "rimraf ./dist",
|
|
47
|
+
"clean": "npx rimraf ./dist",
|
|
47
48
|
"watch": "tsc --watch",
|
|
48
49
|
"prepublishOnly": "npm run build"
|
|
49
50
|
},
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|