Allow configuration of up to 4 circles in a row
parent
96b67513a1
commit
9489375a1c
|
|
@ -12,3 +12,4 @@
|
||||||
Support to show time and progress until next sunrise or sunset
|
Support to show time and progress until next sunrise or sunset
|
||||||
Load daily steps from Bangle health if available
|
Load daily steps from Bangle health if available
|
||||||
0.07: Allow configuration of minimal heart rate confidence
|
0.07: Allow configuration of minimal heart rate confidence
|
||||||
|
0.08: Allow configuration of up to 4 circles in a row
|
||||||
|
|
|
||||||
|
|
@ -23,10 +23,7 @@ const weatherStormy = heatshrink.decompress(atob("iEQwYLIg/gAgUB///wAFBh/AgfwgED
|
||||||
const sunSetDown = heatshrink.decompress(atob("iEQwIHEgOAAocT5EGtEEkF//wLDg1ggfACoo"));
|
const sunSetDown = heatshrink.decompress(atob("iEQwIHEgOAAocT5EGtEEkF//wLDg1ggfACoo"));
|
||||||
const sunSetUp = heatshrink.decompress(atob("iEQwIHEgOAAocT5EGtEEkF//wRFgfAg1gBIY"));
|
const sunSetUp = heatshrink.decompress(atob("iEQwIHEgOAAocT5EGtEEkF//wRFgfAg1gBIY"));
|
||||||
|
|
||||||
let settings;
|
let settings = storage.readJSON("circlesclock.json", 1) || {
|
||||||
|
|
||||||
function loadSettings() {
|
|
||||||
settings = storage.readJSON("circlesclock.json", 1) || {
|
|
||||||
'minHR': 40,
|
'minHR': 40,
|
||||||
'maxHR': 200,
|
'maxHR': 200,
|
||||||
'confidence': 0,
|
'confidence': 0,
|
||||||
|
|
@ -36,19 +33,21 @@ function loadSettings() {
|
||||||
'batteryWarn': 30,
|
'batteryWarn': 30,
|
||||||
'showWidgets': false,
|
'showWidgets': false,
|
||||||
'weatherCircleData': 'humidity',
|
'weatherCircleData': 'humidity',
|
||||||
|
'circleCount': 3,
|
||||||
'circle1': 'hr',
|
'circle1': 'hr',
|
||||||
'circle2': 'steps',
|
'circle2': 'steps',
|
||||||
'circle3': 'battery'
|
'circle3': 'battery',
|
||||||
|
'circle4': 'weather'
|
||||||
};
|
};
|
||||||
// Load step goal from pedometer widget as fallback
|
// Load step goal from pedometer widget as fallback
|
||||||
if (settings.stepGoal == undefined) {
|
if (settings.stepGoal == undefined) {
|
||||||
const d = require('Storage').readJSON("wpedom.json", 1) || {};
|
const d = require('Storage').readJSON("wpedom.json", 1) || {};
|
||||||
settings.stepGoal = d != undefined && d.settings != undefined ? d.settings.goal : 10000;
|
settings.stepGoal = d != undefined && d.settings != undefined ? d.settings.goal : 10000;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
loadSettings();
|
|
||||||
|
|
||||||
|
|
||||||
|
const circleCount = settings.circleCount || 3;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Read location from myLocation app
|
* Read location from myLocation app
|
||||||
*/
|
*/
|
||||||
|
|
@ -78,11 +77,33 @@ const hOffset = 30 - widgetOffset;
|
||||||
const h1 = Math.round(1 * h / 5 - hOffset);
|
const h1 = Math.round(1 * h / 5 - hOffset);
|
||||||
const h2 = Math.round(3 * h / 5 - hOffset);
|
const h2 = Math.round(3 * h / 5 - hOffset);
|
||||||
const h3 = Math.round(8 * h / 8 - hOffset - 3); // circle y position
|
const h3 = Math.round(8 * h / 8 - hOffset - 3); // circle y position
|
||||||
const circlePosX = [Math.round(w / 6), Math.round(3 * w / 6), Math.round(5 * w / 6)]; // cirle x positions
|
|
||||||
const radiusOuter = 25;
|
/*
|
||||||
const radiusInner = 20;
|
* circle x positions
|
||||||
const circleFont = "Vector:15";
|
* depending on circleCount
|
||||||
const circleFontBig = "Vector:16";
|
*
|
||||||
|
* | 1 2 3 4 5 6 |
|
||||||
|
* | (1) (2) (3) |
|
||||||
|
* => circles start at 1,3,5 / 6
|
||||||
|
*
|
||||||
|
* | 1 2 3 4 5 6 7 8 |
|
||||||
|
* | (1) (2) (3) (4) |
|
||||||
|
* => circles start at 1,3,5,7 / 8
|
||||||
|
*/
|
||||||
|
const parts = circleCount * 2;
|
||||||
|
const circlePosX = [
|
||||||
|
Math.round(1 * w / parts),
|
||||||
|
Math.round(3 * w / parts),
|
||||||
|
Math.round(5 * w / parts),
|
||||||
|
Math.round(7 * w / parts),
|
||||||
|
];
|
||||||
|
|
||||||
|
const radiusOuter = circleCount == 3 ? 25 : 20;
|
||||||
|
const radiusInner = circleCount == 3 ? 20 : 15;
|
||||||
|
const circleFont = circleCount == 3 ? "Vector:15" : "Vector:13";
|
||||||
|
const circleFontBig = circleCount == 3 ? "Vector:16" : "Vector:14";
|
||||||
|
const defaultCircleTypes = ["steps", "hr", "battery", "weather"];
|
||||||
|
|
||||||
|
|
||||||
function draw() {
|
function draw() {
|
||||||
g.clear(true);
|
g.clear(true);
|
||||||
|
|
@ -122,10 +143,9 @@ function draw() {
|
||||||
drawCircle(1);
|
drawCircle(1);
|
||||||
drawCircle(2);
|
drawCircle(2);
|
||||||
drawCircle(3);
|
drawCircle(3);
|
||||||
|
if (circleCount >= 4) drawCircle(4);
|
||||||
}
|
}
|
||||||
|
|
||||||
const defaultCircleTypes = ["steps", "hr", "battery"];
|
|
||||||
|
|
||||||
function drawCircle(index) {
|
function drawCircle(index) {
|
||||||
let type = settings['circle' + index];
|
let type = settings['circle' + index];
|
||||||
if (!type) type = defaultCircleTypes[index - 1];
|
if (!type) type = defaultCircleTypes[index - 1];
|
||||||
|
|
@ -147,6 +167,7 @@ function drawCircle(index) {
|
||||||
drawWeather(w);
|
drawWeather(w);
|
||||||
break;
|
break;
|
||||||
case "sunprogress":
|
case "sunprogress":
|
||||||
|
case "sunProgress":
|
||||||
drawSunProgress(w);
|
drawSunProgress(w);
|
||||||
break;
|
break;
|
||||||
case "empty":
|
case "empty":
|
||||||
|
|
@ -319,6 +340,8 @@ function drawWeather(w) {
|
||||||
if (code > 0) {
|
if (code > 0) {
|
||||||
const icon = getWeatherIconByCode(code);
|
const icon = getWeatherIconByCode(code);
|
||||||
if (icon) g.drawImage(icon, w - 6, h3 + radiusOuter - 10);
|
if (icon) g.drawImage(icon, w - 6, h3 + radiusOuter - 10);
|
||||||
|
} else {
|
||||||
|
g.drawString("?", w, h3 + radiusOuter);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
{ "id": "circlesclock",
|
{ "id": "circlesclock",
|
||||||
"name": "Circles clock",
|
"name": "Circles clock",
|
||||||
"shortName":"Circles clock",
|
"shortName":"Circles clock",
|
||||||
"version":"0.07",
|
"version":"0.08",
|
||||||
"description": "A clock with circles for different data at the bottom in a probably familiar style",
|
"description": "A clock with circles for different data at the bottom in a probably familiar style",
|
||||||
"icon": "app.png",
|
"icon": "app.png",
|
||||||
"screenshots": [{"url":"screenshot-dark.png"}, {"url":"screenshot-light.png"}],
|
"screenshots": [{"url":"screenshot-dark.png"}, {"url":"screenshot-light.png"}],
|
||||||
|
|
|
||||||
|
|
@ -96,23 +96,36 @@
|
||||||
format: v => weatherData[v],
|
format: v => weatherData[v],
|
||||||
onchange: x => save('weatherCircleData', weatherData[x]),
|
onchange: x => save('weatherCircleData', weatherData[x]),
|
||||||
},
|
},
|
||||||
'left': {
|
'circle count': {
|
||||||
|
value: "circleCount" in settings ? settings.circleCount : 3,
|
||||||
|
min: 3,
|
||||||
|
max : 4,
|
||||||
|
step: 1,
|
||||||
|
onchange: x => save('circleCount', x),
|
||||||
|
},
|
||||||
|
'circle1': {
|
||||||
value: settings.circle1 ? valuesCircleTypes.indexOf(settings.circle1) : 0,
|
value: settings.circle1 ? valuesCircleTypes.indexOf(settings.circle1) : 0,
|
||||||
min: 0, max: 6,
|
min: 0, max: 6,
|
||||||
format: v => namesCircleTypes[v],
|
format: v => namesCircleTypes[v],
|
||||||
onchange: x => save('circle1', valuesCircleTypes[x]),
|
onchange: x => save('circle1', valuesCircleTypes[x]),
|
||||||
},
|
},
|
||||||
'middle': {
|
'circle2': {
|
||||||
value: settings.circle2 ? valuesCircleTypes.indexOf(settings.circle2) : 2,
|
value: settings.circle2 ? valuesCircleTypes.indexOf(settings.circle2) : 2,
|
||||||
min: 0, max: 6,
|
min: 0, max: 6,
|
||||||
format: v => namesCircleTypes[v],
|
format: v => namesCircleTypes[v],
|
||||||
onchange: x => save('circle2', valuesCircleTypes[x]),
|
onchange: x => save('circle2', valuesCircleTypes[x]),
|
||||||
},
|
},
|
||||||
'right': {
|
'circle3': {
|
||||||
value: settings.circle3 ? valuesCircleTypes.indexOf(settings.circle3) : 3,
|
value: settings.circle3 ? valuesCircleTypes.indexOf(settings.circle3) : 3,
|
||||||
min: 0, max: 6,
|
min: 0, max: 6,
|
||||||
format: v => namesCircleTypes[v],
|
format: v => namesCircleTypes[v],
|
||||||
onchange: x => save('circle3', valuesCircleTypes[x]),
|
onchange: x => save('circle3', valuesCircleTypes[x]),
|
||||||
|
},
|
||||||
|
'circle4': {
|
||||||
|
value: settings.circle4 ? valuesCircleTypes.indexOf(settings.circle4) : 4,
|
||||||
|
min: 0, max: 6,
|
||||||
|
format: v => namesCircleTypes[v],
|
||||||
|
onchange: x => save('circle4', valuesCircleTypes[x]),
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue