hidcam: Bangle.js 2 support
parent
427cfb593e
commit
b593fd56ff
|
|
@ -1,3 +1,4 @@
|
||||||
0.01: Core functionnality
|
0.01: Core functionnality
|
||||||
0.02: Offer to enable HID if disabled
|
0.02: Offer to enable HID if disabled
|
||||||
0.03: Adds Readme and tags to be used by App Loader
|
0.03: Adds Readme and tags to be used by App Loader
|
||||||
|
0.04: Adds Bangle.js 2 support
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ Control the camera shutter from your phone using your watch
|
||||||
1. In settings, enable HID for "Keyboard & Media".
|
1. In settings, enable HID for "Keyboard & Media".
|
||||||
2. Pair your watch to your phone.
|
2. Pair your watch to your phone.
|
||||||
3. Load your camera app on 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 ?
|
## How does it work ?
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,13 @@
|
||||||
var storage = require('Storage');
|
var storage = require('Storage');
|
||||||
|
|
||||||
const settings = storage.readJSON('setting.json',1) || { HID: false };
|
const settings = storage.readJSON('setting.json',1) || { HID: false };
|
||||||
|
const isB2 = process.env.HWVERSION === 2;
|
||||||
var sendHid, camShot, profile;
|
var sendHid, camShot, profile;
|
||||||
|
|
||||||
if (settings.HID=="kbmedia") {
|
if (settings.HID=="kbmedia") {
|
||||||
profile = 'camShutter';
|
profile = 'camShutter';
|
||||||
sendHid = function (code, cb) {
|
sendHid = function (code, cb) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
NRF.sendHIDReport([1,code], () => {
|
NRF.sendHIDReport([1,code], () => {
|
||||||
NRF.sendHIDReport([1,0], () => {
|
NRF.sendHIDReport([1,0], () => {
|
||||||
|
|
@ -16,10 +17,13 @@ if (settings.HID=="kbmedia") {
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
print(e);
|
print(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
camShot = function (cb) { sendHid(0x80, cb); };
|
camShot = function (cb) { sendHid(0x80, cb); };
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
E.showPrompt("Enable HID?",{title:"HID disabled"}).then(function(enable) {
|
E.showPrompt("Enable HID?",{title:"HID disabled"}).then(function(enable) {
|
||||||
|
|
||||||
if (enable) {
|
if (enable) {
|
||||||
settings.HID = "kbmedia";
|
settings.HID = "kbmedia";
|
||||||
require("Storage").write('setting.json', settings);
|
require("Storage").write('setting.json', settings);
|
||||||
|
|
@ -47,11 +51,18 @@ function drawApp() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (camShot) {
|
if (camShot) {
|
||||||
|
if (!isB2) { // Bangle.js 1
|
||||||
setWatch(function(e) {
|
setWatch(function(e) {
|
||||||
E.showMessage('camShot !');
|
E.showMessage('camShot !');
|
||||||
setTimeout(drawApp, 1000);
|
setTimeout(drawApp, 1000);
|
||||||
camShot(() => {});
|
camShot(() => {});
|
||||||
}, BTN2, { edge:"falling",repeat:true,debounce:50});
|
}, BTN2, { edge:"falling",repeat:true,debounce:50});
|
||||||
|
} else { // Bangle.js 2
|
||||||
|
setWatch(function(e) {
|
||||||
|
E.showMessage('camShot !');
|
||||||
|
setTimeout(drawApp, 1000);
|
||||||
|
camShot(() => {});
|
||||||
|
}, BTN, { edge:"falling",repeat:true,debounce:50});
|
||||||
|
}
|
||||||
drawApp();
|
drawApp();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,11 +2,11 @@
|
||||||
"id": "hidcam",
|
"id": "hidcam",
|
||||||
"name": "Camera shutter",
|
"name": "Camera shutter",
|
||||||
"shortName": "Cam 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",
|
"description": "Enable HID, connect to your phone, start your camera and trigger the shot on your Bangle",
|
||||||
"icon": "app.png",
|
"icon": "app.png",
|
||||||
"tags": "bluetooth,tool",
|
"tags": "bluetooth,tool",
|
||||||
"supports": ["BANGLEJS"],
|
"supports": ["BANGLEJS","BANGLEJS2"],
|
||||||
"readme": "README.md",
|
"readme": "README.md",
|
||||||
"storage": [
|
"storage": [
|
||||||
{"name":"hidcam.app.js","url":"app.js"},
|
{"name":"hidcam.app.js","url":"app.js"},
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue