mirror of https://github.com/espruino/BangleApps
Remove 12h clock, change original 24h clock to read settings and present time accordingly (fix #82)
parent
2b409db904
commit
d8e5af43be
20
apps.json
20
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",
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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(" ");
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"name":"24h Clock",
|
||||
"name":"Simple Clock",
|
||||
"type":"clock",
|
||||
"icon":"*sclock",
|
||||
"src":"-sclock",
|
||||
|
|
|
@ -1,2 +0,0 @@
|
|||
0.02: Modified for use with new bootloader and firmware
|
||||
0.03: Actually made this work
|
|
@ -1 +0,0 @@
|
|||
require("heatshrink").decompress(atob("mEwxH+AH4A/AH4ATiwAGFdYzlFp4xeFyYwZD49kxGt2fX6+z1uIsgxcDQtAxArCAA+zxFAGDAYFxAsJAAuIGCxcF1ouPAAOsGCouERRSUKSYguoGARgRCIiMSAAutGCDqUABNkF5yNEFzKRQLzwABxAvRdgYFBDgYFFBphgEF5lkEJwNOYIaORF7KQMBYetEJoDHAo+sF56+DF7TAMBYaBQBpwv/R97vvxCPdxAvLGAdkF7tkFxbAIF7C+MSBQAXRxovEoAvboAvNMD69DFxYvEi2sFy+sDwgvLGAryDACTsEFxrCGGCmzXh5gJSSaMFF6AwGshiPdQguSGA8WxAxK2eIRYguUGBBjBxGsGYWz1mILYwuWGJQANFq4wWFzQxSFrozNFcYA/AH4Av"))
|
|
@ -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"});
|
|
@ -1,7 +0,0 @@
|
|||
{
|
||||
"name": "12h Clock",
|
||||
"type": "clock",
|
||||
"icon": "*stclck",
|
||||
"src": "-stclck",
|
||||
"sortorder": -10
|
||||
}
|
Binary file not shown.
Before Width: | Height: | Size: 590 B |
Loading…
Reference in New Issue