Skip to content

improve icon + screenshots of CC-Clock24 #3795

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions apps/cc_astro/ChangeLog
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.01: First functional release
9 changes: 9 additions & 0 deletions apps/cc_astro/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Astronomy Clock

## Features

* shows earth as hour and venus as minute hand
* shows mercury as second hand only on unlocked screen
* if battery is low, the sun will become to a red giant

![logo](screenshot1.png)
184 changes: 184 additions & 0 deletions apps/cc_astro/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,184 @@
// ----- const -----

const center = {
"x": g.getWidth()/2,
"y": g.getHeight()/2
};

const parameters = {
"earthOrbitRadius": 80,
"venusOrbitRadius": 60,
"mercuryOrbitRadius": 40,
"earthRadius": 8,
"venusRadius": 6,
"mercuryRadius": 4,
"sunRadius": 12,
"maxSunRadius": 115
};

// ----- global vars -----

let drawTimeout;
let queueMillis = 1000;
let unlock = true;
let lastBatteryStates = [E.getBattery()];

// ----- functions -----

function updateState() {
updateBatteryStates();

if (Bangle.isLCDOn()) {
if (!Bangle.isLocked()) {
queueMillis = 1000;
unlock = true;
}
else {
queueMillis = 60000;
unlock = false;
}
draw();
}
else {
if (drawTimeout)
clearTimeout(drawTimeout);
drawTimeout = undefined;
}
}

function updateBatteryStates() {
lastBatteryStates.push(E.getBattery());
if (lastBatteryStates.length > 5)
lastBatteryStates.shift(); // remove 1st item
}

function draw() {
drawBackground();
drawHands();
queueDraw();
}

function drawBackground() {
clearScreen();
drawSun();
}

function clearScreen() {
g.setBgColor(0, 0, 0);
g.clear();
}

function drawSun() {
const batteryState = calcAvgBatteryState();

if (batteryState <= 25)
g.setColor(1, 0, 0); // red sun, if battery low
else
g.setColor(1, 1, 0);

let r = parameters.sunRadius;
if (batteryState <= 20) {
const relSize = (20 - batteryState) / 20;
const dr = parameters.maxSunRadius - parameters.sunRadius;
r = parameters.sunRadius + relSize * dr;
}

g.fillCircle(center.x, center.y, r);
}

function drawHands() {
const date = new Date();

drawHourHand(date.getHours(), date.getMinutes());
drawMinuteHand(date.getMinutes());

if (unlock) {
drawSecondHand(date.getSeconds());
}
}

function drawHourHand(hours, minutes) {
const r = parameters.earthOrbitRadius;
const phi = 30 * (hours + minutes/60) * (Math.PI / 180) - Math.PI/2;
const x = center.x + r * Math.cos(phi);
const y = center.y + r * Math.sin(phi);

g.setColor(1, 1, 1);
g.drawCircle(center.x, center.y, r);

g.setColor(0, 1, 1);
g.fillCircle(x, y, parameters.earthRadius);
}

function drawMinuteHand(minutes) {
const r = parameters.venusOrbitRadius;
const phi = 6 * minutes * (Math.PI / 180) - Math.PI/2;
const x = center.x + r * Math.cos(phi);
const y = center.y + r * Math.sin(phi);

g.setColor(1, 1, 1);
g.drawCircle(center.x, center.y, r);

g.setColor(1, 1, 1);
g.fillCircle(x, y, parameters.venusRadius);
}

function drawSecondHand(seconds) {
const r = parameters.mercuryOrbitRadius;
const phi = 6 * seconds * (Math.PI / 180) - Math.PI/2;
const x = center.x + r * Math.cos(phi);
const y = center.y + r * Math.sin(phi);

g.setColor(1, 1, 1);
g.drawCircle(center.x, center.y, r);

g.setColor(1, 0, 1);
g.fillCircle(x, y, parameters.mercuryRadius);
}

function calcAvgBatteryState() {
const n = lastBatteryStates.length;
if (n == 0)
return 100;

let sum = lastBatteryStates.reduce((acc, value) => acc + value, 0);
return Math.round(sum / n);
}

function queueDraw() {
if (drawTimeout)
clearTimeout(drawTimeout);

drawTimeout = setTimeout(function() {
drawTimeout = undefined;
draw();
}, queueMillis - (Date.now() % queueMillis));
}


//// main running sequence ////

// Show launcher when middle button pressed, and widgets that we're clock
Bangle.setUI({
mode: "clock",
remove: function() {
Bangle.removeListener('lcdPower', updateState);
Bangle.removeListener('lock', updateState);
Bangle.removeListener('charging', draw);

// We clear drawTimout after removing all listeners, because they can add one again
if (drawTimeout)
clearTimeout(drawTimeout);

drawTimeout = undefined;
require("widget_utils").show();
}
});

// Stop updates when LCD is off, restart when on
Bangle.on('lcdPower', updateState);
Bangle.on('lock', updateState);
Bangle.on('charging', draw); // Immediately redraw when charger (dis)connected

updateState();
draw();
1 change: 1 addition & 0 deletions apps/cc_astro/app_icon.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added apps/cc_astro/app_icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 21 additions & 0 deletions apps/cc_astro/metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{ "id": "cc_astro",
"name": "CC Astro",
"shortName": "CC-Astro",
"version": "0.01",
"description": "A clock with planets as clock hands",
"icon": "app_icon.png",
"type": "clock",
"tags": "clock,astro,planets,earth,venus,mercury,sun",
"supports" : ["BANGLEJS2"],
"screenshots": [
{"url":"screenshot1.png"},
{"url":"screenshot2.png"},
{"url":"screenshot3.png"}
],
"readme": "README.md",
"storage": [
{"name": "cc_astro.app.js", "url": "app.js"},
{"name": "cc_astro.img", "url": "app_icon.js", "evaluate":true}
],
"data": [{"name":"cc_astro.json"}]
}
Binary file added apps/cc_astro/screenshot1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added apps/cc_astro/screenshot2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added apps/cc_astro/screenshot3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions apps/cc_clock24/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
0.01: copied from andark (V0.08)
refactored
add 24 hour mode
0.02: fix icon + screenshots
4 changes: 2 additions & 2 deletions apps/cc_clock24/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Analog Clock With 24 hour hands
# Analog Clock With Optional 24 hour hands

## Features

Expand All @@ -7,7 +7,7 @@
* battery percentage (showing charge status with color)
* turned off or swipeable widgets (choose in settings)

![logo](cc_clock24_screen.png)
![logo](screenshot1.png)

## Settings

Expand Down
2 changes: 1 addition & 1 deletion apps/cc_clock24/app_icon.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added apps/cc_clock24/app_icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed apps/cc_clock24/cc_clock24_icon.png
Binary file not shown.
16 changes: 8 additions & 8 deletions apps/cc_clock24/metadata.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
{ "id": "cc_clock24",
"name": "CC Clock 24",
"shortName":"CC-Clock24",
"version":"0.01",
"shortName": "CC-Clock24",
"version": "0.02",
"description": "analog clock face with 24 hour pointer",
"icon": "cc_clock24_icon.png",
"icon": "app_icon.png",
"type": "clock",
"tags": "clock",
"supports" : ["BANGLEJS2"],
"screenshots": [{"url":"cc_clock24_screen.png"}],
"screenshots": [{"url": "screenshot1.png"}, {"url": "screenshot2.png"}, {"url": "screenshot3.png"}],
"readme": "README.md",
"storage": [
{"name":"cc_clock24.app.js","url":"app.js"},
{"name":"cc_clock24.settings.js","url":"settings.js"},
{"name":"cc_clock24.img","url":"app_icon.js","evaluate":true}
{"name": "cc_clock24.app.js", "url": "app.js"},
{"name": "cc_clock24.settings.js", "url": "settings.js"},
{"name": "cc_clock24.img", "url": "app_icon.js", "evaluate": true}
],
"data": [{"name":"cc_clock24.json"}]
"data": [{"name": "cc_clock24.json"}]
}
Binary file added apps/cc_clock24/screenshot1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added apps/cc_clock24/screenshot2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 5 additions & 5 deletions apps/cc_clock24/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,27 @@
shortHrHand : false,
show24HourMode : false
}
let settings = Object.assign(defaultSettings, require('Storage').readJSON('cc_clock24.json',1) || {});
let settings = Object.assign(defaultSettings, require('Storage').readJSON('cc_clock24.json', 1) || {});

const save = () => require('Storage').write('cc_clock24.json', settings);

const appMenu = {
'': {title: 'cc_clock24'}, '< Back': back,
/*LANG*/'Load widgets': {
value : !!settings.loadWidgets,
onchange : v => { settings.loadWidgets=v; save();}
onchange : v => { settings.loadWidgets = v; save();}
},
/*LANG*/'Text above hands': {
value : !!settings.textAboveHands,
onchange : v => { settings.textAboveHands=v; save();}
onchange : v => { settings.textAboveHands = v; save();}
},
/*LANG*/'Short hour hand': {
value : !!settings.shortHrHand,
onchange : v => { settings.shortHrHand=v; save();}
onchange : v => { settings.shortHrHand = v; save();}
},
/*LANG*/'Show 24 hour mode': {
value : !!settings.show24HourMode,
onchange : v => { settings.show24HourMode=v; save();}
onchange : v => { settings.show24HourMode = v; save();}
},
};

Expand Down