1
0
Fork 0

Tidy tooltip, display invalid core as n/a

master
Ivor Hewitt 2021-12-29 15:38:59 +00:00
parent 73f2225354
commit 19126205b9
3 changed files with 22 additions and 14 deletions

View File

@ -28,8 +28,16 @@ class CoreSensor {
this.unit = "C"; this.unit = "C";
} }
if (flags & 1) this.skin = (dv.buffer[4] * 256 + dv.buffer[3]) / 100; if (flags & 1) {
if (flags & 2) this.core = (dv.buffer[2] * 256 + dv.buffer[1]) / 100; this.skin = (dv.buffer[4] * 256 + dv.buffer[3]) / 100;
} else {
this.skin = 0;
}
if (flags & 2) {
this.core = (dv.buffer[2] * 256 + dv.buffer[1]) / 100;
} else {
this.core = 0;
}
Bangle.emit('CoreTemp', Bangle.emit('CoreTemp',
{core : this.core, skin : this.skin, unit : this.unit}); {core : this.core, skin : this.skin, unit : this.unit});
@ -79,8 +87,8 @@ function connection_setup() {
}) })
.then(function() { .then(function() {
console.log("Done!"); console.log("Done!");
// getSensorBatteryLevel(gatt); // getSensorBatteryLevel(gatt);
// g.reset().clearRect(Bangle.appRect).flip(); // g.reset().clearRect(Bangle.appRect).flip();
}) })
.catch(function(e) { .catch(function(e) {
console.log(e.toString(), "ERROR"); console.log(e.toString(), "ERROR");
@ -89,16 +97,17 @@ function connection_setup() {
} }
function connection_end() { function connection_end() {
if (gatt != undefined) gatt.disconnect(); if (gatt != undefined)
gatt.disconnect();
} }
settings = require("Storage").readJSON("coretemp.json",1)||{}; settings = require("Storage").readJSON("coretemp.json", 1) || {};
console.log("Settings:"); console.log("Settings:");
console.log(settings); console.log(settings);
if (settings.enabled) { if (settings.enabled) {
connection_setup(); connection_setup();
NRF.on('disconnect', connection_setup); NRF.on('disconnect', connection_setup);
} }
E.on('kill', () => { connection_end(); }); E.on('kill', () => { connection_end(); });

View File

@ -20,9 +20,9 @@ var corelogo = {
function onCore(c) { function onCore(c) {
g.setFontAlign(0, 0); g.setFontAlign(0, 0);
g.clearRect(0, 48 + 48, g.getWidth(), 48 + 48 + 24 * 2); g.clearRect(0, 32 + 48, g.getWidth(), 32 + 48 + 24 * 3);
g.setColor(0xC618); // Light gray g.setColor(0xC618); // Light gray
g.setFont("6x8", 3).drawString("Core: " + c.core + c.unit, px, 48 + 48); g.setFont("6x8", 3).drawString("Core: " + ((c.core<327)?(c.core + c.unit):'n/a'), px, 48 + 48);
g.setFont("6x8", 3).drawString("Skin: " + c.skin + c.unit, px, 48 + 48 + 24); g.setFont("6x8", 3).drawString("Skin: " + c.skin + c.unit, px, 48 + 48 + 24);
} }

View File

@ -21,12 +21,11 @@
} }
g.drawImage( g.drawImage(
atob( atob("DAyBAAHh0js3EuDMA8A8AWBnDj9A8A=="),
"GBgBAAHwAHP4A+f8B+4cH+4MH84cPwYcfAf4eAP4+AHi+AAO8AAe8AAe8AAe+AAG+AA4eAA8fAB8PgD4P8b4H/7wB/9gA/8AAP4A"), this.x+(24-12)/2,this.y+1);
this.x, this.y);
g.setColor(g.theme.fg); g.setColor(g.theme.fg);
g.drawString(core, this.x + 24 / 2, this.y + 19); g.drawString(parseInt(core)+"\n."+parseInt((core*100)%100), this.x + 24 / 2, this.y + 18);
g.setColor(-1); g.setColor(-1);
} }