Merge pull request #1 from unnamed1337/master

Release
pull/172/head
Pascal Gollnick 2020-03-31 20:22:54 +02:00 committed by GitHub
commit 48120c9e0a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 27 deletions

View File

@ -841,10 +841,10 @@
"name": "Commandline-Clock",
"shortName":"CLI-Clock",
"icon": "app.png",
"version":"0.04",
"version":"0.05",
"description": "Simple CLI-Styled Clock",
"tags": "cli,command,bash,shell",
"type": "clock",
"tags": "clock,cli,command,bash,shell",
"type":"clock",
"allow_emulator":true,
"storage": [
{"name":"cliock.app.js","url":"app.js"},

View File

@ -1,4 +1,3 @@
var line;
var fontsize = 3;
var locale = require("locale");
var marginTop = 40;
@ -10,39 +9,37 @@ function drawAll(){
Bangle.loadWidgets();
Bangle.drawWidgets();
updateTime();
updateRest(new Date(),true);
}
function updateRest(now,force){
if (now.getMinutes() != 0 && force) return;
let date = locale.date(now,false);
writeLine(WeekDays[now.getDay()],1);
writeLine(date,2);
}
function updateTime(){
if (!Bangle.isLCDOn()) return;
line = 0;
var now = new Date();
var date = locale.date(now,false);
var h = now.getHours();
var m = now.getMinutes();
let now = new Date();
let h = now.getHours();
let m = now.getMinutes();
h = h>=10?h:"0"+h;
m = m>=10?m:"0"+m;
writeLine(h+":"+m,0);
writeLine(flag?" ":"_",3);
flag = !flag;
updateRest(now,false);
}
function writeLineStart(line){
g.drawString(">",4,marginTop+line*30);
}
function writeLine(str,line){
g.setFont("6x8",fontsize);
g.setColor(0,1,0);
g.setFontAlign(-1,-1);
writeLine(h+":"+m);
writeLine(WeekDays[now.getDay()]);
writeLine(date);
if(flag){
writeLine(" ");
flag = false;
}
else{
writeLine("_");
flag = true;
}
}
function writeLineStart(){
g.drawString(">",4,marginTop+line*30);
}
function writeLine(str){
g.clearRect(0,marginTop+line*30,((str.length+1)*20),marginTop+25+line*30);
writeLineStart();
writeLineStart(line);
g.drawString(str,25,marginTop+line*30);
line++;
}
drawAll();