mirror of https://github.com/espruino/BangleApps
"tap to Cycle" setting
parent
07b53c5893
commit
d760fcdf93
|
@ -5,4 +5,4 @@
|
||||||
0.05: added charging icon
|
0.05: added charging icon
|
||||||
0.06: Add 12h support and autocycle control
|
0.06: Add 12h support and autocycle control
|
||||||
0.07: added localization, removed deprecated code
|
0.07: added localization, removed deprecated code
|
||||||
0.08: removed unused font, fix autocycle, imported suncalc and trimmed, removed pedometer dependency
|
0.08: removed unused font, fix autocycle, imported suncalc and trimmed, removed pedometer dependency, "tap to cycle" setting
|
||||||
|
|
|
@ -37,7 +37,16 @@ function loadLocation() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function loadSettings() {
|
function loadSettings() {
|
||||||
settings = require("Storage").readJSON(SETTINGS_FILE,1)|| {'bg': '#0f0', 'color': 'Green', 'autoCycle': true};
|
settings = require("Storage").readJSON(SETTINGS_FILE,1)|| {'bg': '#0f0', 'color': 'Green', 'autoCycle': true,'sideTap':'on'};
|
||||||
|
|
||||||
|
let settings = {'bg': '#0f0', 'color': 'Green', 'autoCycle': true,'sideTap':'on'};
|
||||||
|
let tmp = require('Storage').readJSON(SETTINGS_FILE, 1) || settings;
|
||||||
|
for (const key in tmp) {
|
||||||
|
settings[key] = tmp[key]
|
||||||
|
}
|
||||||
|
|
||||||
|
if(settings.sideTap!='on')
|
||||||
|
sideBar=parseInt(settings.sideTap)-1; //tab to show
|
||||||
is12Hour = (require("Storage").readJSON(GLOBAL_SETTINGS, 1) || {})["12hour"] || false;
|
is12Hour = (require("Storage").readJSON(GLOBAL_SETTINGS, 1) || {})["12hour"] || false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -251,20 +260,19 @@ function formatSteps() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function nextSidebar() {
|
function nextSidebar() {
|
||||||
|
|
||||||
if (++sideBar > 2) sideBar = 0;
|
if (++sideBar > 2) sideBar = 0;
|
||||||
log_debug("next: " + sideBar);
|
log_debug("next: " + sideBar);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function prevSidebar() {
|
function prevSidebar() {
|
||||||
|
|
||||||
if (--sideBar < 0) sideBar = 2;
|
if (--sideBar < 0) sideBar = 2;
|
||||||
log_debug("prev: " + sideBar);
|
log_debug("prev: " + sideBar);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Bangle.setUI("clockupdown", btn=> {
|
|
||||||
if (btn<0) prevSidebar();
|
|
||||||
if (btn>0) nextSidebar();
|
|
||||||
draw();
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
// timeout used to update every minute
|
// timeout used to update every minute
|
||||||
|
@ -294,6 +302,24 @@ Bangle.loadWidgets();
|
||||||
for (let wd of WIDGETS) {wd.draw=()=>{};wd.area="";}
|
for (let wd of WIDGETS) {wd.draw=()=>{};wd.area="";}
|
||||||
loadSettings();
|
loadSettings();
|
||||||
loadLocation();
|
loadLocation();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if(settings.autoCycle || settings.sideTap=='on')
|
||||||
|
{
|
||||||
|
Bangle.setUI("clockupdown", btn=> {
|
||||||
|
if (btn<0) prevSidebar();
|
||||||
|
if (btn>0) nextSidebar();
|
||||||
|
draw();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
Bangle.setUI("clock");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
draw(); // queues the next draw for a minutes time
|
draw(); // queues the next draw for a minutes time
|
||||||
Bangle.on('charging', function(charging) {
|
Bangle.on('charging', function(charging) {
|
||||||
//redraw the sidebar ( with the battery )
|
//redraw the sidebar ( with the battery )
|
||||||
|
|
|
@ -2,12 +2,13 @@
|
||||||
const SETTINGS_FILE = "rebble.json";
|
const SETTINGS_FILE = "rebble.json";
|
||||||
|
|
||||||
// initialize with default settings...
|
// initialize with default settings...
|
||||||
let localSettings = {'bg': '#0f0', 'color': 'Green', 'autoCycle': true}
|
let localSettings = {'bg': '#0f0', 'color': 'Green', 'autoCycle': true, 'sideTap':'on'};
|
||||||
|
|
||||||
// ...and overwrite them with any saved values
|
// ...and overwrite them with any saved values
|
||||||
// This way saved values are preserved if a new version adds more settings
|
// This way saved values are preserved if a new version adds more settings
|
||||||
const storage = require('Storage')
|
const storage = require('Storage')
|
||||||
let settings = storage.readJSON(SETTINGS_FILE, 1) || localSettings;
|
let settings = storage.readJSON(SETTINGS_FILE, 1) || localSettings;
|
||||||
|
|
||||||
const saved = settings || {}
|
const saved = settings || {}
|
||||||
for (const key in saved) {
|
for (const key in saved) {
|
||||||
localSettings[key] = saved[key]
|
localSettings[key] = saved[key]
|
||||||
|
@ -21,26 +22,71 @@
|
||||||
var color_options = ['Green','Orange','Cyan','Purple','Red','Blue'];
|
var color_options = ['Green','Orange','Cyan','Purple','Red','Blue'];
|
||||||
var bg_code = ['#0f0','#ff0','#0ff','#f0f','#f00','#00f'];
|
var bg_code = ['#0f0','#ff0','#0ff','#f0f','#f00','#00f'];
|
||||||
|
|
||||||
E.showMenu({
|
function showMenu()
|
||||||
'': { 'title': 'Rebble Clock' },
|
{
|
||||||
'< Back': back,
|
const menu={
|
||||||
'Colour': {
|
'': { 'title': 'Rebble Clock' },
|
||||||
value: 0 | color_options.indexOf(localSettings.color),
|
'< Back': back,
|
||||||
min: 0, max: 5,
|
'Colour': {
|
||||||
format: v => color_options[v],
|
value: 0 | color_options.indexOf(localSettings.color),
|
||||||
onchange: v => {
|
min: 0, max: 5,
|
||||||
localSettings.color = color_options[v];
|
format: v => color_options[v],
|
||||||
localSettings.bg = bg_code[v];
|
onchange: v => {
|
||||||
save();
|
localSettings.color = color_options[v];
|
||||||
|
localSettings.bg = bg_code[v];
|
||||||
|
save();
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
'Auto Cycle': {
|
||||||
'Auto Cycle': {
|
value: localSettings.autoCycle,
|
||||||
value: "autoCycle" in localSettings ? localSettings.autoCycle : true,
|
onchange: (v) => {
|
||||||
format: () => (localSettings.autoCycle ? 'Yes' : 'No'),
|
localSettings.autoCycle = v;
|
||||||
onchange: () => {
|
save();
|
||||||
localSettings.autoCycle = !localSettings.autoCycle;
|
showMenu();
|
||||||
save();
|
}
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
if( !localSettings.autoCycle)
|
||||||
|
{
|
||||||
|
menu['Tap to Cycle']={
|
||||||
|
value: localSettings.sideTap,
|
||||||
|
onchange: () => setTimeout(showTapMenu, 100, changedValue => {
|
||||||
|
localSettings.sideTap=changedValue;
|
||||||
|
save();
|
||||||
|
setTimeout(showMenu, 10);
|
||||||
|
})
|
||||||
|
};
|
||||||
}
|
}
|
||||||
});
|
E.showMenu(menu);
|
||||||
|
}
|
||||||
|
|
||||||
|
function showTapMenu(changeCallback)
|
||||||
|
{
|
||||||
|
var current = localSettings.sideTap;
|
||||||
|
const menu = {
|
||||||
|
"": { "title": /*LANG*/"Tap to Cycle" },
|
||||||
|
"< Back": () => changeCallback(current),
|
||||||
|
"on": { // No days set: the alarm will fire once
|
||||||
|
value: current == 'on',
|
||||||
|
onchange: () => changeCallback('on')
|
||||||
|
},
|
||||||
|
"1": {
|
||||||
|
value: current == '1',
|
||||||
|
onchange: () => changeCallback('1')
|
||||||
|
},
|
||||||
|
"2": {
|
||||||
|
value: current == '2',
|
||||||
|
onchange: () => changeCallback('2')
|
||||||
|
},
|
||||||
|
"3": {
|
||||||
|
value: current == '3',
|
||||||
|
onchange: () => changeCallback('3')
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
E.showMenu(menu);
|
||||||
|
}
|
||||||
|
|
||||||
|
showMenu();
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue