Skip to content

Commit

Permalink
Merge pull request #3483 from Chriz76/master
Browse files Browse the repository at this point in the history
ashadyclock: new clock using dithering effects
  • Loading branch information
bobrippling authored Jul 4, 2024
2 parents a08436b + 6abb02d commit cd54341
Show file tree
Hide file tree
Showing 17 changed files with 167 additions and 0 deletions.
Binary file added apps/ashadyclock/0.bin
Binary file not shown.
Binary file added apps/ashadyclock/1.bin
Binary file not shown.
Binary file added apps/ashadyclock/2.bin
Binary file not shown.
Binary file added apps/ashadyclock/3.bin
Binary file not shown.
Binary file added apps/ashadyclock/4.bin
Binary file not shown.
Binary file added apps/ashadyclock/5.bin
Binary file not shown.
Binary file added apps/ashadyclock/6.bin
Binary file not shown.
Binary file added apps/ashadyclock/7.bin
Binary file not shown.
Binary file added apps/ashadyclock/8.bin
Binary file not shown.
Binary file added apps/ashadyclock/9.bin
Binary file not shown.
1 change: 1 addition & 0 deletions apps/ashadyclock/app-icon.js

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

107 changes: 107 additions & 0 deletions apps/ashadyclock/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
var settings = Object.assign({
// default values
showWidgets: false,
alternativeColor: false,
}, require('Storage').readJSON("ashadyclock.json", true) || {});

let drawTimeout;
// schedule a draw for the next minute
function queueDraw() {
if (drawTimeout) clearTimeout(drawTimeout);
drawTimeout = setTimeout(function() {
drawTimeout = undefined;
draw();
}, 60000 - (Date.now() % 60000));
}

let palBottom;
if (settings.alternativeColor) {
palBottom = new Uint16Array(E.toArrayBuffer(E.toFlatString(new Uint16Array([
g.toColor("#000"),
g.toColor("#000"),
g.toColor("#0FF"),
g.toColor("#0FF"),
g.toColor("#00F"),
g.toColor("#000"),
g.toColor("#00F"),
g.toColor("#000")
]).buffer)));
} else {
palBottom = new Uint16Array(E.toArrayBuffer(E.toFlatString(new Uint16Array([
g.toColor("#000"),
g.toColor("#000"),
g.toColor("#F00"),
g.toColor("#FF0"),
g.toColor("#00F"),
g.toColor("#000"),
g.toColor("#FF0"),
g.toColor("#000")
]).buffer)));
}

let palTop = new Uint16Array(E.toArrayBuffer(E.toFlatString(new Uint16Array([
g.toColor("#FFF"),
g.toColor("#000"),
g.toColor("#FFF"),
g.toColor("#FFF"),
g.toColor("#00F"),
g.toColor("#000"),
g.toColor("#FFF"),
g.toColor("#000"),
]).buffer)));

let xOffset = (g.getWidth() - 176) / 2;
let yOffset = (g.getHeight() - 176) / 2;

function drawTop(d0, d1) {
if (settings.showWidgets && g.getHeight()<=176) {
drawNumber(d1, 82 + xOffset, 24 + yOffset, palTop, {scale: 0.825});
drawNumber(d0, 13 + xOffset, 24 + yOffset, palTop, {scale: 0.825});
} else {
drawNumber(d1, 80, 0, palTop);
drawNumber(d0, -1, 0, palTop);
}
}

function drawBottom(d0, d1) {
if (settings.showWidgets && g.getHeight()<=176) {
drawNumber(d1, 82 + xOffset, 92 + yOffset, palBottom, {scale: 0.825});
drawNumber(d0, 13 + xOffset, 92 + yOffset, palBottom, {scale: 0.825});
} else {
drawNumber(d1, 80, 75, palBottom);
drawNumber(d0, -1, 75, palBottom);
}
}

function drawNumber(number, x, y, palette, options) {
let image =
{
width : 98, height : 100, bpp : 3,
transparent: 4,
buffer : require("Storage").read("ashadyclock." + number +".bin")
};
image.palette = palette;
g.drawImage(image, x, y, options);
}

function draw() {
let d = new Date();
g.clearRect(0, settings.showWidgets ? 24 : 0, g.getWidth(),g.getHeight());

drawBottom(Math.floor(d.getMinutes()/10), d.getMinutes() % 10);
drawTop(Math.floor(d.getHours()/10), d.getHours() % 10);

queueDraw();
}

g.clear();
// draw immediately at first
draw();

// Show launcher when middle button pressed
Bangle.setUI("clock");

if(settings.showWidgets) {
Bangle.loadWidgets();
Bangle.drawWidgets();
}
Binary file added apps/ashadyclock/app.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
27 changes: 27 additions & 0 deletions apps/ashadyclock/metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{ "id": "ashadyclock",
"name": "A Shady Clock",
"shortName":"Shady Clk",
"icon": "app.png",
"version":"0.01",
"description": "A nice clock with drop shadow. Hours and minutes. Configure color and widgets in settings. Create any color combination with the existing images by changing only the app color values.",
"type": "clock",
"tags": "clock",
"screenshots": [{"url":"screenshot-1.png"},{"url":"screenshot.png"}],
"supports": ["BANGLEJS","BANGLEJS2"],
"storage": [
{"name":"ashadyclock.app.js","url":"app.js"},
{"name":"ashadyclock.img","url":"app-icon.js","evaluate":true},
{"name":"ashadyclock.0.bin","url":"0.bin"},
{"name":"ashadyclock.1.bin","url":"1.bin"},
{"name":"ashadyclock.2.bin","url":"2.bin"},
{"name":"ashadyclock.3.bin","url":"3.bin"},
{"name":"ashadyclock.4.bin","url":"4.bin"},
{"name":"ashadyclock.5.bin","url":"5.bin"},
{"name":"ashadyclock.6.bin","url":"6.bin"},
{"name":"ashadyclock.7.bin","url":"7.bin"},
{"name":"ashadyclock.8.bin","url":"8.bin"},
{"name":"ashadyclock.9.bin","url":"9.bin"},
{"name":"ashadyclock.settings.js","url":"settings.js"}
],
"data": [{"name":"ashadyclock.json"}]
}
Binary file added apps/ashadyclock/screenshot-1.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/ashadyclock/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: 32 additions & 0 deletions apps/ashadyclock/settings.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
(function(back) {
var FILE = "ashadyclock.json";
// Load settings
var settings = Object.assign({
showWidgets: false,
alternativeColor: false,
}, require('Storage').readJSON(FILE, true) || {});

function writeSettings() {
require('Storage').writeJSON(FILE, settings);
}

// Show the menu
E.showMenu({
"" : { "title" : "Shady Clck" },
"< Back" : () => back(),
'Show Widgets': {
value: !!settings.showWidgets, // !! converts undefined to false
onchange: v => {
settings.showWidgets = v;
writeSettings();
}
},
'Blue Color': {
value: !!settings.alternativeColor, // !! converts undefined to false
onchange: v => {
settings.alternativeColor = v;
writeSettings();
}
},
});
})

0 comments on commit cd54341

Please sign in to comment.