mirror of https://github.com/espruino/BangleApps
remove dane_cfg for now
parent
9e73c4e9b1
commit
90925d91da
14
apps.json
14
apps.json
|
@ -1523,20 +1523,6 @@
|
|||
],
|
||||
"sortorder" : -10
|
||||
},
|
||||
{ "id": "dane_cfg",
|
||||
"name": "DANE Settings",
|
||||
"icon": "settings.png",
|
||||
"version":"0.01",
|
||||
"description": "The default settings app in DANE Style",
|
||||
"tags": "tool,system",
|
||||
"readme": "README.md",
|
||||
"storage": [
|
||||
{"name":"dane_cfg.app.js","url":"settings.js"},
|
||||
{"name":"dane_cfg.boot.js","url":"boot.js"},
|
||||
{"name":"dane_cfg.img","url":"settings-icon.js","evaluate":true}
|
||||
],
|
||||
"sortorder" : -2
|
||||
},
|
||||
{
|
||||
"id": "buffgym",
|
||||
"name": "BuffGym",
|
||||
|
|
|
@ -34,18 +34,6 @@ let count = 100;
|
|||
let oldCount = count;
|
||||
|
||||
|
||||
// function getImg() {
|
||||
// return atob("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");
|
||||
// }
|
||||
|
||||
// function makeImg() {
|
||||
// return {
|
||||
// width : 120, height : 120, bpp : 8,
|
||||
// transparent : 254,
|
||||
// buffer : require("heatshrink").decompress(getImg())
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
function drawTopLeftCorner(x, y) {
|
||||
g.setColor(mainColor);
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
0.01: Forked Settings, Styled to match DANE Watchface
|
|
@ -1,33 +0,0 @@
|
|||
# Settings
|
||||
|
||||
This is Bangle.js's settings menu
|
||||
|
||||
* **Make Connectable** regardless of the current Bluetooth settings, makes Bangle.js so you can connect to it (while the window is up)
|
||||
* **App/Widget Settings** settings specific to installed applications
|
||||
* **BLE** Bluetooth Settings menu - see below.
|
||||
* **Debug Info** should debug info be shown on the watch's screen or not?
|
||||
* **Beep** most Bangle.js do not have a speaker inside, but they can use the vibration motor to beep in different pitches. You can change the behaviour here to use a Piezo speaker if one is connected
|
||||
* **Vibration** enable/disable the vibration motor
|
||||
* **Locale** set time zone/whether the clock is 12/24 hour (for supported clocks)
|
||||
* **Select Clock** if you have more than one clock face, select the default one
|
||||
* **HID** When Bluetooth is enabled, Bangle.js can appear as a Bluetooth Keyboard/Joystick/etc to send keypresses to a connected device.
|
||||
* **NOTE:** on some platforms enabling HID can cause you problems when trying to connect to Bangle.js to upload apps.
|
||||
* **Set Time** Configure the current time - Note that this can be done much more easily by choosing 'Set Time' from the App Loader
|
||||
* **LCD** Configure settings about the screen. How long it stays on, how bright it is, and when it turns on - see below.
|
||||
* **Reset Settings** Reset the settings to defaults
|
||||
* **Turn Off** Turn Bangle.js off
|
||||
|
||||
## BLE - Bluetooth Settings
|
||||
|
||||
* **BLE** is Bluetooth LE enabled and the watch connectable?
|
||||
* **Programmable** if BLE is on, can the watch be connected to in order to program/upload apps? As long as your watch firmware is up to date, Gadgetbridge will work even with `Programmable` set to `Off`.
|
||||
* **Passkey BETA** allows you to set a passkey that is required to connect and pair to Bangle.js. **Note:** This is Beta and you will almost certainly encounter issues connecting with Web Bluetooth using this option.
|
||||
* **Whitelist** allows you to specify only specific devices that you will let connect to your Bangle.js. Simply choose the menu item, then `Add Device`, and then connect to Bangle.js with the device you want to add. If you are already connected you will have to disconnect first. Changes will take effect when you exit the `Settings` app.
|
||||
* **NOTE:** iOS devices and newer Android devices often implement Address Randomisation and change their Bluetooth address every so often. If you device's address changes, you will be unable to connect until you update the whitelist again.
|
||||
|
||||
## LCD
|
||||
|
||||
* **LCD Brightness** set how bright the LCD is. Due to hardware limitations in the LCD backlight, you may notice flicker if the LCD is not at 100% brightness.
|
||||
* **LCD Timeout** how long should the LCD stay on for if no activity is detected. 0=stay on forever
|
||||
* **Wake on X** should the given activity wake up the Bangle.js LCD?
|
||||
* **Twist X** these options adjust the sensitivity of `Wake on Twist` to ensure Bangle.js wakes up with just the right amount of wrist movement.
|
|
@ -1,9 +0,0 @@
|
|||
(() => {
|
||||
var settings = require('Storage').readJSON('dane_cfg.json', true);
|
||||
if (!settings) return;
|
||||
if (settings.options) Bangle.setOptions(settings.options);
|
||||
if (settings.brightness && settings.brightness!=1) Bangle.setLCDBrightness(settings.brightness);
|
||||
if (settings.passkey!==undefined && settings.passkey.length==6) NRF.setSecurity({passkey:settings.passkey, mitm:1, display:1});
|
||||
if (settings.whitelist) NRF.on('connect', function(addr) { if (!settings.whitelist.includes(addr)) NRF.disconnect(); });
|
||||
delete settings;
|
||||
})()
|
|
@ -1 +0,0 @@
|
|||
require("heatshrink").decompress(atob("mEwghC/AFEiAAgX/C/4SFkADBgQXFBIgECAAYSCkAWGBIoXGyQTHABBZLkUhiMRiQXLIQwVBAAZlIC44tCAAYxGIxIWFGA4XIFwwwHXBAWHGAwXHFxAwGPAYXTX44XDiAJBgIXGyDAHFAYKDMAq+EGAgXNCwwX/C453XU6IWHa6ZFCC6JJCC4hgEAAoOEC5AwIFwhgEBAgwIBoqmGGBIuFVAgXFGAwLFYAoLFGIYtFeA4MGABMpC4pICkBMGBIpGFC4SuIBIoWFAAxZLC/4X/AFQ"))
|
|
@ -1,515 +0,0 @@
|
|||
Bangle.loadWidgets();
|
||||
Bangle.drawWidgets();
|
||||
|
||||
const storage = require('Storage');
|
||||
let settings;
|
||||
|
||||
function updateSettings() {
|
||||
//storage.erase('setting.json'); // - not needed, just causes extra writes if settings were the same
|
||||
storage.write('dane_cfg.json', settings);
|
||||
}
|
||||
|
||||
function updateOptions() {
|
||||
updateSettings();
|
||||
Bangle.setOptions(settings.options)
|
||||
}
|
||||
|
||||
function gToInternal(g) {
|
||||
// converts g to Espruino internal unit
|
||||
return g * 8192;
|
||||
}
|
||||
|
||||
function internalToG(u) {
|
||||
// converts Espruino internal unit to g
|
||||
return u / 8192
|
||||
}
|
||||
|
||||
function resetSettings() {
|
||||
settings = {
|
||||
ble: true, // Bluetooth enabled by default
|
||||
blerepl: true, // Is REPL on Bluetooth - can Espruino IDE be used?
|
||||
log: false, // Do log messages appear on screen?
|
||||
timeout: 10, // Default LCD timeout in seconds
|
||||
vibrate: true, // Vibration enabled by default. App must support
|
||||
beep: "vib", // Beep enabled by default. App must support
|
||||
timezone: 0, // Set the timezone for the device
|
||||
HID: false, // BLE HID mode, off by default
|
||||
clock: null, // a string for the default clock's name
|
||||
"12hour" : false, // 12 or 24 hour clock?
|
||||
brightness: 1, // LCD brightness from 0 to 1
|
||||
// welcomed : undefined/true (whether welcome app should show)
|
||||
options: {
|
||||
wakeOnBTN1: true,
|
||||
wakeOnBTN2: true,
|
||||
wakeOnBTN3: true,
|
||||
wakeOnFaceUp: false,
|
||||
wakeOnTouch: false,
|
||||
wakeOnTwist: true,
|
||||
twistThreshold: 819.2,
|
||||
twistMaxY: -800,
|
||||
twistTimeout: 1000
|
||||
}
|
||||
};
|
||||
updateSettings();
|
||||
}
|
||||
|
||||
settings = storage.readJSON('dane_cfg.json', 1);
|
||||
if (!settings) resetSettings();
|
||||
|
||||
const boolFormat = v => v ? "On" : "Off";
|
||||
|
||||
function showMainMenu() {
|
||||
var beepV = [false, true, "vib"];
|
||||
var beepN = ["Off", "Piezo", "Vibrate"];
|
||||
var hidV = [false, "kbmedia", "kb", "joy"];
|
||||
var hidN = ["Off", "Kbrd & Media", "Kbrd","Joystick"];
|
||||
const mainmenu = {
|
||||
'': { 'title': 'Settings' },
|
||||
'Make Connectable': ()=>makeConnectable(),
|
||||
'App/Widget Settings': ()=>showAppSettingsMenu(),
|
||||
'BLE': ()=>showBLEMenu(),
|
||||
'Debug Info': {
|
||||
value: settings.log,
|
||||
format: v => v ? "Show" : "Hide",
|
||||
onchange: () => {
|
||||
settings.log = !settings.log;
|
||||
updateSettings();
|
||||
}
|
||||
},
|
||||
'Beep': {
|
||||
value: 0 | beepV.indexOf(settings.beep),
|
||||
min: 0, max: 2,
|
||||
format: v => beepN[v],
|
||||
onchange: v => {
|
||||
settings.beep = beepV[v];
|
||||
if (v==1) { analogWrite(D18,0.5,{freq:2000});setTimeout(()=>D18.reset(),200); } // piezo
|
||||
else if (v==2) { analogWrite(D13,0.1,{freq:2000});setTimeout(()=>D13.reset(),200); } // vibrate
|
||||
updateSettings();
|
||||
}
|
||||
},
|
||||
'Vibration': {
|
||||
value: settings.vibrate,
|
||||
format: boolFormat,
|
||||
onchange: () => {
|
||||
settings.vibrate = !settings.vibrate;
|
||||
updateSettings();
|
||||
if (settings.vibrate) {
|
||||
VIBRATE.write(1);
|
||||
setTimeout(() => VIBRATE.write(0), 10);
|
||||
}
|
||||
}
|
||||
},
|
||||
'Locale': ()=>showLocaleMenu(),
|
||||
'Select Clock': ()=>showClockMenu(),
|
||||
'HID': {
|
||||
value: 0 | hidV.indexOf(settings.HID),
|
||||
min: 0, max: 3,
|
||||
format: v => hidN[v],
|
||||
onchange: v => {
|
||||
settings.HID = hidV[v];
|
||||
updateSettings();
|
||||
}
|
||||
},
|
||||
'Set Time': ()=>showSetTimeMenu(),
|
||||
'LCD': ()=>showLCDMenu(),
|
||||
'Reset Settings': ()=>showResetMenu(),
|
||||
'Turn Off': ()=>Bangle.off(),
|
||||
'< Back': ()=>load()
|
||||
};
|
||||
return E.showMenu(mainmenu);
|
||||
}
|
||||
|
||||
|
||||
function showBLEMenu() {
|
||||
E.showMenu({
|
||||
'BLE': {
|
||||
value: settings.ble,
|
||||
format: boolFormat,
|
||||
onchange: () => {
|
||||
settings.ble = !settings.ble;
|
||||
updateSettings();
|
||||
}
|
||||
},
|
||||
'Programmable': {
|
||||
value: settings.blerepl,
|
||||
format: boolFormat,
|
||||
onchange: () => {
|
||||
settings.blerepl = !settings.blerepl;
|
||||
updateSettings();
|
||||
}
|
||||
},
|
||||
'Passkey BETA': {
|
||||
value: settings.passkey?settings.passkey:"none",
|
||||
onchange: () => setTimeout(showPasskeyMenu) // graphical_menu redraws after the call
|
||||
},
|
||||
'Whitelist': {
|
||||
value: settings.whitelist?(settings.whitelist.length+" devs"):"off",
|
||||
onchange: () => setTimeout(showWhitelistMenu) // graphical_menu redraws after the call
|
||||
},
|
||||
'< Back': ()=>showMainMenu()
|
||||
});
|
||||
}
|
||||
|
||||
function showPasskeyMenu() {
|
||||
var menu = {
|
||||
"Disable" : () => {
|
||||
settings.passkey = undefined;
|
||||
updateSettings();
|
||||
showBLEMenu();
|
||||
}
|
||||
};
|
||||
if (!settings.passkey || settings.passkey.length!=6)
|
||||
settings.passkey = "123456";
|
||||
for (var i=0;i<6;i++) (function(i){
|
||||
menu[`Digit ${i+1}`] = {
|
||||
value : 0|settings.passkey[i],
|
||||
min: 0, max: 9,
|
||||
onchange: v => {
|
||||
var p = settings.passkey.split("");
|
||||
p[i] = v;
|
||||
settings.passkey = p.join("");
|
||||
updateSettings();
|
||||
}
|
||||
};
|
||||
})(i);
|
||||
menu['< Back']=()=>showBLEMenu();
|
||||
E.showMenu(menu);
|
||||
}
|
||||
|
||||
function showWhitelistMenu() {
|
||||
var menu = {
|
||||
"Disable" : () => {
|
||||
settings.whitelist = undefined;
|
||||
updateSettings();
|
||||
showBLEMenu();
|
||||
}
|
||||
};
|
||||
if (settings.whitelist) settings.whitelist.forEach(function(d){
|
||||
menu[d.substr(0,17)] = function() {
|
||||
E.showPrompt('Remove\n'+d).then((v) => {
|
||||
if (v) {
|
||||
settings.whitelist.splice(settings.whitelist.indexOf(d),1);
|
||||
updateSettings();
|
||||
}
|
||||
setTimeout(showWhitelistMenu, 50);
|
||||
});
|
||||
}
|
||||
});
|
||||
menu['Add Device']=function() {
|
||||
E.showAlert("Connect device\nto add to\nwhitelist","Whitelist").then(function() {
|
||||
NRF.removeAllListeners('connect');
|
||||
showWhitelistMenu();
|
||||
});
|
||||
NRF.removeAllListeners('connect');
|
||||
NRF.on('connect', function(addr) {
|
||||
if (!settings.whitelist) settings.whitelist=[];
|
||||
settings.whitelist.push(addr);
|
||||
updateSettings();
|
||||
NRF.removeAllListeners('connect');
|
||||
showWhitelistMenu();
|
||||
});
|
||||
};
|
||||
menu['< Back']=()=>showBLEMenu();
|
||||
E.showMenu(menu);
|
||||
}
|
||||
|
||||
function showLCDMenu() {
|
||||
const lcdMenu = {
|
||||
'': { 'title': 'LCD' },
|
||||
'< Back': ()=>showMainMenu(),
|
||||
'LCD Brightness': {
|
||||
value: settings.brightness,
|
||||
min: 0.1,
|
||||
max: 1,
|
||||
step: 0.1,
|
||||
onchange: v => {
|
||||
settings.brightness = v || 1;
|
||||
updateSettings();
|
||||
Bangle.setLCDBrightness(settings.brightness);
|
||||
}
|
||||
},
|
||||
'LCD Timeout': {
|
||||
value: settings.timeout,
|
||||
min: 0,
|
||||
max: 60,
|
||||
step: 5,
|
||||
onchange: v => {
|
||||
settings.timeout = 0 | v;
|
||||
updateSettings();
|
||||
Bangle.setLCDTimeout(settings.timeout);
|
||||
}
|
||||
},
|
||||
'Wake on BTN1': {
|
||||
value: settings.options.wakeOnBTN1,
|
||||
format: boolFormat,
|
||||
onchange: () => {
|
||||
settings.options.wakeOnBTN1 = !settings.options.wakeOnBTN1;
|
||||
updateOptions();
|
||||
}
|
||||
},
|
||||
'Wake on BTN2': {
|
||||
value: settings.options.wakeOnBTN2,
|
||||
format: boolFormat,
|
||||
onchange: () => {
|
||||
settings.options.wakeOnBTN2 = !settings.options.wakeOnBTN2;
|
||||
updateOptions();
|
||||
}
|
||||
},
|
||||
'Wake on BTN3': {
|
||||
value: settings.options.wakeOnBTN3,
|
||||
format: boolFormat,
|
||||
onchange: () => {
|
||||
settings.options.wakeOnBTN3 = !settings.options.wakeOnBTN3;
|
||||
updateOptions();
|
||||
}
|
||||
},
|
||||
'Wake on FaceUp': {
|
||||
value: settings.options.wakeOnFaceUp,
|
||||
format: boolFormat,
|
||||
onchange: () => {
|
||||
settings.options.wakeOnFaceUp = !settings.options.wakeOnFaceUp;
|
||||
updateOptions();
|
||||
}
|
||||
},
|
||||
'Wake on Touch': {
|
||||
value: settings.options.wakeOnTouch,
|
||||
format: boolFormat,
|
||||
onchange: () => {
|
||||
settings.options.wakeOnTouch = !settings.options.wakeOnTouch;
|
||||
updateOptions();
|
||||
}
|
||||
},
|
||||
'Wake on Twist': {
|
||||
value: settings.options.wakeOnTwist,
|
||||
format: boolFormat,
|
||||
onchange: () => {
|
||||
settings.options.wakeOnTwist = !settings.options.wakeOnTwist;
|
||||
updateOptions();
|
||||
}
|
||||
},
|
||||
'Twist Threshold': {
|
||||
value: internalToG(settings.options.twistThreshold),
|
||||
min: -0.5,
|
||||
max: 0.5,
|
||||
step: 0.01,
|
||||
onchange: v => {
|
||||
settings.options.twistThreshold = gToInternal(v || 0.1);
|
||||
updateOptions();
|
||||
}
|
||||
},
|
||||
'Twist Max Y': {
|
||||
value: settings.options.twistMaxY,
|
||||
min: -1500,
|
||||
max: 1500,
|
||||
step: 100,
|
||||
onchange: v => {
|
||||
settings.options.twistMaxY = v || -800;
|
||||
updateOptions();
|
||||
}
|
||||
},
|
||||
'Twist Timeout': {
|
||||
value: settings.options.twistTimeout,
|
||||
min: 0,
|
||||
max: 2000,
|
||||
step: 100,
|
||||
onchange: v => {
|
||||
settings.options.twistTimeout = v || 1000;
|
||||
updateOptions();
|
||||
}
|
||||
}
|
||||
}
|
||||
return E.showMenu(lcdMenu)
|
||||
}
|
||||
|
||||
function showLocaleMenu() {
|
||||
const localemenu = {
|
||||
'': { 'title': 'Locale' },
|
||||
'< Back': ()=>showMainMenu(),
|
||||
'Time Zone': {
|
||||
value: settings.timezone,
|
||||
min: -11,
|
||||
max: 12,
|
||||
step: 0.5,
|
||||
onchange: v => {
|
||||
settings.timezone = v || 0;
|
||||
updateSettings();
|
||||
}
|
||||
},
|
||||
'Clock Style': {
|
||||
value: !!settings["12hour"],
|
||||
format: v => v ? "12hr" : "24hr",
|
||||
onchange: v => {
|
||||
settings["12hour"] = v;
|
||||
updateSettings();
|
||||
}
|
||||
}
|
||||
};
|
||||
return E.showMenu(localemenu);
|
||||
}
|
||||
|
||||
function showResetMenu() {
|
||||
const resetmenu = {
|
||||
'': { 'title': 'Reset' },
|
||||
'< Back': ()=>showMainMenu(),
|
||||
'Reset Settings': () => {
|
||||
E.showPrompt('Reset Settings?').then((v) => {
|
||||
if (v) {
|
||||
E.showMessage('Resetting');
|
||||
resetSettings();
|
||||
}
|
||||
setTimeout(showMainMenu, 50);
|
||||
});
|
||||
}
|
||||
};
|
||||
return E.showMenu(resetmenu);
|
||||
}
|
||||
|
||||
function makeConnectable() {
|
||||
try { NRF.wake(); } catch (e) { }
|
||||
Bluetooth.setConsole(1);
|
||||
var name = "Bangle.js " + NRF.getAddress().substr(-5).replace(":", "");
|
||||
E.showPrompt(name + "\nStay Connectable?", { title: "Connectable" }).then(r => {
|
||||
if (settings.ble != r) {
|
||||
settings.ble = r;
|
||||
updateSettings();
|
||||
}
|
||||
if (!r) try { NRF.sleep(); } catch (e) { }
|
||||
showMainMenu();
|
||||
});
|
||||
}
|
||||
function showClockMenu() {
|
||||
var clockApps = require("Storage").list(/\.info$/)
|
||||
.map(app => {var a=storage.readJSON(app, 1);return (a&&a.type == "clock")?a:undefined})
|
||||
.filter(app => app) // filter out any undefined apps
|
||||
.sort((a, b) => a.sortorder - b.sortorder);
|
||||
const clockMenu = {
|
||||
'': {
|
||||
'title': 'Select Clock',
|
||||
},
|
||||
'< Back': ()=>showMainMenu(),
|
||||
};
|
||||
clockApps.forEach((app, index) => {
|
||||
var label = app.name;
|
||||
if ((!settings.clock && index === 0) || (settings.clock === app.src)) {
|
||||
label = "* " + label;
|
||||
}
|
||||
clockMenu[label] = () => {
|
||||
if (settings.clock !== app.src) {
|
||||
settings.clock = app.src;
|
||||
updateSettings();
|
||||
showMainMenu();
|
||||
}
|
||||
};
|
||||
});
|
||||
if (clockApps.length === 0) {
|
||||
clockMenu["No Clocks Found"] = () => { };
|
||||
}
|
||||
return E.showMenu(clockMenu);
|
||||
}
|
||||
|
||||
function showSetTimeMenu() {
|
||||
d = new Date();
|
||||
const timemenu = {
|
||||
'': { 'title': 'Set Time' },
|
||||
'< Back': function () {
|
||||
setTime(d.getTime() / 1000);
|
||||
showMainMenu();
|
||||
},
|
||||
'Hour': {
|
||||
value: d.getHours(),
|
||||
onchange: function (v) {
|
||||
this.value = (v+24)%24;
|
||||
d.setHours(this.value);
|
||||
}
|
||||
},
|
||||
'Minute': {
|
||||
value: d.getMinutes(),
|
||||
onchange: function (v) {
|
||||
this.value = (v+60)%60;
|
||||
d.setMinutes(this.value);
|
||||
}
|
||||
},
|
||||
'Second': {
|
||||
value: d.getSeconds(),
|
||||
onchange: function (v) {
|
||||
this.value = (v+60)%60;
|
||||
d.setSeconds(this.value);
|
||||
}
|
||||
},
|
||||
'Date': {
|
||||
value: d.getDate(),
|
||||
onchange: function (v) {
|
||||
this.value = ((v+30)%31)+1;
|
||||
d.setDate(this.value);
|
||||
}
|
||||
},
|
||||
'Month': {
|
||||
value: d.getMonth() + 1,
|
||||
onchange: function (v) {
|
||||
this.value = ((v+11)%12)+1;
|
||||
d.setMonth(this.value - 1);
|
||||
}
|
||||
},
|
||||
'Year': {
|
||||
value: d.getFullYear(),
|
||||
min: 2019,
|
||||
max: 2100,
|
||||
onchange: function (v) {
|
||||
d.setFullYear(v);
|
||||
}
|
||||
}
|
||||
};
|
||||
return E.showMenu(timemenu);
|
||||
}
|
||||
|
||||
function showAppSettingsMenu() {
|
||||
let appmenu = {
|
||||
'': { 'title': 'App Settings' },
|
||||
'< Back': ()=>showMainMenu(),
|
||||
}
|
||||
const apps = storage.list(/\.settings\.js$/)
|
||||
.map(s => s.substr(0, s.length-12))
|
||||
.map(id => {
|
||||
const a=storage.readJSON(id+'.info',1) || {name: id};
|
||||
return {id:id,name:a.name,sortorder:a.sortorder};
|
||||
})
|
||||
.sort((a, b) => {
|
||||
const n = (0|a.sortorder)-(0|b.sortorder);
|
||||
if (n) return n; // do sortorder first
|
||||
if (a.name<b.name) return -1;
|
||||
if (a.name>b.name) return 1;
|
||||
return 0;
|
||||
})
|
||||
if (apps.length === 0) {
|
||||
appmenu['No app has settings'] = () => { };
|
||||
}
|
||||
apps.forEach(function (app) {
|
||||
appmenu[app.name] = () => { showAppSettings(app) };
|
||||
})
|
||||
E.showMenu(appmenu)
|
||||
}
|
||||
function showAppSettings(app) {
|
||||
const showError = msg => {
|
||||
E.showMessage(`${app.name}:\n${msg}!\n\nBTN1 to go back`);
|
||||
setWatch(showAppSettingsMenu, BTN1, { repeat: false });
|
||||
}
|
||||
let appSettings = storage.read(app.id+'.settings.js');
|
||||
try {
|
||||
appSettings = eval(appSettings);
|
||||
} catch (e) {
|
||||
console.log(`${app.name} settings error:`, e)
|
||||
return showError('Error in settings');
|
||||
}
|
||||
if (typeof appSettings !== "function") {
|
||||
return showError('Invalid settings');
|
||||
}
|
||||
try {
|
||||
// pass showAppSettingsMenu as "back" argument
|
||||
appSettings(()=>showAppSettingsMenu());
|
||||
} catch (e) {
|
||||
console.log(`${app.name} settings error:`, e)
|
||||
return showError('Error in settings');
|
||||
}
|
||||
}
|
||||
|
||||
showMainMenu();
|
Binary file not shown.
Before Width: | Height: | Size: 1.7 KiB |
Loading…
Reference in New Issue