SUwX~k)2OK;nI
z?>T$ez5;fH*2l^|NqzBXP>>#hCvMCmkk*RQvG1&7{vD?=!~w=HaxmW
zayK7#Tg&wZI?a3c0~ryiMr^%a3O0Z5rk>>{89?Vhe~x*847~D!+j8zVaQ3n334P__
z!T>aY4ghDb7>EY`(|by`xh>|6rbxHWorvg4AO)oiuV=MPD>>R@v2hk-d8Ps*A~KB#
zi+k1Bes>nO^9VvA;K!IpC9mwu{=7x?7SfOAR089}LJqNXU5NV8^QF&||n;0a4tO78j_-D;p3xVo40QH0evzJE*J+jUX#
zeR$7kJfVkB9s#m?DXW&;^*Q}e@$jGx)0u>O=FddZQ21
zfXXg}RRsJSq@cVl8eehk#JY7}HsU-0*29sr(h$gC`Jtj7$2~c26(f@yBf~8S>rnGA
z$t|ml)k{K03ElC)5JK$*owLGpfbI2D*?FSp3Hn`T1=B9xd0Kie$|~@!l^JjOQ`1EW|iDt_O%)}etut{J8|*C8(q~L
zh@JSnVz7aq8?HW&`c!@qDzElkM3Fqdd9_=b?!AQ;{(d52eF`M^BN@WtHu-z`=Wgh_
z(t!SL)+j<|4=^S?-qv^m5K=NOicpn0kO{JM)A2;L6J7(lvz`d^fz}q9>uYJQ
zKSrSSRKy@1jWK1qq%bK_{lph>+t6je)bNlU=%A_gTP_%u_Q{a6^es)b-(Uv=-Ny-&
z@V75bR6enz#KMBR5nUS|Gmb;Uw+HbJN!gyhu6jB^
z9v^W%Lb@nF9m7V#%>&K#wOGESjgjU7(o3smS>k!8<%e^wg@$0sJG!7?WISGCZa|kT
zu`se0xI8@WZ~Rf!IA!T22maXG*!1<)e{w>>4Q(g?A9-HN!qQSLER1}<`bF$B;NSCX
z*Z1og1X@q26KH=cz2v~`{)T6iR?i8x``-+14G(6RVw=)_^`$a2Ki@!^hdd
zfYWyJ$A6}+sr*YUT+R24e>rtz=3^dTa`?Zli2Om8mcJVNs|=rKvbp
z^8jgY?|(AT+*GW_*kNHo^`%&N64(bMWQRKDr@p?sI9`U-*LN4&9c_<+gw94arklN}
zF1EtBA424{&fn&Vq?dQRe>zoP^XXU{Z=S*gfg8YNf@A<*gp;T?0##sDT53KVojv6%
z5z(YqK6yCt(1O5pYkDn3u_b|jd1HB^?Xcu&+
zVtrHR=^ln%H`gvA9-Yf~Zad()>e5xTSyop*wcCVm@IKRh7EKUu3Is
zCMoMZXr;9#Qqaj$`6hbnHunEOPS1zZ|0jSBB6
zvgWdJlXu5M5K{wHRaHsDy-oLv>f^u-VX5Q5XTTSV)>z1Qc2G~WdNTX~!)YGs@sjCa
zF1HNVsBkmF6qHeC7?gc#v7*IJUz3xQ6Lh@+Rh91#{dXT{uh|<=ebb1PUOH~_UJ;4u
z{jI9j@tR#X8_UcSG?5RF7%W00000NkvXXu0mjfg?9%b
literal 0
HcmV?d00001
diff --git a/apps/sevenmin/metadata.json b/apps/sevenmin/metadata.json
new file mode 100644
index 0000000000..f39b23bce7
--- /dev/null
+++ b/apps/sevenmin/metadata.json
@@ -0,0 +1,16 @@
+{ "id": "sevenmin",
+ "name": "Seven minute workout",
+ "shortName": "7 min wo",
+ "version": "0.01",
+ "description": "A basic implementation of the famous consice workout",
+ "icon": "icon.png",
+ "type":"app",
+ "tags": "Training, Workout",
+ "supports": ["BANGLEJS2"],
+ "readme": "README.md",
+ "allow_emulator":true,
+ "storage": [
+ {"name":"sevenmin.app.js", "url":"app.js"},
+ {"name":"sevenmin.img", "url":"app-icon.js","evaluate":true}
+ ]
+}
From 65e240dc4e9a138f8655ac0b91c38b5a2866f2db Mon Sep 17 00:00:00 2001
From: Rarder44
Date: Fri, 18 Nov 2022 00:15:12 +0100
Subject: [PATCH 2/6] convert var -> let convert function -> let
---
apps/rebble/rebble.app.js | 557 +++++++++++++++++----------------
apps/rebble/rebble.settings.js | 8 +-
2 files changed, 292 insertions(+), 273 deletions(-)
diff --git a/apps/rebble/rebble.app.js b/apps/rebble/rebble.app.js
index 82e4a62d75..6bdb8ff03c 100644
--- a/apps/rebble/rebble.app.js
+++ b/apps/rebble/rebble.app.js
@@ -1,11 +1,3 @@
-var SunCalc = require("suncalc");
-const SETTINGS_FILE = "rebble.json";
-const LOCATION_FILE = "mylocation.json";
-const GLOBAL_SETTINGS = "setting.json";
-let settings;
-let location;
-let is12Hour;
-
Graphics.prototype.setFontKdamThmor = function(scale) {
// Actual height 70 (69 - 0)
this.setFontCustom(
@@ -17,312 +9,339 @@ Graphics.prototype.setFontKdamThmor = function(scale) {
return this;
}
-var boot_img = require("heatshrink").decompress(atob("oFAwkEogA/AH4A/AH4A/AH4A/AE8AAAoeXoAfeDQUBmcyD7A+Dh///8QD649CiAfaHwUvD4sEHy0DDYIfEICg+Cn4fHICY+DD4nxcgojOHwgfEIAYfRCIQaDD4ZAFD5r7DH4//kAfRCIZ/GAAnwD5p9DX44fTHgYSBf4ofVDAQEBl4fFUAgfOXoQzBgIfFBAIfPP4RAEAoYAB+cRiK/SG4h/WIBAfXIA7CBAAswD55AHn6fUIBMCD65AHl4gCmcziAfQQJqfQQJpiDgk0IDXxQLRAEECaBM+QgRYRYgUIA0CD4ggSQJiDCiAKBICszAAswD55AHABKBVD7BAFABIqBD5pAFABPxD55AOD6BADiIAJQAyxLABwf/gaAPAH4A/AH4ARA=="));
-var sunrise_img = require("heatshrink").decompress(atob("oFAwkEogA/AH4A/AH4A/AH4ACp5A/AH4A/AH4AIoEAggfcgAABD/4f/D/4f/CiNPmgfUoYIHoEAggfSoEQgYJGmAUJD5QJBgQ/IIBBKJChiVSCYR1LBZAzTICQyNICAxOICAwPD40xA4UTc5xAFiAuDiAWCAAMBc5hgHDxAgFeCKEDh//AAPwdiKDHh9PD4X0EAX0DyQ+BHoYgFh4+UDwofB/68OAAlBHw6CEQKITBDxAABMCReHUQhgSLxRgDDx9CD4g8DD4sUbqEUH5SABUB4fBDxYfKkQAFkEAiQJGAAcjgECBQ6qBAH4A9Y5wA/AH4Aw"));
-var sunset_img = require("heatshrink").decompress(atob("oFAwkEogA/AH4A/AH4A/AH4A/AH4A/AH4AMoEAggfcgAABD/4f/D/4f/CqU0D6lDBA9AgEED6VAiEDBI0wChIfKBIMCH5BAIJRIUMSqQTCOpYLIGaZASGRpAQGJxAQGB4fGmIHCibnOIAsQFwcQCwQABgLnMMA4eIEArwRQgY0DAwwARC44gC+geSORJ8PHw4KTABFBGhRAT+AzLgEPLzZgUKRhgBDx9CD50UbqARMUCBROD5MiAAsggESBIwADkcAgQKHVQIA/AHrHOAH4A/AGA"));
-var drawCount = 0;
-var sideBar = 0;
-var sunRise = "00:00";
-var sunSet = "00:00";
+{
+ let SunCalc = require("suncalc");
+ const SETTINGS_FILE = "rebble.json";
+ const LOCATION_FILE = "mylocation.json";
+ const GLOBAL_SETTINGS = "setting.json";
+ let settings;
+ let location;
+ let is12Hour;
-function log_debug(o) {
- //console.log(o);
-
-}
-// requires the myLocation app
-function loadLocation() {
- location = require("Storage").readJSON(LOCATION_FILE,1)||{"lat":51.5072,"lon":0.1276,"location":"London"};
-}
-function loadSettings() {
- settings = {'bg': '#0f0', 'color': 'Green', 'autoCycle': true,'sideTap':0};
- //sideTap 0 = on | 1 = sidebar1...
+ let boot_img = require("heatshrink").decompress(atob("oFAwkEogA/AH4A/AH4A/AH4A/AE8AAAoeXoAfeDQUBmcyD7A+Dh///8QD649CiAfaHwUvD4sEHy0DDYIfEICg+Cn4fHICY+DD4nxcgojOHwgfEIAYfRCIQaDD4ZAFD5r7DH4//kAfRCIZ/GAAnwD5p9DX44fTHgYSBf4ofVDAQEBl4fFUAgfOXoQzBgIfFBAIfPP4RAEAoYAB+cRiK/SG4h/WIBAfXIA7CBAAswD55AHn6fUIBMCD65AHl4gCmcziAfQQJqfQQJpiDgk0IDXxQLRAEECaBM+QgRYRYgUIA0CD4ggSQJiDCiAKBICszAAswD55AHABKBVD7BAFABIqBD5pAFABPxD55AOD6BADiIAJQAyxLABwf/gaAPAH4A/AH4ARA=="));
+ let sunrise_img = require("heatshrink").decompress(atob("oFAwkEogA/AH4A/AH4A/AH4ACp5A/AH4A/AH4AIoEAggfcgAABD/4f/D/4f/CiNPmgfUoYIHoEAggfSoEQgYJGmAUJD5QJBgQ/IIBBKJChiVSCYR1LBZAzTICQyNICAxOICAwPD40xA4UTc5xAFiAuDiAWCAAMBc5hgHDxAgFeCKEDh//AAPwdiKDHh9PD4X0EAX0DyQ+BHoYgFh4+UDwofB/68OAAlBHw6CEQKITBDxAABMCReHUQhgSLxRgDDx9CD4g8DD4sUbqEUH5SABUB4fBDxYfKkQAFkEAiQJGAAcjgECBQ6qBAH4A9Y5wA/AH4Aw"));
+ let sunset_img = require("heatshrink").decompress(atob("oFAwkEogA/AH4A/AH4A/AH4A/AH4A/AH4AMoEAggfcgAABD/4f/D/4f/CqU0D6lDBA9AgEED6VAiEDBI0wChIfKBIMCH5BAIJRIUMSqQTCOpYLIGaZASGRpAQGJxAQGB4fGmIHCibnOIAsQFwcQCwQABgLnMMA4eIEArwRQgY0DAwwARC44gC+geSORJ8PHw4KTABFBGhRAT+AzLgEPLzZgUKRhgBDx9CD50UbqARMUCBROD5MiAAsggESBIwADkcAgQKHVQIA/AHrHOAH4A/AGA"));
+
+ let drawCount = 0;
+ let sideBar = 0;
+ let sunRise = "00:00";
+ let sunSet = "00:00";
- let tmp = require('Storage').readJSON(SETTINGS_FILE, 1) || settings;
- for (const key in tmp) {
- settings[key] = tmp[key]
+ function log_debug(o) {
+ //console.log(o);
+
}
- if(settings.sideTap!=0)
- sideBar=parseInt(settings.sideTap)-1; //tab to show
- is12Hour = (require("Storage").readJSON(GLOBAL_SETTINGS, 1) || {})["12hour"] || false;
-}
+ // requires the myLocation app
+ let loadLocation= function() {
+ location = require("Storage").readJSON(LOCATION_FILE,1)||{"lat":51.5072,"lon":0.1276,"location":"London"};
+ }
-const zeroPad = (num, places) => String(num).padStart(places, '0')
+ let loadSettings=function() {
+ settings = {'bg': '#0f0', 'color': 'Green', 'autoCycle': true,'sideTap':0};
+ //sideTap 0 = on | 1 = sidebar1...
-function formatHours(h) {
- if (is12Hour) {
- if (h == 0) {
- h = 12;
- } else if (h > 12) {
- h -= 12;
+ let tmp = require('Storage').readJSON(SETTINGS_FILE, 1) || settings;
+ for (const key in tmp) {
+ settings[key] = tmp[key]
}
+
+ if(settings.sideTap!=0)
+ sideBar=parseInt(settings.sideTap)-1; //tab to
+ is12Hour = (require("Storage").readJSON(GLOBAL_SETTINGS, 1) || {})["12hour"] || false;
}
- return zeroPad(h, 2);
-}
-function extractTime(d){
- var h = d.getHours(), m = d.getMinutes();
- return(formatHours(h) + ":" + zeroPad(m, 2));
-}
+ const zeroPad = (num, places) => String(num).padStart(places, '0')
-function updateSunRiseSunSet(lat, lon){
- // get today's sunlight times for lat/lon
- var times = SunCalc.getTimes(new Date(), lat, lon);
+ let formatHours=function(h) {
+ if (is12Hour) {
+ if (h == 0) {
+ h = 12;
+ } else if (h > 12) {
+ h -= 12;
+ }
+ }
+ return zeroPad(h, 2);
+ }
- // format sunrise time from the Date object
- sunRise = extractTime(times.sunrise);
- sunSet = extractTime(times.sunset);
-}
+ let extractTime=function(d){
+ let h = d.getHours(), m = d.getMinutes();
+ return(formatHours(h) + ":" + zeroPad(m, 2));
+ }
-// wrapper, makes it easier if we want to switch to a different font later
-function setSmallFont() {
- g.setFont('Vector', 20);
-}
+ let updateSunRiseSunSet=function(lat, lon){
+ // get today's sunlight times for lat/lon
+ let times = SunCalc.getTimes(new Date(), lat, lon);
-// set the text color of the sidebar elements that dont change with the Theme
-function setTextColor() {
- // day and steps
- if (settings.color == 'Blue' || settings.color == 'Red') {
- g.setColor('#fff'); // white on blue or red best contrast
- } else {
- g.setColor('#000'); // otherwise black regardless of theme
+ // format sunrise time from the Date object
+ sunRise = extractTime(times.sunrise);
+ sunSet = extractTime(times.sunset);
}
-}
-const h = g.getHeight();
-const w = g.getWidth();
-const ha = 2*h/5 - 8;
-const h2 = 3*h/5 - 10;
-const h3 = 7*h/8;
-const w2 = 9*w/14;
-const w3 = w2 + ((w - w2)/2); // centre line of the sidebar
-const ws = w - w2; // sidebar width
-const wb = 40; // battery width
-
-function draw() {
- log_debug("draw()");
- let date = new Date();
- let hh = date.getHours();
- let mm = date.getMinutes();
-
- hh = formatHours(hh);
- mm = zeroPad(mm,2);
-
- //const t = 6;
-
- if (drawCount % 60 == 0)
- updateSunRiseSunSet(location.lat, location.lon);
-
- g.reset();
- g.setColor(g.theme.bg);
- g.fillRect(0, 0, w2, h);
- g.setColor(settings.bg);
- g.fillRect(w2, 0, w, h);
-
- // time
- g.setColor(g.theme.fg);
- g.setFontKdamThmor();
- g.setFontAlign(0, -1);
- g.drawString(hh, w2/2, 10 + 0);
- g.drawString(mm, w2/2, 10 + h/2);
-
- switch(sideBar) {
- case 0:
- drawSideBar1();
- break;
- case 1:
- drawSideBar2();
- break;
- case 2:
- drawSideBar3();
- break;
+ // wrapper, makes it easier if we want to switch to a different font later
+ let setSmallFont=function() {
+ g.setFont('Vector', 20);
}
-
- drawCount++;
- queueDraw();
-}
-function drawSideBar1() {
- let date = new Date();
- let dy=require("date_utils").dow(date.getDay(),1).toUpperCase();
- let dd=date.getDate();
- let mm=require("date_utils").month(date.getMonth()+1,1).toUpperCase();
-
-
- drawBattery(w2 + (w-w2-wb)/2, h/10, wb, 17);
-
- setTextColor();
- g.setFont('Vector', 20);
- g.setFontAlign(0, -1);
- g.drawString(E.getBattery() + '%', w3, (h/10) + 17 + 7);
-
- drawDateAndCalendar(w3, h/2, dy, dd, mm);
-}
+ // set the text color of the sidebar elements that dont change with the Theme
+ let setTextColor=function() {
+ // day and steps
+ if (settings.color == 'Blue' || settings.color == 'Red') {
+ g.setColor('#fff'); // white on blue or red best contrast
+ } else {
+ g.setColor('#000'); // otherwise black regardless of theme
+ }
+ }
-function drawSideBar2() {
- drawBattery(w2 + (w-w2-wb)/2, h/10, wb, 17);
+ const h = g.getHeight();
+ const w = g.getWidth();
+ /*const ha = 2*h/5 - 8;
+ const h2 = 3*h/5 - 10;
+ const h3 = 7*h/8;*/
+ const w2 = 9*w/14;
+ const w3 = w2 + ((w - w2)/2); // centre line of the sidebar
+ const ws = w - w2; // sidebar width
+ const wb = 40; // battery width
+
+ let draw=function() {
+ log_debug("draw()");
+ let date = new Date();
+ let hh = date.getHours();
+ let mm = date.getMinutes();
+
+ hh = formatHours(hh);
+ mm = zeroPad(mm,2);
+
+ //const t = 6;
+
+ if (drawCount % 60 == 0)
+ updateSunRiseSunSet(location.lat, location.lon);
+
+ g.reset();
+ g.setColor(g.theme.bg);
+ g.fillRect(0, 0, w2, h);
+ g.setColor(settings.bg);
+ g.fillRect(w2, 0, w, h);
+
+ // time
+ g.setColor(g.theme.fg);
+ g.setFontKdamThmor();
+ g.setFontAlign(0, -1);
+ g.drawString(hh, w2/2, 10 + 0);
+ g.drawString(mm, w2/2, 10 + h/2);
+
+ switch(sideBar) {
+ case 0:
+ drawSideBar1();
+ break;
+ case 1:
+ drawSideBar2();
+ break;
+ case 2:
+ drawSideBar3();
+ break;
+ }
+
+ drawCount++;
+ queueDraw();
+ }
- setTextColor();
- g.setFont('Vector', 20);
- g.setFontAlign(0, -1);
- g.drawString(E.getBattery() + '%', w3, (h/10) + 17 + 7);
+ let drawSideBar1=function() {
+ let date = new Date();
+ let dy=require("date_utils").dow(date.getDay(),1).toUpperCase();
+ let dd=date.getDate();
+ let mm=require("date_utils").month(date.getMonth()+1,1).toUpperCase();
+
+
+ drawBattery(w2 + (w-w2-wb)/2, h/10, wb, 17);
+
+ setTextColor();
+ g.setFont('Vector', 20);
+ g.setFontAlign(0, -1);
+ g.drawString(E.getBattery() + '%', w3, (h/10) + 17 + 7);
+
+ drawDateAndCalendar(w3, h/2, dy, dd, mm);
+ }
- // steps
- g.drawImage(boot_img, w2 + (ws - 64)/2, h/2, { scale: 1 });
- setSmallFont();
- g.setFontAlign(0, -1);
- g.drawString(formatSteps(), w3, 7*h/8);
-}
+ let drawSideBar2=function() {
+ drawBattery(w2 + (w-w2-wb)/2, h/10, wb, 17);
-// sunrise, sunset times
-function drawSideBar3() {
- g.setColor('#fff'); // sunrise white
- g.drawImage(sunrise_img, w2 + (ws - 64)/2, 0, { scale: 1 });
- setTextColor();
- setSmallFont();
- g.setFontAlign(0, -1);
- g.drawString(sunRise, w3, 64);
-
- g.setColor('#000'); // sunset black
- g.drawImage(sunset_img, w2 + (ws - 64)/2, h/2, { scale: 1 });
- setTextColor();
- setSmallFont();
- g.setFontAlign(0, -1);
- g.drawString(sunSet, w3, (h/2) + 64);
-}
+ setTextColor();
+ g.setFont('Vector', 20);
+ g.setFontAlign(0, -1);
+ g.drawString(E.getBattery() + '%', w3, (h/10) + 17 + 7);
-function drawDateAndCalendar(x,y,dy,dd,mm) {
- // day
- setTextColor();
- setSmallFont();
- g.setFontAlign(0, -1);
- g.drawString(dy.toUpperCase(), x, y);
+ // steps
+ g.drawImage(boot_img, w2 + (ws - 64)/2, h/2, { scale: 1 });
+ setSmallFont();
+ g.setFontAlign(0, -1);
+ g.drawString(formatSteps(), w3, 7*h/8);
+ }
- drawCalendar(x - (w/10), y + 28, w/5, 3, dd);
+ // sunrise, sunset times
+ let drawSideBar3=function() {
+ g.setColor('#fff'); // sunrise white
+ g.drawImage(sunrise_img, w2 + (ws - 64)/2, 0, { scale: 1 });
+ setTextColor();
+ setSmallFont();
+ g.setFontAlign(0, -1);
+ g.drawString(sunRise, w3, 64);
+
+ g.setColor('#000'); // sunset black
+ g.drawImage(sunset_img, w2 + (ws - 64)/2, h/2, { scale: 1 });
+ setTextColor();
+ setSmallFont();
+ g.setFontAlign(0, -1);
+ g.drawString(sunSet, w3, (h/2) + 64);
+ }
- // month
- setTextColor();
- setSmallFont();
- g.setFontAlign(0, -1);
- g.drawString(mm.toUpperCase(), x, y + 70);
-}
+ let drawDateAndCalendar=function(x,y,dy,dd,mm) {
+ // day
+ setTextColor();
+ setSmallFont();
+ g.setFontAlign(0, -1);
+ g.drawString(dy.toUpperCase(), x, y);
-// at x,y width:wi thicknes:th
-function drawCalendar(x,y,wi,th,str) {
- g.setColor(g.theme.fg);
- g.fillRect(x, y, x + wi, y + wi);
- g.setColor(g.theme.bg);
- g.fillRect(x + th, y + th, x + wi - th, y + wi - th);
- g.setColor(g.theme.fg);
-
- let hook_t = 6;
- // first calendar hook, one third in
- g.fillRect(x + (wi/3) - (th/2), y - hook_t, x + wi/3 + th - (th/2), y + hook_t);
- // second calendar hook, two thirds in
- g.fillRect(x + (2*wi/3) -(th/2), y - hook_t, x + 2*wi/3 + th - (th/2), y + hook_t);
-
- setSmallFont();
- g.setFontAlign(0, 0);
- g.drawString(str, x + wi/2 + th/2, y + wi/2 + th/2);
-}
+ drawCalendar(x - (w/10), y + 28, w/5, 3, dd);
-function drawBattery(x,y,wi,hi) {
- g.reset();
- g.setColor(g.theme.fg);
- g.fillRect(x,y+2,x+wi-4,y+2+hi); // outer
- g.clearRect(x+2,y+2+2,x+wi-4-2,y+2+hi-2); // centre
- g.setColor(g.theme.fg);
- g.fillRect(x+wi-3,y+2+(((hi - 1)/2)-1),x+wi-2,y+2+(((hi - 1)/2)-1)+4); // contact
- g.fillRect(x+3, y+5, x +3 + E.getBattery()*(wi-10)/100, y+hi-1); // the level
+ // month
+ setTextColor();
+ setSmallFont();
+ g.setFontAlign(0, -1);
+ g.drawString(mm.toUpperCase(), x, y + 70);
+ }
- if( Bangle.isCharging() )
- {
- g.setBgColor(settings.bg);
- image = ()=> { return require("heatshrink").decompress(atob("j8OwMB/4AD94DC44DCwP//n/gH//EOgE/+AdBh/gAYMH4EAvkDAYP/+/AFAX+FgfzGAnAA=="));}
- g.drawImage(image(),x+3,y+4);
+ // at x,y width:wi thicknes:th
+ let drawCalendar=function(x,y,wi,th,str) {
+ g.setColor(g.theme.fg);
+ g.fillRect(x, y, x + wi, y + wi);
+ g.setColor(g.theme.bg);
+ g.fillRect(x + th, y + th, x + wi - th, y + wi - th);
+ g.setColor(g.theme.fg);
+
+ let hook_t = 6;
+ // first calendar hook, one third in
+ g.fillRect(x + (wi/3) - (th/2), y - hook_t, x + wi/3 + th - (th/2), y + hook_t);
+ // second calendar hook, two thirds in
+ g.fillRect(x + (2*wi/3) -(th/2), y - hook_t, x + 2*wi/3 + th - (th/2), y + hook_t);
+
+ setSmallFont();
+ g.setFontAlign(0, 0);
+ g.drawString(str, x + wi/2 + th/2, y + wi/2 + th/2);
}
-}
-
-// format steps so they fit in the place
-function formatSteps() {
- var s = Bangle.getHealthStatus("day").steps;
-
- if (s < 1000) {
- return s + '';
- } else if (s < 10000) {
- return '' + (s/1000).toFixed(1) + 'K';
+ let drawBattery=function(x,y,wi,hi) {
+ g.reset();
+ g.setColor(g.theme.fg);
+ g.fillRect(x,y+2,x+wi-4,y+2+hi); // outer
+ g.clearRect(x+2,y+2+2,x+wi-4-2,y+2+hi-2); // centre
+ g.setColor(g.theme.fg);
+ g.fillRect(x+wi-3,y+2+(((hi - 1)/2)-1),x+wi-2,y+2+(((hi - 1)/2)-1)+4); // contact
+ g.fillRect(x+3, y+5, x +3 + E.getBattery()*(wi-10)/100, y+hi-1); // the level
+
+ log_debug("Charging "+Bangle.isCharging());
+ if( Bangle.isCharging() )
+ {
+ g.setBgColor(settings.bg);
+ image = ()=> { return require("heatshrink").decompress(atob("j8OwMB/4AD94DC44DCwP//n/gH//EOgE/+AdBh/gAYMH4EAvkDAYP/+/AFAX+FgfzGAnAA=="));}
+ g.drawImage(image(),x+3,y+4);
+ }
+
+ }
+
+ // format steps so they fit in the place
+ let formatSteps=function() {
+ let s = Bangle.getHealthStatus("day").steps;
+
+ if (s < 1000) {
+ return s + '';
+ } else if (s < 10000) {
+ return '' + (s/1000).toFixed(1) + 'K';
+ }
+ return Math.floor(s / 1000) + 'K';
}
- return Math.floor(s / 1000) + 'K';
-}
-function nextSidebar() {
-
- if (++sideBar > 2) sideBar = 0;
- log_debug("next: " + sideBar);
-
-}
+ let nextSidebar=function() {
+ if (++sideBar > 2) sideBar = 0;
+ log_debug("next: " + sideBar);
+ }
-function prevSidebar() {
-
- if (--sideBar < 0) sideBar = 2;
- log_debug("prev: " + sideBar);
-
-}
+ let prevSidebar=function() {
+ if (--sideBar < 0) sideBar = 2;
+ log_debug("prev: " + sideBar);
+ }
-// timeout used to update every minute
-var drawTimeout;
+ // timeout used to update every minute
+ let drawTimeout;
-// schedule a draw for the next minute
-function queueDraw() {
- if (drawTimeout) clearTimeout(drawTimeout);
- drawTimeout = setTimeout(function() {
- drawTimeout = undefined;
- if (settings.autoCycle) {
- nextSidebar();
- }
- draw();
- }, 60000 - (Date.now() % 60000));
-}
+ // schedule a draw for the next minute
+ let queueDraw=function() {
+ if (drawTimeout) clearTimeout(drawTimeout);
+ drawTimeout = setTimeout(function() {
+ drawTimeout = undefined;
+ if (settings.autoCycle) {
+ nextSidebar();
+ }
+ draw();
+ }, 60000 - (Date.now() % 60000));
+ }
-log_debug("starting..");
-loadSettings();
-loadLocation();
+ log_debug("starting..");
+ loadSettings();
+ loadLocation();
-if(settings.autoCycle || settings.sideTap==0)
-{
- Bangle.setUI("clockupdown", btn=> {
- if (btn<0) prevSidebar();
- if (btn>0) nextSidebar();
- draw();
- });
-}
-else{
- Bangle.setUI("clock");
-}
+ 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();
-require("widget_utils").hide();
+ Bangle.loadWidgets();
+ require("widget_utils").hide();
+ draw(); // queues the next draw for a minutes time
-draw(); // queues the next draw for a minutes time
-Bangle.on('charging', function(charging) {
- //redraw the sidebar ( with the battery )
- switch(sideBar) {
- case 0:
- drawSideBar1();
- break;
- case 1:
- drawSideBar2();
- break;
- }
-});
+ Bangle.on('charging', function(charging) {
+
+ //redraw the sidebar ( with the battery )
+ switch(sideBar) {
+ case 0:
+ drawSideBar1();
+ break;
+ case 1:
+ drawSideBar2();
+ break;
+ }
+ });
+}
\ No newline at end of file
diff --git a/apps/rebble/rebble.settings.js b/apps/rebble/rebble.settings.js
index 37b7be3a19..46252d156c 100644
--- a/apps/rebble/rebble.settings.js
+++ b/apps/rebble/rebble.settings.js
@@ -15,13 +15,13 @@
localSettings[key] = saved[key]
}
- function save() {
+ let save=function() {
settings = localSettings
storage.write(SETTINGS_FILE, settings)
}
- var color_options = ['Green','Orange','Cyan','Purple','Red','Blue'];
- var bg_code = ['#0f0','#ff0','#0ff','#f0f','#f00','#00f'];
+ let color_options = ['Green','Orange','Cyan','Purple','Red','Blue'];
+ let bg_code = ['#0f0','#ff0','#0ff','#f0f','#f00','#00f'];
function showMenu()
{
@@ -66,7 +66,7 @@
E.showMenu(menu);
}
- function NumberToSideTap(Number)
+ let NumberToSideTap=function(Number)
{
if(Number==0)
return 'on';
From 584fcb9980bb138d985c52504bfb5189a1407880 Mon Sep 17 00:00:00 2001
From: Rarder44
Date: Fri, 18 Nov 2022 00:16:02 +0100
Subject: [PATCH 3/6] bump version and changelog
---
apps/rebble/ChangeLog | 3 ++-
apps/rebble/metadata.json | 2 +-
2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/apps/rebble/ChangeLog b/apps/rebble/ChangeLog
index 21dd44e77f..9e21d1b22e 100644
--- a/apps/rebble/ChangeLog
+++ b/apps/rebble/ChangeLog
@@ -9,4 +9,5 @@
0.09: fix battery icon size
0.10: Tell clock widgets to hide.
0.11: fix issue https://github.com/espruino/BangleApps/issues/2128 (#2128) ( settings undefined )
-0.12: implemented widget_utils
\ No newline at end of file
+0.12: implemented widget_utils
+0.13: convert var/function into let
\ No newline at end of file
diff --git a/apps/rebble/metadata.json b/apps/rebble/metadata.json
index dfc0703c0c..972cb7e112 100644
--- a/apps/rebble/metadata.json
+++ b/apps/rebble/metadata.json
@@ -2,7 +2,7 @@
"id": "rebble",
"name": "Rebble Clock",
"shortName": "Rebble",
- "version": "0.12",
+ "version": "0.13",
"description": "A Pebble style clock, with configurable background, three sidebars including steps, day, date, sunrise, sunset, long live the rebellion",
"readme": "README.md",
"icon": "rebble.png",
From b1819945518cc32f07771c8834e1372a8819f3e7 Mon Sep 17 00:00:00 2001
From: Rarder44
Date: Fri, 18 Nov 2022 00:43:15 +0100
Subject: [PATCH 4/6] draw moved removed comments
---
apps/rebble/rebble.app.js | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/apps/rebble/rebble.app.js b/apps/rebble/rebble.app.js
index 6bdb8ff03c..e23bbe661d 100644
--- a/apps/rebble/rebble.app.js
+++ b/apps/rebble/rebble.app.js
@@ -327,9 +327,10 @@ Graphics.prototype.setFontKdamThmor = function(scale) {
Bangle.loadWidgets();
+ draw();
require("widget_utils").hide();
- draw(); // queues the next draw for a minutes time
+
Bangle.on('charging', function(charging) {
From 5cd48ec7058b7963ef2748722a7981c77d497fd2 Mon Sep 17 00:00:00 2001
From: Rarder44
Date: Fri, 18 Nov 2022 12:13:23 +0100
Subject: [PATCH 5/6] - fix log_debug
---
apps/rebble/rebble.app.js | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/apps/rebble/rebble.app.js b/apps/rebble/rebble.app.js
index e23bbe661d..6c39b8bc29 100644
--- a/apps/rebble/rebble.app.js
+++ b/apps/rebble/rebble.app.js
@@ -30,9 +30,8 @@ Graphics.prototype.setFontKdamThmor = function(scale) {
let sunRise = "00:00";
let sunSet = "00:00";
- function log_debug(o) {
+ let log_debug= function(o) {
//console.log(o);
-
}
// requires the myLocation app
From c6255ce9c8f761746df72eda06613f7bdc9b23a0 Mon Sep 17 00:00:00 2001
From: Rarder44
Date: Fri, 18 Nov 2022 17:18:59 +0100
Subject: [PATCH 6/6] cleanup code and fix fastload issue
---
apps/rebble/ChangeLog | 3 +-
apps/rebble/metadata.json | 2 +-
apps/rebble/rebble.app.js | 94 ++++++++++++++++++++++-----------------
3 files changed, 55 insertions(+), 44 deletions(-)
diff --git a/apps/rebble/ChangeLog b/apps/rebble/ChangeLog
index 9e21d1b22e..7255b17855 100644
--- a/apps/rebble/ChangeLog
+++ b/apps/rebble/ChangeLog
@@ -10,4 +10,5 @@
0.10: Tell clock widgets to hide.
0.11: fix issue https://github.com/espruino/BangleApps/issues/2128 (#2128) ( settings undefined )
0.12: implemented widget_utils
-0.13: convert var/function into let
\ No newline at end of file
+0.13: convert var/function into let
+0.14: cleanup code and fix fastload issue
\ No newline at end of file
diff --git a/apps/rebble/metadata.json b/apps/rebble/metadata.json
index 972cb7e112..9a746a0f92 100644
--- a/apps/rebble/metadata.json
+++ b/apps/rebble/metadata.json
@@ -2,7 +2,7 @@
"id": "rebble",
"name": "Rebble Clock",
"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",
"readme": "README.md",
"icon": "rebble.png",
diff --git a/apps/rebble/rebble.app.js b/apps/rebble/rebble.app.js
index 6c39b8bc29..ef75bbb219 100644
--- a/apps/rebble/rebble.app.js
+++ b/apps/rebble/rebble.app.js
@@ -291,48 +291,8 @@ Graphics.prototype.setFontKdamThmor = function(scale) {
}
- log_debug("starting..");
- loadSettings();
- loadLocation();
-
- 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) {
+ let chargingListener= function(charging) {
//redraw the sidebar ( with the battery )
switch(sideBar) {
@@ -343,5 +303,55 @@ Graphics.prototype.setFontKdamThmor = function(scale) {
drawSideBar2();
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();
}
\ No newline at end of file