diff --git a/apps.json b/apps.json index fdf154b48..df658b4cd 100644 --- a/apps.json +++ b/apps.json @@ -454,6 +454,18 @@ {"name":"*scolor","url":"show-color-icon.js","evaluate":true} ] }, + { "id": "miclock", + "name": "Mixed Clock", + "icon": "clock-mixed.png", + "description": "A mix of analog and digital Clock", + "tags": "miclock", + "type":"clock", + "storage": [ + {"name":"+miclock","url":"clock-mixed.json"}, + {"name":"-miclock","url":"clock-mixed.js"}, + {"name":"*miclock","url":"clock-mixed-icon.js","evaluate":true} + ] + }, { "id": "bclock", "name": "Binary Clock", "icon": "clock-binary.png", diff --git a/apps/clock-mixed-icon.js b/apps/clock-mixed-icon.js new file mode 100644 index 000000000..3ca3b0612 --- /dev/null +++ b/apps/clock-mixed-icon.js @@ -0,0 +1 @@ +require("heatshrink").decompress(atob("mEwxH+AH4A/AH4ATiwAGFdYzlFp4xeFyYwZD49kxGs2fX6+z1mIsgxcDQtAxArCAA+zxFAGDAYFxAsJAAuIGCxcF1omHgEABI+sGCouERRIvJSgKTEFzovLGAJgRCIiMIF5ySGF57qMF5nXsgvORoggLF5yRPLyAvO6+IF6LsKF6JgEF5lkD5gvPYIiOaF6CQMBYesD5oAP1gvPXxpfDAQIAFYCILDJ5wvP64veACCPeAB6PQd4p9EQQ4MLd6GIF7uIF5YwDsgiNAY4vHsguLYBJfXXxiQKL66ONF4lAL7dAF5pgIF6y9DFxYvEi2sF6+sDwgvLGAryEACLsEFxrCGGCmzXh5gJSQYAPRgovQGA1kMR7qEFyQwHi2IGJWzxCLEFygwIMYOI1gzC2esxBbGFywxKABotXGCwuaGKQtdGZorjAH4A/AF4=")) diff --git a/apps/clock-mixed.js b/apps/clock-mixed.js new file mode 100644 index 000000000..97c73c0aa --- /dev/null +++ b/apps/clock-mixed.js @@ -0,0 +1,87 @@ +/* jshint esversion: 6 */ +(function() { + + const Radius = { "center": 8, "hour": 78, "min": 95, "dots": 102 }; + const Center = { "x": 120, "y": 132 }; + + function rotatePoint(x, y, d) { + rad = -1 * d / 180 * Math.PI; + var sin = Math.sin(rad); + var cos = Math.cos(rad); + xn = ((Center.x + x * cos - y * sin) + 0.5) | 0; + yn = ((Center.y + x * sin - y * cos) + 0.5) | 0; + p = [xn, yn]; + return p; + } + + function drawMixedClock() { + + var date = new Date(); + var dateArray = date.toString().split(" "); + var point = []; + var minute = date.getMinutes(); + var hour = date.getHours(); + var radius; + + // draw date + g.setColor(0x7be0); + g.setFont("6x8", 2); + g.setFontAlign(-1, 0); + g.drawString(dateArray[0] + ' ', 4, 35, true); + g.drawString(' ' + dateArray[2], 4, 225, true); + g.setFontAlign(1, 0); + g.drawString(dateArray[1], 237, 35, true); + g.drawString(dateArray[3], 237, 225, true); + + // draw hour and minute dots + g.setColor(0xFD20); // orange + for (i = 0; i < 60; i++) { + radius = (i % 5) ? 2 : 4; + point = rotatePoint(0, Radius.dots, i * 6); + g.fillCircle(point[0], point[1], radius); + } + + // erase last minutes hand + g.setColor(0); + point = rotatePoint(0, Radius.min, (minute - 1) * 6); + g.drawLine(Center.x, Center.y, point[0], point[1]); + + // erase last two hour hands + g.setColor(0); + p = rotatePoint(0, Radius.hour, hour % 12 * 30 + (minute - 2) / 2 | 0); + g.drawLine(Center.x, Center.y, p[0], p[1]); + point = rotatePoint(0, Radius.hour, hour % 12 * 30 + (minute - 1) / 2 | 0); + g.drawLine(Center.x, Center.y, point[0], point[1]); + + // draw digital time + g.setFont("6x8", 3); + g.setColor(0x7be0); + g.setFontAlign(0, 0); + g.drawString(dateArray[4].substr(0, 5), 120, 180, true); + + // draw new minute hand + point = rotatePoint(0, Radius.min, minute * 6); + g.setColor(0xFFFF); + g.drawLine(Center.x, Center.y, point[0], point[1]); + // draw new hour hand + point = rotatePoint(0, Radius.hour, hour % 12 * 30 + date.getMinutes() / 2 | 0); + g.setColor(0xFFFF); + g.drawLine(Center.x, Center.y, point[0], point[1]); + + // draw center + g.setColor(0xFD20); + g.fillCircle(Center.x, Center.y, Radius.center); + } + Bangle.on('lcdPower', function(on) { + if (on) { + drawWidgets(); + drawMixedClock(); + } + }); + + g.clear(); + setInterval(drawMixedClock, 5E3); + drawWidgets(); + drawMixedClock(); + +})(); diff --git a/apps/clock-mixed.json b/apps/clock-mixed.json new file mode 100644 index 000000000..b5396287a --- /dev/null +++ b/apps/clock-mixed.json @@ -0,0 +1,6 @@ +{ + "name":"Mixed Clock","type":"clock", + "icon":"*miclock", + "src":"-miclock", + "sortorder":-10 +} diff --git a/apps/clock-mixed.png b/apps/clock-mixed.png new file mode 100755 index 000000000..f02ad5e9e Binary files /dev/null and b/apps/clock-mixed.png differ diff --git a/apps/widget-battery.js b/apps/widget-battery.js index 818e8a170..0e30daabe 100644 --- a/apps/widget-battery.js +++ b/apps/widget-battery.js @@ -7,12 +7,12 @@ function draw() { var s = 63; var x = xpos, y = 0; g.clearRect(x,y,x+s,y+23); + g.setColor(1,1,1); if (Bangle.isCharging()) { g.drawImage(img_charge,x,y); x+=16; s-=16; } - g.setColor(1,1,1); g.fillRect(x,y+2,x+s-4,y+21); g.clearRect(x+2,y+4,x+s-6,y+19); g.fillRect(x+s-3,y+10,x+s,y+14);