Merge branch 'master' of github.com:espruino/BangleApps

master
Gordon Williams 2021-05-28 09:30:15 +01:00
commit 34228a84d9
6 changed files with 129 additions and 0 deletions

View File

@ -3243,5 +3243,20 @@
{"name":"doztime.app.js","url":"app.js"}, {"name":"doztime.app.js","url":"app.js"},
{"name":"doztime.img","url":"app-icon.js","evaluate":true} {"name":"doztime.img","url":"app-icon.js","evaluate":true}
] ]
},
{ "id":"gbtwist",
"name":"Gadgetbridge Twist Control",
"shortName":"Twist Control",
"icon":"app.png",
"version":"0.01",
"description":"Shake your wrist to control your music app via Gadgetbridge",
"tags":"tools,bluetooth,gadgetbridge,music",
"type":"app",
"allow_emulator":false,
"readme": "README.md",
"storage": [
{"name":"gbtwist.app.js","url":"app.js"},
{"name":"gbtwist.img","url":"app-icon.js","evaluate":true}
]
} }
] ]

1
apps/gbtwist/ChangeLog Normal file
View File

@ -0,0 +1 @@
0.01: Initial version

15
apps/gbtwist/README.md Normal file
View File

@ -0,0 +1,15 @@
# Gadgetbridge Twist Control
Control your music app (e.g. MortPlayer Music [a folder based, not tag based player] ) that handles multiple play-commands (same as using a single-button-headset's button to change songs) on your Gadgetbridge-connected phone.
- Activate counting for 4 seconds with a twist (beeps at start and end of counting)
- twist multiple times for:
play/pause (1),
next song (2),
prev. song (3),
next folder (4),
prev. folder (5),
reset counter (6)
- the command to be sent is shown in green
- Volume up/down is controlled by BTN1/BTN3 presses
![screenshot1](https://user-images.githubusercontent.com/84921310/119907374-65bb6180-bf50-11eb-9073-f29f7e333e00.jpg)

1
apps/gbtwist/app-icon.js Normal file
View File

@ -0,0 +1 @@
require("heatshrink").decompress(atob("mEwwIYVhAFEjgFEh4FEg+AAocD4AME8ADCgPAvAFCj/8nkQAoN//8enAQB///44FBgYFB8f4FoIFB+IFBh/+n/4AocH/AXBj/+gP8FIIFDFwM//0x/wFDAIIFNv4FB/4FNEaIFFj/gn5HCj+AAoUEh4FBMgUP4AFDw/gv/wAoPDPoKhBjnxAoKtBjl4TYLICninBagUPWYLJPFoIADZIYABnj6KABIA="))

97
apps/gbtwist/app.js Normal file
View File

@ -0,0 +1,97 @@
// just a watch, to fill an empty screen
function drwClock() {
var d = new Date();
var h = d.getHours(), m = d.getMinutes();
var time = ("0"+h).substr(-2) + ":" + ("0"+m).substr(-2);
g.reset();
g.setFont('6x8',7);
g.setFontAlign(-1,-1);
g.drawString(time,20,80);
}
g.clear();
drwClock();
Bangle.loadWidgets();
Bangle.drawWidgets();
/////////////////////////////////////////////////////////////
// control music by twist/buttons
var counter = 0; //stores your counted your twists
var tstate = false; //are you ready to count the twists?
function playx() {
Bluetooth.println(JSON.stringify({t:"music", n:"play"}));
}
function volup() {
Bluetooth.println(JSON.stringify({t:"music", n:"volumeup"}));
}
function voldn() {
Bluetooth.println(JSON.stringify({t:"music", n:"volumedown"}));
}
function sendCmd() {
print (counter);
Bangle.beep(200,3000);
if (tstate==false && counter>0){
do {playx(); counter--;}
while (counter >= 1);
}
}
function twistctrl() {
if (tstate==false){
tstate=true;
setTimeout('tstate=false',4000);
setTimeout(sendCmd,4100);
Bangle.beep(200,3000);
}
else{
g.clearRect(10,140,230,200);
if (tstate==true){
if (counter < 5){
counter++;
drwCmd();
Bangle.buzz(100,2);
}
else {
counter = 0;
Bangle.buzz(400);
}
}
}
}
function drwCmd() {
g.setFont('6x8',6);
g.setColor(0.3,1,0.3);
g.clearRect(10,140,230,200);
switch (counter){
case 1:
g.drawString('play',50,150);
break;
case 2:
g.drawString('next',50,150);
break;
case 3:
g.drawString('prev',50,150);
break;
case 4:
g.drawString('nx f',50,150);
break;
case 5:
g.drawString('pr f',50,150);
break;
case 0:
g.clearRect(10,140,230,200);
break;
}
}
setWatch(volup,BTN1,{repeat:true});
setWatch(voldn,BTN3,{repeat:true});
Bangle.on('twist',twistctrl);
setWatch(Bangle.showLauncher, BTN2, {repeat:false,edge:"falling"});

BIN
apps/gbtwist/app.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 906 B