diff --git a/apps.json b/apps.json index 0826bbf81..f5e1d5d87 100644 --- a/apps.json +++ b/apps.json @@ -4931,5 +4931,21 @@ {"name":"awairmonitor.app.js","url":"app.js"}, {"name":"awairmonitor.img","url":"app-icon.js","evaluate":true} ] + }, + { + "id": "coretemp", + "name": "Core Temp Display", + "version": "0.01", + "description": "Display CoreTemp device sensor data", + "icon": "coretemp.png", + "type": "app", + "tags": "health", + "readme": "README.md", + "supports": ["BANGLEJS","BANGLEJS2"], + "storage": [ + {"name":"coretemp.boot.js","url":"boot.js"}, + {"name":"coretemp.app.js","url":"coretemp.js"}, + {"name":"coretemp.img","url":"coretemp-icon.js","evaluate":true} + ] } ] diff --git a/apps/coretemp/ChangeLog b/apps/coretemp/ChangeLog new file mode 100644 index 000000000..c7b309a74 --- /dev/null +++ b/apps/coretemp/ChangeLog @@ -0,0 +1 @@ +0.1: New app diff --git a/apps/coretemp/README.md b/apps/coretemp/README.md new file mode 100644 index 000000000..fac25df21 --- /dev/null +++ b/apps/coretemp/README.md @@ -0,0 +1,20 @@ +# CoreTemp display + +Basic bare-bones example of connecting to a bluetooth [CoreTemp](https://corebodytemp.com/) device and displaying the current body core temperature readings. + +## Usage + +On startup connects to a CoreTemp device (1809/2A1C) and emits a "Core, temp" value for each reading. +The app simply displays these readings on screen. + +## TODO + +* Integrate with other tracking/sports apps to log data. +* Add device selection +* Provide enable/disable option +* Check status, add Retry/reconnect +* Also provide skin temp reading + +## Creator + +Ivor Hewitt diff --git a/apps/coretemp/boot.js b/apps/coretemp/boot.js new file mode 100644 index 000000000..59e227dad --- /dev/null +++ b/apps/coretemp/boot.js @@ -0,0 +1,23 @@ +(function() { + var gatt; + + //Would it be better to scan by uuid rather than name? + NRF.requestDevice({ timeout: 20000, filters: [{ name: 'CORE [a]' }] }).then(function(device) { + return device.gatt.connect(); + }).then(function(g) { + gatt = g; + return gatt.getPrimaryService("1809"); + }).then(function(service) { + return service.getCharacteristic("2A1C"); + }).then(function(characteristic) { + characteristic.on('characteristicvaluechanged', function(event) { + var dv = event.target.value; + var core = (dv.buffer[2]*256+dv.buffer[1])/100; + Bangle.emit('Core',{ + temp:core + }); + }); + return characteristic.startNotifications(); + }).then(function() { + }); +})(); diff --git a/apps/coretemp/coretemp-icon.js b/apps/coretemp/coretemp-icon.js new file mode 100644 index 000000000..5f36b9090 --- /dev/null +++ b/apps/coretemp/coretemp-icon.js @@ -0,0 +1 @@ +require("heatshrink").decompress(atob("mEw4UA///k0DxUFgsDCY8KwAfJlQLHhWglWq1WgBIcCA4QCB1WoComq0+iBYWqCwl//4OBAAQxChWlv/2BYIlCBYUqv9VvQLBwA9BBYWlqtV/QLBGoRIBgQLBr9aBYQ2BBYMKroLBtQLCgALClIKC1AXG1NVuoFBF4sC09V+woCBAJHCgWXq9oPQZrDgWdq9gBZG9rqgCTwSbCgVVqysDBYkK6tWYoa/DkEJ6vaaIgWBaAILCbQhUCBYXoc4wNBBZWqBfBtB1ALKKZILCR4J3FToQLBU4KPEWoQLNZYILIa4NVcYReEcYOnqtaDAbvDgALBcg4EBlNVqtqDoOgd4YoBBYNWytWCwQdCgQLBAAVaBYkA0oLDuwLFkv1BgZGDAAMJuoKCroWEGAOnDAVftShGr////1tDdG14LB+wiEAAdqHAjTHBYgA==")) diff --git a/apps/coretemp/coretemp.js b/apps/coretemp/coretemp.js new file mode 100644 index 000000000..226508c83 --- /dev/null +++ b/apps/coretemp/coretemp.js @@ -0,0 +1,19 @@ +Bangle.setLCDPower(1); +Bangle.setLCDTimeout(0); +var btm = g.getHeight()-1; + +function onCore(c) { + var px = g.getWidth()/2; + g.setFontAlign(0,0); + g.clearRect(0,24,g.getWidth(),80); + var str = c.temp + "C"; + g.setFontVector(40).drawString(str,px,45); +} +Bangle.on('Core', onCore); + +g.clear(); +Bangle.loadWidgets(); +Bangle.drawWidgets(); + +g.reset().setFont("6x8",2).setFontAlign(0,0); +g.drawString("Please wait...",g.getWidth()/2,g.getHeight()/2 - 16); diff --git a/apps/coretemp/coretemp.png b/apps/coretemp/coretemp.png new file mode 100644 index 000000000..a573828f8 Binary files /dev/null and b/apps/coretemp/coretemp.png differ