Skip to content

Commit 0c0679d

Browse files
committed
Changed object name BLESense to NiclaSenseME
1 parent 50cb1f3 commit 0c0679d

File tree

1 file changed

+32
-32
lines changed

1 file changed

+32
-32
lines changed

NiclaSenseME-dashboard/index.html

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@
297297

298298
var maxRecords = 64;
299299

300-
var BLEsense =
300+
var NiclaSenseME =
301301
{
302302
temperature:
303303
{
@@ -373,7 +373,7 @@
373373
}
374374
}
375375

376-
const sensors = Object.keys(BLEsense);
376+
const sensors = Object.keys(NiclaSenseME);
377377
const SERVICE_UUID = '6fbe1da7-0000-44de-92c4-bb6e04fb0212';
378378
var bytesReceived = 0;
379379
var bytesPrevious = 0;
@@ -440,21 +440,21 @@
440440
// Set up the characteristics
441441
for (const sensor of sensors) {
442442
msg('characteristic ' + sensor + "...");
443-
BLEsense[sensor].characteristic = await service.getCharacteristic(BLEsense[sensor].uuid);
443+
NiclaSenseME[sensor].characteristic = await service.getCharacteristic(NiclaSenseME[sensor].uuid);
444444
// Set up notification
445-
if (BLEsense[sensor].properties.includes("BLENotify")) {
446-
BLEsense[sensor].characteristic.addEventListener('characteristicvaluechanged', function (event) { handleIncoming(BLEsense[sensor], event.target.value); });
447-
await BLEsense[sensor].characteristic.startNotifications();
445+
if (NiclaSenseME[sensor].properties.includes("BLENotify")) {
446+
NiclaSenseME[sensor].characteristic.addEventListener('characteristicvaluechanged', function (event) { handleIncoming(NiclaSenseME[sensor], event.target.value); });
447+
await NiclaSenseME[sensor].characteristic.startNotifications();
448448
}
449449
// Set up polling for read
450-
if (BLEsense[sensor].properties.includes("BLERead")) {
451-
BLEsense[sensor].polling = setInterval(function () {
452-
BLEsense[sensor].characteristic.readValue().then(function (data) { handleIncoming(BLEsense[sensor], data); })
450+
if (NiclaSenseME[sensor].properties.includes("BLERead")) {
451+
NiclaSenseME[sensor].polling = setInterval(function () {
452+
NiclaSenseME[sensor].characteristic.readValue().then(function (data) { handleIncoming(NiclaSenseME[sensor], data); })
453453
}
454454
, 500);
455455
}
456456

457-
BLEsense[sensor].rendered = false;
457+
NiclaSenseME[sensor].rendered = false;
458458
}
459459
pairButton.style.backgroundColor = 'green';
460460
pairButton.style.color = 'white';
@@ -501,8 +501,8 @@
501501
snack("Device disconnected, please retry", 1)
502502
// clear read polling
503503
for (const sensor of sensors) {
504-
if (typeof BLEsense[sensor].polling !== 'undefined') {
505-
clearInterval(BLEsense[sensor].polling);
504+
if (typeof NiclaSenseME[sensor].polling !== 'undefined') {
505+
clearInterval(NiclaSenseME[sensor].polling);
506506
}
507507
}
508508
// clear color picker write
@@ -514,11 +514,11 @@
514514
}
515515

516516
function BLEwriteTo(sensor) {
517-
if (BLEsense[sensor].writeBusy) return; // dropping writes when one is in progress instead of queuing as LED is non-critical / realtime
518-
BLEsense[sensor].writeBusy = true; // Ensure no write happens when GATT operation in progress
519-
BLEsense[sensor].characteristic.writeValue(BLEsense[sensor].writeValue)
517+
if (NiclaSenseME[sensor].writeBusy) return; // dropping writes when one is in progress instead of queuing as LED is non-critical / realtime
518+
NiclaSenseME[sensor].writeBusy = true; // Ensure no write happens when GATT operation in progress
519+
NiclaSenseME[sensor].characteristic.writeValue(NiclaSenseME[sensor].writeValue)
520520
.then(_ => {
521-
BLEsense[sensor].writeBusy = false;
521+
NiclaSenseME[sensor].writeBusy = false;
522522
})
523523
.catch(error => {
524524
console.log(error);
@@ -530,7 +530,7 @@
530530
<script>
531531

532532
function initColorPicker() {
533-
BLEsense.led.colorPicker = new iro.ColorPicker("#color-picker-container", {
533+
NiclaSenseME.led.colorPicker = new iro.ColorPicker("#color-picker-container", {
534534
width: 150,
535535
color: "rgb(255, 0, 0)",
536536
borderWidth: 1,
@@ -539,12 +539,12 @@
539539
sliderMargin: 6
540540
});
541541
// RGB Color Picker
542-
BLEsense.led.colorPicker.on('color:change', updateModelLed);
542+
NiclaSenseME.led.colorPicker.on('color:change', updateModelLed);
543543
function updateModelLed(color) {
544544
ledLight.color.setHex("0x" + color.hexString.substring(1, 7));
545545
ledMaterial.color.set(color.hexString) // where r, g, and b are 0 to 1
546546
var rgb_values = Uint8Array.of(color.rgb.r, color.rgb.g, color.rgb.b);
547-
BLEsense['led'].writeValue = rgb_values;
547+
NiclaSenseME['led'].writeValue = rgb_values;
548548
BLEwriteTo('led');
549549
}
550550
}
@@ -554,7 +554,7 @@
554554
var colorIndex = 0;
555555
function initGraph(sensor) {
556556
var title = sensor;
557-
var series = Object.keys(BLEsense[sensor].data);
557+
var series = Object.keys(NiclaSenseME[sensor].data);
558558
var format = [];
559559
series.forEach(function (item) {
560560
colorIndex++;
@@ -649,9 +649,9 @@
649649
ctx.fillStyle = "#111111";
650650
ctx.fillRect(0, 0, canvas.width, canvas.height);
651651
for (i = 0; i < maxRecords; i++) {
652-
R = BLEsense[sensor].data.R[i];
653-
G = BLEsense[sensor].data.G[i];
654-
B = BLEsense[sensor].data.B[i];
652+
R = NiclaSenseME[sensor].data.R[i];
653+
G = NiclaSenseME[sensor].data.G[i];
654+
B = NiclaSenseME[sensor].data.B[i];
655655
total = R + G + B;
656656
R = R / total * 255; G = G / total * 255; B = B / total * 255;
657657
ctx.fillStyle = "rgba(" + R + "," + G + "," + B + ")";
@@ -662,28 +662,28 @@
662662
Array.prototype.latest = function () { return this[this.length - 1]; };
663663

664664
function graph(sensor) {
665-
var labels = Object.keys(BLEsense[sensor].data);
665+
var labels = Object.keys(NiclaSenseME[sensor].data);
666666
var values = [];
667667
// after
668668
labels.forEach(function (label) {
669-
values.push(BLEsense[sensor].data[label]);
669+
values.push(NiclaSenseME[sensor].data[label]);
670670
});
671671
Plotly.restyle(sensor, { y: values });
672672
}
673673

674674
function digit(sensor) {
675-
const value = BLEsense[sensor].data[sensor].latest();
675+
const value = NiclaSenseME[sensor].data[sensor].latest();
676676
const div = document.getElementById(sensor + "-value");
677677
if (!Number.isNaN(value)) { div.innerHTML = Math.round(value * 10) / 10; };
678678
}
679679

680680
function update3d(sensor) {
681681

682682
// Get the quaternion values
683-
var x = BLEsense['quaternion'].data.x.latest();
684-
var y = BLEsense['quaternion'].data.y.latest();
685-
var z = BLEsense['quaternion'].data.z.latest();
686-
var w = BLEsense['quaternion'].data.w.latest();
683+
var x = NiclaSenseME['quaternion'].data.x.latest();
684+
var y = NiclaSenseME['quaternion'].data.y.latest();
685+
var z = NiclaSenseME['quaternion'].data.z.latest();
686+
var w = NiclaSenseME['quaternion'].data.w.latest();
687687

688688
// Construct the quaternion object with the values and apply that to the 3D model
689689
const quaternion = new THREE.Quaternion(x, y, z, w);
@@ -710,11 +710,11 @@
710710
var skip_frame = false;
711711
function draw() {
712712
function updateViz(sensor, fns) {
713-
if (BLEsense[sensor].rendered == false) { // only render if new values are received
713+
if (NiclaSenseME[sensor].rendered == false) { // only render if new values are received
714714
fns.forEach(function (fn) {
715715
fn(sensor);
716716
});
717-
BLEsense[sensor].rendered = true;
717+
NiclaSenseME[sensor].rendered = true;
718718
}
719719
}
720720
if (skip_frame == false) { // TODO update with fuction to iterate object with viz function as a property

0 commit comments

Comments
 (0)