From c039069db729ffc803b957d2739c0b939083c9d1 Mon Sep 17 00:00:00 2001 From: Gordon Williams Date: Wed, 23 Nov 2022 10:35:47 +0000 Subject: [PATCH] slopeclockpp 0.04: Changed to use clock_info for displayed data (see #2226) Made fonts smaller to avoid overlap when (eg) 22:00 Allowed black/white background (as that can look nice too) --- apps/slopeclockpp/README.md | 16 ++++ apps/slopeclockpp/app.js | 144 ++++++++----------------------- apps/slopeclockpp/default.json | 6 +- apps/slopeclockpp/metadata.json | 7 +- apps/slopeclockpp/screenshot.png | Bin 15562 -> 3307 bytes apps/slopeclockpp/settings.js | 32 +++---- modules/clock_info.js | 2 +- 7 files changed, 74 insertions(+), 133 deletions(-) create mode 100644 apps/slopeclockpp/README.md diff --git a/apps/slopeclockpp/README.md b/apps/slopeclockpp/README.md new file mode 100644 index 0000000000..9352db685f --- /dev/null +++ b/apps/slopeclockpp/README.md @@ -0,0 +1,16 @@ +# Slope Clock ++ + +A version of Slope Clock with extra information displayed on +the clock face using the clock_info module. + +## Usage + +When the screen is unlocked, tap on the information that you would like +to change (top right or bottom left). It should change color showing +it is selected. + +* Swipe up or down to cycle through the info screens that can be displayed +* Swipe left or right to change the type of info screens displayed (by default + there is only one type of data so this will have no effect) + +Settings are saved automatically and reloaded along with the clock. diff --git a/apps/slopeclockpp/app.js b/apps/slopeclockpp/app.js index 3dc4aad680..99ef7272b2 100644 --- a/apps/slopeclockpp/app.js +++ b/apps/slopeclockpp/app.js @@ -1,10 +1,10 @@ Graphics.prototype.setFontPaytoneOne = function(scale) { - // Actual height 81 (91 - 11) + // Actual height 71 (81 - 11) this.setFontCustom( - E.toString(require('heatshrink').decompress(atob('AH8AgP/BpcD//gBpn4Bpn+Bpn/wANMHBRTB//wBphGLBoJGLv4OBBpU/KhkfBoPABpMPMRkHMRh+CMRRwC/hwmMQQNKMQTTNBpRGCRhSpCBpY4BFJY4BBpcAjgMLAHUwBpl4BhcBd5Z/Bd5abCBpa3BTZd/YpcBcIPgBpMHBoPwIhf//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AoAD+LHGfMa4CDBJUCAAicBDBKYBAASbBDBJwC/5BDZQJwF+YYD4BXF/xBDRAY+D4IYDRAY+C/CZDN4Y+DQAZWEEoXAM4Y9EUYIGBHwRWEFAyUEDYp7GAAglBEhJLBJIoyGBZQA/MBDPEPI7DFfQy3FAAUBaAkBUQrdCGQSKFewYlBv41EEgQlCj//wBJFAAPwaoJbEbgTqCCIJOEHoQVBgbhFHoYuBGIJXDHoYVBAoLuECQJXDDAorBDAZvBOAhWDCoI3BOAYYEFwIYFKwYYBNIIYDN4gYBCQKJDAoPwAQIYCRIY3BMAgYFPIQPBDBA3Bv4YIBAIVBDBCCBn4YKOYIYY4ASBDBCuDDCn4cwR8FDAWAZoIYFAoM/+C0CY4b2CBIIFCY4xgB8DyCcAv+g/8j7jCcA7jEfI78DBYRTBAAp/BAAQ4CAAnABYR2CAAhvDgBFCAAgLDNQQAEN4aJCKxJXHHoZXHHog+HBYg+GPYY+HPYh9HdYZ9HEgolFEgwlFBYxLENwhxGGAzvET4gZGC5AA/ABl8AYV4BY0fdIU/OQx8BSYIDDUQv+AYokESgQDDcI2AWQTUHHwIDDY43AXwWADAz3Bv4YGCgQYJCgIYDAYIYKOAoYYJRZjOPhKVGDAqqBCgKuHYYKqBDgLHGHQPggEPcA8/NYU/HoolCIQQkGAEIA=='))), 46, - atob("ITZOMzs7SDxHNUdGIQ=="), - 113+(scale<<8)+(1<<16) + atob("HTBFLTQ0PzU/Lz8+HQ=="), + 100+(scale<<8)+(1<<16) ); return this; }; @@ -35,12 +35,14 @@ if (g.theme.dark) { if (settings.colorYellow) bgColors.push("#ff0"); if (settings.colorCyan) bgColors.push("#0ff"); if (settings.colorMagenta) bgColors.push("#f0f"); + if (settings.colorWhite) bgColors.push("#fff"); } else { if (settings.colorRed) bgColors.push("#f00"); if (settings.colorGreen) bgColors.push("#0f0"); if (settings.colorBlue) bgColors.push("#00f"); + if (settings.colorBlack) bgColors.push("#000"); } -let bgColor = bgColors[(Math.random()*bgColors.length)|0]; +let bgColor = bgColors[(Math.random()*bgColors.length)|0]||"#000"; // Draw the hour, and the minute into an offscreen buffer @@ -61,7 +63,6 @@ let draw = function() { // add slope in background color g.setColor(g.theme.bg).fillPoly([0,y+slope-slopeBorderUpper, R.w,y-slope-slopeBorderUpper, R.w,y-slope, 0,y+slope]); - // Draw minute to offscreen buffer g2.setColor(0).fillRect(0,0,g2.getWidth(),g2.getHeight()).setFontAlign(1, 0).setFont("PaytoneOne"); g2.setColor(1).drawString(minStr, g2.getWidth()-fontBorder, g2.getHeight()/2).setFont("4x6"); // draw and unload custom font @@ -109,117 +110,34 @@ let animate = function(isIn, callback) { if (isAnimIn) { // draw the date g.setColor(g.theme.bg).setFontAlign(0, 0).setFont("6x15").drawString(dateStr, R.x + R.w/2, R.y+R.h-9); - - if (settings.showSteps) { - // draw steps to bottom left - const steps = getSteps(); - if (steps > 0) - g.setFontAlign(-1, 0).drawString(shortValue(steps), 3, R.y+R.h-30); - } - - if (settings.showWeather) { - // draw weather to top right - const weather = getWeather(); - const tempString = weather ? require("locale").temp(weather.temp - 273.15) : undefined; - const code = weather ? weather.code : -1; - if (code > -1) { - g.setColor(g.theme.fg).setFontAlign(1, 0).drawString(tempString, R.w - 3, y-slope-slopeBorderUpper); - const icon = getWeatherIconByCode(code); - if (icon) g.drawImage(icon, R.w - 3 - 15, y-slope-slopeBorderUpper - 15 - 15); - } - } + // draw the menu items + clockInfoMenu.redraw(); + clockInfoMenu2.redraw(); } if (callback) callback(); } }, 20); }; -let getSteps = function() { - if (Bangle.getHealthStatus) { - return Bangle.getHealthStatus("day").steps; +// clock info menus (scroll up/down for info) +let clockInfoDraw = (itm, info, options) => { + let texty = options.y+26; + g.reset().setFont("6x15").setBgColor(options.bg).setColor(options.fg).clearRect(options.x, texty, options.x+options.w-2, texty+15); + + if (options.focus) g.setColor(options.hl); + if (options.x < g.getWidth()/2) { // left align + let x = options.x+2; + g.clearRect(x, options.y, x+23, options.y+23).drawImage(info.img, x, options.y); + g.setFontAlign(-1,-1).drawString(info.text, x,texty); + } else { // right align + let x = options.x+options.w-3; + g.clearRect(x-23, options.y, x, options.y+23).drawImage(info.img, x-23, options.y); + g.setFontAlign(1,-1).drawString(info.text, x,texty); } - if (WIDGETS && WIDGETS.wpedom !== undefined) { - return WIDGETS.wpedom.getSteps(); - } - return 0; }; - -let shortValue = function(v) { - if (isNaN(v)) return '-'; - if (v <= 999) return v; - if (v >= 1000 && v < 10000) { - v = Math.floor(v / 100) * 100; - return (v / 1000).toFixed(1).replace(/\.0$/, '') + 'k'; - } - if (v >= 10000) { - v = Math.floor(v / 1000) * 1000; - return (v / 1000).toFixed(1).replace(/\.0$/, '') + 'k'; - } -}; - -let getWeather = function() { - let jsonWeather = require("Storage").readJSON('weather.json'); - return jsonWeather && jsonWeather.weather ? jsonWeather.weather : undefined; -}; - -/* - * Choose weather icon to display based on weather conditition code - * https://openweathermap.org/weather-conditions#Weather-Condition-Codes-2 - */ -let getWeatherIconByCode = function(code) { - let codeGroup = Math.round(code / 100); - - // weather icons: - let weatherCloudy = atob("EBCBAAAAAAAAAAfgD/Af8H/4//7///////9//z/+AAAAAAAA"); - let weatherSunny = atob("EBCBAAAAAYAQCBAIA8AH4A/wb/YP8A/gB+ARiBAIAYABgAAA"); - let weatherMoon = atob("EBCBAAAAAYAP8B/4P/w//D/8f/5//j/8P/w//B/4D/ABgAAA"); - let weatherPartlyCloudy = atob("EBCBAAAAAAAYQAMAD8AIQBhoW+AOYBwwOBBgHGAGP/wf+AAA"); - let weatherRainy = atob("EBCBAAAAAYAH4AwwOBBgGEAOQAJBgjPOEkgGYAZgA8ABgAAA"); - let weatherPartlyRainy = atob("EBCBAAAAEEAQAAeADMAYaFvoTmAMMDgQIBxhhiGGG9wDwAGA"); - let weatherSnowy = atob("EBCBAAAAAAADwAGAEYg73C50BCAEIC50O9wRiAGAA8AAAAAA"); - let weatherFoggy = atob("EBCBAAAAAAADwAZgDDA4EGAcQAZAAgAAf74AAAAAd/4AAAAA"); - let weatherStormy = atob("EBCBAAAAAYAH4AwwOBBgGEAOQMJAgjmOGcgAgACAAAAAAAAA"); - let unknown = undefined; - - switch (codeGroup) { - case 2: - return weatherStormy; - case 3: - return weatherCloudy; - case 5: - switch (code) { - case 511: - return weatherSnowy; - case 520: - return weatherPartlyRainy; - case 521: - return weatherPartlyRainy; - case 522: - return weatherPartlyRainy; - case 531: - return weatherPartlyRainy; - default: - return weatherRainy; - } - case 6: - return weatherSnowy; - case 7: - return weatherFoggy; - case 8: - switch (code) { - case 800: - return weatherSunny; - case 801: - return weatherPartlyCloudy; - case 802: - return weatherPartlyCloudy; - default: - return weatherCloudy; - } - default: - return unknown; - } -} +let clockInfoItems = require("clock_info").load(); +let clockInfoMenu = require("clock_info").addInteractive(clockInfoItems, { x:126, y:24, w:50, h:40, draw : clockInfoDraw, bg : g.theme.bg, fg : g.theme.fg, hl : "#f00"/*red*/ }); +let clockInfoMenu2 = require("clock_info").addInteractive(clockInfoItems, { x:0, y:115, w:50, h:40, draw : clockInfoDraw, bg : bgColor, fg : g.theme.bg, hl : (bgColor=="#000")?"#f00"/*red*/:g.theme.fg }); // Show launcher when middle button pressed Bangle.setUI({ @@ -231,7 +149,13 @@ Bangle.setUI({ if (drawTimeout) clearTimeout(drawTimeout); drawTimeout = undefined; delete Graphics.prototype.setFontPaytoneOne; - }}); + // remove info menu + clockInfoMenu.remove(); + delete clockInfoMenu; + clockInfoMenu2.remove(); + delete clockInfoMenu2; + } +}); // Load widgets Bangle.loadWidgets(); draw(); diff --git a/apps/slopeclockpp/default.json b/apps/slopeclockpp/default.json index 448d64f6ae..29b6187351 100644 --- a/apps/slopeclockpp/default.json +++ b/apps/slopeclockpp/default.json @@ -1,10 +1,10 @@ { - "showSteps": true, - "showWeather": true, "colorRed": true, "colorGreen": true, "colorBlue": true, "colorYellow": true, "colorMagenta": true, - "colorCyan": true + "colorCyan": true, + "colorBlack": true, + "colorWhite": true } diff --git a/apps/slopeclockpp/metadata.json b/apps/slopeclockpp/metadata.json index f8d71af9b4..3100d8b507 100644 --- a/apps/slopeclockpp/metadata.json +++ b/apps/slopeclockpp/metadata.json @@ -1,12 +1,13 @@ { "id": "slopeclockpp", "name": "Slope Clock ++", - "version":"0.03", - "description": "A clock where hours and minutes are divided by a sloping line. When the minute changes, the numbers slide off the screen. This is a clone of the original Slope Clock which can show the weather and steps.", + "version":"0.04", + "description": "A clock where hours and minutes are divided by a sloping line. When the minute changes, the numbers slide off the screen. This is a clone of the original Slope Clock which shows extra information and allows the colors to be selected.", "icon": "app.png", "screenshots": [{"url":"screenshot.png"}], "type": "clock", "tags": "clock", - "supports" : ["BANGLEJS2"], + "supports" : ["BANGLEJS2"], + "readme": "README.md", "storage": [ {"name":"slopeclockpp.app.js","url":"app.js"}, {"name":"slopeclockpp.img","url":"app-icon.js","evaluate":true}, diff --git a/apps/slopeclockpp/screenshot.png b/apps/slopeclockpp/screenshot.png index 93970956c17750f51c2281a8ee7f483b737b0468..dfa76fed70b61e0cdf2fb5e5663b54a756245fac 100644 GIT binary patch literal 3307 zcmV

5Q;P)Px>rAb6VRCr$Po$Y$tAPj|@`@iVyaa(tU0Qx`zp`86$w_uRYc`XCB)5r7qe172% z6gX6Y2LL|QIfVVK002H1gvaA2c&}^d;~pT0My<&L01je~CXA9V4~PM<#uXgHR^S5o z0@te&-vIAkCXM1i1!m(Cui*{w_gru=ooLMj?utFC;s7|F=cytp0UkkIx4T7X9bZmG zYJeYKzh{Yoiq9|p<`*ikf#AElXjNDVz-9cekpBOqo<{@V-L5AazlNAQg{WmH=gu|E zsKCjfiIz?YF?SKyn<`)m5zXBXiD$GZ>q*dCtVtGeyXU}lZrAPzb|DUh-g^)DXHodG zXuG%30Pvx(L<}1M|D0H;z!B*rV$w_@G-;v&YgEHALj^R8xN_h3{+V;@82|%DQw3(W z(Rw#CMgc|x7!UK9;uD*%9xwhzGrU@&mB0s#1E`w%<;1_MVc0DzCS z55WUqFc3%9tKPm^1Ma+A@Tku4vs4y%rMjIEfcMu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opeclockpp/settings.js index a9319cd998..1d285767ab 100644 --- a/apps/slopeclockpp/settings.js +++ b/apps/slopeclockpp/settings.js @@ -15,45 +15,45 @@ let menu ={ '': { 'title': 'Slope Clock ++' }, /*LANG*/'< Back': back, - /*LANG*/'show steps': { - value: !!settings.showSteps, - format: () => (settings.showSteps ? 'Yes' : 'No'), - onchange: x => save('showSteps', x), - }, - /*LANG*/'show weather': { - value: !!settings.showWeather, - format: () => (settings.showWeather ? 'Yes' : 'No'), - onchange: x => save('showWeather', x), - }, - /*LANG*/'red': { + /*LANG*/'Red': { value: !!settings.colorRed, format: () => (settings.colorRed ? 'Yes' : 'No'), onchange: x => save('colorRed', x), }, - /*LANG*/'green': { + /*LANG*/'Green': { value: !!settings.colorGreen, format: () => (settings.colorGreen ? 'Yes' : 'No'), onchange: x => save('colorGreen', x), }, - /*LANG*/'blue': { + /*LANG*/'Blue': { value: !!settings.colorBlue, format: () => (settings.colorBlue ? 'Yes' : 'No'), onchange: x => save('colorBlue', x), }, - /*LANG*/'magenta': { + /*LANG*/'Magenta': { value: !!settings.colorMagenta, format: () => (settings.colorMagenta ? 'Yes' : 'No'), onchange: x => save('colorMagenta', x), }, - /*LANG*/'cyan': { + /*LANG*/'Cyan': { value: !!settings.colorCyan, format: () => (settings.colorCyan ? 'Yes' : 'No'), onchange: x => save('colorCyan', x), }, - /*LANG*/'yellow': { + /*LANG*/'Yellow': { value: !!settings.colorYellow, format: () => (settings.colorYellow ? 'Yes' : 'No'), onchange: x => save('colorYellow', x), + }, + /*LANG*/'Black': { + value: !!settings.colorBlack, + format: () => (settings.colorBlack ? 'Yes' : 'No'), + onchange: x => save('colorBlack', x), + }, + /*LANG*/'White': { + value: !!settings.colorWhite, + format: () => (settings.colorWhite ? 'Yes' : 'No'), + onchange: x => save('colorWhite', x), } }; E.showMenu(menu); diff --git a/modules/clock_info.js b/modules/clock_info.js index 7343f45358..4ce2a08fcf 100644 --- a/modules/clock_info.js +++ b/modules/clock_info.js @@ -174,7 +174,7 @@ exports.addInteractive = function(menu, options) { if ("function" == typeof options) options = {draw:options}; // backwards compatibility options.index = 0|exports.loadCount; exports.loadCount = options.index+1; - options.focus = options.index==0; // focus if we're the first one loaded + options.focus = options.index==0 && options.x===undefined; // focus if we're the first one loaded and no position has been defined const appName = "default:"+options.index; { // load the currently showing clock_infos