-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3483 from Chriz76/master
ashadyclock: new clock using dithering effects
- Loading branch information
Showing
17 changed files
with
167 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"}] | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
}, | ||
}); | ||
}) |