I really prefer TouchMenu over the default settings page. For some reason though, it messes with my app´s own settings menu. As far as i know, TouchMenu just replaces the built in E.showMenu with some custom functions. My app does not use E.showMenu, but somehow parts of the TouchMenu are still drawn. Here is my settings code:
(function(back) {
Bangle.setUI("");
var settings = require('Storage').readJSON("contourclock.json", true) || {};
if (settings.fontIndex==undefined) {
settings.fontIndex=0;
require('Storage').writeJSON("myapp.json", settings);
}
savedIndex=settings.fontIndex;
setWatch(function() { //save changes and return to settings menu
require('Storage').writeJSON("contourclock.json", settings);
g.clear();
back();
}, BTN, { repeat:false, edge:'falling' });
Bangle.on('lock', function () { //discard changes and return to clock
settings.fontIndex=savedIndex;
require('Storage').writeJSON("contourclock.json", settings);
g.clear();
load();
});
Bangle.on('swipe', function (direction) {
g.clearRect(0,24,g.getWidth()-1,137);
var fontName = require('contourclock').drawClock(settings.fontIndex+direction);
if (fontName) {
settings.fontIndex+=direction;
g.clearRect(0,0,g.getWidth()-1,16);
g.setFontAlign(0,-1).drawString(fontName,g.getWidth()/2,0);
}
});
g.reset();
g.clear();
g.setFont("6x8:2x2").setFontAlign(0,-1);
g.drawString(require('contourclock').drawClock(settings.fontIndex),g.getWidth()/2,0);
g.drawString("Swipe - change",g.getWidth()/2,g.getHeight()-36);
g.drawString("BTN - save",g.getWidth()/2,g.getHeight()-18);
})
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
I really prefer TouchMenu over the default settings page. For some reason though, it messes with my app´s own settings menu. As far as i know, TouchMenu just replaces the built in E.showMenu with some custom functions. My app does not use E.showMenu, but somehow parts of the TouchMenu are still drawn. Here is my settings code: