added id, fw ver, batt %, mem % on BTN1 press in cliock
parent
b8c181209c
commit
2e520a6d75
|
|
@ -1,2 +1,3 @@
|
||||||
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,0 +1,14 @@
|
||||||
|
# Cli Clock
|
||||||
|
|
||||||
|
A retro VT100 command line style clock
|
||||||
|
|
||||||
|
## Screenshots
|
||||||
|
### Normall face
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
### With BTN1 pressed
|
||||||
|
|
||||||
|
* Successive presses of BTN1 will show id, FW version, battery %, memory %
|
||||||
|
|
||||||
|

|
||||||
|
|
@ -4,6 +4,14 @@ var marginTop = 40;
|
||||||
var flag = false;
|
var flag = false;
|
||||||
var WeekDays = ["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];
|
var WeekDays = ["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];
|
||||||
|
|
||||||
|
|
||||||
|
const NONE_MODE = "none";
|
||||||
|
const ID_MODE = "id";
|
||||||
|
const VER_MODE = "ver";
|
||||||
|
const BATT_MODE = "batt";
|
||||||
|
const MEM_MODE = "mem";
|
||||||
|
let infoMode = NONE_MODE;
|
||||||
|
|
||||||
function drawAll(){
|
function drawAll(){
|
||||||
updateTime();
|
updateTime();
|
||||||
updateRest(new Date());
|
updateRest(new Date());
|
||||||
|
|
@ -13,6 +21,7 @@ function updateRest(now){
|
||||||
let date = locale.date(now,false);
|
let date = locale.date(now,false);
|
||||||
writeLine(WeekDays[now.getDay()],1);
|
writeLine(WeekDays[now.getDay()],1);
|
||||||
writeLine(date,2);
|
writeLine(date,2);
|
||||||
|
drawInfo(5);
|
||||||
}
|
}
|
||||||
function updateTime(){
|
function updateTime(){
|
||||||
if (!Bangle.isLCDOn()) return;
|
if (!Bangle.isLCDOn()) return;
|
||||||
|
|
@ -32,13 +41,67 @@ function writeLineStart(line){
|
||||||
}
|
}
|
||||||
function writeLine(str,line){
|
function writeLine(str,line){
|
||||||
g.setFont("6x8",fontsize);
|
g.setFont("6x8",fontsize);
|
||||||
g.setColor(0,1,0);
|
//g.setColor(0,1,0);
|
||||||
|
g.setColor(0,0x07E0,0);
|
||||||
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,marginTop+line*30,((str.length+1)*20),marginTop+25+line*30);
|
||||||
writeLineStart(line);
|
writeLineStart(line);
|
||||||
g.drawString(str,25,marginTop+line*30);
|
g.drawString(str,25,marginTop+line*30);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function drawInfo(line) {
|
||||||
|
let val;
|
||||||
|
let str = "";
|
||||||
|
let col = 0x07E0; // green
|
||||||
|
|
||||||
|
switch(infoMode) {
|
||||||
|
case NONE_MODE:
|
||||||
|
col = 0x0000;
|
||||||
|
str = "";
|
||||||
|
break;
|
||||||
|
case ID_MODE:
|
||||||
|
val = NRF.getAddress().split(":");
|
||||||
|
str = "Id: " + val[4] + val[5];
|
||||||
|
break;
|
||||||
|
case VER_MODE:
|
||||||
|
str = "Fw: " + process.env.VERSION;
|
||||||
|
break;
|
||||||
|
case MEM_MODE:
|
||||||
|
val = process.memory();
|
||||||
|
str = "Memory: " + Math.round(val.usage*100/val.total) + "%";
|
||||||
|
break;
|
||||||
|
case BATT_MODE:
|
||||||
|
default:
|
||||||
|
str = "Battery: " + E.getBattery() + "%";
|
||||||
|
}
|
||||||
|
|
||||||
|
g.setColor(col);
|
||||||
|
g.fillRect(0, marginTop-3+line*30, 239, marginTop+25+line*30);
|
||||||
|
g.setColor(0,0,0);
|
||||||
|
g.setFontAlign(0, -1);
|
||||||
|
g.drawString(str, g.getWidth()/2, marginTop+line*30);
|
||||||
|
}
|
||||||
|
|
||||||
|
function changeInfoMode() {
|
||||||
|
switch(infoMode) {
|
||||||
|
case NONE_MODE:
|
||||||
|
infoMode = ID_MODE;
|
||||||
|
break;
|
||||||
|
case ID_MODE:
|
||||||
|
infoMode = VER_MODE;
|
||||||
|
break;
|
||||||
|
case VER_MODE:
|
||||||
|
infoMode = BATT_MODE;
|
||||||
|
break;
|
||||||
|
case BATT_MODE:
|
||||||
|
infoMode = MEM_MODE;
|
||||||
|
break;
|
||||||
|
case MEM_MODE:
|
||||||
|
default:
|
||||||
|
infoMode = NONE_MODE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
g.clear();
|
g.clear();
|
||||||
Bangle.loadWidgets();
|
Bangle.loadWidgets();
|
||||||
Bangle.drawWidgets();
|
Bangle.drawWidgets();
|
||||||
|
|
@ -49,3 +112,4 @@ Bangle.on('lcdPower',function(on) {
|
||||||
});
|
});
|
||||||
var click = setInterval(updateTime, 1000);
|
var click = setInterval(updateTime, 1000);
|
||||||
setWatch(Bangle.showLauncher, BTN2, {repeat:false,edge:"falling"});
|
setWatch(Bangle.showLauncher, BTN2, {repeat:false,edge:"falling"});
|
||||||
|
setWatch(() => { changeInfoMode(); drawAll(); }, BTN1, {repeat: true});
|
||||||
|
|
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 116 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 130 KiB |
|
|
@ -1,2 +1,3 @@
|
||||||
0.01: New App
|
0.01: New App
|
||||||
0.02: Restore to SuperE mode on power off.
|
0.02: Restore to SuperE mode on power off.
|
||||||
|
0.03: dont reset to SuperE mode on power, as it prevents its general use
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@
|
||||||
|
|
||||||
function gps_get_fix() { return last_fix; }
|
function gps_get_fix() { return last_fix; }
|
||||||
function gps_get_status() { return WIDGETS.gpsservice.width === 24 ? true : false;}
|
function gps_get_status() { return WIDGETS.gpsservice.width === 24 ? true : false;}
|
||||||
function gps_get_version() { return "0.2"; }
|
function gps_get_version() { return "0.03"; }
|
||||||
|
|
||||||
function log_debug(o) {
|
function log_debug(o) {
|
||||||
if (debug) console.log(o);
|
if (debug) console.log(o);
|
||||||
|
|
@ -67,7 +67,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
function gps_power_off() {
|
function gps_power_off() {
|
||||||
setupSuperE(); // return to expected setup for other apps
|
//setupSuperE(); // return to expected setup for other apps
|
||||||
Bangle.setGPSPower(0);
|
Bangle.setGPSPower(0);
|
||||||
have_fix = false;
|
have_fix = false;
|
||||||
fixToggle = false;
|
fixToggle = false;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue