mirror of https://github.com/espruino/BangleApps
commit
cbdbe20b34
|
@ -1,3 +1,4 @@
|
|||
0.01: Core functionnality
|
||||
0.02: Offer to enable HID if disabled
|
||||
0.03: Adds Readme and tags to be used by App Loader
|
||||
0.04: Adds Bangle.js 2 support, Buzz and Touch
|
||||
|
|
|
@ -7,7 +7,7 @@ Control the camera shutter from your phone using your watch
|
|||
1. In settings, enable HID for "Keyboard & Media".
|
||||
2. Pair your watch to your phone.
|
||||
3. Load your camera app on your phone.
|
||||
4. There you go, launch the app on your watch and press button 2 to trigger the shutter !
|
||||
4. There you go, launch the app on your watch and press the button (button 2 on Bangle.js 1) to trigger the shutter !
|
||||
|
||||
## How does it work ?
|
||||
|
||||
|
|
|
@ -1,25 +1,29 @@
|
|||
var storage = require('Storage');
|
||||
|
||||
const settings = storage.readJSON('setting.json',1) || { HID: false };
|
||||
|
||||
const isB2 = process.env.HWVERSION === 2;
|
||||
var sendHid, camShot, profile;
|
||||
|
||||
if (settings.HID=="kbmedia") {
|
||||
profile = 'camShutter';
|
||||
sendHid = function (code, cb) {
|
||||
try {
|
||||
NRF.sendHIDReport([1,code], () => {
|
||||
NRF.sendHIDReport([1,0], () => {
|
||||
if (cb) cb();
|
||||
});
|
||||
});
|
||||
} catch(e) {
|
||||
print(e);
|
||||
}
|
||||
|
||||
try {
|
||||
NRF.sendHIDReport([1,code], () => {
|
||||
NRF.sendHIDReport([1,0], () => {
|
||||
if (cb) cb();
|
||||
});
|
||||
});
|
||||
} catch(e) {
|
||||
print(e);
|
||||
}
|
||||
|
||||
};
|
||||
camShot = function (cb) { sendHid(0x80, cb); };
|
||||
} else {
|
||||
|
||||
E.showPrompt("Enable HID?",{title:"HID disabled"}).then(function(enable) {
|
||||
|
||||
if (enable) {
|
||||
settings.HID = "kbmedia";
|
||||
require("Storage").write('setting.json', settings);
|
||||
|
@ -31,10 +35,15 @@ function drawApp() {
|
|||
g.clear();
|
||||
Bangle.loadWidgets();
|
||||
Bangle.drawWidgets();
|
||||
g.fillCircle(122,127,60);
|
||||
g.drawImage(storage.read("hidcam.img"),100,105);
|
||||
const d = g.getWidth() - 18;
|
||||
|
||||
if (!isB2) { // Bangle.js 1
|
||||
g.fillCircle(122,127,60);
|
||||
g.drawImage(storage.read("hidcam.img"),100,105);
|
||||
const d = g.getWidth() - 18;
|
||||
} else {
|
||||
g.fillCircle(90,95,60);
|
||||
g.drawImage(storage.read("hidcam.img"),65,70);
|
||||
const d = g.getWidth() - 18;
|
||||
}
|
||||
function c(a) {
|
||||
return {
|
||||
width: 8,
|
||||
|
@ -46,12 +55,27 @@ function drawApp() {
|
|||
g.fillRect(180,130, 240, 124);
|
||||
}
|
||||
|
||||
if (camShot) {
|
||||
setWatch(function(e) {
|
||||
E.showMessage('camShot !');
|
||||
setTimeout(drawApp, 1000);
|
||||
camShot(() => {});
|
||||
}, BTN2, { edge:"falling",repeat:true,debounce:50});
|
||||
|
||||
if (camShot) {
|
||||
if (!isB2) { // Bangle.js 1
|
||||
setWatch(function(e) {
|
||||
E.showMessage('camShot !');
|
||||
Bangle.buzz(300, 1);
|
||||
setTimeout(drawApp, 1000);
|
||||
camShot(() => {});
|
||||
}, BTN2, { edge:"falling",repeat:true,debounce:50});
|
||||
} else { // Bangle.js 2
|
||||
setWatch(function(e) {
|
||||
E.showMessage('camShot !');
|
||||
Bangle.buzz(300, 1);
|
||||
setTimeout(drawApp, 1000);
|
||||
camShot(() => {});
|
||||
}, BTN, { edge:"falling",repeat:true,debounce:50});
|
||||
Bangle.on('touch', function (wat, tap) {
|
||||
E.showMessage('camShot !');
|
||||
Bangle.buzz(300, 1);
|
||||
setTimeout(drawApp, 1000);
|
||||
camShot(() => {});
|
||||
});
|
||||
}
|
||||
drawApp();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,11 +2,11 @@
|
|||
"id": "hidcam",
|
||||
"name": "Camera shutter",
|
||||
"shortName": "Cam shutter",
|
||||
"version": "0.03",
|
||||
"version": "0.04",
|
||||
"description": "Enable HID, connect to your phone, start your camera and trigger the shot on your Bangle",
|
||||
"icon": "app.png",
|
||||
"tags": "bluetooth,tool",
|
||||
"supports": ["BANGLEJS"],
|
||||
"supports": ["BANGLEJS","BANGLEJS2"],
|
||||
"readme": "README.md",
|
||||
"storage": [
|
||||
{"name":"hidcam.app.js","url":"app.js"},
|
||||
|
|
Loading…
Reference in New Issue