diff --git a/apps.json b/apps.json index a47451b87..dedbb22a1 100644 --- a/apps.json +++ b/apps.json @@ -432,10 +432,10 @@ { "id": "sclock", - "name": "Simple 24hr Clock", + "name": "Simple Clock", "icon": "clock-simple.png", - "version":"0.03", - "description": "Simple Digital 24 Hour Clock", + "version":"0.04", + "description": "A Simple Digital Clock", "tags": "clock", "type":"clock", "allow_emulator":true, @@ -445,20 +445,6 @@ {"name":"*sclock","url":"clock-simple-icon.js","evaluate":true} ] }, - { "id": "stclck", - "name": "Simple 12hr Clock", - "icon": "clock-simple.png", - "version":"0.03", - "description": "Simple Digital 12 Hour Clock", - "tags": "clock", - "type":"clock", - "allow_emulator":true, - "storage": [ - {"name":"+stclck","url":"clock-simple.json"}, - {"name":"-stclck","url":"clock-simple.js"}, - {"name":"*stclck","url":"clock-simple-icon.js","evaluate":true} - ] - }, { "id": "gesture", "name": "Gesture Test", "icon": "gesture.png", diff --git a/apps/sclock/ChangeLog b/apps/sclock/ChangeLog index 91fa53402..afe0c99cb 100644 --- a/apps/sclock/ChangeLog +++ b/apps/sclock/ChangeLog @@ -1,2 +1,3 @@ 0.02: Modified for use with new bootloader and firmware 0.03: Actually make into 24h clock since there's a 12h variant +0.04: Make this clock do 12h and 24h diff --git a/apps/sclock/clock-simple.js b/apps/sclock/clock-simple.js index f20080328..6fad41f17 100644 --- a/apps/sclock/clock-simple.js +++ b/apps/sclock/clock-simple.js @@ -10,6 +10,9 @@ const yposDate = 130; const yposYear = 175; const yposGMT = 220; +// Check settings for what type our clock should be +var is12Hour = (require("Storage").readJSON("@setting")||{})["12hour"]; + function drawSimpleClock() { // get date var d = new Date(); @@ -22,8 +25,24 @@ function drawSimpleClock() { var time = da[4].substr(0, 5).split(":"); var hours = time[0], minutes = time[1]; + var meridian = ""; + if (is12Hour) { + hours = parseInt(hours,10); + meridian = "AM"; + if (hours == 0) { + hours = 12; + meridian = "AM"; + } else if (hours >= 12) { + meridian = "PM"; + if (hours>12) hours -= 12; + } + hours = (" "+hours).substr(-2); + } + g.setFont(font, timeFontSize); g.drawString(`${hours}:${minutes}`, xyCenter, yposTime, true); + g.setFont(font, gmtFontSize); + g.drawString(meridian, xyCenter + 102, yposTime + 10, true); // draw Day, name of month, Date var date = [da[0], da[1], da[2]].join(" "); diff --git a/apps/sclock/clock-simple.json b/apps/sclock/clock-simple.json index 9a0a040aa..66cf827ba 100644 --- a/apps/sclock/clock-simple.json +++ b/apps/sclock/clock-simple.json @@ -1,5 +1,5 @@ { - "name":"24h Clock", + "name":"Simple Clock", "type":"clock", "icon":"*sclock", "src":"-sclock", diff --git a/apps/stclck/ChangeLog b/apps/stclck/ChangeLog deleted file mode 100644 index afa047eda..000000000 --- a/apps/stclck/ChangeLog +++ /dev/null @@ -1,2 +0,0 @@ -0.02: Modified for use with new bootloader and firmware -0.03: Actually made this work diff --git a/apps/stclck/clock-simple-icon.js b/apps/stclck/clock-simple-icon.js deleted file mode 100644 index b41bd6fcc..000000000 --- a/apps/stclck/clock-simple-icon.js +++ /dev/null @@ -1 +0,0 @@ -require("heatshrink").decompress(atob("mEwxH+AH4A/AH4ATiwAGFdYzlFp4xeFyYwZD49kxGt2fX6+z1uIsgxcDQtAxArCAA+zxFAGDAYFxAsJAAuIGCxcF1ouPAAOsGCouERRSUKSYguoGARgRCIiMSAAutGCDqUABNkF5yNEFzKRQLzwABxAvRdgYFBDgYFFBphgEF5lkEJwNOYIaORF7KQMBYetEJoDHAo+sF56+DF7TAMBYaBQBpwv/R97vvxCPdxAvLGAdkF7tkFxbAIF7C+MSBQAXRxovEoAvboAvNMD69DFxYvEi2sFy+sDwgvLGAryDACTsEFxrCGGCmzXh5gJSSaMFF6AwGshiPdQguSGA8WxAxK2eIRYguUGBBjBxGsGYWz1mILYwuWGJQANFq4wWFzQxSFrozNFcYA/AH4Av")) diff --git a/apps/stclck/clock-simple.js b/apps/stclck/clock-simple.js deleted file mode 100644 index 8eed2cfed..000000000 --- a/apps/stclck/clock-simple.js +++ /dev/null @@ -1,72 +0,0 @@ -/* jshint esversion: 6 */ -const timeFontSize = 6; -const dateFontSize = 3; -const gmtFontSize = 2; -const font = "6x8"; - -const xyCenter = g.getWidth() / 2; -const yposTime = 75; -const yposDate = 130; -const yposYear = 175; -const yposGMT = 220; - -function drawSimpleClock() { - // get date - var d = new Date(); - var da = d.toString().split(" "); - - // drawSting centered - g.setFontAlign(0, 0); - - // draw time - var time = da[4].substr(0, 5).split(":"); - var hours = parseInt(time[0],10), - minutes = time[1]; - var meridian = "AM"; - if (hours == 0) { - hours = 12; - meridian = "PM"; - } - if (hours > 12) { - hours -= 12; - meridian = "PM"; - } - g.setFont(font, timeFontSize); - g.drawString(`${(" "+hours).substr(-2)}:${minutes}`, xyCenter, yposTime, true); - g.setFont(font, gmtFontSize); - g.drawString(meridian, xyCenter + 102, yposTime + 10, true); - - // draw Day, name of month, Date - var date = [da[0], da[1], da[2]].join(" "); - g.setFont(font, dateFontSize); - - g.drawString(date, xyCenter, yposDate, true); - - // draw year - g.setFont(font, dateFontSize); - g.drawString(d.getFullYear(), xyCenter, yposYear, true); - - // draw gmt - var gmt = da[5]; - g.setFont(font, gmtFontSize); - g.drawString(gmt, xyCenter, yposGMT, true); -} - -// handle switch display on by pressing BTN1 -Bangle.on('lcdPower', function(on) { - if (on) drawSimpleClock(); -}); - -// clean app screen -g.clear(); -Bangle.loadWidgets(); -Bangle.drawWidgets(); - -// refesh every 15 sec -setInterval(drawSimpleClock, 15E3); - -// draw now -drawSimpleClock(); - -// Show launcher when middle button pressed -setWatch(Bangle.showLauncher, BTN2, {repeat:false,edge:"falling"}); diff --git a/apps/stclck/clock-simple.json b/apps/stclck/clock-simple.json deleted file mode 100644 index f30e88ea4..000000000 --- a/apps/stclck/clock-simple.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "name": "12h Clock", - "type": "clock", - "icon": "*stclck", - "src": "-stclck", - "sortorder": -10 -} diff --git a/apps/stclck/clock-simple.png b/apps/stclck/clock-simple.png deleted file mode 100755 index 824062aed..000000000 Binary files a/apps/stclck/clock-simple.png and /dev/null differ