brilliantsole 0.0.34 → 0.0.35

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/build/dts/BS.d.ts CHANGED
@@ -32,9 +32,7 @@ export { default as DisplayCanvasHelper, DisplayCanvasHelperEvent, DisplayCanvas
32
32
  /** BROWSER_START */
33
33
  export { Font, Glyph } from "opentype.js";
34
34
  /** BROWSER_END */
35
- /** BROWSER_START */
36
35
  export { resizeAndQuantizeImage, quantizeImage, imageToSprite, imageToSpriteSheet, canvasToSprite, canvasToSpriteSheet, resizeImage, imageToBitmaps, canvasToBitmaps, } from "./utils/DisplayBitmapUtils.ts";
37
- /** BROWSER_END */
38
36
  export { rgbToHex, hexToRGB } from "./utils/ColorUtils.ts";
39
37
  export { default as DevicePair, DevicePairEvent, DevicePairEventMap, DevicePairEventListenerMap, BoundDevicePairEventListeners, DevicePairType, DevicePairTypes, } from "./devicePair/DevicePair.ts";
40
38
  import { addEventListeners, removeEventListeners } from "./utils/EventUtils.ts";
@@ -1800,6 +1800,36 @@ declare function simplifyCurves(curves: DisplayBezierCurve[], epsilon?: number):
1800
1800
  declare function simplifyPoints(points: Vector2[], tolerance?: number): Vector2[];
1801
1801
  declare function simplifyPointsAsCubicCurveControlPoints(points: Vector2[], error?: number): Vector2[];
1802
1802
 
1803
+ declare function quantizeImage(image: HTMLImageElement, width: number, height: number, numberOfColors: number, colors?: string[], canvas?: HTMLCanvasElement): Promise<{
1804
+ blob: Blob;
1805
+ colors: string[];
1806
+ colorIndices: number[];
1807
+ }>;
1808
+ declare function resizeImage(image: CanvasImageSource, width: number, height: number, canvas?: HTMLCanvasElement): HTMLCanvasElement;
1809
+ declare function resizeAndQuantizeImage(image: CanvasImageSource, width: number, height: number, numberOfColors: number, colors?: string[], canvas?: HTMLCanvasElement): Promise<{
1810
+ blob: Blob;
1811
+ colors: string[];
1812
+ colorIndices: number[];
1813
+ }>;
1814
+ declare function canvasToBitmaps(canvas: HTMLCanvasElement, numberOfColors: number, mtu: number): Promise<{
1815
+ bitmapRows: DisplayBitmap[][];
1816
+ colors: string[];
1817
+ }>;
1818
+ declare function imageToBitmaps(image: HTMLImageElement, width: number, height: number, numberOfColors: number, mtu: number): Promise<{
1819
+ bitmapRows: DisplayBitmap[][];
1820
+ colors: string[];
1821
+ }>;
1822
+ declare function canvasToSprite(canvas: HTMLCanvasElement, spriteName: string, numberOfColors: number, paletteName: string, overridePalette: boolean, spriteSheet: DisplaySpriteSheet, paletteOffset?: number): Promise<{
1823
+ sprite: DisplaySprite;
1824
+ blob: Blob;
1825
+ }>;
1826
+ declare function imageToSprite(image: HTMLImageElement, spriteName: string, width: number, height: number, numberOfColors: number, paletteName: string, overridePalette: boolean, spriteSheet: DisplaySpriteSheet, paletteOffset?: number): Promise<{
1827
+ sprite: DisplaySprite;
1828
+ blob: Blob;
1829
+ }>;
1830
+ declare function canvasToSpriteSheet(canvas: HTMLCanvasElement, spriteSheetName: string, numberOfColors: number, paletteName: string, maxFileLength?: number): Promise<DisplaySpriteSheet>;
1831
+ declare function imageToSpriteSheet(image: HTMLImageElement, spriteSheetName: string, width: number, height: number, numberOfColors: number, paletteName: string, maxFileLength?: number): Promise<DisplaySpriteSheet>;
1832
+
1803
1833
  declare function hexToRGB(hex: string): DisplayColorRGB;
1804
1834
  declare function rgbToHex({ r, g, b }: DisplayColorRGB): string;
1805
1835
 
@@ -2033,5 +2063,5 @@ declare const ThrottleUtils: {
2033
2063
  debounce: typeof debounce;
2034
2064
  };
2035
2065
 
2036
- export { CameraCommands, CameraConfigurationTypes, ContinuousSensorTypes, DefaultNumberOfDisplayColors, DefaultNumberOfPressureSensors, Device, _default as DeviceManager, DevicePair, DevicePairTypes, DeviceTypes, DisplayAlignments, DisplayBezierCurveTypes, DisplayBrightnesses, DisplayContextCommandTypes, DisplayDirections, DisplayPixelDepths, DisplaySegmentCaps, DisplaySpriteContextCommandTypes, environment_d as Environment, EventUtils, FileTransferDirections, FileTypes, MaxNameLength, MaxNumberOfVibrationWaveformEffectSegments, MaxNumberOfVibrationWaveformSegments, MaxSensorRate, MaxSpriteSheetNameLength, MaxVibrationWaveformEffectSegmentDelay, MaxVibrationWaveformEffectSegmentLoopCount, MaxVibrationWaveformEffectSequenceLoopCount, MaxVibrationWaveformSegmentDuration, MaxWifiPasswordLength, MaxWifiSSIDLength, MicrophoneCommands, MicrophoneConfigurationTypes, MicrophoneConfigurationValues, MinNameLength, MinSpriteSheetNameLength, MinWifiPasswordLength, MinWifiSSIDLength, RangeHelper, scanner as Scanner, SensorRateStep, SensorTypes, Sides, TfliteSensorTypes, TfliteTasks, ThrottleUtils, Timer, UDPServer, VibrationLocations, VibrationTypes, VibrationWaveformEffects, WebSocketServer, displayCurveTypeToNumberOfControlPoints, englishRegex, fontToSpriteSheet, getFontMaxHeight, getFontMetrics, getFontUnicodeRange, getMaxSpriteSheetSize, hexToRGB, intersectWireframes, isWireframePolygon, maxDisplayScale, mergeWireframes, parseFont, pixelDepthToNumberOfColors, rgbToHex, setAllConsoleLevelFlags, setConsoleLevelFlagsForType, simplifyCurves, simplifyPoints, simplifyPointsAsCubicCurveControlPoints, stringToSprites, wait };
2066
+ export { CameraCommands, CameraConfigurationTypes, ContinuousSensorTypes, DefaultNumberOfDisplayColors, DefaultNumberOfPressureSensors, Device, _default as DeviceManager, DevicePair, DevicePairTypes, DeviceTypes, DisplayAlignments, DisplayBezierCurveTypes, DisplayBrightnesses, DisplayContextCommandTypes, DisplayDirections, DisplayPixelDepths, DisplaySegmentCaps, DisplaySpriteContextCommandTypes, environment_d as Environment, EventUtils, FileTransferDirections, FileTypes, MaxNameLength, MaxNumberOfVibrationWaveformEffectSegments, MaxNumberOfVibrationWaveformSegments, MaxSensorRate, MaxSpriteSheetNameLength, MaxVibrationWaveformEffectSegmentDelay, MaxVibrationWaveformEffectSegmentLoopCount, MaxVibrationWaveformEffectSequenceLoopCount, MaxVibrationWaveformSegmentDuration, MaxWifiPasswordLength, MaxWifiSSIDLength, MicrophoneCommands, MicrophoneConfigurationTypes, MicrophoneConfigurationValues, MinNameLength, MinSpriteSheetNameLength, MinWifiPasswordLength, MinWifiSSIDLength, RangeHelper, scanner as Scanner, SensorRateStep, SensorTypes, Sides, TfliteSensorTypes, TfliteTasks, ThrottleUtils, Timer, UDPServer, VibrationLocations, VibrationTypes, VibrationWaveformEffects, WebSocketServer, canvasToBitmaps, canvasToSprite, canvasToSpriteSheet, displayCurveTypeToNumberOfControlPoints, englishRegex, fontToSpriteSheet, getFontMaxHeight, getFontMetrics, getFontUnicodeRange, getMaxSpriteSheetSize, hexToRGB, imageToBitmaps, imageToSprite, imageToSpriteSheet, intersectWireframes, isWireframePolygon, maxDisplayScale, mergeWireframes, parseFont, pixelDepthToNumberOfColors, quantizeImage, resizeAndQuantizeImage, resizeImage, rgbToHex, setAllConsoleLevelFlags, setConsoleLevelFlagsForType, simplifyCurves, simplifyPoints, simplifyPointsAsCubicCurveControlPoints, stringToSprites, wait };
2037
2067
  export type { BoundDeviceEventListeners, BoundDeviceManagerEventListeners, BoundDevicePairEventListeners, CameraCommand, CameraConfiguration, CameraConfigurationType, CenterOfPressure, ContinuousSensorType, DeviceEvent, DeviceEventListenerMap, DeviceEventMap, DeviceInformation, DeviceManagerEvent, DeviceManagerEventListenerMap, DeviceManagerEventMap, DevicePairEvent, DevicePairEventListenerMap, DevicePairEventMap, DevicePairType, DeviceType, DiscoveredDevice, DisplayAlignment, DisplayBezierCurveType, DisplayBitmap, DisplayBitmapColorPair, DisplayBrightness, DisplayColorRGB, DisplayContextCommand, DisplayContextCommandType, DisplayDirection, DisplaySegmentCap, DisplaySize, DisplaySprite, DisplaySpriteColorPair, DisplaySpriteContextCommandType, DisplaySpriteLine, DisplaySpriteLines, DisplaySpritePaletteSwap, DisplaySpriteSheet, DisplaySpriteSheetPalette, DisplaySpriteSubLine, DisplayWireframe, DisplayWireframeEdge, Euler, FileTransferDirection, FileType, FontToSpriteSheetOptions, MicrophoneCommand, MicrophoneConfiguration, MicrophoneConfigurationType, PressureData, Quaternion, Range, SensorConfiguration, SensorType, Side, TfliteFileConfiguration, TfliteSensorType, TfliteTask, Vector2, Vector3, VibrationConfiguration, VibrationLocation, VibrationType, VibrationWaveformEffect };
@@ -202,10 +202,4 @@ window.addEventListener("drop", async (e) => {
202
202
  }
203
203
  });
204
204
 
205
- // UMYO
206
-
207
- // import { uMyoBLE } from "./uMyoBLE.js";
208
- // const umyo = new uMyoBLE();
209
- // window.umyo = umyo;
210
-
211
205
  didLoad = true;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "brilliantsole",
3
- "version": "0.0.34",
3
+ "version": "0.0.35",
4
4
  "description": "JavaScript SDK for BrilliantSole Smart Insoles",
5
5
  "main": "./build/brilliantsole.module.js",
6
6
  "module": "./build/brilliantsole.module.js",
package/src/BS.ts CHANGED
@@ -195,7 +195,6 @@ export {
195
195
  export { Font, Glyph } from "opentype.js";
196
196
  /** BROWSER_END */
197
197
 
198
- /** BROWSER_START */
199
198
  export {
200
199
  resizeAndQuantizeImage,
201
200
  quantizeImage,
@@ -207,7 +206,6 @@ export {
207
206
  imageToBitmaps,
208
207
  canvasToBitmaps,
209
208
  } from "./utils/DisplayBitmapUtils.ts";
210
- /** BROWSER_END */
211
209
 
212
210
  export { rgbToHex, hexToRGB } from "./utils/ColorUtils.ts";
213
211
 
@@ -1,133 +0,0 @@
1
- // uMyoBLE.js
2
- // JavaScript version of uMyo_BLE.cpp
3
- // Works in browser with Web Bluetooth API
4
-
5
- class uMyoDevice {
6
- constructor(id) {
7
- this.id = id;
8
- this.lastDataTime = Date.now();
9
- this.batt_mv = 0;
10
- this.deviceAvgMuscleLevel = 0;
11
- this.curSpectrum = [0, 0, 0, 0];
12
- this.Qsg = { w: 1, x: 0, y: 0, z: 0 };
13
- this.lastDataId = 0;
14
- }
15
- }
16
-
17
- export class uMyoBLE {
18
- constructor() {
19
- this.devices = new Map(); // id -> uMyoDevice
20
- }
21
-
22
- async begin() {
23
- console.log("Starting BLE scan for uMyo devices...");
24
-
25
- // Request Bluetooth scanning permission
26
- this.scan = await navigator.bluetooth.requestLEScan({
27
- keepRepeatedDevices: true,
28
- filters: [{ namePrefix: "uMyo v2" }],
29
- });
30
-
31
- navigator.bluetooth.addEventListener("advertisementreceived", (event) => {
32
- this.handleAdvertisement(event);
33
- });
34
-
35
- console.log("Scanning...");
36
- }
37
-
38
- stop() {
39
- if (!this.scan) {
40
- return;
41
- }
42
- this.scan.stop();
43
- }
44
-
45
- handleAdvertisement(event) {
46
- if (event.name != "uMyo v2") {
47
- return;
48
- }
49
- //console.log(event);
50
- const data = new Uint8Array(
51
- event.manufacturerData.entries().next().value[1].buffer
52
- );
53
- if (!data) {
54
- return;
55
- }
56
- //console.log("data", data);
57
-
58
- for (let pp = 0; pp < data.byteLength; pp++) {
59
- const sp0 = data[pp++] << 8;
60
- const muscle_avg = data[pp++];
61
- const sp1 = (data[pp++] << 8) | data[pp++];
62
- const sp2 = (data[pp++] << 8) | data[pp++];
63
- const sp3 = (data[pp++] << 8) | data[pp++];
64
- const qw = (data[pp++] << 8) | data[pp++];
65
- const qx = data[pp++] << 8;
66
- const qy = data[pp++] << 8;
67
- const qz = data[pp++] << 8;
68
-
69
- const Qsg = { w: qw, x: qx, y: qy, z: qz };
70
- this.qRenorm(Qsg);
71
-
72
- // Parse MAC address from event.device.id or address field
73
- const id = event.device.id;
74
- const device = this.getDeviceByID(id);
75
- device.deviceAvgMuscleLevel = (muscle_avg * muscle_avg) >> 3;
76
- device.curSpectrum = [sp0, sp1, sp2, sp3];
77
- device.Qsg = Qsg;
78
-
79
- device.lastDataTime = Date.now();
80
-
81
- console.log(id, muscle_avg, device.curSpectrum, Qsg);
82
- }
83
- }
84
-
85
- parseMAC(address) {
86
- // Convert AA:BB:CC:DD:EE:FF to [0xAA, 0xBB, ...]
87
- const parts = address.split(":");
88
- if (parts.length !== 6) return new Uint8Array(6);
89
- return Uint8Array.from(parts.map((p) => parseInt(p, 16)));
90
- }
91
-
92
- getDeviceByID(id) {
93
- if (!this.devices.has(id)) {
94
- this.devices.set(id, new uMyoDevice(id));
95
- }
96
- return this.devices.get(id);
97
- }
98
-
99
- getDeviceCount() {
100
- return this.devices.size;
101
- }
102
-
103
- getBattery(id) {
104
- const d = this.devices.get(id);
105
- return d ? d.batt_mv : 0;
106
- }
107
-
108
- getMuscleLevel(id) {
109
- const d = this.devices.get(id);
110
- if (!d) return 0;
111
- return d.curSpectrum[2] + 2 * d.curSpectrum[3];
112
- }
113
-
114
- getAverageMuscleLevel(id) {
115
- const d = this.devices.get(id);
116
- return d ? d.deviceAvgMuscleLevel : 0;
117
- }
118
-
119
- getSpectrum(id) {
120
- const d = this.devices.get(id);
121
- return d ? [...d.curSpectrum] : [0, 0, 0, 0];
122
- }
123
-
124
- qRenorm(Q) {
125
- const norm = Math.sqrt(Q.w ** 2 + Q.x ** 2 + Q.y ** 2 + Q.z ** 2);
126
- if (norm > 0) {
127
- Q.w /= norm;
128
- Q.x /= norm;
129
- Q.y /= norm;
130
- Q.z /= norm;
131
- }
132
- }
133
- }