mirror of https://github.com/espruino/BangleApps
parent
a897cbb38d
commit
6511031ba1
|
@ -28,3 +28,5 @@
|
|||
Memory optimizations
|
||||
0.14: Support to show big weather info
|
||||
0.15: Use Bangle.setUI({remove:...}) to allow loading the launcher without a full reset on 2v16
|
||||
0.16: Fix const error
|
||||
Use widget_utils if available
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
const locale = require("locale");
|
||||
const storage = require("Storage");
|
||||
let locale = require("locale");
|
||||
let storage = require("Storage");
|
||||
Graphics.prototype.setFontRobotoRegular50NumericOnly = function(scale) {
|
||||
// Actual height 39 (40 - 2)
|
||||
this.setFontCustom(atob("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAADAAAAAAAB8AAAAAAAfAAAAAAAPwAAAAAAB8AAAAAAAeAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAAAAA4AAAAAAB+AAAAAAD/gAAAAAD/4AAAAAH/4AAAAAP/wAAAAAP/gAAAAAf/gAAAAAf/AAAAAA/+AAAAAB/+AAAAAB/8AAAAAD/4AAAAAH/4AAAAAD/wAAAAAA/wAAAAAAPgAAAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA///wAAAB////gAAA////8AAA/////gAAP////8AAH8AAA/gAB8AAAD4AA+AAAAfAAPAAAADwADwAAAA8AA8AAAAPAAPAAAADwADwAAAA8AA8AAAAPAAPgAAAHwAB8AAAD4AAfwAAD+AAD/////AAA/////wAAH////4AAAf///4AAAB///wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAeAAAAAAAPgAAAAAADwAAAAAAB8AAAAAAAfAAAAAAAHgAAAAAAD4AAAAAAA+AAAAAAAPAAAAAAAH/////wAB/////8AA//////AAP/////wAD/////8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA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B8AA8AfgA+AAPAH+B/gAAAA///wAAAAH//4AAAAA//8AAAAAH/8AAAAAAP4AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADwAAAAAAA8AAAAAAAPAAAAAAADwAAAAAAA8AAAABAAPAAAABwADwAAAB8AA8AAAB/AAPAAAB/wADwAAD/8AA8AAD/8AAPAAD/4AADwAD/4AAA8AD/4AAAPAH/wAAADwH/wAAAA8H/wAAAAPH/wAAAAD3/gAAAAA//gAAAAAP/gAAAAAD/gAAAAAA/AAAAAAAPAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADwA/4AAAH/Af/AAAH/8P/4AAD//n//AAA//7//4AAfx/+A+AAHwD+AHwAD4AfgB8AA8AHwAPAAPAA8ADwADwAPAA8AA8ADwAPAAPAA8ADwADwAfAA8AA+AH4AfAAHwD+AHwAB/D/4D4AAP/+/n+AAD//n//AAAf/w//gAAB/wH/wAAAHwA/4AAAAAABgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAB+AAAAAAD/8AAAAAD//wAAAAB//+AAAAA///wAAAAf4H+APAAH4AfgDwAD8AB8A8AA+AAfAPAAPAADwDwADwAA8B8AA8AAPAfAAPAADwHgADwAA8D4AA+AAeB+AAHwAHg/AAB+ADwfgAAP8D4/4AAD////8AAAf///8AAAB///+AAAAP//+AAAAAP/4AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAAOAAAB8AAHwAAAfgAD8AAAH4AA/AAAB8AAHwAAAOAAA4AAAAAAAAAAAAAAAAAAAAAAAAAA"), 46, atob("DRUcHBwcHBwcHBwcDA=="), 50+(scale<<8)+(1<<16));
|
||||
|
@ -12,7 +12,7 @@ Graphics.prototype.setFontRobotoRegular21 = function(scale) {
|
|||
return this;
|
||||
};
|
||||
|
||||
const SETTINGS_FILE = "circlesclock.json";
|
||||
let SETTINGS_FILE = "circlesclock.json";
|
||||
let settings = Object.assign(
|
||||
storage.readJSON("circlesclock.default.json", true) || {},
|
||||
storage.readJSON(SETTINGS_FILE, true) || {}
|
||||
|
@ -40,30 +40,30 @@ function getLocation() {
|
|||
}
|
||||
let location = getLocation();
|
||||
|
||||
const showWidgets = settings.showWidgets || false;
|
||||
const circleCount = settings.circleCount || 3;
|
||||
const showBigWeather = settings.showBigWeather || false;
|
||||
let showWidgets = settings.showWidgets || false;
|
||||
let circleCount = settings.circleCount || 3;
|
||||
let showBigWeather = settings.showBigWeather || false;
|
||||
|
||||
let hrtValue;
|
||||
let now = Math.round(new Date().getTime() / 1000);
|
||||
|
||||
|
||||
// layout values:
|
||||
const colorFg = g.theme.dark ? '#fff' : '#000';
|
||||
const colorBg = g.theme.dark ? '#000' : '#fff';
|
||||
const colorGrey = '#808080';
|
||||
const colorRed = '#ff0000';
|
||||
const colorGreen = '#008000';
|
||||
const colorBlue = '#0000ff';
|
||||
const colorYellow = '#ffff00';
|
||||
const widgetOffset = showWidgets ? 24 : 0;
|
||||
const dowOffset = circleCount == 3 ? 20 : 22; // dow offset relative to date
|
||||
const h = g.getHeight() - widgetOffset;
|
||||
const w = g.getWidth();
|
||||
const hOffset = (circleCount == 3 ? 34 : 30) - widgetOffset;
|
||||
const h1 = Math.round(1 * h / 5 - hOffset);
|
||||
const h2 = Math.round(3 * h / 5 - hOffset);
|
||||
const h3 = Math.round(8 * h / 8 - hOffset - 3); // circle y position
|
||||
let colorFg = g.theme.dark ? '#fff' : '#000';
|
||||
let colorBg = g.theme.dark ? '#000' : '#fff';
|
||||
let colorGrey = '#808080';
|
||||
let colorRed = '#ff0000';
|
||||
let colorGreen = '#008000';
|
||||
let colorBlue = '#0000ff';
|
||||
let colorYellow = '#ffff00';
|
||||
let widgetOffset = showWidgets ? 24 : 0;
|
||||
let dowOffset = circleCount == 3 ? 20 : 22; // dow offset relative to date
|
||||
let h = g.getHeight() - widgetOffset;
|
||||
let w = g.getWidth();
|
||||
let hOffset = (circleCount == 3 ? 34 : 30) - widgetOffset;
|
||||
let h1 = Math.round(1 * h / 5 - hOffset);
|
||||
let h2 = Math.round(3 * h / 5 - hOffset);
|
||||
let h3 = Math.round(8 * h / 8 - hOffset - 3); // circle y position
|
||||
|
||||
/*
|
||||
* circle x positions
|
||||
|
@ -77,21 +77,22 @@ const h3 = Math.round(8 * h / 8 - hOffset - 3); // circle y position
|
|||
* | (1) (2) (3) (4) |
|
||||
* => circles start at 1,3,5,7 / 8
|
||||
*/
|
||||
const parts = circleCount * 2;
|
||||
const circlePosX = [
|
||||
let parts = circleCount * 2;
|
||||
let circlePosX = [
|
||||
Math.round(1 * w / parts), // circle1
|
||||
Math.round(3 * w / parts), // circle2
|
||||
Math.round(5 * w / parts), // circle3
|
||||
Math.round(7 * w / parts), // circle4
|
||||
];
|
||||
|
||||
const radiusOuter = circleCount == 3 ? 25 : 20;
|
||||
const radiusInner = circleCount == 3 ? 20 : 15;
|
||||
const circleFontSmall = circleCount == 3 ? "Vector:14" : "Vector:10";
|
||||
const circleFont = circleCount == 3 ? "Vector:15" : "Vector:11";
|
||||
const circleFontBig = circleCount == 3 ? "Vector:16" : "Vector:12";
|
||||
const iconOffset = circleCount == 3 ? 6 : 8;
|
||||
const defaultCircleTypes = ["steps", "hr", "battery", "weather"];
|
||||
let radiusOuter = circleCount == 3 ? 25 : 20;
|
||||
let radiusInner = circleCount == 3 ? 20 : 15;
|
||||
let circleFontSmall = circleCount == 3 ? "Vector:14" : "Vector:10";
|
||||
let circleFont = circleCount == 3 ? "Vector:15" : "Vector:11";
|
||||
let circleFontBig = circleCount == 3 ? "Vector:16" : "Vector:12";
|
||||
let iconOffset = circleCount == 3 ? 6 : 8;
|
||||
let defaultCircleTypes = ["steps", "hr", "battery", "weather"];
|
||||
|
||||
|
||||
function hideWidgets() {
|
||||
/*
|
||||
|
@ -109,9 +110,16 @@ function hideWidgets() {
|
|||
|
||||
function draw() {
|
||||
g.clear(true);
|
||||
let widgetUtils;
|
||||
|
||||
try {
|
||||
widgetUtils = require("widget_utils");
|
||||
} catch (e) {
|
||||
}
|
||||
if (!showWidgets) {
|
||||
hideWidgets();
|
||||
if (widgetUtils) widgetUtils.hide(); else hideWidgets();
|
||||
} else {
|
||||
if (widgetUtils) widgetUtils.show();
|
||||
Bangle.drawWidgets();
|
||||
}
|
||||
|
||||
|
@ -145,13 +153,13 @@ function draw() {
|
|||
|
||||
// weather
|
||||
if (showBigWeather) {
|
||||
const weather = getWeather();
|
||||
const tempString = weather ? locale.temp(weather.temp - 273.15) : undefined;
|
||||
let weather = getWeather();
|
||||
let tempString = weather ? locale.temp(weather.temp - 273.15) : undefined;
|
||||
g.setFontAlign(1, 0);
|
||||
if (tempString) g.drawString(tempString, w, h2);
|
||||
|
||||
const code = weather ? weather.code : -1;
|
||||
const icon = getWeatherIconByCode(code, true);
|
||||
let code = weather ? weather.code : -1;
|
||||
let icon = getWeatherIconByCode(code, true);
|
||||
if (icon) g.drawImage(icon, w - 48, h1, {scale:0.75});
|
||||
}
|
||||
|
||||
|
@ -166,7 +174,7 @@ function draw() {
|
|||
function drawCircle(index) {
|
||||
let type = settings['circle' + index];
|
||||
if (!type) type = defaultCircleTypes[index - 1];
|
||||
const w = getCircleXPosition(type);
|
||||
let w = getCircleXPosition(type);
|
||||
|
||||
switch (type) {
|
||||
case "steps":
|
||||
|
@ -218,7 +226,7 @@ function getCirclePosition(type) {
|
|||
return circlePositionsCache[type];
|
||||
}
|
||||
for (let i = 1; i <= circleCount; i++) {
|
||||
const setting = settings['circle' + i];
|
||||
let setting = settings['circle' + i];
|
||||
if (setting == type) {
|
||||
circlePositionsCache[type] = i - 1;
|
||||
return i - 1;
|
||||
|
@ -234,7 +242,7 @@ function getCirclePosition(type) {
|
|||
}
|
||||
|
||||
function getCircleXPosition(type) {
|
||||
const circlePos = getCirclePosition(type);
|
||||
let circlePos = getCirclePosition(type);
|
||||
if (circlePos != undefined) {
|
||||
return circlePosX[circlePos];
|
||||
}
|
||||
|
@ -246,14 +254,14 @@ function isCircleEnabled(type) {
|
|||
}
|
||||
|
||||
function getCircleColor(type) {
|
||||
const pos = getCirclePosition(type);
|
||||
const color = settings["circle" + (pos + 1) + "color"];
|
||||
let pos = getCirclePosition(type);
|
||||
let color = settings["circle" + (pos + 1) + "color"];
|
||||
if (color && color != "") return color;
|
||||
}
|
||||
|
||||
function getCircleIconColor(type, color, percent) {
|
||||
const pos = getCirclePosition(type);
|
||||
const colorizeIcon = settings["circle" + (pos + 1) + "colorizeIcon"] == true;
|
||||
let pos = getCirclePosition(type);
|
||||
let colorizeIcon = settings["circle" + (pos + 1) + "colorizeIcon"] == true;
|
||||
if (colorizeIcon) {
|
||||
return getGradientColor(color, percent);
|
||||
} else {
|
||||
|
@ -264,18 +272,18 @@ function getCircleIconColor(type, color, percent) {
|
|||
function getGradientColor(color, percent) {
|
||||
if (isNaN(percent)) percent = 0;
|
||||
if (percent > 1) percent = 1;
|
||||
const colorList = [
|
||||
let colorList = [
|
||||
'#00FF00', '#80FF00', '#FFFF00', '#FF8000', '#FF0000'
|
||||
];
|
||||
if (color == "fg") {
|
||||
color = colorFg;
|
||||
}
|
||||
if (color == "green-red") {
|
||||
const colorIndex = Math.round(colorList.length * percent);
|
||||
let colorIndex = Math.round(colorList.length * percent);
|
||||
return colorList[Math.min(colorIndex, colorList.length) - 1] || "#00ff00";
|
||||
}
|
||||
if (color == "red-green") {
|
||||
const colorIndex = colorList.length - Math.round(colorList.length * percent);
|
||||
let colorIndex = colorList.length - Math.round(colorList.length * percent);
|
||||
return colorList[Math.min(colorIndex, colorList.length)] || "#ff0000";
|
||||
}
|
||||
return color;
|
||||
|
@ -298,14 +306,14 @@ function getImage(graphic, color) {
|
|||
|
||||
function drawSteps(w) {
|
||||
if (!w) w = getCircleXPosition("steps");
|
||||
const steps = getSteps();
|
||||
let steps = getSteps();
|
||||
|
||||
drawCircleBackground(w);
|
||||
|
||||
const color = getCircleColor("steps");
|
||||
let color = getCircleColor("steps");
|
||||
|
||||
let percent;
|
||||
const stepGoal = settings.stepGoal;
|
||||
let stepGoal = settings.stepGoal;
|
||||
if (stepGoal > 0) {
|
||||
percent = steps / stepGoal;
|
||||
if (stepGoal < steps) percent = 1;
|
||||
|
@ -321,16 +329,16 @@ function drawSteps(w) {
|
|||
|
||||
function drawStepsDistance(w) {
|
||||
if (!w) w = getCircleXPosition("stepsDistance");
|
||||
const steps = getSteps();
|
||||
const stepDistance = settings.stepLength;
|
||||
const stepsDistance = Math.round(steps * stepDistance);
|
||||
let steps = getSteps();
|
||||
let stepDistance = settings.stepLength;
|
||||
let stepsDistance = Math.round(steps * stepDistance);
|
||||
|
||||
drawCircleBackground(w);
|
||||
|
||||
const color = getCircleColor("stepsDistance");
|
||||
let color = getCircleColor("stepsDistance");
|
||||
|
||||
let percent;
|
||||
const stepDistanceGoal = settings.stepDistanceGoal;
|
||||
let stepDistanceGoal = settings.stepDistanceGoal;
|
||||
if (stepDistanceGoal > 0) {
|
||||
percent = stepsDistance / stepDistanceGoal;
|
||||
if (stepDistanceGoal < stepsDistance) percent = 1;
|
||||
|
@ -347,16 +355,16 @@ function drawStepsDistance(w) {
|
|||
function drawHeartRate(w) {
|
||||
if (!w) w = getCircleXPosition("hr");
|
||||
|
||||
const heartIcon = atob("EBCBAAAAAAAeeD/8P/x//n/+P/w//B/4D/AH4APAAYAAAAAA");
|
||||
let heartIcon = atob("EBCBAAAAAAAeeD/8P/x//n/+P/w//B/4D/AH4APAAYAAAAAA");
|
||||
|
||||
drawCircleBackground(w);
|
||||
|
||||
const color = getCircleColor("hr");
|
||||
let color = getCircleColor("hr");
|
||||
|
||||
let percent;
|
||||
if (hrtValue != undefined) {
|
||||
const minHR = settings.minHR;
|
||||
const maxHR = settings.maxHR;
|
||||
let minHR = settings.minHR;
|
||||
let maxHR = settings.maxHR;
|
||||
percent = (hrtValue - minHR) / (maxHR - minHR);
|
||||
if (isNaN(percent)) percent = 0;
|
||||
drawGauge(w, h3, percent, color);
|
||||
|
@ -371,9 +379,9 @@ function drawHeartRate(w) {
|
|||
|
||||
function drawBattery(w) {
|
||||
if (!w) w = getCircleXPosition("battery");
|
||||
const battery = E.getBattery();
|
||||
let battery = E.getBattery();
|
||||
|
||||
const powerIcon = atob("EBCBAAAAA8ADwA/wD/AP8A/wD/AP8A/wD/AP8A/wD/AH4AAA");
|
||||
let powerIcon = atob("EBCBAAAAA8ADwA/wD/AP8A/wD/AP8A/wD/AP8A/wD/AH4AAA");
|
||||
|
||||
drawCircleBackground(w);
|
||||
|
||||
|
@ -401,18 +409,18 @@ function drawBattery(w) {
|
|||
|
||||
function drawWeather(w) {
|
||||
if (!w) w = getCircleXPosition("weather");
|
||||
const weather = getWeather();
|
||||
const tempString = weather ? locale.temp(weather.temp - 273.15) : undefined;
|
||||
const code = weather ? weather.code : -1;
|
||||
let weather = getWeather();
|
||||
let tempString = weather ? locale.temp(weather.temp - 273.15) : undefined;
|
||||
let code = weather ? weather.code : -1;
|
||||
|
||||
drawCircleBackground(w);
|
||||
|
||||
const color = getCircleColor("weather");
|
||||
let color = getCircleColor("weather");
|
||||
let percent;
|
||||
const data = settings.weatherCircleData;
|
||||
let data = settings.weatherCircleData;
|
||||
switch (data) {
|
||||
case "humidity":
|
||||
const humidity = weather ? weather.hum : undefined;
|
||||
let humidity = weather ? weather.hum : undefined;
|
||||
if (humidity >= 0) {
|
||||
percent = humidity / 100;
|
||||
drawGauge(w, h3, percent, color);
|
||||
|
@ -420,7 +428,7 @@ function drawWeather(w) {
|
|||
break;
|
||||
case "wind":
|
||||
if (weather) {
|
||||
const wind = locale.speed(weather.wind).match(/^(\D*\d*)(.*)$/);
|
||||
let wind = locale.speed(weather.wind).match(/^(\D*\d*)(.*)$/);
|
||||
if (wind[1] >= 0) {
|
||||
if (wind[2] == "kmh") {
|
||||
wind[1] = windAsBeaufort(wind[1]);
|
||||
|
@ -440,7 +448,7 @@ function drawWeather(w) {
|
|||
writeCircleText(w, tempString ? tempString : "?");
|
||||
|
||||
if (code > 0) {
|
||||
const icon = getWeatherIconByCode(code);
|
||||
let icon = getWeatherIconByCode(code);
|
||||
if (icon) g.drawImage(getImage(icon, getCircleIconColor("weather", color, percent)), w - iconOffset, h3 + radiusOuter - iconOffset);
|
||||
} else {
|
||||
g.drawString("?", w, h3 + radiusOuter);
|
||||
|
@ -449,15 +457,15 @@ function drawWeather(w) {
|
|||
|
||||
function drawSunProgress(w) {
|
||||
if (!w) w = getCircleXPosition("sunprogress");
|
||||
const percent = getSunProgress();
|
||||
let percent = getSunProgress();
|
||||
|
||||
// sunset icons:
|
||||
const sunSetDown = atob("EBCBAAAAAAABgAAAAAATyAZoBCB//gAAAAAGYAPAAYAAAAAA");
|
||||
const sunSetUp = atob("EBCBAAAAAAABgAAAAAATyAZoBCB//gAAAAABgAPABmAAAAAA");
|
||||
let sunSetDown = atob("EBCBAAAAAAABgAAAAAATyAZoBCB//gAAAAAGYAPAAYAAAAAA");
|
||||
let sunSetUp = atob("EBCBAAAAAAABgAAAAAATyAZoBCB//gAAAAABgAPABmAAAAAA");
|
||||
|
||||
drawCircleBackground(w);
|
||||
|
||||
const color = getCircleColor("sunprogress");
|
||||
let color = getCircleColor("sunprogress");
|
||||
|
||||
drawGauge(w, h3, percent, color);
|
||||
|
||||
|
@ -465,15 +473,15 @@ function drawSunProgress(w) {
|
|||
|
||||
let icon = sunSetDown;
|
||||
let text = "?";
|
||||
const times = getSunData();
|
||||
let times = getSunData();
|
||||
if (times != undefined) {
|
||||
const sunRise = Math.round(times.sunrise.getTime() / 1000);
|
||||
const sunSet = Math.round(times.sunset.getTime() / 1000);
|
||||
let sunRise = Math.round(times.sunrise.getTime() / 1000);
|
||||
let sunSet = Math.round(times.sunset.getTime() / 1000);
|
||||
if (!isDay()) {
|
||||
// night
|
||||
if (now > sunRise) {
|
||||
// after sunRise
|
||||
const upcomingSunRise = sunRise + 60 * 60 * 24;
|
||||
let upcomingSunRise = sunRise + 60 * 60 * 24;
|
||||
text = formatSeconds(upcomingSunRise - now);
|
||||
} else {
|
||||
text = formatSeconds(sunRise - now);
|
||||
|
@ -497,12 +505,12 @@ function drawTemperature(w) {
|
|||
getPressureValue("temperature").then((temperature) => {
|
||||
drawCircleBackground(w);
|
||||
|
||||
const color = getCircleColor("temperature");
|
||||
let color = getCircleColor("temperature");
|
||||
|
||||
let percent;
|
||||
if (temperature) {
|
||||
const min = -40;
|
||||
const max = 85;
|
||||
let min = -40;
|
||||
let max = 85;
|
||||
percent = (temperature - min) / (max - min);
|
||||
drawGauge(w, h3, percent, color);
|
||||
}
|
||||
|
@ -523,12 +531,12 @@ function drawPressure(w) {
|
|||
getPressureValue("pressure").then((pressure) => {
|
||||
drawCircleBackground(w);
|
||||
|
||||
const color = getCircleColor("pressure");
|
||||
let color = getCircleColor("pressure");
|
||||
|
||||
let percent;
|
||||
if (pressure && pressure > 0) {
|
||||
const minPressure = 950;
|
||||
const maxPressure = 1050;
|
||||
let minPressure = 950;
|
||||
let maxPressure = 1050;
|
||||
percent = (pressure - minPressure) / (maxPressure - minPressure);
|
||||
drawGauge(w, h3, percent, color);
|
||||
}
|
||||
|
@ -549,12 +557,12 @@ function drawAltitude(w) {
|
|||
getPressureValue("altitude").then((altitude) => {
|
||||
drawCircleBackground(w);
|
||||
|
||||
const color = getCircleColor("altitude");
|
||||
let color = getCircleColor("altitude");
|
||||
|
||||
let percent;
|
||||
if (altitude) {
|
||||
const min = 0;
|
||||
const max = 10000;
|
||||
let min = 0;
|
||||
let max = 10000;
|
||||
percent = (altitude - min) / (max - min);
|
||||
drawGauge(w, h3, percent, color);
|
||||
}
|
||||
|
@ -573,7 +581,7 @@ function drawAltitude(w) {
|
|||
* wind goes from 0 to 12 (see https://en.wikipedia.org/wiki/Beaufort_scale)
|
||||
*/
|
||||
function windAsBeaufort(windInKmh) {
|
||||
const beaufort = [2, 6, 12, 20, 29, 39, 50, 62, 75, 89, 103, 118];
|
||||
let beaufort = [2, 6, 12, 20, 29, 39, 50, 62, 75, 89, 103, 118];
|
||||
let l = 0;
|
||||
while (l < beaufort.length && beaufort[l] < windInKmh) {
|
||||
l++;
|
||||
|
@ -587,20 +595,20 @@ function windAsBeaufort(windInKmh) {
|
|||
* https://openweathermap.org/weather-conditions#Weather-Condition-Codes-2
|
||||
*/
|
||||
function getWeatherIconByCode(code, big) {
|
||||
const codeGroup = Math.round(code / 100);
|
||||
let codeGroup = Math.round(code / 100);
|
||||
if (big == undefined) big = false;
|
||||
|
||||
// weather icons:
|
||||
const weatherCloudy = big ? atob("QEDBAP//wxgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD/AAAAAAAAB//gAAAAAAAP//gAAAAAAD///AAAAAAAf4H+AAAAAAD8AD8AAAAAAfgAH4AAAAAB8AAPwAAAAAPgAAf/AAAAB8AAA//AAAAHgAAB/+AAAAeAAAH/8AAAH4AAAIH4AAB/AAAAAHwAAf8AAAAAPgAD/wAAAAAeAAPwAAAAAB4AB8AAAAAADwAHgAAAAAAPAA+AAAAAAA8ADwAAAAAADwA/AAAAAAAPAH8AAAAAAA8A/wAAAAAAHwH4AAAAAAAfg+AAAAAAAAfHwAAAAAAAA+eAAAAAAAAB54AAAAAAAAHvAAAAAAAAAP8AAAAAAAAA/wAAAAAAAAD/AAAAAAAAAP8AAAAAAAAA/wAAAAAAAAD3gAAAAAAAAeeAAAAAAAAB58AAAAAAAAPj4AAAAAAAB8H4AAAAAAAfgP////////8Af////////gA////////8AAf//////+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==") : atob("EBCBAAAAAAAAAAfgD/Af8H/4//7///////9//z/+AAAAAAAA");
|
||||
const weatherSunny = big ? atob("QEDBAP//wxgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA8AAAAAAAAADw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APAAAAAB58AA8AAAAAPj4ADwAAAAB8H4APAAAAAfgP/wAA8A//8Af/AADwD//gA/8AAPAP/8AAfwAA8A/+AAAAAA//AAAAAAAAD/8AAAAAAAAP/wAAAAAAAA//AAAAAAAAAPAAAAAAAAAA8AAAAAAAAADwAAAAAAAAAPAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==") : atob("EBCBAAAAAAADwAGAEYg73C50BCAEIC50O9wRiAGAA8AAAAAA");
|
||||
const weatherFoggy = big ? atob("QEDBAP//AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA8AAAAAAAAADwAAAAAAAAAPAAAAAAAAAA8AAAAAAAAADwAAAAAAAAAPAAAAAAAAAA8AAAAAAAwADwADAAAAHgAPAAeAAAAfAA8AD4AAAA+ADwAfAAAAB8APAD4AAAAD4B+AfAAAAAHw//D4AAAAAPv//fAAAAAAf///4AAAAAA/4H/AAAAAAB+AH4AAAAAAPgAHwAAAAAA8AAPAAAAAAHwAA+AAAAAAeAAB4AAAAAB4AAHgAAAAAPAAAPAAAAAAAAAA//8AAAAAAAD//wAAAAAAAP//AAAAAAAA//8AD///AADwAAAP//8AAeAAAA///wAB4AAAD///AAPgAAAAAAAAA8AAAAAAAAAHwAAAAAAAAB+AAAAAAAAAf8AAAAD///D/4AAAAP//8P3wAAAA///w8PgAAAD///CAfAAAAAAAAAA+AAAAAAAAAB8AAAAAAAAAD4AAAAAAAAAHgAAP//8PAAMAAA///w8AAAAAD///DwAAAAAP//8PAAAAAAAAAA8AAAAAAAAADwAAAAAAAAAPAAAAAAAAAA8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==") : atob("EBCBAAAAAAADwAZgDDA4EGAcQAZAAgAAf74AAAAAd/4AAAAA");
|
||||
const weatherStormy = big ? atob("QEDBAP//wxgAAAAAAA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AAA/AA/AAAAAAH4AB+AAAAAA/AAD4AAAAAD4H4HwAAAAAfB/4PgAAAAB8P/weAAAAAHg//h4AAAAA+Hw+HwAAAAD4eB8PAAAAAP/wDw8AAAAA//APDwAAAAD/8A8PAAAAAH/gDw8AAAAAAAAfDwAAAAAAAH4fAAAAAAAB/B4AAAAAAAf4HgAAAAAAD/A+AAAAAAAfwHwAAAAAAD8A+AAAAAAAPgH4AAAAAAB8B/AAAAAAAHgf4AAAAAAA+H+AAAAAAADwfwAAAAAAAPD8AAAAAAAA8PAAAAAAAAD/8AAAAAAAAP/wAAAAAAAA//AAAAAAAAB/4AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAf+AAAAAAAAD/8AAAAAAAAP/wAAAAAAAA//AAAAAAAADw8AAAAAAAAPDwAAAAAAAA8PAAAAAAAADw8AAAAAAAAP/wAAAAAAAA//AAAAAAAAD/8AAAAAAAAH/gAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==") : undefined;
|
||||
|
||||
switch (codeGroup) {
|
||||
case 2:
|
||||
|
@ -644,10 +652,10 @@ function getWeatherIconByCode(code, big) {
|
|||
|
||||
|
||||
function isDay() {
|
||||
const times = getSunData();
|
||||
let times = getSunData();
|
||||
if (times == undefined) return true;
|
||||
const sunRise = Math.round(times.sunrise.getTime() / 1000);
|
||||
const sunSet = Math.round(times.sunset.getTime() / 1000);
|
||||
let sunRise = Math.round(times.sunrise.getTime() / 1000);
|
||||
let sunSet = Math.round(times.sunset.getTime() / 1000);
|
||||
|
||||
return (now > sunRise && now < sunSet);
|
||||
}
|
||||
|
@ -664,7 +672,7 @@ function formatSeconds(s) {
|
|||
|
||||
function getSunData() {
|
||||
if (location != undefined && location.lat != undefined) {
|
||||
const SunCalc = require("https://raw.githubusercontent.com/mourner/suncalc/master/suncalc.js");
|
||||
let SunCalc = require("https://raw.githubusercontent.com/mourner/suncalc/master/suncalc.js");
|
||||
// get today's sunlight times for lat/lon
|
||||
return SunCalc ? SunCalc.getTimes(new Date(), location.lat, location.lon) : undefined;
|
||||
}
|
||||
|
@ -677,14 +685,14 @@ function getSunData() {
|
|||
* Taken from rebble app and modified
|
||||
*/
|
||||
function getSunProgress() {
|
||||
const times = getSunData();
|
||||
let times = getSunData();
|
||||
if (times == undefined) return 0;
|
||||
const sunRise = Math.round(times.sunrise.getTime() / 1000);
|
||||
const sunSet = Math.round(times.sunset.getTime() / 1000);
|
||||
let sunRise = Math.round(times.sunrise.getTime() / 1000);
|
||||
let sunSet = Math.round(times.sunset.getTime() / 1000);
|
||||
|
||||
if (isDay()) {
|
||||
// during day
|
||||
const dayLength = sunSet - sunRise;
|
||||
let dayLength = sunSet - sunRise;
|
||||
if (now > sunRise) {
|
||||
return (now - sunRise) / dayLength;
|
||||
} else {
|
||||
|
@ -693,10 +701,10 @@ function getSunProgress() {
|
|||
} else {
|
||||
// during night
|
||||
if (now < sunRise) {
|
||||
const prevSunSet = sunSet - 60 * 60 * 24;
|
||||
let prevSunSet = sunSet - 60 * 60 * 24;
|
||||
return 1 - (sunRise - now) / (sunRise - prevSunSet);
|
||||
} else {
|
||||
const upcomingSunRise = sunRise + 60 * 60 * 24;
|
||||
let upcomingSunRise = sunRise + 60 * 60 * 24;
|
||||
return (upcomingSunRise - now) / (upcomingSunRise - sunSet);
|
||||
}
|
||||
}
|
||||
|
@ -731,16 +739,16 @@ function radians(a) {
|
|||
* This draws the actual gauge consisting out of lots of little filled circles
|
||||
*/
|
||||
function drawGauge(cx, cy, percent, color) {
|
||||
const offset = 15;
|
||||
const end = 360 - offset;
|
||||
const radius = radiusInner + (circleCount == 3 ? 3 : 2);
|
||||
const size = radiusOuter - radiusInner - 2;
|
||||
let offset = 15;
|
||||
let end = 360 - offset;
|
||||
let radius = radiusInner + (circleCount == 3 ? 3 : 2);
|
||||
let size = radiusOuter - radiusInner - 2;
|
||||
|
||||
if (percent <= 0) return; // no gauge needed
|
||||
if (percent > 1) percent = 1;
|
||||
|
||||
const startRotation = -offset;
|
||||
const endRotation = startRotation - ((end - offset) * percent);
|
||||
let startRotation = -offset;
|
||||
let endRotation = startRotation - ((end - offset) * percent);
|
||||
|
||||
color = getGradientColor(color, percent);
|
||||
g.setColor(color);
|
||||
|
@ -754,7 +762,7 @@ function drawGauge(cx, cy, percent, color) {
|
|||
|
||||
function writeCircleText(w, content) {
|
||||
if (content == undefined) return;
|
||||
const font = String(content).length > 4 ? circleFontSmall : String(content).length > 3 ? circleFont : circleFontBig;
|
||||
let font = String(content).length > 4 ? circleFontSmall : String(content).length > 3 ? circleFont : circleFontBig;
|
||||
g.setFont(font);
|
||||
|
||||
g.setFontAlign(0, 0);
|
||||
|
@ -786,7 +794,7 @@ function getSteps() {
|
|||
}
|
||||
|
||||
function getWeather() {
|
||||
const jsonWeather = storage.readJSON('weather.json');
|
||||
let jsonWeather = storage.readJSON('weather.json');
|
||||
return jsonWeather && jsonWeather.weather ? jsonWeather.weather : undefined;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
{ "id": "circlesclock",
|
||||
"name": "Circles clock",
|
||||
"shortName":"Circles clock",
|
||||
"version":"0.15",
|
||||
"version":"0.16",
|
||||
"description": "A clock with three or four circles for different data at the bottom in a probably familiar style",
|
||||
"icon": "app.png",
|
||||
"screenshots": [{"url":"screenshot-dark.png"}, {"url":"screenshot-light.png"}, {"url":"screenshot-dark-4.png"}, {"url":"screenshot-light-4.png"}],
|
||||
|
|
Loading…
Reference in New Issue