brilliantsole 0.0.27 → 0.0.29
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/assets/3d/anchor.glb +0 -0
- package/assets/3d/coin.glb +0 -0
- package/assets/3d/glasses.glb +0 -0
- package/assets/audio/bounceMedium.wav +0 -0
- package/assets/audio/bounceStrong.wav +0 -0
- package/assets/audio/bounceWeak.wav +0 -0
- package/assets/audio/coin.wav +0 -0
- package/assets/audio/getUp.wav +0 -0
- package/assets/audio/grab.wav +0 -0
- package/assets/audio/kick.wav +0 -0
- package/assets/audio/platterFadeIn old.wav +0 -0
- package/assets/audio/platterFadeIn.wav +0 -0
- package/assets/audio/platterFadeOut.wav +0 -0
- package/assets/audio/punch.wav +0 -0
- package/assets/audio/punchSqueak.wav +0 -0
- package/assets/audio/purr.wav +0 -0
- package/assets/audio/purrFadeOut.wav +0 -0
- package/assets/audio/release.wav +0 -0
- package/assets/audio/splat.wav +0 -0
- package/assets/audio/stomp.wav +0 -0
- package/build/brilliantsole.cjs +3091 -741
- package/build/brilliantsole.cjs.map +1 -1
- package/build/brilliantsole.js +2759 -709
- package/build/brilliantsole.js.map +1 -1
- package/build/brilliantsole.ls.js +2602 -543
- package/build/brilliantsole.ls.js.map +1 -1
- package/build/brilliantsole.min.js +1 -1
- package/build/brilliantsole.min.js.map +1 -1
- package/build/brilliantsole.module.d.ts +295 -65
- package/build/brilliantsole.module.js +2749 -710
- package/build/brilliantsole.module.js.map +1 -1
- package/build/brilliantsole.module.min.d.ts +295 -65
- package/build/brilliantsole.module.min.js +1 -1
- package/build/brilliantsole.module.min.js.map +1 -1
- package/build/brilliantsole.node.module.d.ts +289 -62
- package/build/brilliantsole.node.module.js +3080 -742
- package/build/brilliantsole.node.module.js.map +1 -1
- package/build/dts/BS-output.d.ts +10 -0
- package/build/dts/BS.d.ts +21 -8
- package/build/dts/CameraManager.d.ts +72 -0
- package/build/dts/Device.d.ts +64 -13
- package/build/dts/DeviceInformationManager.d.ts +4 -4
- package/build/dts/DeviceManager.d.ts +2 -0
- package/build/dts/FileTransferManager.d.ts +18 -8
- package/build/dts/InformationManager.d.ts +2 -0
- package/build/dts/MicrophoneManager.d.ts +88 -0
- package/build/dts/TfliteManager.d.ts +22 -2
- package/build/dts/WifiManager.d.ts +61 -0
- package/build/dts/connection/BaseConnectionManager.d.ts +35 -3
- package/build/dts/connection/ClientConnectionManager.d.ts +7 -2
- package/build/dts/connection/bluetooth/NobleConnectionManager.d.ts +2 -1
- package/build/dts/connection/bluetooth/WebBluetoothConnectionManager.d.ts +1 -0
- package/build/dts/connection/bluetooth/bluetoothUUIDs.d.ts +2 -2
- package/build/dts/connection/udp/UDPConnectionManager.d.ts +28 -0
- package/build/dts/connection/webSocket/WebSocketConnectionManager.d.ts +25 -0
- package/build/dts/devicePair/DevicePair.d.ts +5 -5
- package/build/dts/scanner/BaseScanner.d.ts +4 -1
- package/build/dts/scanner/NobleScanner.d.ts +2 -1
- package/build/dts/sensor/MotionSensorDataManager.d.ts +5 -2
- package/build/dts/sensor/SensorDataManager.d.ts +5 -4
- package/build/dts/server/BaseClient.d.ts +5 -3
- package/build/dts/server/ServerUtils.d.ts +1 -1
- package/build/dts/server/websocket/WebSocketUtils.d.ts +1 -1
- package/build/dts/utils/AudioUtils.d.ts +2 -0
- package/build/dts/utils/Console.d.ts +2 -0
- package/build/dts/utils/ThrottleUtils.d.ts +2 -0
- package/build/dts/vibration/VibrationManager.d.ts +19 -2
- package/build/index.d.ts +292 -62
- package/build/index.node.d.ts +286 -59
- package/examples/3d/scene.html +19 -5
- package/examples/3d-generic/index.html +144 -0
- package/examples/3d-generic/script.js +266 -0
- package/examples/basic/index.html +267 -17
- package/examples/basic/script.js +958 -105
- package/examples/camera/barcode-detector.js +109 -0
- package/examples/camera/depth-estimation.js +71 -0
- package/examples/camera/face-detector.js +119 -0
- package/examples/camera/face-landmark.js +111 -0
- package/examples/camera/gesture-recognition.js +97 -0
- package/examples/camera/hand-landmark.js +74 -0
- package/examples/camera/image-segmentation.js +98 -0
- package/examples/camera/image-to-text.js +43 -0
- package/examples/camera/image-upscale.js +75 -0
- package/examples/camera/index.html +129 -0
- package/examples/camera/object-detection.js +98 -0
- package/examples/camera/pose-landmark.js +60 -0
- package/examples/camera/script.js +316 -0
- package/examples/camera/utils.js +165 -0
- package/examples/camera/yolo-tiny.js +54 -0
- package/examples/camera/yolo.js +119 -0
- package/examples/edge-impulse/script.js +157 -48
- package/examples/edge-impulse-test/README.md +11 -0
- package/examples/edge-impulse-test/edge-impulse-standalone.js +7228 -0
- package/examples/edge-impulse-test/edge-impulse-standalone.wasm +0 -0
- package/examples/edge-impulse-test/index.html +75 -0
- package/examples/edge-impulse-test/run-impulse.js +135 -0
- package/examples/edge-impulse-test/script.js +200 -0
- package/examples/glasses-gestures/README.md +11 -0
- package/examples/glasses-gestures/edge-impulse-standalone.js +7228 -0
- package/examples/glasses-gestures/edge-impulse-standalone.wasm +0 -0
- package/examples/glasses-gestures/index.html +69 -0
- package/examples/glasses-gestures/run-impulse.js +135 -0
- package/examples/glasses-gestures/script.js +226 -0
- package/examples/gloves/edge-impulse-standalone.js +7228 -0
- package/examples/gloves/edge-impulse-standalone.wasm +0 -0
- package/examples/gloves/index.html +4 -1
- package/examples/gloves/run-impulse.js +135 -0
- package/examples/gloves/script.js +367 -51
- package/examples/graph/script.js +94 -37
- package/examples/microphone/gender.js +54 -0
- package/examples/microphone/index.html +102 -0
- package/examples/microphone/script.js +394 -0
- package/examples/microphone/utils.js +45 -0
- package/examples/microphone/whisper-realtime.js +166 -0
- package/examples/microphone/whisper.js +132 -0
- package/examples/punch/index.html +135 -0
- package/examples/punch/punch.tflite +0 -0
- package/examples/punch/script.js +169 -0
- package/examples/server/index.html +98 -22
- package/examples/server/script.js +317 -109
- package/examples/ukaton-firmware-update/merged-firmware.bin +0 -0
- package/examples/utils/aframe/aframe-master.min.js +2 -0
- package/examples/utils/aframe/bs-vibration.js +150 -0
- package/examples/utils/aframe/force-pushable.js +80 -0
- package/examples/utils/aframe/grabbable-anchor.js +46 -0
- package/examples/utils/aframe/grabbable-listener.js +31 -0
- package/examples/utils/aframe/grabbable-physics-body.js +190 -0
- package/examples/utils/aframe/grow-shrink.js +25 -0
- package/examples/utils/aframe/hand-punch.js +119 -0
- package/examples/utils/aframe/my-obb-collider.js +293 -0
- package/examples/utils/aframe/occlude-hand-tracking-controls.js +47 -0
- package/examples/utils/aframe/occlude-mesh.js +42 -0
- package/examples/utils/aframe/palm-up-detector.js +47 -0
- package/examples/utils/aframe/shadow-material.js +20 -0
- package/examples/utils/aframe/soft-shadow-light.js +9 -0
- package/examples/webxr-2/assets/3d/soccerBall.glb +0 -0
- package/examples/webxr-2/assets/audio/shellBounce.wav +0 -0
- package/examples/webxr-2/assets/audio/shellHit.wav +0 -0
- package/examples/webxr-2/assets/audio/shellKick.wav +0 -0
- package/examples/webxr-2/assets/audio/soccerBounce.wav +0 -0
- package/examples/webxr-2/assets/audio/soccerKick.mp3 +0 -0
- package/examples/webxr-2/assets/images/shellTexture.png +0 -0
- package/examples/webxr-2/components/bs-ankle.js +337 -0
- package/examples/webxr-2/components/coin.js +84 -0
- package/examples/webxr-2/components/custom-wrap.js +17 -0
- package/examples/webxr-2/components/goomba.js +3250 -0
- package/examples/webxr-2/components/init-shell-material.js +215 -0
- package/examples/webxr-2/components/platter.js +172 -0
- package/examples/webxr-2/components/shell.js +374 -0
- package/examples/webxr-2/components/soccer-ball.js +250 -0
- package/examples/webxr-2/components/squashed-goomba.js +249 -0
- package/examples/webxr-2/edge-impulse-standalone.js +7228 -0
- package/examples/webxr-2/edge-impulse-standalone.wasm +0 -0
- package/examples/webxr-2/index.html +996 -0
- package/examples/webxr-2/kick.tflite +0 -0
- package/examples/webxr-2/kick2.tflite +0 -0
- package/examples/webxr-2/run-impulse.js +135 -0
- package/examples/webxr-2/script.js +384 -0
- package/examples/webxr-3/components/bs-camera.js +65 -0
- package/examples/webxr-3/index.html +134 -0
- package/examples/webxr-3/script.js +432 -0
- package/package.json +2 -1
- package/src/.prettierrc +4 -0
- package/src/BS.ts +79 -8
- package/src/CameraManager.ts +497 -0
- package/src/Device.ts +691 -86
- package/src/DeviceInformationManager.ts +19 -10
- package/src/DeviceManager.ts +85 -25
- package/src/FileTransferManager.ts +145 -20
- package/src/InformationManager.ts +40 -15
- package/src/MicrophoneManager.ts +599 -0
- package/src/TfliteManager.ts +171 -25
- package/src/WifiManager.ts +323 -0
- package/src/connection/BaseConnectionManager.ts +130 -30
- package/src/connection/ClientConnectionManager.ts +34 -10
- package/src/connection/bluetooth/BluetoothConnectionManager.ts +8 -2
- package/src/connection/bluetooth/NobleConnectionManager.ts +147 -41
- package/src/connection/bluetooth/WebBluetoothConnectionManager.ts +99 -34
- package/src/connection/bluetooth/bluetoothUUIDs.ts +40 -13
- package/src/connection/udp/UDPConnectionManager.ts +356 -0
- package/src/connection/websocket/WebSocketConnectionManager.ts +282 -0
- package/src/devicePair/DevicePair.ts +95 -25
- package/src/devicePair/DevicePairPressureSensorDataManager.ts +27 -7
- package/src/scanner/BaseScanner.ts +49 -11
- package/src/scanner/NobleScanner.ts +76 -14
- package/src/sensor/MotionSensorDataManager.ts +21 -6
- package/src/sensor/PressureSensorDataManager.ts +37 -8
- package/src/sensor/SensorConfigurationManager.ts +73 -22
- package/src/sensor/SensorDataManager.ts +109 -23
- package/src/server/BaseClient.ts +150 -36
- package/src/server/BaseServer.ts +50 -2
- package/src/server/ServerUtils.ts +39 -9
- package/src/server/udp/UDPServer.ts +73 -22
- package/src/server/udp/UDPUtils.ts +9 -2
- package/src/server/websocket/WebSocketClient.ts +27 -7
- package/src/server/websocket/WebSocketUtils.ts +4 -2
- package/src/utils/AudioUtils.ts +65 -0
- package/src/utils/Console.ts +62 -9
- package/src/utils/ParseUtils.ts +24 -5
- package/src/utils/ThrottleUtils.ts +62 -0
- package/src/utils/Timer.ts +1 -1
- package/src/vibration/VibrationManager.ts +166 -40
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
<html>
|
|
2
|
+
<head>
|
|
3
|
+
<title>WebXR Camera | BrilliantSole JavaScript SDK</title>
|
|
4
|
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
5
|
+
<link rel="shortcut icon" type="image/x-icon" href="/favicon.ico" />
|
|
6
|
+
<script src="../utils/aframe/aframe-master.min.js"></script>
|
|
7
|
+
<script src="../utils/aframe/occlude-hand-tracking-controls.js"></script>
|
|
8
|
+
<script src="./components/bs-camera.js" type="module"></script>
|
|
9
|
+
|
|
10
|
+
<script type="module" src="./script.js"></script>
|
|
11
|
+
</head>
|
|
12
|
+
|
|
13
|
+
<style>
|
|
14
|
+
a-scene {
|
|
15
|
+
width: 500px;
|
|
16
|
+
height: 400px;
|
|
17
|
+
margin: auto;
|
|
18
|
+
border-radius: 2rem;
|
|
19
|
+
overflow: hidden;
|
|
20
|
+
border: solid black;
|
|
21
|
+
box-sizing: border-box;
|
|
22
|
+
}
|
|
23
|
+
</style>
|
|
24
|
+
|
|
25
|
+
<body>
|
|
26
|
+
<nav>
|
|
27
|
+
<a href="../../">home</a>
|
|
28
|
+
</nav>
|
|
29
|
+
|
|
30
|
+
<h1>WebXR Camera | BrilliantSole JavaScript SDK</h1>
|
|
31
|
+
|
|
32
|
+
<div>
|
|
33
|
+
<label
|
|
34
|
+
>webSocket url
|
|
35
|
+
<input id="webSocketUrl" type="url" placeholder="localhost"
|
|
36
|
+
/></label>
|
|
37
|
+
<button id="toggleConnection">connect</button>
|
|
38
|
+
</div>
|
|
39
|
+
|
|
40
|
+
<div>
|
|
41
|
+
<label>
|
|
42
|
+
is scanning available?
|
|
43
|
+
<input id="isScanningAvailable" type="checkbox" readonly disabled />
|
|
44
|
+
</label>
|
|
45
|
+
<button id="toggleScan" disabled>scan</button>
|
|
46
|
+
</div>
|
|
47
|
+
|
|
48
|
+
<div>
|
|
49
|
+
<h2>camera</h2>
|
|
50
|
+
|
|
51
|
+
<label>
|
|
52
|
+
<b>is camera available?</b>
|
|
53
|
+
<span id="isCameraAvailable"></span>
|
|
54
|
+
</label>
|
|
55
|
+
|
|
56
|
+
<label><b>status:</b> <span id="cameraStatus"></span></label>
|
|
57
|
+
<br />
|
|
58
|
+
|
|
59
|
+
<label>auto picture: <input type="checkbox" id="autoPicture" /> </label>
|
|
60
|
+
|
|
61
|
+
<button disabled id="takePicture">take picture</button>
|
|
62
|
+
<progress value="0" id="cameraImageProgress"></progress>
|
|
63
|
+
<br />
|
|
64
|
+
<button disabled id="focusCamera">focus camera</button>
|
|
65
|
+
<br />
|
|
66
|
+
<button disabled id="sleepCamera">sleep camera</button>
|
|
67
|
+
|
|
68
|
+
<div style="display: flex; flex-direction: row">
|
|
69
|
+
<div>
|
|
70
|
+
<label>
|
|
71
|
+
<b>camera configuration: </b>
|
|
72
|
+
<pre id="cameraConfigurationPre"></pre>
|
|
73
|
+
</label>
|
|
74
|
+
<br />
|
|
75
|
+
|
|
76
|
+
<label>
|
|
77
|
+
take picture after update?
|
|
78
|
+
<input type="checkbox" id="takePictureAfterUpdate" />
|
|
79
|
+
</label>
|
|
80
|
+
|
|
81
|
+
<div id="cameraConfiguration">
|
|
82
|
+
<template id="cameraConfigurationTypeTemplate">
|
|
83
|
+
<label class="cameraConfigurationType">
|
|
84
|
+
<input class="value" type="range" value="" disabled />
|
|
85
|
+
<b class="type"></b> <span></span>
|
|
86
|
+
<br />
|
|
87
|
+
</label>
|
|
88
|
+
</template>
|
|
89
|
+
</div>
|
|
90
|
+
<label>
|
|
91
|
+
<b>white balance</b>
|
|
92
|
+
<input type="color" id="cameraWhiteBalance" disabled />
|
|
93
|
+
</label>
|
|
94
|
+
</div>
|
|
95
|
+
<div>
|
|
96
|
+
<img id="cameraImage" />
|
|
97
|
+
</div>
|
|
98
|
+
</div>
|
|
99
|
+
</div>
|
|
100
|
+
|
|
101
|
+
<a-scene
|
|
102
|
+
embedded
|
|
103
|
+
obb-collider="showColliders: false;"
|
|
104
|
+
xr-mode-ui="enabled: true; XRMode: ar"
|
|
105
|
+
device-orientation-permission-ui="enabled: false"
|
|
106
|
+
>
|
|
107
|
+
<a-assets></a-assets>
|
|
108
|
+
|
|
109
|
+
<a-camera position="0 1.6 0">
|
|
110
|
+
<a-image
|
|
111
|
+
grabbable
|
|
112
|
+
width="0.15"
|
|
113
|
+
height="0.15"
|
|
114
|
+
position="0 0 -0.5"
|
|
115
|
+
bs-camera
|
|
116
|
+
></a-image>
|
|
117
|
+
</a-camera>
|
|
118
|
+
|
|
119
|
+
<a-entity
|
|
120
|
+
class="left hand"
|
|
121
|
+
hand-tracking-grab-controls="hand: left;"
|
|
122
|
+
occlude-hand-tracking-controls
|
|
123
|
+
></a-entity>
|
|
124
|
+
|
|
125
|
+
<a-entity
|
|
126
|
+
class="right hand"
|
|
127
|
+
hand-tracking-grab-controls="hand: right;"
|
|
128
|
+
occlude-hand-tracking-controls
|
|
129
|
+
></a-entity>
|
|
130
|
+
|
|
131
|
+
<a-sky hide-on-enter-ar color="black"></a-sky>
|
|
132
|
+
</a-scene>
|
|
133
|
+
</body>
|
|
134
|
+
</html>
|
|
@@ -0,0 +1,432 @@
|
|
|
1
|
+
import * as BS from "../../build/brilliantsole.module.js";
|
|
2
|
+
window.BS = BS;
|
|
3
|
+
console.log({ BS });
|
|
4
|
+
//BS.setAllConsoleLevelFlags({ log: true });
|
|
5
|
+
|
|
6
|
+
const client = new BS.WebSocketClient();
|
|
7
|
+
console.log({ client });
|
|
8
|
+
|
|
9
|
+
window.client = client;
|
|
10
|
+
|
|
11
|
+
// WEBSOCKET URL SEARCH PARAMS
|
|
12
|
+
|
|
13
|
+
const url = new URL(location);
|
|
14
|
+
function setUrlParam(key, value) {
|
|
15
|
+
if (history.pushState) {
|
|
16
|
+
let searchParams = new URLSearchParams(window.location.search);
|
|
17
|
+
if (value) {
|
|
18
|
+
searchParams.set(key, value);
|
|
19
|
+
} else {
|
|
20
|
+
searchParams.delete(key);
|
|
21
|
+
}
|
|
22
|
+
let newUrl =
|
|
23
|
+
window.location.protocol +
|
|
24
|
+
"//" +
|
|
25
|
+
window.location.host +
|
|
26
|
+
window.location.pathname +
|
|
27
|
+
"?" +
|
|
28
|
+
searchParams.toString();
|
|
29
|
+
window.history.pushState({ path: newUrl }, "", newUrl);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
client.addEventListener("isConnected", () => {
|
|
33
|
+
if (client.isConnected) {
|
|
34
|
+
setUrlParam("webSocketUrl", client.webSocket.url);
|
|
35
|
+
webSocketUrlInput.value = client.webSocket.url;
|
|
36
|
+
webSocketUrlInput.dispatchEvent(new Event("input"));
|
|
37
|
+
} else {
|
|
38
|
+
setUrlParam("webSocketUrl");
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
// WEBSOCKET SERVER URL
|
|
43
|
+
|
|
44
|
+
/** @type {HTMLInputElement} */
|
|
45
|
+
const webSocketUrlInput = document.getElementById("webSocketUrl");
|
|
46
|
+
webSocketUrlInput.value = url.searchParams.get("webSocketUrl") || "";
|
|
47
|
+
webSocketUrlInput.dispatchEvent(new Event("input"));
|
|
48
|
+
|
|
49
|
+
// WEBSOCKET CONNECTION
|
|
50
|
+
|
|
51
|
+
/** @type {HTMLButtonElement} */
|
|
52
|
+
const toggleConnectionButton = document.getElementById("toggleConnection");
|
|
53
|
+
toggleConnectionButton.addEventListener("click", () => {
|
|
54
|
+
if (client.isConnected) {
|
|
55
|
+
client.disconnect();
|
|
56
|
+
} else {
|
|
57
|
+
/** @type {string?} */
|
|
58
|
+
let webSocketUrl;
|
|
59
|
+
if (webSocketUrlInput.value.length > 0) {
|
|
60
|
+
webSocketUrl = webSocketUrlInput.value;
|
|
61
|
+
}
|
|
62
|
+
client.connect(webSocketUrl);
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
client.addEventListener("connectionStatus", () => {
|
|
66
|
+
switch (client.connectionStatus) {
|
|
67
|
+
case "connected":
|
|
68
|
+
case "notConnected":
|
|
69
|
+
toggleConnectionButton.disabled = false;
|
|
70
|
+
toggleConnectionButton.innerText = client.isConnected
|
|
71
|
+
? "disconnect"
|
|
72
|
+
: "connect";
|
|
73
|
+
break;
|
|
74
|
+
case "connecting":
|
|
75
|
+
case "disconnecting":
|
|
76
|
+
toggleConnectionButton.innerText = client.connectionStatus;
|
|
77
|
+
toggleConnectionButton.disabled = true;
|
|
78
|
+
break;
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
// SCANNER
|
|
83
|
+
|
|
84
|
+
/** @type {HTMLInputElement} */
|
|
85
|
+
const isScanningAvailableCheckbox = document.getElementById(
|
|
86
|
+
"isScanningAvailable"
|
|
87
|
+
);
|
|
88
|
+
client.addEventListener("isScanningAvailable", () => {
|
|
89
|
+
isScanningAvailableCheckbox.checked = client.isScanningAvailable;
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
/** @type {HTMLButtonElement} */
|
|
93
|
+
const toggleScanButton = document.getElementById("toggleScan");
|
|
94
|
+
toggleScanButton.addEventListener("click", () => {
|
|
95
|
+
client.toggleScan();
|
|
96
|
+
});
|
|
97
|
+
client.addEventListener("isScanningAvailable", () => {
|
|
98
|
+
toggleScanButton.disabled = !client.isScanningAvailable;
|
|
99
|
+
});
|
|
100
|
+
client.addEventListener("isScanning", () => {
|
|
101
|
+
toggleScanButton.innerText = client.isScanning ? "stop scanning" : "scan";
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
// DEVICES
|
|
105
|
+
|
|
106
|
+
/** @type {BS.Device?} */
|
|
107
|
+
let device;
|
|
108
|
+
|
|
109
|
+
client.addEventListener("discoveredDevice", (event) => {
|
|
110
|
+
if (device) {
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
const { discoveredDevice } = event.message;
|
|
114
|
+
if (discoveredDevice.deviceType == "glasses") {
|
|
115
|
+
console.log("connecting to discoveredDevice", discoveredDevice);
|
|
116
|
+
device = client.connectToDevice(discoveredDevice.bluetoothId);
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
BS.DeviceManager.AddEventListener("deviceConnected", (event) => {
|
|
121
|
+
if (event.message.device.hasCamera) {
|
|
122
|
+
device = event.message.device;
|
|
123
|
+
onDevice();
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
const onDevice = () => {
|
|
128
|
+
console.log("onDevice", device);
|
|
129
|
+
if (client.isScanning) {
|
|
130
|
+
client.stopScan();
|
|
131
|
+
}
|
|
132
|
+
device.setSensorConfiguration({ camera: 5 });
|
|
133
|
+
|
|
134
|
+
// CAMERA
|
|
135
|
+
|
|
136
|
+
/** @type {HTMLSpanElement} */
|
|
137
|
+
const isCameraAvailableSpan = document.getElementById("isCameraAvailable");
|
|
138
|
+
const updateIsCameraAvailableSpan = () => {
|
|
139
|
+
isCameraAvailableSpan.innerText = device.hasCamera;
|
|
140
|
+
};
|
|
141
|
+
device.addEventListener("connected", () => {
|
|
142
|
+
updateIsCameraAvailableSpan();
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
/** @type {HTMLSpanElement} */
|
|
146
|
+
const cameraStatusSpan = document.getElementById("cameraStatus");
|
|
147
|
+
const updateCameraStatusSpan = () => {
|
|
148
|
+
cameraStatusSpan.innerText = device.cameraStatus;
|
|
149
|
+
};
|
|
150
|
+
device.addEventListener("cameraStatus", () => {
|
|
151
|
+
updateCameraStatusSpan();
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
/** @type {HTMLButtonElement} */
|
|
155
|
+
const takePictureButton = document.getElementById("takePicture");
|
|
156
|
+
takePictureButton.addEventListener("click", () => {
|
|
157
|
+
if (device.cameraStatus == "idle") {
|
|
158
|
+
device.takePicture();
|
|
159
|
+
} else {
|
|
160
|
+
device.stopCamera();
|
|
161
|
+
}
|
|
162
|
+
});
|
|
163
|
+
device.addEventListener("connected", () => {
|
|
164
|
+
updateTakePictureButton();
|
|
165
|
+
});
|
|
166
|
+
device.addEventListener("getSensorConfiguration", () => {
|
|
167
|
+
updateTakePictureButton();
|
|
168
|
+
});
|
|
169
|
+
const updateTakePictureButton = () => {
|
|
170
|
+
takePictureButton.disabled =
|
|
171
|
+
!device.isConnected ||
|
|
172
|
+
device.sensorConfiguration.camera == 0 ||
|
|
173
|
+
device.cameraStatus != "idle";
|
|
174
|
+
};
|
|
175
|
+
device.addEventListener("cameraStatus", () => {
|
|
176
|
+
updateTakePictureButton();
|
|
177
|
+
});
|
|
178
|
+
updateTakePictureButton();
|
|
179
|
+
|
|
180
|
+
/** @type {HTMLButtonElement} */
|
|
181
|
+
const focusCameraButton = document.getElementById("focusCamera");
|
|
182
|
+
focusCameraButton.addEventListener("click", () => {
|
|
183
|
+
if (device.cameraStatus == "idle") {
|
|
184
|
+
device.focusCamera();
|
|
185
|
+
} else {
|
|
186
|
+
device.stopCamera();
|
|
187
|
+
}
|
|
188
|
+
});
|
|
189
|
+
device.addEventListener("connected", () => {
|
|
190
|
+
updateFocusCameraButton();
|
|
191
|
+
});
|
|
192
|
+
device.addEventListener("getSensorConfiguration", () => {
|
|
193
|
+
updateFocusCameraButton();
|
|
194
|
+
});
|
|
195
|
+
const updateFocusCameraButton = () => {
|
|
196
|
+
focusCameraButton.disabled =
|
|
197
|
+
!device.isConnected ||
|
|
198
|
+
device.sensorConfiguration.camera == 0 ||
|
|
199
|
+
device.cameraStatus != "idle";
|
|
200
|
+
};
|
|
201
|
+
device.addEventListener("cameraStatus", (event) => {
|
|
202
|
+
updateFocusCameraButton();
|
|
203
|
+
if (
|
|
204
|
+
device.cameraStatus == "idle" &&
|
|
205
|
+
event.message.previousCameraStatus == "focusing"
|
|
206
|
+
) {
|
|
207
|
+
device.takePicture();
|
|
208
|
+
}
|
|
209
|
+
});
|
|
210
|
+
updateFocusCameraButton();
|
|
211
|
+
|
|
212
|
+
/** @type {HTMLButtonElement} */
|
|
213
|
+
const sleepCameraButton = document.getElementById("sleepCamera");
|
|
214
|
+
sleepCameraButton.addEventListener("click", () => {
|
|
215
|
+
if (device.cameraStatus == "asleep") {
|
|
216
|
+
device.wakeCamera();
|
|
217
|
+
} else {
|
|
218
|
+
device.sleepCamera();
|
|
219
|
+
}
|
|
220
|
+
});
|
|
221
|
+
device.addEventListener("connected", () => {
|
|
222
|
+
updateSleepCameraButton();
|
|
223
|
+
});
|
|
224
|
+
device.addEventListener("getSensorConfiguration", () => {
|
|
225
|
+
updateSleepCameraButton();
|
|
226
|
+
});
|
|
227
|
+
const updateSleepCameraButton = () => {
|
|
228
|
+
let disabled = !device.isConnected || !device.hasCamera;
|
|
229
|
+
switch (device.cameraStatus) {
|
|
230
|
+
case "asleep":
|
|
231
|
+
sleepCameraButton.innerText = "wake camera";
|
|
232
|
+
break;
|
|
233
|
+
case "idle":
|
|
234
|
+
sleepCameraButton.innerText = "sleep camera";
|
|
235
|
+
break;
|
|
236
|
+
default:
|
|
237
|
+
disabled = true;
|
|
238
|
+
break;
|
|
239
|
+
}
|
|
240
|
+
sleepCameraButton.disabled = disabled;
|
|
241
|
+
};
|
|
242
|
+
device.addEventListener("cameraStatus", () => {
|
|
243
|
+
updateSleepCameraButton();
|
|
244
|
+
});
|
|
245
|
+
updateSleepCameraButton();
|
|
246
|
+
|
|
247
|
+
/** @type {HTMLImageElement} */
|
|
248
|
+
const cameraImage = document.getElementById("cameraImage");
|
|
249
|
+
device.addEventListener("cameraImage", (event) => {
|
|
250
|
+
cameraImage.src = event.message.url;
|
|
251
|
+
});
|
|
252
|
+
|
|
253
|
+
/** @type {HTMLProgressElement} */
|
|
254
|
+
const cameraImageProgress = document.getElementById("cameraImageProgress");
|
|
255
|
+
device.addEventListener("cameraImageProgress", (event) => {
|
|
256
|
+
if (event.message.type == "image") {
|
|
257
|
+
cameraImageProgress.value = event.message.progress;
|
|
258
|
+
}
|
|
259
|
+
});
|
|
260
|
+
|
|
261
|
+
/** @type {HTMLInputElement} */
|
|
262
|
+
const autoPictureCheckbox = document.getElementById("autoPicture");
|
|
263
|
+
let autoPicture = autoPictureCheckbox.checked;
|
|
264
|
+
autoPictureCheckbox.addEventListener("input", () => {
|
|
265
|
+
autoPicture = autoPictureCheckbox.checked;
|
|
266
|
+
});
|
|
267
|
+
device.addEventListener("cameraImage", () => {
|
|
268
|
+
if (autoPicture) {
|
|
269
|
+
device.takePicture();
|
|
270
|
+
}
|
|
271
|
+
});
|
|
272
|
+
|
|
273
|
+
/** @type {HTMLPreElement} */
|
|
274
|
+
const cameraConfigurationPre = document.getElementById(
|
|
275
|
+
"cameraConfigurationPre"
|
|
276
|
+
);
|
|
277
|
+
const updateCameraConfigurationPre = () => {
|
|
278
|
+
cameraConfigurationPre.textContent = JSON.stringify(
|
|
279
|
+
device.cameraConfiguration,
|
|
280
|
+
null,
|
|
281
|
+
2
|
|
282
|
+
);
|
|
283
|
+
};
|
|
284
|
+
device.addEventListener("getCameraConfiguration", () => {
|
|
285
|
+
updateCameraConfigurationPre();
|
|
286
|
+
});
|
|
287
|
+
|
|
288
|
+
const cameraConfigurationContainer = document.getElementById(
|
|
289
|
+
"cameraConfiguration"
|
|
290
|
+
);
|
|
291
|
+
/** @type {HTMLTemplateElement} */
|
|
292
|
+
const cameraConfigurationTypeTemplate = document.getElementById(
|
|
293
|
+
"cameraConfigurationTypeTemplate"
|
|
294
|
+
);
|
|
295
|
+
BS.CameraConfigurationTypes.forEach((cameraConfigurationType) => {
|
|
296
|
+
const cameraConfigurationTypeContainer =
|
|
297
|
+
cameraConfigurationTypeTemplate.content
|
|
298
|
+
.cloneNode(true)
|
|
299
|
+
.querySelector(".cameraConfigurationType");
|
|
300
|
+
|
|
301
|
+
cameraConfigurationContainer.appendChild(cameraConfigurationTypeContainer);
|
|
302
|
+
|
|
303
|
+
cameraConfigurationTypeContainer.querySelector(".type").innerText =
|
|
304
|
+
cameraConfigurationType;
|
|
305
|
+
|
|
306
|
+
/** @type {HTMLInputElement} */
|
|
307
|
+
const input = cameraConfigurationTypeContainer.querySelector("input");
|
|
308
|
+
|
|
309
|
+
/** @type {HTMLSpanElement} */
|
|
310
|
+
const span = cameraConfigurationTypeContainer.querySelector("span");
|
|
311
|
+
|
|
312
|
+
device.addEventListener("isConnected", () => {
|
|
313
|
+
updateisInputDisabled();
|
|
314
|
+
});
|
|
315
|
+
device.addEventListener("cameraStatus", () => {
|
|
316
|
+
updateisInputDisabled();
|
|
317
|
+
});
|
|
318
|
+
const updateisInputDisabled = () => {
|
|
319
|
+
input.disabled =
|
|
320
|
+
!device.isConnected ||
|
|
321
|
+
!device.hasCamera ||
|
|
322
|
+
device.cameraStatus != "idle";
|
|
323
|
+
};
|
|
324
|
+
|
|
325
|
+
const updateInput = () => {
|
|
326
|
+
const value = device.cameraConfiguration[cameraConfigurationType];
|
|
327
|
+
span.innerText = value;
|
|
328
|
+
input.value = value;
|
|
329
|
+
};
|
|
330
|
+
const range = device.cameraConfigurationRanges[cameraConfigurationType];
|
|
331
|
+
input.min = range.min;
|
|
332
|
+
input.max = range.max;
|
|
333
|
+
updateInput();
|
|
334
|
+
|
|
335
|
+
device.addEventListener("connected", () => {
|
|
336
|
+
if (!device.hasCamera) {
|
|
337
|
+
return;
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
updateInput();
|
|
341
|
+
});
|
|
342
|
+
|
|
343
|
+
device.addEventListener("getCameraConfiguration", () => {
|
|
344
|
+
updateInput();
|
|
345
|
+
});
|
|
346
|
+
|
|
347
|
+
input.addEventListener("change", () => {
|
|
348
|
+
const value = Number(input.value);
|
|
349
|
+
// console.log(`updating ${cameraConfigurationType} to ${value}`);
|
|
350
|
+
device.setCameraConfiguration({
|
|
351
|
+
[cameraConfigurationType]: value,
|
|
352
|
+
});
|
|
353
|
+
if (takePictureAfterUpdate) {
|
|
354
|
+
device.addEventListener(
|
|
355
|
+
"getCameraConfiguration",
|
|
356
|
+
() => {
|
|
357
|
+
setTimeout(() => device.takePicture()), 100;
|
|
358
|
+
},
|
|
359
|
+
{ once: true }
|
|
360
|
+
);
|
|
361
|
+
}
|
|
362
|
+
});
|
|
363
|
+
});
|
|
364
|
+
|
|
365
|
+
/** @type {HTMLInputElement} */
|
|
366
|
+
const takePictureAfterUpdateCheckbox = document.getElementById(
|
|
367
|
+
"takePictureAfterUpdate"
|
|
368
|
+
);
|
|
369
|
+
let takePictureAfterUpdate = false;
|
|
370
|
+
takePictureAfterUpdateCheckbox.addEventListener("input", () => {
|
|
371
|
+
takePictureAfterUpdate = takePictureAfterUpdateCheckbox.checked;
|
|
372
|
+
console.log({ takePictureAfterUpdate });
|
|
373
|
+
});
|
|
374
|
+
|
|
375
|
+
/** @type {HTMLInputElement} */
|
|
376
|
+
const cameraWhiteBalanceInput = document.getElementById("cameraWhiteBalance");
|
|
377
|
+
const updateWhiteBalance = BS.ThrottleUtils.throttle(
|
|
378
|
+
(config) => {
|
|
379
|
+
if (device.cameraStatus != "idle") {
|
|
380
|
+
return;
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
device.setCameraConfiguration(config);
|
|
384
|
+
|
|
385
|
+
if (takePictureAfterUpdate) {
|
|
386
|
+
device.addEventListener(
|
|
387
|
+
"getCameraConfiguration",
|
|
388
|
+
() => {
|
|
389
|
+
setTimeout(() => device.takePicture()), 100;
|
|
390
|
+
},
|
|
391
|
+
{ once: true }
|
|
392
|
+
);
|
|
393
|
+
}
|
|
394
|
+
},
|
|
395
|
+
200,
|
|
396
|
+
true
|
|
397
|
+
);
|
|
398
|
+
cameraWhiteBalanceInput.addEventListener("input", () => {
|
|
399
|
+
let [redGain, greenGain, blueGain] = cameraWhiteBalanceInput.value
|
|
400
|
+
.replace("#", "")
|
|
401
|
+
.match(/.{1,2}/g)
|
|
402
|
+
.map((value) => Number(`0x${value}`))
|
|
403
|
+
.map((value) => value / 255)
|
|
404
|
+
.map((value) => value * device.cameraConfigurationRanges.blueGain.max)
|
|
405
|
+
.map((value) => Math.round(value));
|
|
406
|
+
|
|
407
|
+
updateWhiteBalance({ redGain, greenGain, blueGain });
|
|
408
|
+
});
|
|
409
|
+
const updateCameraWhiteBalanceInput = () => {
|
|
410
|
+
if (!device.hasCamera) {
|
|
411
|
+
return;
|
|
412
|
+
}
|
|
413
|
+
cameraWhiteBalanceInput.disabled =
|
|
414
|
+
!device.isConnected || !device.hasCamera || device.cameraStatus != "idle";
|
|
415
|
+
|
|
416
|
+
const { redGain, blueGain, greenGain } = device.cameraConfiguration;
|
|
417
|
+
|
|
418
|
+
cameraWhiteBalanceInput.value = `#${[redGain, blueGain, greenGain]
|
|
419
|
+
.map((value) => value / device.cameraConfigurationRanges.redGain.max)
|
|
420
|
+
.map((value) => value * 255)
|
|
421
|
+
.map((value) => Math.round(value))
|
|
422
|
+
.map((value) => value.toString(16))
|
|
423
|
+
.join("")}`;
|
|
424
|
+
};
|
|
425
|
+
device.addEventListener("connected", () => {
|
|
426
|
+
updateCameraWhiteBalanceInput();
|
|
427
|
+
});
|
|
428
|
+
device.addEventListener("getCameraConfiguration", () => {
|
|
429
|
+
updateCameraWhiteBalanceInput();
|
|
430
|
+
});
|
|
431
|
+
updateCameraWhiteBalanceInput();
|
|
432
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "brilliantsole",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.29",
|
|
4
4
|
"description": "JavaScript SDK for BrilliantSole Smart Insoles",
|
|
5
5
|
"main": "./build/brilliantsole.module.js",
|
|
6
6
|
"module": "./build/brilliantsole.module.js",
|
|
@@ -53,6 +53,7 @@
|
|
|
53
53
|
"@types/web-bluetooth": "^0.0.20",
|
|
54
54
|
"@types/ws": "^8.5.10",
|
|
55
55
|
"axios": "^1.7.7",
|
|
56
|
+
"bonjour": "^3.5.0",
|
|
56
57
|
"cors": "^2.8.5",
|
|
57
58
|
"express": "^4.18.3",
|
|
58
59
|
"ip": "^2.0.1",
|
package/src/.prettierrc
ADDED
package/src/BS.ts
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export {
|
|
2
|
+
setAllConsoleLevelFlags,
|
|
3
|
+
setConsoleLevelFlagsForType,
|
|
4
|
+
} from "./utils/Console.ts";
|
|
2
5
|
export * as Environment from "./utils/environment.ts";
|
|
3
6
|
export { Vector2, Vector3, Quaternion, Euler } from "./utils/MathUtils.ts";
|
|
4
7
|
|
|
@@ -18,11 +21,36 @@ export {
|
|
|
18
21
|
} from "./DeviceManager.ts";
|
|
19
22
|
|
|
20
23
|
export { DeviceInformation } from "./DeviceInformationManager.ts";
|
|
21
|
-
export {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
+
export {
|
|
25
|
+
DeviceType,
|
|
26
|
+
DeviceTypes,
|
|
27
|
+
MinNameLength,
|
|
28
|
+
MaxNameLength,
|
|
29
|
+
Sides,
|
|
30
|
+
Side,
|
|
31
|
+
} from "./InformationManager.ts";
|
|
32
|
+
export {
|
|
33
|
+
MinWifiSSIDLength,
|
|
34
|
+
MaxWifiSSIDLength,
|
|
35
|
+
MinWifiPasswordLength,
|
|
36
|
+
MaxWifiPasswordLength,
|
|
37
|
+
} from "./WifiManager.ts";
|
|
38
|
+
export {
|
|
39
|
+
SensorType,
|
|
40
|
+
SensorTypes,
|
|
41
|
+
ContinuousSensorType,
|
|
42
|
+
ContinuousSensorTypes,
|
|
43
|
+
} from "./sensor/SensorDataManager.ts";
|
|
44
|
+
export {
|
|
45
|
+
MaxSensorRate,
|
|
46
|
+
SensorRateStep,
|
|
47
|
+
SensorConfiguration,
|
|
48
|
+
} from "./sensor/SensorConfigurationManager.ts";
|
|
24
49
|
|
|
25
|
-
export {
|
|
50
|
+
export {
|
|
51
|
+
DefaultNumberOfPressureSensors,
|
|
52
|
+
PressureData,
|
|
53
|
+
} from "./sensor/PressureSensorDataManager.ts";
|
|
26
54
|
export { CenterOfPressure } from "./utils/CenterOfPressureHelper.ts";
|
|
27
55
|
export {
|
|
28
56
|
VibrationConfiguration,
|
|
@@ -37,10 +65,41 @@ export {
|
|
|
37
65
|
MaxNumberOfVibrationWaveformSegments,
|
|
38
66
|
MaxVibrationWaveformEffectSequenceLoopCount,
|
|
39
67
|
} from "./vibration/VibrationManager.ts";
|
|
40
|
-
export {
|
|
68
|
+
export {
|
|
69
|
+
VibrationWaveformEffect,
|
|
70
|
+
VibrationWaveformEffects,
|
|
71
|
+
} from "./vibration/VibrationWaveformEffects.ts";
|
|
41
72
|
|
|
42
|
-
export {
|
|
43
|
-
|
|
73
|
+
export {
|
|
74
|
+
FileType,
|
|
75
|
+
FileTypes,
|
|
76
|
+
FileTransferDirection,
|
|
77
|
+
FileTransferDirections,
|
|
78
|
+
} from "./FileTransferManager.ts";
|
|
79
|
+
export {
|
|
80
|
+
TfliteSensorType,
|
|
81
|
+
TfliteSensorTypes,
|
|
82
|
+
TfliteTask,
|
|
83
|
+
TfliteTasks,
|
|
84
|
+
TfliteFileConfiguration as TfliteFileConfiguration,
|
|
85
|
+
} from "./TfliteManager.ts";
|
|
86
|
+
|
|
87
|
+
export {
|
|
88
|
+
CameraConfiguration,
|
|
89
|
+
CameraCommand,
|
|
90
|
+
CameraCommands,
|
|
91
|
+
CameraConfigurationType,
|
|
92
|
+
CameraConfigurationTypes,
|
|
93
|
+
} from "./CameraManager.ts";
|
|
94
|
+
|
|
95
|
+
export {
|
|
96
|
+
MicrophoneConfiguration,
|
|
97
|
+
MicrophoneCommand,
|
|
98
|
+
MicrophoneCommands,
|
|
99
|
+
MicrophoneConfigurationType,
|
|
100
|
+
MicrophoneConfigurationTypes,
|
|
101
|
+
MicrophoneConfigurationValues,
|
|
102
|
+
} from "./MicrophoneManager.ts";
|
|
44
103
|
|
|
45
104
|
export {
|
|
46
105
|
default as DevicePair,
|
|
@@ -52,6 +111,18 @@ export {
|
|
|
52
111
|
DevicePairTypes,
|
|
53
112
|
} from "./devicePair/DevicePair.ts";
|
|
54
113
|
|
|
114
|
+
import { addEventListeners, removeEventListeners } from "./utils/EventUtils.ts";
|
|
115
|
+
export const EventUtils = {
|
|
116
|
+
addEventListeners,
|
|
117
|
+
removeEventListeners,
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
import { throttle, debounce } from "./utils/ThrottleUtils.ts";
|
|
121
|
+
export const ThrottleUtils = {
|
|
122
|
+
throttle,
|
|
123
|
+
debounce,
|
|
124
|
+
};
|
|
125
|
+
|
|
55
126
|
export { DiscoveredDevice } from "./scanner/BaseScanner.ts";
|
|
56
127
|
/** NODE_START */
|
|
57
128
|
export { default as Scanner } from "./scanner/Scanner.ts";
|