diff --git a/apps/dailycolorclk/Icon.png b/apps/dailycolorclk/Icon.png new file mode 100644 index 0000000000..1235ec88d5 Binary files /dev/null and b/apps/dailycolorclk/Icon.png differ diff --git a/apps/dailycolorclk/README.md b/apps/dailycolorclk/README.md new file mode 100644 index 0000000000..10af09cddd --- /dev/null +++ b/apps/dailycolorclk/README.md @@ -0,0 +1,16 @@ +# Daily Color Clock +A clock that randomly changes the accent color every day to freshen up the clock face every day. + +This is forked from `Slope Clock ++` + +![](Scr4.png) +## Settings +Choose what colors are enabled or disabled, which affects the colors it can be. + +#### Dithered colors: +Colors that are dithered, which may affect quality. + + + +## Creator +RKBoss6 diff --git a/apps/dailycolorclk/Scr1.png b/apps/dailycolorclk/Scr1.png new file mode 100644 index 0000000000..feeb499c00 Binary files /dev/null and b/apps/dailycolorclk/Scr1.png differ diff --git a/apps/dailycolorclk/Scr2.png b/apps/dailycolorclk/Scr2.png new file mode 100644 index 0000000000..5c7b35dd8a Binary files /dev/null and b/apps/dailycolorclk/Scr2.png differ diff --git a/apps/dailycolorclk/Scr3.png b/apps/dailycolorclk/Scr3.png new file mode 100644 index 0000000000..5cdcd4e1a5 Binary files /dev/null and b/apps/dailycolorclk/Scr3.png differ diff --git a/apps/dailycolorclk/Scr4.png b/apps/dailycolorclk/Scr4.png new file mode 100644 index 0000000000..0949fbbdce Binary files /dev/null and b/apps/dailycolorclk/Scr4.png differ diff --git a/apps/dailycolorclk/app-icon.js b/apps/dailycolorclk/app-icon.js new file mode 100644 index 0000000000..adf17ed9ea --- /dev/null +++ b/apps/dailycolorclk/app-icon.js @@ -0,0 +1 @@ +require("heatshrink").decompress(atob("mEw4n/AAPgg4JBimlvvv8UXosp/vvjnnnnnuut9df8MP11z8kn8cfEwUEAQN5yA1JBwNEAAMApWohHd7EA3e5C5MIxAACwGKxUKxGKg+6C5QUBpFKwk07uipBFBgGb24XJocIpGYonUC4JHBndwzOAF5eITQWK1EApGbuBPBL5VEL4YJDWANAfX7IE1RGChGoJaEykUtgEJ6UilQWOgcmkVi6EGAgWgCRFKAgdCsXdk0kwVi1oEBCw8JUwmik0A6UqmRFBsUoF5E6LwkjAQXSCgIcBRBGIyAXGF4MthEmF5NKTYYXEL4KQBsC5JI5EKkSPKhB2DFgR6BDQOKF4LYIxTjE0TVBGQSOBa5OooaQDLQOIsxyBboK+IgEK1GIAoTqDOQLdBdxJlGOQMiCYPSboIAPxWI1AEBAYYALu4ABuEAg4EBAYYALiIAWqoAKr/B093zceqvh3OZ2P1iMe93u8ojG58ZLAWx+PhLAOx8MR4IQCqIXF8OwC4Vx/0bDgcVjWZzObj4XGFAOXgEOisXC4kZvW7zIXGqNwg8agELqOQC4ccjMLiOwjhgG3e7MIMOIwK0BF4d5zN6j8VTw5hBuJGB04vDjYkB2MV4IxFUQJDB2Owg4ZBR43hjdRSQkeIYMJj1whOggGbisfjOR3Obzf5SQtR8EAvzDDDoUVjeRjaoB1eX2IwDIwYXHjV73OaveRzOhKIJGDYAOau93YwN7j53DPIQBBM4RGCAAMBSgZ3GiJdBSAZGCAAMO/3hC4XxCQP159V93l+peCCAO61QAB13h4IGBNokRaoUfr/BAoMebYo6CZwtRVIOxBQPx3IEB33h3cb0MR53uLghiB2+5zx4Bj17VwN7iOZ2+fFgrmDjPqvOZ2MbuLHBzcR3I7BKwQAFeYO73Wn3cR0+rzYEBy46BF5CrE3cfOwUejnuNwQXIjkcivFBwPxqscCQUcBIIADA")) diff --git a/apps/dailycolorclk/app.js b/apps/dailycolorclk/app.js new file mode 100644 index 0000000000..94aa908840 --- /dev/null +++ b/apps/dailycolorclk/app.js @@ -0,0 +1,180 @@ +{ // must be inside our own scope here so that when we are unloaded everything disappears + +let settings; +let getSettings=function(){ + settings = Object.assign( + require("Storage").readJSON("dailycolorclk.default.json", true) || {}, + require("Storage").readJSON("dailycolorclk.json", true) || {} + ); +} +let writeSettings=function(){ + require("Storage").writeJSON("dailycolorclk.json", settings); +} +getSettings(); + +const fontBitmap = E.toString(require('heatshrink').decompress(atob('A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v5iDDILTCLQaeBaYXgSoihCFYaCCv4rDERrBEIoQlBFYfwAQKXENAV/VAl4AQN+RJQ='))); + +Graphics.prototype.setFontPaytoneOne = function(scale) { + this.setFontCustom(fontBitmap, 46, atob("ER0mGCMjJiMkIiUkEg=="), 70|65536); + return this; +} + +let drawTimeout; + + +const slopeHeight = 90; +const fontBorder = 13; +const hoursYPos=68; +const minOffset=4; //offset from slope +const slopeBorder = 4; + +let R; +let dateStr = ""; +let bgColor = settings.colorSaved; +let changeBGColor = function() { + let bgColors = []; + if (settings.colorYellow) bgColors.push("#ff0"); + if (settings.colorCyan) bgColors.push("#0ff"); + if (settings.colorMagenta) bgColors.push("#f0f"); + if (settings.colorWhite) bgColors.push("#fff"); + if (settings.colorRed) bgColors.push("#f00"); + if (settings.colorGreen) bgColors.push("#0f0"); + if (settings.colorBlue) bgColors.push("#00f"); + if (settings.colorOrange) bgColors.push("#FC6A03"); + if (settings.colorPurple) bgColors.push("#B200ED"); + if (settings.colorBlack) bgColors.push("#000"); + + let oldColorIdx = bgColors.indexOf(settings.colorSaved); + if (oldColorIdx !== -1) bgColors.splice(oldColorIdx, 1); + let col = bgColors[(Math.random()*bgColors.length)|0] || "#000"; + + settings.colorSaved = col; + writeSettings(); +} +let checkForColorChange = function() { + let dayNow = new Date().getDay(); + if (settings.dayChanged != dayNow) { + settings.dayChanged = dayNow; + changeBGColor(); + load(); + } +} + +//draws bg color once, erases background +let preDraw=function(){ + g.setColor(g.theme.bg).fillRect(0,0,g.getWidth(),g.getHeight()); + g.setColor(bgColor).fillRect( + 0,slopeHeight,g.getWidth(), g.getHeight() + ); + +} +// Draw the hour, minute, and date +let draw = function() { + + checkForColorChange(); + + if (drawTimeout) clearTimeout(drawTimeout); + drawTimeout = setTimeout(draw, 60000 - (Date.now() % 60000)); + + R = Bangle.appRect; + + + var date = new Date(); + var local_time = require("locale").time(date, 1); + var hourStr = " "+local_time.split(":")[0].padStart(2,'0')+" "; + var minStr = " "+local_time.split(":")[1].padStart(2,'0')+" "; + + dateStr = require("locale").dow(date,1) + ', ' + + require("locale").month(date,1) + " " + date.getDate(); + + //clear old hour + g.setColor(g.theme.bg); + g.fillRect(0,24,96,88); + // Draw hour + g.setColor(g.theme.fg) + .setFontAlign(-1, 0) + .setFont("PaytoneOne") + .drawString(hourStr, fontBorder, hoursYPos); + + + + + + + // draw minutes + var yo = slopeHeight + minOffset; + g.setColor(bgColor); + //clear old minutes + g.fillRect(92,92,g.getWidth(),152); + g.setFontAlign(1, -1).setFont("PaytoneOne") + .setColor(g.theme.bg).drawString(minStr,g.getWidth()-7, yo); + + // Transition bar + g.setColor(g.theme.bg).fillRect( + 0,slopeHeight-slopeBorder,g.getWidth(), slopeHeight + ); + // Draw date + g.setColor(g.theme.bg) + .setFontAlign(0, 0) + .setFont("Vector",16) + .drawString(dateStr, R.x + R.w/2, R.y+R.h-13); + +}; + + + +// Clock info menus +let clockInfoDraw = (itm, info, options) => { + let texty = options.y+41; + g.reset().setClipRect(options.x, options.y, options.x+options.w-1, options.y+options.h-1); + g.setFont("Vector",15).setBgColor(options.bg).clearRect(options.x, texty-15, options.x+options.w-2, texty); + + g.setColor(options.focus ? options.hl : options.fg); + if (options.x < g.getWidth()/2) { + let x = options.x+2; + if (info.img) g.clearRect(x, options.y, x+23, options.y+23).drawImage(info.img, x, options.y); + g.setFontAlign(-1,1).drawString(info.text, x,texty); + } else { + let x = options.x+options.w-3; + if (info.img) g.clearRect(x-23, options.y, x, options.y+23).drawImage(info.img, x-23, options.y); + g.setFontAlign(1,1).drawString(info.text, x,texty); + } + g.setClipRect(0,0,g.getWidth()-1, g.getHeight()-1); +}; + +let clockInfoItems = require("clock_info").load(); +let clockInfoMenu = require("clock_info").addInteractive(clockInfoItems, { + app:"slopeclockpp",x:98, y:38, w:70, h:50, + draw : clockInfoDraw, bg : g.theme.bg, fg : g.theme.fg, hl : + (g.theme.fg===g.toColor(bgColor))?"#f00":bgColor +}); +let clockInfoMenu2 = require("clock_info").addInteractive(clockInfoItems, { + app:"slopeclockpp",x:10, y:102, w:70, h:50, + draw : clockInfoDraw, bg : bgColor, fg : g.theme.bg, hl : + (g.theme.fg===g.toColor(bgColor))?"#f00":g.theme.fg +}); + +// Show launcher when middle button pressed +Bangle.setUI({ + mode : "clock", + remove : function() { + if (drawTimeout) clearTimeout(drawTimeout); + drawTimeout = undefined; + delete Graphics.prototype.setFontPaytoneOne; + clockInfoMenu.remove(); + delete clockInfoMenu; + clockInfoMenu2.remove(); + delete clockInfoMenu2; + }, + redraw: draw, +}); + +Bangle.loadWidgets(); +if (settings.hideWidgets) require("widget_utils").swipeOn(); +else setTimeout(Bangle.drawWidgets,0); +preDraw(); +draw(); +clockInfoMenu.redraw(); +clockInfoMenu2.redraw(); + +} diff --git a/apps/dailycolorclk/default.json b/apps/dailycolorclk/default.json new file mode 100644 index 0000000000..84d5b744ee --- /dev/null +++ b/apps/dailycolorclk/default.json @@ -0,0 +1,12 @@ +{ + "colorRed": true, + "colorGreen": true, + "colorBlue": true, + "colorYellow": true, + "colorMagenta": true, + "colorCyan": true, + "colorBlack": true, + "colorWhite": true, + "colorOrange": true, + "colorPurple": true +} diff --git a/apps/dailycolorclk/metadata.json b/apps/dailycolorclk/metadata.json new file mode 100644 index 0000000000..ef00382541 --- /dev/null +++ b/apps/dailycolorclk/metadata.json @@ -0,0 +1,29 @@ +{ + "id": "dailycolorclk", + "name": "Daily Color Clock", + "shortName":"Daily Color", + "icon": "Icon.png", + "version":"0.01", + "description": "A clock with 2 ClockInfos and a bar of color at the bottom that changes color every day. Forked from Slope Clock ++", + "type":"clock", + "tags": "clock,clkinfo", + "author":"RKBoss6", + "supports": ["BANGLEJS2"], + "screenshots" : [ { "url":"Scr1.png" }, + { "url":"Scr2.png" },{ "url":"Scr3.png" },{ "url":"Scr4.png" }], + "dependencies" : { "clock_info":"module"}, + "allow_emulator":true, + "readme":"README.md", + "storage": [ + {"name":"dailycolorclk.app.js","url":"app.js"}, + {"name":"dailycolorclk.img","url":"app-icon.js","evaluate":true}, + {"name":"dailycolorclk.settings.js","url":"settings.js"}, + {"name":"dailycolorclk.default.json","url":"default.json"} + ], + "data": [ + {"name":"dailycolorclk.settings.json"}, + {"name":"dailycolorclk.json"} + ] +} + + diff --git a/apps/dailycolorclk/settings.js b/apps/dailycolorclk/settings.js new file mode 100644 index 0000000000..8be4c6c01e --- /dev/null +++ b/apps/dailycolorclk/settings.js @@ -0,0 +1,76 @@ +(function(back) { + const SETTINGS_FILE = "dailycolorclk.json"; + const storage = require('Storage'); + let settings = Object.assign( + storage.readJSON("dailycolorclk.default.json", true) || {}, + storage.readJSON(SETTINGS_FILE, true) || {} + ); + + function save(key, value) { + settings[key] = value; + storage.write(SETTINGS_FILE, settings); + } + function showDitheringMenu(){ + var menu={ + "< Back": () => showMainMenu, + /*LANG*/'Orange (Dithered)': { + value: !!settings.colorOrange, + onchange: x => save('colorOrange', x), + }, + /*LANG*/'Purple (Dithered)': { + value: !!settings.colorPurple, + onchange: x => save('colorPurple', x), + } + } + E.showMenu(menu); + } + function showMainMenu() { + let menu ={ + '': { 'title': 'Daily Color Clock' }, + /*LANG*/'< Back': back, + /*LANG*/'Hide Widgets': { + value: !!settings.hideWidgets, + onchange: x => save('hideWidgets', x), + }, + /*LANG*/'Dithered Colors': () => {showDitheringMenu()}, + /*LANG*/'Red': { + value: !!settings.colorRed, + onchange: x => save('colorRed', x), + }, + /*LANG*/'Green': { + value: !!settings.colorGreen, + onchange: x => save('colorGreen', x), + }, + /*LANG*/'Blue': { + value: !!settings.colorBlue, + onchange: x => save('colorBlue', x), + }, + /*LANG*/'Magenta': { + value: !!settings.colorMagenta, + onchange: x => save('colorMagenta', x), + }, + /*LANG*/'Cyan': { + value: !!settings.colorCyan, + onchange: x => save('colorCyan', x), + }, + /*LANG*/'Yellow': { + value: !!settings.colorYellow, + onchange: x => save('colorYellow', x), + }, + /*LANG*/'Black': { + value: !!settings.colorBlack, + onchange: x => save('colorBlack', x), + }, + /*LANG*/'White': { + value: !!settings.colorWhite, + onchange: x => save('colorWhite', x), + }, + + + }; + E.showMenu(menu); + } + + + showMainMenu(); +})