mirror of https://github.com/espruino/BangleApps
bthrm fixes for reading characteristics generally and displaying location
parent
d89db8f7d7
commit
75c4e5b54b
|
@ -168,14 +168,14 @@
|
||||||
//Body sensor location
|
//Body sensor location
|
||||||
handler: function(data){
|
handler: function(data){
|
||||||
if (!lastReceivedData["0x180d"]) lastReceivedData["0x180d"] = {};
|
if (!lastReceivedData["0x180d"]) lastReceivedData["0x180d"] = {};
|
||||||
if (!lastReceivedData["0x180d"]["0x2a38"]) lastReceivedData["0x180d"]["0x2a38"] = data.target.value;
|
lastReceivedData["0x180d"]["0x2a38"] = parseInt(data.buffer, 10);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"0x2a19": {
|
"0x2a19": {
|
||||||
//Battery
|
//Battery
|
||||||
handler: function (event){
|
handler: function (event){
|
||||||
if (!lastReceivedData["0x180f"]) lastReceivedData["0x180f"] = {};
|
if (!lastReceivedData["0x180f"]) lastReceivedData["0x180f"] = { "0x2a19": null };
|
||||||
if (!lastReceivedData["0x180f"]["0x2a19"]) lastReceivedData["0x180f"]["0x2a19"] = event.target.value.getUint8(0);
|
lastReceivedData["0x180f"]["0x2a19"] = event.target.value.getUint8(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -295,12 +295,13 @@
|
||||||
}
|
}
|
||||||
return startPromise;
|
return startPromise;
|
||||||
});
|
});
|
||||||
} else if (newCharacteristic.read){
|
} else if (newCharacteristic.readValue){
|
||||||
result = result.then(()=>{
|
result = result.then(()=>{
|
||||||
// readData(newCharacteristic);
|
log("Reading data for " + JSON.stringify(newCharacteristic));
|
||||||
log("Reading data for " + newCharacteristic);
|
return newCharacteristic.readValue().then((data)=>{
|
||||||
return newCharacteristic.read().then((data)=>{
|
if (supportedCharacteristics[newCharacteristic.uuid] && supportedCharacteristics[newCharacteristic.uuid].handler) {
|
||||||
supportedCharacteristics[newCharacteristic.uuid].handler(data);
|
supportedCharacteristics[newCharacteristic.uuid].handler(data);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,16 @@
|
||||||
var btm = g.getHeight()-1;
|
|
||||||
var intervalInt;
|
var intervalInt;
|
||||||
var intervalBt;
|
var intervalBt;
|
||||||
|
|
||||||
|
var BODY_LOCS = {
|
||||||
|
0: 'Other',
|
||||||
|
1: 'Chest',
|
||||||
|
2: 'Wrist',
|
||||||
|
3: 'Finger',
|
||||||
|
4: 'Hand',
|
||||||
|
5: 'Ear Lobe',
|
||||||
|
6: 'Foot',
|
||||||
|
}
|
||||||
|
|
||||||
function clear(y){
|
function clear(y){
|
||||||
g.reset();
|
g.reset();
|
||||||
g.clearRect(0,y,g.getWidth(),y+75);
|
g.clearRect(0,y,g.getWidth(),y+75);
|
||||||
|
@ -25,7 +34,7 @@ function draw(y, type, event) {
|
||||||
if (event.battery) str += " Bat: " + (event.battery ? event.battery : "");
|
if (event.battery) str += " Bat: " + (event.battery ? event.battery : "");
|
||||||
g.setFontVector(12).drawString(str,px,y+40);
|
g.setFontVector(12).drawString(str,px,y+40);
|
||||||
str= "";
|
str= "";
|
||||||
if (event.location) str += "Loc: " + event.location.toFixed(0) + "ms";
|
if (event.location) str += "Loc: " + BODY_LOCS[event.location];
|
||||||
if (event.rr && event.rr.length > 0) str += " RR: " + event.rr.join(",");
|
if (event.rr && event.rr.length > 0) str += " RR: " + event.rr.join(",");
|
||||||
g.setFontVector(12).drawString(str,px,y+50);
|
g.setFontVector(12).drawString(str,px,y+50);
|
||||||
str= "";
|
str= "";
|
||||||
|
|
|
@ -158,9 +158,9 @@ declare type Image = {
|
||||||
};
|
};
|
||||||
|
|
||||||
declare type GraphicsApi = {
|
declare type GraphicsApi = {
|
||||||
reset: () => void;
|
reset: () => GraphicsApi;
|
||||||
flip: () => void;
|
flip: () => void;
|
||||||
setColor: (color: string) => void; // TODO we can most likely type color more usefully than this
|
setColor: (color: string) => GraphicsApi; // TODO we can most likely type color more usefully than this
|
||||||
drawImage: (
|
drawImage: (
|
||||||
image: string | Image | ArrayBuffer,
|
image: string | Image | ArrayBuffer,
|
||||||
xOffset: number,
|
xOffset: number,
|
||||||
|
@ -169,7 +169,7 @@ declare type GraphicsApi = {
|
||||||
rotate?: number;
|
rotate?: number;
|
||||||
scale?: number;
|
scale?: number;
|
||||||
}
|
}
|
||||||
) => void;
|
) => GraphicsApi;
|
||||||
// TODO add more
|
// TODO add more
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue