diff --git a/apps.json b/apps.json index b965d7d3b..aa1f751a0 100644 --- a/apps.json +++ b/apps.json @@ -120,6 +120,15 @@ {"name":"=sbat","url":"widget-battery.js"} ] }, + { "id": "sbt", + "name": "Bluetooth Widget", + "icon": "widget-bluetooth.png", + "description": "Show the current Bluetooth connection status in the top right of the clock", + "tags": "widget,bluetooth", + "storage": [ + {"name":"=sbt","url":"widget-bluetooth.js"} + ] + }, { "id": "hrm", "name": "Heart Rate Monitor", "icon": "heartrate.png", diff --git a/apps/widget-bluetooth.js b/apps/widget-bluetooth.js new file mode 100644 index 000000000..03275ea8d --- /dev/null +++ b/apps/widget-bluetooth.js @@ -0,0 +1,22 @@ +(function(){ +var img_bt = E.toArrayBuffer(atob("CxQBBgDgFgJgR4jZMawfAcA4D4NYybEYIwTAsBwDAA==")); +var xpos = WIDGETPOS.tr-24; +WIDGETPOS.tr-=24; + +function draw() { + var x = xpos, y = 0; + if (NRF.getSecurityStatus().connected) + g.setColor(0,0.5,1); + else + g.setColor(0.3,0.3,0.3); + g.drawImage(img_bt,10+x,2+y); + g.setColor(1,1,1); +} +function changed() { + draw(); + g.flip(); +} +NRF.on('connected',changed); +NRF.on('disconnected',changed); +WIDGETS["bluetooth"]={draw:draw}; +})() diff --git a/apps/widget-bluetooth.png b/apps/widget-bluetooth.png new file mode 100644 index 000000000..1a884a62c Binary files /dev/null and b/apps/widget-bluetooth.png differ