mirror of https://github.com/espruino/BangleApps
App to control music via HID commands using swipes on the touch screen on the Bangle.js 2. Based on the original Bluetooth Music Controls.
parent
100384f2e8
commit
be34234a04
14
apps.json
14
apps.json
|
@ -4307,5 +4307,19 @@
|
||||||
{"name":"binwatch.app.js","url":"app.js"},
|
{"name":"binwatch.app.js","url":"app.js"},
|
||||||
{"name":"binwatch.img","url":"app-icon.js","evaluate":true}
|
{"name":"binwatch.img","url":"app-icon.js","evaluate":true}
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "hidmsicswipe",
|
||||||
|
"name": "Bluetooth Music Swipe Controls",
|
||||||
|
"shortName": "Swipe Control",
|
||||||
|
"version": "0.01",
|
||||||
|
"description": "Based on the original Bluetooth Music Controls. Swipe up/down for volume, left/right for previous and next, tap for play/pause and btn1 to lock and unlock the controls. Enable HID in settings, pair with your phone, then use this app to control music from your watch!",
|
||||||
|
"icon": "hidmsicswipe.png",
|
||||||
|
"tags": "bluetooth",
|
||||||
|
"supports": ["BANGLEJS2"],
|
||||||
|
"storage": [
|
||||||
|
{"name":"hidmsicswipe.app.js","url":"hidmsicswipe.js"},
|
||||||
|
{"name":"hidmsicswipe.img","url":"hidmsicswipe-icon.js","evaluate":true}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
0.01: Core functionnality based entirely on hidmsic
|
|
@ -0,0 +1 @@
|
||||||
|
require("heatshrink").decompress(atob("mEwwhC/AH4A5xGICquZzAVUAAIXQCogXQCoxHPCox0BxIXNxIVFBAQXPUAwXPBw4XowAvuC/4X/C9sIC6kIxGZzIXSFgIWBC6QWEC6RECAAOJwAXQFwoXLxAqBC4MICweZCxhWEC4mICxxuDA4I3BCxQ/FQxpyEK6AucC4idMI5OICyQwBQpgA/AH4Au"))
|
|
@ -0,0 +1,93 @@
|
||||||
|
var storage = require('Storage');
|
||||||
|
|
||||||
|
const settings = storage.readJSON('setting.json',1) || { HID: false };
|
||||||
|
|
||||||
|
var sendHid, next, prev, toggle, up, down, profile;
|
||||||
|
var lasty = 0;
|
||||||
|
var lastx = 0;
|
||||||
|
|
||||||
|
if (settings.HID=="kbmedia") {
|
||||||
|
profile = 'Music';
|
||||||
|
sendHid = function (code, cb) {
|
||||||
|
try {
|
||||||
|
NRF.sendHIDReport([1,code], () => {
|
||||||
|
NRF.sendHIDReport([1,0], () => {
|
||||||
|
if (cb) cb();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
} catch(e) {
|
||||||
|
print(e);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
next = function (cb) { sendHid(0x01, cb); };
|
||||||
|
prev = function (cb) { sendHid(0x02, cb); };
|
||||||
|
toggle = function (cb) { sendHid(0x10, cb); };
|
||||||
|
up = function (cb) {sendHid(0x40, cb); };
|
||||||
|
down = 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);
|
||||||
|
setTimeout(load, 1000, "hidmsicswipe.app.js");
|
||||||
|
} else setTimeout(load, 1000);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function drawApp() {
|
||||||
|
g.clear();
|
||||||
|
if(Bangle.isLocked()==false) E.showMessage('Swipe', 'Music');
|
||||||
|
else E.showMessage('Locked', 'Music');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (next) {
|
||||||
|
setWatch(function(e) {
|
||||||
|
var len = e.time - e.lastTime;
|
||||||
|
E.showMessage('lock');
|
||||||
|
setTimeout(drawApp, 1000);
|
||||||
|
Bangle.setLocked(true);
|
||||||
|
}, BTN1, { edge:"falling",repeat:true,debounce:50});
|
||||||
|
Bangle.on('drag', function(e) {
|
||||||
|
if(!e.b){
|
||||||
|
//console.log(lasty);
|
||||||
|
//console.log(lastx);
|
||||||
|
if(lasty > 40){
|
||||||
|
E.showMessage('down');
|
||||||
|
setTimeout(drawApp, 1000);
|
||||||
|
down(() => {});
|
||||||
|
}
|
||||||
|
else if(lasty < -40){
|
||||||
|
E.showMessage('up');
|
||||||
|
setTimeout(drawApp, 1000);
|
||||||
|
up(() => {});
|
||||||
|
} else if(lastx < -40){
|
||||||
|
E.showMessage('prev');
|
||||||
|
setTimeout(drawApp, 1000);
|
||||||
|
prev(() => {});
|
||||||
|
} else if(lastx > 40){
|
||||||
|
E.showMessage('next');
|
||||||
|
setTimeout(drawApp, 1000);
|
||||||
|
next(() => {});
|
||||||
|
} else if(lastx==0 && lasty==0){
|
||||||
|
E.showMessage('play/pause');
|
||||||
|
setTimeout(drawApp, 1000);
|
||||||
|
toggle(() => {});
|
||||||
|
}
|
||||||
|
lastx = 0;
|
||||||
|
lasty = 0;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
lastx = lastx + e.dx;
|
||||||
|
lasty = lasty + e.dy;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
Bangle.on("lock", function(on) {
|
||||||
|
if(!on){
|
||||||
|
E.showMessage('unlock');
|
||||||
|
setTimeout(drawApp, 1000);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
drawApp();
|
||||||
|
}
|
Binary file not shown.
After Width: | Height: | Size: 632 B |
Loading…
Reference in New Issue