mirror of https://github.com/espruino/BangleApps
cliock 0.13: Use setUI, work with smaller screens and themes
parent
03ee6aea83
commit
f6389ead76
|
@ -1289,9 +1289,9 @@
|
||||||
"name": "Commandline-Clock",
|
"name": "Commandline-Clock",
|
||||||
"shortName":"CLI-Clock",
|
"shortName":"CLI-Clock",
|
||||||
"icon": "app.png",
|
"icon": "app.png",
|
||||||
"version":"0.12",
|
"version":"0.13",
|
||||||
"description": "Simple CLI-Styled Clock",
|
"description": "Simple CLI-Styled Clock",
|
||||||
"tags": "clock,cli,command,bash,shell",
|
"tags": "clock,cli,command,bash,shell,b2",
|
||||||
"type":"clock",
|
"type":"clock",
|
||||||
"allow_emulator":true,
|
"allow_emulator":true,
|
||||||
"storage": [
|
"storage": [
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
0.07: Submitted to App Loader
|
0.07: Submitted to App Loader
|
||||||
0.08: Fixes issue where face would redraw on wake leading to all memory being used and watch crashing.
|
0.08: Fixes issue where face would redraw on wake leading to all memory being used and watch crashing.
|
||||||
0.09: Add BTN1 status line with ID,Fw ver, mem %, battery %
|
0.09: Add BTN1 status line with ID,Fw ver, mem %, battery %
|
||||||
0.10: Icon fixed for transparency
|
0.10: Icon fixed for transparency
|
||||||
0.11: added Heart Rate Monitor status and ability to turn on/off
|
0.11: added Heart Rate Monitor status and ability to turn on/off
|
||||||
0.12: added support for different locales
|
0.12: added support for different locales
|
||||||
|
0.13: Use setUI, work with smaller screens and themes
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
var fontsize = 3;
|
var fontsize = g.getWidth()>200 ? 3 : 2;
|
||||||
|
var fontheight = 10*fontsize;
|
||||||
var locale = require("locale");
|
var locale = require("locale");
|
||||||
var marginTop = 40;
|
var marginTop = 40;
|
||||||
var flag = false;
|
var flag = false;
|
||||||
|
@ -39,22 +40,23 @@ function updateTime(){
|
||||||
updateRest(now);
|
updateRest(now);
|
||||||
}
|
}
|
||||||
function writeLineStart(line){
|
function writeLineStart(line){
|
||||||
g.drawString(">",4,marginTop+line*30);
|
g.drawString(">",4,marginTop+line*fontheight);
|
||||||
}
|
}
|
||||||
function writeLine(str,line){
|
function writeLine(str,line){
|
||||||
|
var y = marginTop+line*fontheight;
|
||||||
g.setFont("6x8",fontsize);
|
g.setFont("6x8",fontsize);
|
||||||
//g.setColor(0,1,0);
|
//g.setColor(0,1,0);
|
||||||
g.setColor(0,0x07E0,0);
|
g.setColor("#0f0");
|
||||||
g.setFontAlign(-1,-1);
|
g.setFontAlign(-1,-1);
|
||||||
g.clearRect(0,marginTop+line*30,((str.length+1)*20),marginTop+25+line*30);
|
g.clearRect(0,y,((str.length+1)*20),y+fontheight-1);
|
||||||
writeLineStart(line);
|
writeLineStart(line);
|
||||||
g.drawString(str,25,marginTop+line*30);
|
g.drawString(str,25,y);
|
||||||
}
|
}
|
||||||
|
|
||||||
function drawInfo(line) {
|
function drawInfo(line) {
|
||||||
let val;
|
let val;
|
||||||
let str = "";
|
let str = "";
|
||||||
let col = 0x07E0; // green
|
let col = "#0f0"; // green
|
||||||
|
|
||||||
//console.log("drawInfo(), infoMode=" + infoMode + " funcMode=" + functionMode);
|
//console.log("drawInfo(), infoMode=" + infoMode + " funcMode=" + functionMode);
|
||||||
|
|
||||||
|
@ -62,15 +64,15 @@ function drawInfo(line) {
|
||||||
case NONE_FN_MODE:
|
case NONE_FN_MODE:
|
||||||
break;
|
break;
|
||||||
case HRT_FN_MODE:
|
case HRT_FN_MODE:
|
||||||
col = 0x07FF; // cyan
|
col = "#0ff"; // cyan
|
||||||
str = "HRM: " + (hrtOn ? "ON" : "OFF");
|
str = "HRM: " + (hrtOn ? "ON" : "OFF");
|
||||||
drawModeLine(line,str,col);
|
drawModeLine(line,str,col);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch(infoMode) {
|
switch(infoMode) {
|
||||||
case NONE_MODE:
|
case NONE_MODE:
|
||||||
col = 0x0000;
|
col = "#fff";
|
||||||
str = "";
|
str = "";
|
||||||
break;
|
break;
|
||||||
case HRT_MODE:
|
case HRT_MODE:
|
||||||
|
@ -100,10 +102,11 @@ function drawInfo(line) {
|
||||||
|
|
||||||
function drawModeLine(line, str, col) {
|
function drawModeLine(line, str, col) {
|
||||||
g.setColor(col);
|
g.setColor(col);
|
||||||
g.fillRect(0, marginTop-3+line*30, 239, marginTop+25+line*30);
|
var y = marginTop+line*fontheight;
|
||||||
g.setColor(0,0,0);
|
g.fillRect(0, y, 239, y+fontheight-1);
|
||||||
|
g.setColor(0);
|
||||||
g.setFontAlign(0, -1);
|
g.setFontAlign(0, -1);
|
||||||
g.drawString(str, g.getWidth()/2, marginTop+line*30);
|
g.drawString(str, g.getWidth()/2, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
function changeInfoMode() {
|
function changeInfoMode() {
|
||||||
|
@ -160,7 +163,7 @@ function changeFunctionMode() {
|
||||||
functionMode = NONE_FN_MODE;
|
functionMode = NONE_FN_MODE;
|
||||||
}
|
}
|
||||||
//console.log(functionMode);
|
//console.log(functionMode);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function stepsWidget() {
|
function stepsWidget() {
|
||||||
|
@ -185,10 +188,12 @@ Bangle.loadWidgets();
|
||||||
Bangle.drawWidgets();
|
Bangle.drawWidgets();
|
||||||
drawAll();
|
drawAll();
|
||||||
Bangle.on('lcdPower',function(on) {
|
Bangle.on('lcdPower',function(on) {
|
||||||
if (on)
|
if (on) drawAll();
|
||||||
drawAll();
|
|
||||||
});
|
});
|
||||||
var click = setInterval(updateTime, 1000);
|
var click = setInterval(updateTime, 1000);
|
||||||
setWatch(Bangle.showLauncher, BTN2, {repeat:false,edge:"falling"});
|
// Show launcher when button pressed
|
||||||
setWatch(() => { changeInfoMode(); drawAll(); }, BTN1, {repeat: true});
|
Bangle.setUI("clockupdown", btn=>{
|
||||||
setWatch(() => { changeFunctionMode(); drawAll(); }, BTN3, {repeat: true});
|
if (btn==0) changeInfoMode();
|
||||||
|
if (btn==1) changeFunctionMode();
|
||||||
|
drawAll();
|
||||||
|
});
|
||||||
|
|
Loading…
Reference in New Issue