@hangtime/grip-connect 0.0.10 → 0.0.11
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 +8 -7
- package/package.json +1 -1
- package/src/devices/entralpi.js +8 -6
- package/src/devices/entralpi.ts +8 -6
- package/src/devices/moterboard.js +16 -10
- package/src/devices/moterboard.ts +16 -12
package/README.md
CHANGED
|
@@ -75,16 +75,16 @@ motherboardButton.addEventListener("click", () => {
|
|
|
75
75
|
})
|
|
76
76
|
|
|
77
77
|
// read battery + device info
|
|
78
|
-
await read(Motherboard, "battery", "level",
|
|
79
|
-
await read(Motherboard, "device", "manufacturer",
|
|
80
|
-
await read(Motherboard, "device", "hardware",
|
|
81
|
-
await read(Motherboard, "device", "firmware",
|
|
78
|
+
await read(Motherboard, "battery", "level", 250)
|
|
79
|
+
await read(Motherboard, "device", "manufacturer", 250)
|
|
80
|
+
await read(Motherboard, "device", "hardware", 250)
|
|
81
|
+
await read(Motherboard, "device", "firmware", 250)
|
|
82
82
|
|
|
83
83
|
// read calibration (required before reading data)
|
|
84
|
-
await write(Motherboard, "uart", "tx", "C",
|
|
84
|
+
await write(Motherboard, "uart", "tx", "C", 2500)
|
|
85
85
|
|
|
86
|
-
// start
|
|
87
|
-
await write(Motherboard, "uart", "tx", "S30",
|
|
86
|
+
// start streaming for a minute
|
|
87
|
+
await write(Motherboard, "uart", "tx", "S30", 60000)
|
|
88
88
|
|
|
89
89
|
// end stream
|
|
90
90
|
await write(Motherboard, "uart", "tx", "", 0)
|
|
@@ -100,6 +100,7 @@ A special thank you to:
|
|
|
100
100
|
|
|
101
101
|
- [@CassimLadha](https://github.com/CassimLadha) for sharing insights on reading the Motherboards data.
|
|
102
102
|
- [@donaldharvey](https://github.com/donaldharvey) for a valuable example on connecting to the motherboard.
|
|
103
|
+
- [@ecstrema](https://github.com/ecstrema) for providing an example on how to play games with the entralpi.
|
|
103
104
|
|
|
104
105
|
## Disclamer
|
|
105
106
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hangtime/grip-connect",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.11",
|
|
4
4
|
"description": "A client that can establish connections with various Force-Sensing Hangboards/Plates used by climbers for strength measurement. Examples of such hangboards include the Motherboard, Climbro, SmartBoard, Entralpi or Tindeq Progressor",
|
|
5
5
|
"main": "src/index.ts",
|
|
6
6
|
"scripts": {
|
package/src/devices/entralpi.js
CHANGED
|
@@ -57,10 +57,12 @@ export const Entralpi = {
|
|
|
57
57
|
* @param receivedData - Received data string
|
|
58
58
|
*/
|
|
59
59
|
export function handleEntralpiData(uuid, receivedData) {
|
|
60
|
-
notifyCallback
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
60
|
+
if (notifyCallback) {
|
|
61
|
+
notifyCallback({
|
|
62
|
+
uuid,
|
|
63
|
+
value: {
|
|
64
|
+
massTotal: receivedData,
|
|
65
|
+
},
|
|
66
|
+
});
|
|
67
|
+
}
|
|
66
68
|
}
|
package/src/devices/entralpi.ts
CHANGED
|
@@ -60,10 +60,12 @@ export const Entralpi: Device = {
|
|
|
60
60
|
* @param receivedData - Received data string
|
|
61
61
|
*/
|
|
62
62
|
export function handleEntralpiData(uuid: string, receivedData: number): void {
|
|
63
|
-
notifyCallback
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
63
|
+
if (notifyCallback) {
|
|
64
|
+
notifyCallback({
|
|
65
|
+
uuid,
|
|
66
|
+
value: {
|
|
67
|
+
massTotal: receivedData,
|
|
68
|
+
},
|
|
69
|
+
})
|
|
70
|
+
}
|
|
69
71
|
}
|
|
@@ -98,7 +98,7 @@ const applyCalibration = (sample, calibration) => {
|
|
|
98
98
|
// Change the sign to negative
|
|
99
99
|
sign = -1;
|
|
100
100
|
// Reflect the sample around the zero calibration point
|
|
101
|
-
sample = 2 * zeroCalibration -
|
|
101
|
+
sample = /* 2 * zeroCalibration */ -sample;
|
|
102
102
|
}
|
|
103
103
|
// Iterate through the calibration data
|
|
104
104
|
for (let i = 1; i < calibration.length; i++) {
|
|
@@ -156,18 +156,24 @@ export function handleMotherboardData(uuid, receivedData) {
|
|
|
156
156
|
return;
|
|
157
157
|
packet.masses[i] = applyCalibration(packet.samples[i], CALIBRATION[i]);
|
|
158
158
|
}
|
|
159
|
+
// invert center and right values
|
|
160
|
+
packet.masses[1] *= -1;
|
|
161
|
+
packet.masses[2] *= -1;
|
|
162
|
+
// map to variables
|
|
159
163
|
const left = packet.masses[0];
|
|
160
164
|
const center = packet.masses[1];
|
|
161
165
|
const right = packet.masses[2];
|
|
162
|
-
notifyCallback
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
166
|
+
if (notifyCallback) {
|
|
167
|
+
notifyCallback({
|
|
168
|
+
uuid,
|
|
169
|
+
value: {
|
|
170
|
+
massTotal: Math.max(-1000, left + right + center).toFixed(1),
|
|
171
|
+
massLeft: Math.max(-1000, left).toFixed(1),
|
|
172
|
+
massRight: Math.max(-1000, right).toFixed(1),
|
|
173
|
+
massCenter: Math.max(-1000, center).toFixed(1),
|
|
174
|
+
},
|
|
175
|
+
});
|
|
176
|
+
}
|
|
171
177
|
}
|
|
172
178
|
else if ((receivedData.match(/,/g) || []).length === 3) {
|
|
173
179
|
console.log(receivedData);
|
|
@@ -105,7 +105,7 @@ const applyCalibration = (sample: number, calibration: number[][]): number => {
|
|
|
105
105
|
sign = -1
|
|
106
106
|
|
|
107
107
|
// Reflect the sample around the zero calibration point
|
|
108
|
-
sample = 2 * zeroCalibration -
|
|
108
|
+
sample = /* 2 * zeroCalibration */ -sample
|
|
109
109
|
}
|
|
110
110
|
|
|
111
111
|
// Iterate through the calibration data
|
|
@@ -184,20 +184,24 @@ export function handleMotherboardData(uuid: string, receivedData: string): void
|
|
|
184
184
|
if (!CALIBRATION[0].length) return
|
|
185
185
|
packet.masses[i] = applyCalibration(packet.samples[i], CALIBRATION[i])
|
|
186
186
|
}
|
|
187
|
-
|
|
187
|
+
// invert center and right values
|
|
188
|
+
packet.masses[1] *= -1;
|
|
189
|
+
packet.masses[2] *= -1;
|
|
190
|
+
// map to variables
|
|
188
191
|
const left: number = packet.masses[0]
|
|
189
192
|
const center: number = packet.masses[1]
|
|
190
193
|
const right: number = packet.masses[2]
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
194
|
+
if (notifyCallback) {
|
|
195
|
+
notifyCallback({
|
|
196
|
+
uuid,
|
|
197
|
+
value: {
|
|
198
|
+
massTotal: Math.max(-1000, left + right + center).toFixed(1),
|
|
199
|
+
massLeft: Math.max(-1000, left).toFixed(1),
|
|
200
|
+
massRight: Math.max(-1000, right).toFixed(1),
|
|
201
|
+
massCenter: Math.max(-1000, center).toFixed(1),
|
|
202
|
+
},
|
|
203
|
+
})
|
|
204
|
+
}
|
|
201
205
|
} else if ((receivedData.match(/,/g) || []).length === 3) {
|
|
202
206
|
console.log(receivedData)
|
|
203
207
|
// if the returned notification is a calibration string add them to the array
|