mirror of https://github.com/espruino/BangleApps
minor readability tweak when checking for messages
parent
3e09813143
commit
097730245a
|
@ -149,11 +149,11 @@ function drawHSeg(x1,y1,x2,y2,Num,Color,Size) {
|
||||||
if (Color == "fg") {
|
if (Color == "fg") {
|
||||||
g.setColor(g.theme.fg);
|
g.setColor(g.theme.fg);
|
||||||
} else {
|
} else {
|
||||||
g.setColor(mColor[0],mColor[1],mColor[2]);
|
g.setColor(mColor[0],mColor[1],mColor[2]);
|
||||||
}
|
}
|
||||||
g.fillCircle(x1+Dx+(i-1)*(x2-x1)/7,y1+Dy+(j-1)*(y2-y1)/7,Size);
|
g.fillCircle(x1+Dx+(i-1)*(x2-x1)/7,y1+Dy+(j-1)*(y2-y1)/7,Size);
|
||||||
} else {
|
} else {
|
||||||
g.setColor(bColor[0],bColor[1],bColor[2]);
|
g.setColor(bColor[0],bColor[1],bColor[2]);
|
||||||
g.fillCircle(x1+Dx+(i-1)*(x2-x1)/7,y1+Dy+(j-1)*(y2-y1)/7,1);
|
g.fillCircle(x1+Dx+(i-1)*(x2-x1)/7,y1+Dy+(j-1)*(y2-y1)/7,1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -166,7 +166,7 @@ function drawSSeg(x1,y1,x2,y2,Num,Color,Size) {
|
||||||
for (let j = 1; j < 8; j++) {
|
for (let j = 1; j < 8; j++) {
|
||||||
if (Font[Num][j-1][i-1] == 1) {
|
if (Font[Num][j-1][i-1] == 1) {
|
||||||
if (Color == "fg") {
|
if (Color == "fg") {
|
||||||
g.setColor(sColor[0],sColor[1],sColor[2]);
|
g.setColor(sColor[0],sColor[1],sColor[2]);
|
||||||
} else {
|
} else {
|
||||||
g.setColor(g.theme.fg);
|
g.setColor(g.theme.fg);
|
||||||
//g.setColor(0.7,0.7,0.7);
|
//g.setColor(0.7,0.7,0.7);
|
||||||
|
@ -253,8 +253,8 @@ function actions(v){
|
||||||
if(BTN1.read() === true) {
|
if(BTN1.read() === true) {
|
||||||
print("BTN pressed");
|
print("BTN pressed");
|
||||||
Bangle.showLauncher();
|
Bangle.showLauncher();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(v==-1){
|
if(v==-1){
|
||||||
print("up swipe event");
|
print("up swipe event");
|
||||||
if(settings.swupApp != "") load(settings.swupApp);
|
if(settings.swupApp != "") load(settings.swupApp);
|
||||||
|
@ -269,7 +269,7 @@ function actions(v){
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get Messages status
|
// Get Messages status
|
||||||
var messages_installed = require("Storage").list(/^messages$/).length > 0;
|
var messages_installed = require("Storage").read("messages") !== undefined;
|
||||||
|
|
||||||
//var BTconnected = NRF.getSecurityStatus().connected;
|
//var BTconnected = NRF.getSecurityStatus().connected;
|
||||||
//NRF.on('connect',BTconnected = NRF.getSecurityStatus().connected);
|
//NRF.on('connect',BTconnected = NRF.getSecurityStatus().connected);
|
||||||
|
@ -289,27 +289,27 @@ function drawWidgeds() {
|
||||||
g.setColor((g.getBPP()>8) ? "#07f" : (g.theme.dark ? "#0ff" : "#00f"));
|
g.setColor((g.getBPP()>8) ? "#07f" : (g.theme.dark ? "#0ff" : "#00f"));
|
||||||
else
|
else
|
||||||
g.setColor(g.theme.dark ? "#666" : "#999");
|
g.setColor(g.theme.dark ? "#666" : "#999");
|
||||||
g.drawImage(atob("CxQBBgDgFgJgR4jZMawfAcA4D4NYybEYIwTAsBwDAA=="),x1Bt,y1Bt);
|
g.drawImage(atob("CxQBBgDgFgJgR4jZMawfAcA4D4NYybEYIwTAsBwDAA=="),x1Bt,y1Bt);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//Battery
|
//Battery
|
||||||
//print(E.getBattery());
|
//print(E.getBattery());
|
||||||
//print(Bangle.isCharging());
|
//print(Bangle.isCharging());
|
||||||
|
|
||||||
var x1B = 130;
|
var x1B = 130;
|
||||||
var y1B = 2;
|
var y1B = 2;
|
||||||
var x2B = x1B + 20;
|
var x2B = x1B + 20;
|
||||||
var y2B = y1B + 15;
|
var y2B = y1B + 15;
|
||||||
|
|
||||||
g.setColor(g.theme.bg);
|
g.setColor(g.theme.bg);
|
||||||
g.clearRect(x1B,y1B,x2B,y2B);
|
g.clearRect(x1B,y1B,x2B,y2B);
|
||||||
|
|
||||||
g.setColor(g.theme.fg);
|
g.setColor(g.theme.fg);
|
||||||
g.drawRect(x1B,y1B,x2B,y2B);
|
g.drawRect(x1B,y1B,x2B,y2B);
|
||||||
g.fillRect(x1B,y1B,x1B+(E.getBattery()*(x2B-x1B)/100),y2B);
|
g.fillRect(x1B,y1B,x1B+(E.getBattery()*(x2B-x1B)/100),y2B);
|
||||||
g.fillRect(x2B,y1B+(y2B-y1B)/2-3,x2B+4,y1B+(y2B-y1B)/2+3);
|
g.fillRect(x2B,y1B+(y2B-y1B)/2-3,x2B+4,y1B+(y2B-y1B)/2+3);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//Messages
|
//Messages
|
||||||
|
|
||||||
|
@ -325,18 +325,18 @@ function drawWidgeds() {
|
||||||
g.drawLine(x1M,y1M,x1M+(x2M-x1M)/2,y1M+(y2M-y1M)/2);
|
g.drawLine(x1M,y1M,x1M+(x2M-x1M)/2,y1M+(y2M-y1M)/2);
|
||||||
g.drawLine(x1M+(x2M-x1M)/2,y1M+(y2M-y1M)/2,x2M,y1M);
|
g.drawLine(x1M+(x2M-x1M)/2,y1M+(y2M-y1M)/2,x2M,y1M);
|
||||||
}
|
}
|
||||||
|
|
||||||
var strDow = ['Sun','Mon','Tue','Wed','Thu','Fri','Sat'];
|
var strDow = ['Sun','Mon','Tue','Wed','Thu','Fri','Sat'];
|
||||||
var d = new Date();
|
var d = new Date();
|
||||||
var dow = d.getDay(),day = d.getDate(), month = d.getMonth() + 1, year = d.getFullYear();
|
var dow = d.getDay(),day = d.getDate(), month = d.getMonth() + 1, year = d.getFullYear();
|
||||||
|
|
||||||
print(strDow[dow] + ' ' + day + '.' + month + ' ' + year);
|
print(strDow[dow] + ' ' + day + '.' + month + ' ' + year);
|
||||||
|
|
||||||
g.setColor(g.theme.fg);
|
g.setColor(g.theme.fg);
|
||||||
g.setFontAlign(-1, -1,0);
|
g.setFontAlign(-1, -1,0);
|
||||||
g.setFont("Vector", 20);
|
g.setFont("Vector", 20);
|
||||||
g.drawString(strDow[dow] + ' ' + day, 0, 0, true);
|
g.drawString(strDow[dow] + ' ' + day, 0, 0, true);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -354,7 +354,7 @@ function SetFull(on) {
|
||||||
} else {
|
} else {
|
||||||
Ys = 30;
|
Ys = 30;
|
||||||
Bangle.setUI("updown",actions);
|
Bangle.setUI("updown",actions);
|
||||||
Bangle.on('swipe', function(direction) {
|
Bangle.on('swipe', function(direction) {
|
||||||
switch (direction) {
|
switch (direction) {
|
||||||
case 1:
|
case 1:
|
||||||
print("swipe left event");
|
print("swipe left event");
|
||||||
|
@ -362,7 +362,7 @@ function SetFull(on) {
|
||||||
print(settings.swleftApp);
|
print(settings.swleftApp);
|
||||||
break;
|
break;
|
||||||
case -1:
|
case -1:
|
||||||
print("swipe right event");
|
print("swipe right event");
|
||||||
if(settings.swrightApp != "") load(settings.swrightApp);
|
if(settings.swrightApp != "") load(settings.swrightApp);
|
||||||
print(settings.swrightApp);
|
print(settings.swrightApp);
|
||||||
break;
|
break;
|
||||||
|
@ -374,7 +374,7 @@ function SetFull(on) {
|
||||||
|
|
||||||
SegH = (Ye-Ys)/2;
|
SegH = (Ye-Ys)/2;
|
||||||
Dy = SegH/16;
|
Dy = SegH/16;
|
||||||
|
|
||||||
draw();
|
draw();
|
||||||
|
|
||||||
if (on != true) {
|
if (on != true) {
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
// Numbers Rect order (left, top, right, bottom)
|
// Numbers Rect order (left, top, right, bottom)
|
||||||
// Each number defines a set of rects to draw
|
// Each number defines a set of rects to draw
|
||||||
|
|
||||||
const numbers =
|
const numbers =
|
||||||
[
|
[
|
||||||
[// Zero
|
[// Zero
|
||||||
[0, 0, 1, 0.2],
|
[0, 0, 1, 0.2],
|
||||||
|
@ -64,7 +64,7 @@ const numbers =
|
||||||
[0, 0.8, 1, 1],
|
[0, 0.8, 1, 1],
|
||||||
[0, 0, 0.1, 0.6],
|
[0, 0, 0.1, 0.6],
|
||||||
[0.9, 0, 1, 1]
|
[0.9, 0, 1, 1]
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
|
|
||||||
const months = [ "JAN", "FEB", "MAR", "APR", "MAY", "JUN", "JUL", "AUG", "SEP", "OCT", "NOV", "DEC" ];
|
const months = [ "JAN", "FEB", "MAR", "APR", "MAY", "JUN", "JUL", "AUG", "SEP", "OCT", "NOV", "DEC" ];
|
||||||
|
@ -103,7 +103,7 @@ function updateTime()
|
||||||
let mo = now.getMonth();
|
let mo = now.getMonth();
|
||||||
let y = now.getFullYear();
|
let y = now.getFullYear();
|
||||||
let d = now.getDate();
|
let d = now.getDate();
|
||||||
|
|
||||||
if(h != hour)
|
if(h != hour)
|
||||||
{
|
{
|
||||||
hour = h;
|
hour = h;
|
||||||
|
@ -127,7 +127,7 @@ function updateTime()
|
||||||
day = d;
|
day = d;
|
||||||
g.setFont("6x8", 2);
|
g.setFont("6x8", 2);
|
||||||
g.setFontAlign(0, -1, 0);
|
g.setFontAlign(0, -1, 0);
|
||||||
g.drawString(fmtDate(d,mo,y,hour), 120, 120);
|
g.drawString(fmtDate(d,mo,y,hour), 120, 120);
|
||||||
}
|
}
|
||||||
drawMessages();
|
drawMessages();
|
||||||
}
|
}
|
||||||
|
@ -136,7 +136,7 @@ function drawDigits(x, value)
|
||||||
{
|
{
|
||||||
if(!Bangle.isLCDOn()) // No need to draw when LCD Off
|
if(!Bangle.isLCDOn()) // No need to draw when LCD Off
|
||||||
return;
|
return;
|
||||||
|
|
||||||
drawChar(Math.floor(value/10), 15, x, 115, x+50);
|
drawChar(Math.floor(value/10), 15, x, 115, x+50);
|
||||||
if(value%10 == 1)
|
if(value%10 == 1)
|
||||||
drawChar(value%10, 55, x, 155, x+50);
|
drawChar(value%10, 55, x, 155, x+50);
|
||||||
|
@ -228,7 +228,7 @@ function flipColors()
|
||||||
// MESSAGE HANDLING()
|
// MESSAGE HANDLING()
|
||||||
//
|
//
|
||||||
|
|
||||||
let messages_installed = require("Storage").list(/^messages$/).length > 0;
|
let messages_installed = require("Storage").read("messages") !== undefined;
|
||||||
|
|
||||||
function handleMessages()
|
function handleMessages()
|
||||||
{
|
{
|
||||||
|
@ -255,7 +255,7 @@ function drawMessages()
|
||||||
g.setFont("6x8", 2);
|
g.setFont("6x8", 2);
|
||||||
g.setFontAlign(0, -1, 0);
|
g.setFontAlign(0, -1, 0);
|
||||||
g.drawString(">", 224, 216);
|
g.drawString(">", 224, 216);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
g.setColor(0,0,0);
|
g.setColor(0,0,0);
|
||||||
|
|
Loading…
Reference in New Issue