diff --git a/apps/compass.js b/apps/compass.js index c1d131093..10895e3cd 100644 --- a/apps/compass.js +++ b/apps/compass.js @@ -23,7 +23,7 @@ Bangle.on('mag', function(m) { g.fillRect(70,0,170,24); g.setColor(0xffff); g.setFontAlign(0,0); - g.drawString((m.heading===undefined)?"---":Math.round(m.heading),120,12); + g.drawString(isNaN(m.heading)?"---":Math.round(m.heading),120,12); g.setColor(0,0,0); arrow(oldHeading,0); arrow(oldHeading+180,0); diff --git a/apps/heartrate.js b/apps/heartrate.js index c31314af1..84658e85f 100644 --- a/apps/heartrate.js +++ b/apps/heartrate.js @@ -14,9 +14,9 @@ function readHRM() { min=Math.min(min*0.97+a*0.03,a); max=Math.max(max*0.97+a*0.03,a); y = E.clip(170 - (a*960*4),100,230); - if (x==0) { - g.clearRect(0,100,239,239); - g.moveTo(-100,0); + if (x==0) { + g.clearRect(0,100,239,239); + g.moveTo(-100,0); } /*g.setColor(0,1,0); var z = 170 - (min*960*4); g.fillRect(x,z,x,z); @@ -39,11 +39,16 @@ function readHRM() { t.sort(); // average the middle 3 var mid = t.length>>1; - hrm = (t[mid]+t[mid+1]+t[mid+2])/3; + if (mid+2 { + clearWatch(); + show(charl,callback); + }, BTN4); + setWatch(() => { + clearWatch(); + show(charr,callback); + }, BTN5); +} + +function getCharacter() { + return new Promise(resolve => { + show("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789",resolve); + }); +} + +function startKeyboardHID() { + getCharacter().then(ch => { + return sendHID(KEY[ch]); + }).then(startKeyboardHID); +}; + +if (!settings.HID) { + E.showMessage('HID disabled'); + setTimeout(load, 1000); +} else { + startKeyboardHID(); + setWatch(() => { + sendHID(44); // space + }, BTN2, {repeat:true}); + setWatch(() => { + sendHID(40); // enter + }, BTN3, {repeat:true}); +} diff --git a/apps/hid-binary-keyboard.json b/apps/hid-binary-keyboard.json new file mode 100644 index 000000000..e2059a9c2 --- /dev/null +++ b/apps/hid-binary-keyboard.json @@ -0,0 +1,5 @@ +{ + "name": "Binary Keyboard","type":"app", + "icon": "*hidbkbd", + "src": "-hidbkbd" +} diff --git a/apps/hid-binary-keyboard.png b/apps/hid-binary-keyboard.png new file mode 100644 index 000000000..19aec3c05 Binary files /dev/null and b/apps/hid-binary-keyboard.png differ diff --git a/testing/binary-keyboard.js b/testing/binary-keyboard.js deleted file mode 100644 index 3b68179a4..000000000 --- a/testing/binary-keyboard.js +++ /dev/null @@ -1,50 +0,0 @@ -/* -Binary search keyboard for typing with -the touchscreen -*/ - -function showChars(x,chars) { - var lines = Math.round(Math.sqrt(chars.length)*2); - g.setFontAlign(0,0); - var sy = Math.round(200/lines); - var sx = sy; - g.setFont("Vector", sy-2); - var y = (240 - lines*sy); - var last = 0; - for (var i=0;i { - clearWatch(); - show(charl,callback); - }, BTN4); - setWatch(() => { - clearWatch(); - show(charr,callback); - }, BTN5); -} - -function getCharacter() { - return new Promise(resolve => { - show("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789",resolve); - }); -} - -getCharacter().then(print) \ No newline at end of file