Skip to content

Commit

Permalink
slopeclockpp 0.04: Changed to use clock_info for displayed data (see #…
Browse files Browse the repository at this point in the history
…2226)

      Made fonts smaller to avoid overlap when (eg) 22:00
      Allowed black/white background (as that can look nice too)
  • Loading branch information
gfwilliams committed Nov 23, 2022
1 parent f9433dc commit c039069
Show file tree
Hide file tree
Showing 7 changed files with 74 additions and 133 deletions.
16 changes: 16 additions & 0 deletions apps/slopeclockpp/README.md
Original file line number Diff line number Diff line change
@@ -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.
144 changes: 34 additions & 110 deletions apps/slopeclockpp/app.js
Original file line number Diff line number Diff line change
@@ -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//BEL/5wKIgP/OBJECAAJELAAJwIIgQABOBBECOBRECOBJEEOBBEEOBBEEOBBEEOBBEEOA5EFBo5EFFI5EFKY5EGN4woGTIpEpj5EMDYzeGG4xEFgEDWZhhFbo59FfI7QFIgynGIgxwGBg5wEIhBwE+ANIOAZEIOAhEIOAgMJOAREJOAZEJOAZEJOAZEKOAQMKOAJELOAJELAAJELAH0EBhaQBSJa6BZJbkCDhMDBof4XJIADBpvAKRIqKBov+Bo0fBogqHBozpGBoyAGBoxjGBo44FBo44F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wYYBNIIYDN4gYBCQKJDAoPwAQIYCRIY3BMAgYFPIQPBDBA3Bv4YIBAIVBDBCCBn4YKOYIYY4ASBDBCuDDCn4cwR8FDAWAZoIYFAoM/+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;
};
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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({
Expand All @@ -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();
Expand Down
6 changes: 3 additions & 3 deletions apps/slopeclockpp/default.json
Original file line number Diff line number Diff line change
@@ -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
}
7 changes: 4 additions & 3 deletions apps/slopeclockpp/metadata.json
Original file line number Diff line number Diff line change
@@ -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},
Expand Down
Binary file modified apps/slopeclockpp/screenshot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
32 changes: 16 additions & 16 deletions apps/slopeclockpp/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion modules/clock_info.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit c039069

Please sign in to comment.