cleanup code and fix fastload issue

master
Rarder44 2022-11-18 17:18:59 +01:00
parent 35668fd853
commit c6255ce9c8
3 changed files with 55 additions and 44 deletions

View File

@ -11,3 +11,4 @@
0.11: fix issue https://github.com/espruino/BangleApps/issues/2128 (#2128) ( settings undefined ) 0.11: fix issue https://github.com/espruino/BangleApps/issues/2128 (#2128) ( settings undefined )
0.12: implemented widget_utils 0.12: implemented widget_utils
0.13: convert var/function into let 0.13: convert var/function into let
0.14: cleanup code and fix fastload issue

View File

@ -2,7 +2,7 @@
"id": "rebble", "id": "rebble",
"name": "Rebble Clock", "name": "Rebble Clock",
"shortName": "Rebble", "shortName": "Rebble",
"version": "0.13", "version": "0.14",
"description": "A Pebble style clock, with configurable background, three sidebars including steps, day, date, sunrise, sunset, long live the rebellion", "description": "A Pebble style clock, with configurable background, three sidebars including steps, day, date, sunrise, sunset, long live the rebellion",
"readme": "README.md", "readme": "README.md",
"icon": "rebble.png", "icon": "rebble.png",

View File

@ -291,48 +291,8 @@ Graphics.prototype.setFontKdamThmor = function(scale) {
} }
log_debug("starting..");
loadSettings();
loadLocation();
let chargingListener= function(charging) {
if(settings.autoCycle || settings.sideTap==0)
{
Bangle.setUI({
mode : "clockupdown",
remove : function() {
// Called to unload all of the clock app
if (drawTimeout) clearTimeout(drawTimeout);
drawTimeout = undefined;
delete Graphics.prototype.setFontKdamThmor;
}},
btn=> {
if (btn<0) prevSidebar();
if (btn>0) nextSidebar();
draw();
});
}
else{
Bangle.setUI({
mode : "clock",
remove : function() {
// Called to unload all of the clock app
if (drawTimeout) clearTimeout(drawTimeout);
drawTimeout = undefined;
delete Graphics.prototype.setFontKdamThmor;
}});
}
Bangle.loadWidgets();
draw();
require("widget_utils").hide();
Bangle.on('charging', function(charging) {
//redraw the sidebar ( with the battery ) //redraw the sidebar ( with the battery )
switch(sideBar) { switch(sideBar) {
@ -343,5 +303,55 @@ Graphics.prototype.setFontKdamThmor = function(scale) {
drawSideBar2(); drawSideBar2();
break; break;
} }
}
let deleteAll=function()
{
// Called to unload all of the clock app
if (drawTimeout) clearTimeout(drawTimeout);
drawTimeout = undefined;
delete Graphics.prototype.setFontKdamThmor;
Bangle.removeListener('charging',chargingListener);
}
let main=function(){
log_debug("starting..");
loadSettings();
loadLocation();
if(settings.autoCycle || settings.sideTap==0)
{
Bangle.setUI({
mode : "clockupdown",
remove : deleteAll
},
btn=> {
if (btn<0) prevSidebar();
if (btn>0) nextSidebar();
draw();
}); });
}
else{
Bangle.setUI({
mode : "clock",
remove : deleteAll
});
}
Bangle.on('charging',chargingListener);
Bangle.loadWidgets();
draw();
require("widget_utils").hide();
}
main();
} }