mirror of https://github.com/espruino/BangleApps
parent
31c08d149f
commit
66bbdd1242
|
@ -4,3 +4,4 @@
|
|||
Set 'n' for buttons in Bangle.btHomeData correctly (avoids adding extra buttons on end of advertising)
|
||||
0.04: Fix duplicate button on edit->save
|
||||
0.05: Use the bleAdvert module
|
||||
0.06: button number can't be 0. Now generates number automatically
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
{ "id": "bthome",
|
||||
"name": "BTHome",
|
||||
"shortName":"BTHome",
|
||||
"version":"0.05",
|
||||
"version":"0.06",
|
||||
"description": "Allow your Bangle to advertise with BTHome and send events to Home Assistant via Bluetooth",
|
||||
"icon": "icon.png",
|
||||
"type": "app",
|
||||
|
|
|
@ -11,10 +11,24 @@
|
|||
require("Storage").writeJSON("bthome.json",settings)
|
||||
}
|
||||
|
||||
function getNewIdNumber(){
|
||||
var id_start = 1;
|
||||
var select = false;
|
||||
while(!select){
|
||||
select = true;
|
||||
settings.buttons.forEach((button, idx) => {
|
||||
if (id_start == button.n){
|
||||
id_start++;
|
||||
select = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
return id_start;
|
||||
}
|
||||
|
||||
function showButtonMenu(button, isNew) {
|
||||
var isNew = false;
|
||||
if (!button) {
|
||||
button = {name:"home", icon:"home", n:0, v:"press"};
|
||||
button = {name:"home", icon:"home", n:getNewIdNumber(), v:"press"};
|
||||
isNew = true;
|
||||
}
|
||||
var actions = ["press","double_press","triple_press","long_press","long_double_press","long_triple_press"];
|
||||
|
@ -51,10 +65,6 @@
|
|||
format : v => actions[v],
|
||||
onchange : v => button.v=actions[v]
|
||||
},
|
||||
/*LANG*/"Button #" : {
|
||||
value : button.n, min:0, max:3,
|
||||
onchange : v => button.n=v
|
||||
},
|
||||
/*LANG*/"Save" : () => {
|
||||
if (isNew) settings.buttons.push(button);
|
||||
saveSettings();
|
||||
|
|
Loading…
Reference in New Issue