mirror of https://github.com/espruino/BangleApps
0.03: Cope with identical duplicate buttons (fix #3260)
Set 'n' for buttons in Bangle.btHomeData correctly (avoids adding extra buttons on end of advertising)pull/3308/head
parent
e769b346b7
commit
21a17cc751
|
@ -1,2 +1,4 @@
|
|||
0.01: New App!
|
||||
0.02: Fix double-button press if you press the next button within 30s (#3243)
|
||||
0.02: Fix double-button press if you press the next button within 30s (#3243)
|
||||
0.03: Cope with identical duplicate buttons (fix #3260)
|
||||
Set 'n' for buttons in Bangle.btHomeData correctly (avoids adding extra buttons on end of advertising)
|
|
@ -5,20 +5,26 @@ function showMenu() {
|
|||
var settings = require("Storage").readJSON("bthome.json",1)||{};
|
||||
if (!(settings.buttons instanceof Array))
|
||||
settings.buttons = [];
|
||||
var menu = { "": {title:"BTHome", back:load} };
|
||||
var menu = [];
|
||||
menu[""] = {title:"BTHome", back:load };
|
||||
settings.buttons.forEach((button,idx) => {
|
||||
var img = require("icons").getIcon(button.icon);
|
||||
menu[/*LANG*/"\0"+img+" "+button.name] = function() {
|
||||
Bangle.btHome([{type:"button_event",v:button.v,n:button.n}],{event:true});
|
||||
E.showMenu();
|
||||
E.showMessage("Sending Event");
|
||||
Bangle.buzz();
|
||||
setTimeout(showMenu, 500);
|
||||
};
|
||||
menu.push({
|
||||
title : /*LANG*/"\0"+img+" "+button.name,
|
||||
onchange : function() {
|
||||
Bangle.btHome([{type:"button_event",v:button.v,n:button.n}],{event:true});
|
||||
E.showMenu();
|
||||
E.showMessage("Sending Event");
|
||||
Bangle.buzz();
|
||||
setTimeout(showMenu, 500);
|
||||
}
|
||||
});
|
||||
});
|
||||
menu[/*LANG*/"Settings"] = function() {
|
||||
menu.push({
|
||||
title : /*LANG*/"Settings",
|
||||
onchange : function() {
|
||||
eval(require("Storage").read("bthome.settings.js"))(()=>showMenu());
|
||||
};
|
||||
}});
|
||||
E.showMenu(menu);
|
||||
}
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ Bangle.btHomeData = [];
|
|||
if (settings.buttons instanceof Array) {
|
||||
let n = settings.buttons.reduce((n,b)=>b.n>n?b.n:n,-1);
|
||||
for (var i=0;i<=n;i++)
|
||||
Bangle.btHomeData.push({type:"button_event",v:"none",n:n});
|
||||
Bangle.btHomeData.push({type:"button_event",v:"none",n:i});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
{ "id": "bthome",
|
||||
"name": "BTHome",
|
||||
"shortName":"BTHome",
|
||||
"version":"0.02",
|
||||
"version":"0.03",
|
||||
"description": "Allow your Bangle to advertise with BTHome and send events to Home Assistant via Bluetooth",
|
||||
"icon": "icon.png",
|
||||
"type": "app",
|
||||
|
|
|
@ -67,24 +67,31 @@
|
|||
}
|
||||
|
||||
function showMenu() {
|
||||
var menu = { "": {title:"BTHome", back:back},
|
||||
/*LANG*/"Show Battery" : {
|
||||
value : !!settings.showBattery,
|
||||
onchange : v=>{
|
||||
settings.showBattery = v;
|
||||
saveSettings();
|
||||
}
|
||||
var menu = [];
|
||||
menu[""] = {title:"BTHome", back:back};
|
||||
menu.push({
|
||||
title : /*LANG*/"Show Battery",
|
||||
value : !!settings.showBattery,
|
||||
onchange : v=>{
|
||||
settings.showBattery = v;
|
||||
saveSettings();
|
||||
}
|
||||
};
|
||||
});
|
||||
settings.buttons.forEach((button,idx) => {
|
||||
var img = require("icons").getIcon(button.icon);
|
||||
menu[/*LANG*/"Button"+(img ? " \0"+img : (idx+1))] = function() {
|
||||
showButtonMenu(button, false);
|
||||
};
|
||||
menu.push({
|
||||
title : /*LANG*/"Button"+(img ? " \0"+img : (idx+1)),
|
||||
onchange : function() {
|
||||
showButtonMenu(button, false);
|
||||
}
|
||||
});
|
||||
});
|
||||
menu.push({
|
||||
title : /*LANG*/"Add Button",
|
||||
onchange : function() {
|
||||
showButtonMenu(undefined, true);
|
||||
}
|
||||
});
|
||||
menu[/*LANG*/"Add Button"] = function() {
|
||||
showButtonMenu(undefined, true);
|
||||
};
|
||||
E.showMenu(menu);
|
||||
}
|
||||
showMenu();
|
||||
|
|
Loading…
Reference in New Issue