Thanks! I've just updated it so when I next push the website that'll be active. Not sure how I missed that (it's even obvious from the picture of the LCD!).
If you want better resolution then one easy solution is to reduce the range by multiplying it. By default you're using 8 bits, so 0..255 (or -128 to 127 if you use g.getInt8(1)). For normal outside temperatures -64 to 63.5 would be ok, so you could do:
But then the temperature reported is actually to 0.25, and multiplying by 4 and restricting to -32 to 31.75 is probably too much.
In that case you'd want to use two bytes and then you can multiply by a much bigger number. Using DataView on both ends is probably easier to read:
// sender
var data = new Uint8Array(3); // 3 bytes
var d = new DataView(data.buffer);
d.setUint8(0, Puck.getBatteryPercentage());
d.setInt16(1, E.getTemperature()*256);
NRF.setAdvertising({}, {
manufacturer: 0x590,
manufacturerData: data
});
// receiver
g.drawString(`${dev.name}: ${d.getInt16(1)/256}'C (${d.getUint8(0)}% bat)`,0,idx*6);
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
Thanks! I've just updated it so when I next push the website that'll be active. Not sure how I missed that (it's even obvious from the picture of the LCD!).
If you want better resolution then one easy solution is to reduce the range by multiplying it. By default you're using 8 bits, so 0..255 (or -128 to 127 if you use
g.getInt8(1)
). For normal outside temperatures -64 to 63.5 would be ok, so you could do:But then the temperature reported is actually to 0.25, and multiplying by 4 and restricting to -32 to 31.75 is probably too much.
In that case you'd want to use two bytes and then you can multiply by a much bigger number. Using DataView on both ends is probably easier to read: