doztime 0.05: extraneous comments and code removed
display improved
now supports Adjust Clock widget, if installed
master
parent
954580dc17
commit
393a0adfff
|
|
@ -2,3 +2,6 @@
|
||||||
0.02: added emulator capability and display of widgets
|
0.02: added emulator capability and display of widgets
|
||||||
0.03: bug of advancing time fixed; doztime now correct within ca. 1 second
|
0.03: bug of advancing time fixed; doztime now correct within ca. 1 second
|
||||||
0.04: changed time colour from slightly off white to pure white
|
0.04: changed time colour from slightly off white to pure white
|
||||||
|
0.05: extraneous comments and code removed
|
||||||
|
display improved
|
||||||
|
now supports Adjust Clock widget, if installed
|
||||||
|
|
|
||||||
|
|
@ -1,23 +1,23 @@
|
||||||
// Positioning values for graphics buffers
|
// Positioning values for graphics buffers
|
||||||
const g_height = 80; // total graphics height
|
const g_height = 80; // total graphics height
|
||||||
const g_x_off = 0; // position from left was 16, then 8 here
|
const g_x_off = 0; // position from left
|
||||||
const g_y_off = (184 - g_height)/2; // vertical center for graphics region was 240
|
const g_y_off = (180 - g_height)/2; // vertical center for graphics region
|
||||||
const g_width = 240 - 2 * g_x_off; // total graphics width
|
const g_width = 240 - 2 * g_x_off; // total graphics width
|
||||||
const g_height_d = 28; // height of date region was 32
|
const g_height_d = 28; // height of date region
|
||||||
const g_y_off_d = 0; // y position of date region within graphics region
|
const g_y_off_d = 0; // y position of date region within graphics region
|
||||||
const spacing = 0; // space between date and time in graphics region
|
const spacing = 6; // space between date and time in graphics region
|
||||||
const g_y_off_t = g_y_off_d + g_height_d + spacing; // y position of time within graphics region
|
const g_y_off_t = g_y_off_d + g_height_d + spacing; // y position of time within graphics region
|
||||||
const g_height_t = 44; // height of time region was 48
|
const g_height_t = 44; // height of time region
|
||||||
|
|
||||||
// Other vars
|
// Other vars
|
||||||
const A1 = [30,30,30,30,31,31,31,31,31,31,30,30];
|
const A1 = [30,30,30,30,31,31,31,31,31,31,30,30];
|
||||||
const B1 = [30,30,30,30,30,31,31,31,31,31,30,30];
|
const B1 = [30,30,30,30,30,31,31,31,31,31,30,30];
|
||||||
const B2 = [30,30,30,30,31,31,31,31,31,30,30,30];
|
const B2 = [30,30,30,30,31,31,31,31,31,30,30,30];
|
||||||
const timeColour = "#ffffff";
|
const timeColour = "#ffffff";
|
||||||
const dateColours = ["#ff0000","#ffa500","#ffff00","#00b800","#8383ff","#ff00ff","#ff0080"]; //blue was 0000ff
|
const dateColours = ["#ff0000","#ff8000","#ffff00","#00ff00","#0080ff","#ff00ff","#ffffff"];
|
||||||
const calen10 = {"size":26,"pt0":[18-g_x_off,16],"step":[16,0],"dx":-4.5,"dy":-4.5}; // positioning for usual calendar line ft w 32, 32-g, step 20
|
const calen10 = {"size":26,"pt0":[18-g_x_off,16],"step":[16,0],"dx":-4.5,"dy":-4.5}; // positioning for usual calendar line
|
||||||
const calen7 = {"size":26,"pt0":[48-g_x_off,16],"step":[16,0],"dx":-4.5,"dy":-4.5}; // positioning for S-day calendar line ft w 32, 62-g, step 20
|
const calen7 = {"size":26,"pt0":[48-g_x_off,16],"step":[16,0],"dx":-4.5,"dy":-4.5}; // positioning for S-day calendar line
|
||||||
const time5 = {"size":42,"pt0":[39-g_x_off,24],"step":[26,0],"dx":-6.5,"dy":-6.5}; // positioning for lull time line ft w 48, 64-g, step 30
|
const time5 = {"size":42,"pt0":[39-g_x_off,24],"step":[26,0],"dx":-6.5,"dy":-6.5}; // positioning for lull time line
|
||||||
const time6 = {"size":42,"pt0":[26-g_x_off,24],"step":[26,0],"dx":-6.5,"dy":-6.5}; // positioning for twinkling time line ft w 48, 48-g, step 30
|
const time6 = {"size":42,"pt0":[26-g_x_off,24],"step":[26,0],"dx":-6.5,"dy":-6.5}; // positioning for twinkling time line ft w 48, 48-g, step 30
|
||||||
const baseYear = 11584;
|
const baseYear = 11584;
|
||||||
const baseDate = Date(2020,11,21); // month values run from 0 to 11
|
const baseDate = Date(2020,11,21); // month values run from 0 to 11
|
||||||
|
|
@ -59,11 +59,8 @@ g.flip = function()
|
||||||
}, g_x_off, g_y_off + g_y_off_t);
|
}, g_x_off, g_y_off + g_y_off_t);
|
||||||
};
|
};
|
||||||
|
|
||||||
setWatch(function(){ modeTime(); }, BTN, {repeat:true} ); //was BTN1
|
setWatch(function(){ modeTime(); }, BTN, {repeat:true} );
|
||||||
setWatch(function(){ Bangle.showLauncher(); }, BTN, { repeat: false, edge: "falling" }); //was BTN2
|
setWatch(function(){ Bangle.showLauncher(); }, BTN, { repeat: false, edge: "falling" });
|
||||||
//setWatch(function(){ modeWeather(); }, BTN3, {repeat:true});
|
|
||||||
//setWatch(function(){ toggleTimeDigits(); }, BTN4, {repeat:true});
|
|
||||||
//setWatch(function(){ toggleDateFormat(); }, BTN5, {repeat:true});
|
|
||||||
|
|
||||||
Bangle.on('touch', function(button, xy) { //from Gordon Williams
|
Bangle.on('touch', function(button, xy) { //from Gordon Williams
|
||||||
if (button==1) toggleTimeDigits();
|
if (button==1) toggleTimeDigits();
|
||||||
|
|
@ -132,10 +129,10 @@ function writeDozTime(text,def){
|
||||||
let x=def.pt0[0];
|
let x=def.pt0[0];
|
||||||
let y=def.pt0[1];
|
let y=def.pt0[1];
|
||||||
g_t.clear();
|
g_t.clear();
|
||||||
g_t.setFont("Vector",def.size);
|
g_t.setFont("Vector",def.size);
|
||||||
for(let i in text){
|
for(let i in text){
|
||||||
if(text[i]=="a"){ g_t.setFontAlign(0,0,2); g_t.drawString("2",x+2+def.dx,y+1+def.dy); } //+1s are new
|
if(text[i]=="a"){ g_t.setFontAlign(0,0,2); g_t.drawString("2",x+2+def.dx,y+1+def.dy); }
|
||||||
else if(text[i]=="b"){ g_t.setFontAlign(0,0,2); g_t.drawString("3",x+2+def.dx,y+1+def.dy); } //+1s are new
|
else if(text[i]=="b"){ g_t.setFontAlign(0,0,2); g_t.drawString("3",x+2+def.dx,y+1+def.dy); }
|
||||||
else{ g_t.setFontAlign(0,0,0); g_t.drawString(text[i],x,y); }
|
else{ g_t.setFontAlign(0,0,0); g_t.drawString(text[i],x,y); }
|
||||||
x = x+def.step[0];
|
x = x+def.step[0];
|
||||||
y = y+def.step[1];
|
y = y+def.step[1];
|
||||||
|
|
@ -150,18 +147,25 @@ function writeDozDate(text,def,colour){
|
||||||
g_d.clear();
|
g_d.clear();
|
||||||
g_d.setFont("Vector",def.size);
|
g_d.setFont("Vector",def.size);
|
||||||
for(let i in text){
|
for(let i in text){
|
||||||
if(text[i]=="a"){ g_d.setFontAlign(0,0,2); g_d.drawString("2",x+2+def.dx,y+1+def.dy); } //+1s new
|
if(text[i]=="a"){ g_d.setFontAlign(0,0,2); g_d.drawString("2",x+2+def.dx,y+1+def.dy); }
|
||||||
else if(text[i]=="b"){ g_d.setFontAlign(0,0,2); g_d.drawString("3",x+2+def.dx,y+1+def.dy); } //+1s new
|
else if(text[i]=="b"){ g_d.setFontAlign(0,0,2); g_d.drawString("3",x+2+def.dx,y+1+def.dy); }
|
||||||
else{ g_d.setFontAlign(0,0,0); g_d.drawString(text[i],x,y); }
|
else{ g_d.setFontAlign(0,0,0); g_d.drawString(text[i],x,y); }
|
||||||
x = x+def.step[0];
|
x = x+def.step[0];
|
||||||
y = y+def.step[1];
|
y = y+def.step[1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Bangle.loadWidgets();
|
||||||
|
//for malaire's Adjust Clock widget, if used
|
||||||
|
function adjustedNow() {
|
||||||
|
return WIDGETS.adjust ? new Date(WIDGETS.adjust.now()) : new Date();
|
||||||
|
}
|
||||||
|
Bangle.drawWidgets();
|
||||||
|
|
||||||
// Functions for time mode
|
// Functions for time mode
|
||||||
function drawTime()
|
function drawTime()
|
||||||
{
|
{
|
||||||
let dt = new Date();
|
let dt = adjustedNow();
|
||||||
let date = "";
|
let date = "";
|
||||||
let timeDef;
|
let timeDef;
|
||||||
let x = 0;
|
let x = 0;
|
||||||
|
|
@ -204,41 +208,17 @@ function drawTime()
|
||||||
}
|
}
|
||||||
function modeTime()
|
function modeTime()
|
||||||
{
|
{
|
||||||
timeActiveUntil = new Date();
|
timeActiveUntil = adjustedNow();
|
||||||
timeActiveUntil.setDate(timeActiveUntil.getDate());
|
timeActiveUntil.setDate(timeActiveUntil.getDate());
|
||||||
timeActiveUntil.setSeconds(timeActiveUntil.getSeconds()+86400);
|
timeActiveUntil.setSeconds(timeActiveUntil.getSeconds()+604800);
|
||||||
if (typeof drawtime_timeout !== 'undefined')
|
if (typeof drawtime_timeout !== 'undefined')
|
||||||
{
|
{
|
||||||
clearTimeout(drawtime_timeout);
|
clearTimeout(drawtime_timeout);
|
||||||
}
|
}
|
||||||
drawTime();
|
drawTime();
|
||||||
}
|
}
|
||||||
Bangle.loadWidgets();
|
|
||||||
Bangle.drawWidgets();
|
|
||||||
|
|
||||||
// Functions for weather mode - TODO
|
|
||||||
// function drawWeather() {}
|
|
||||||
// function modeWeather() {}
|
|
||||||
|
|
||||||
// Start time on twist
|
// Start time on twist
|
||||||
Bangle.on('twist',function() {
|
Bangle.on('twist',function() {
|
||||||
modeTime();
|
modeTime();
|
||||||
});
|
});
|
||||||
|
|
||||||
// Time fix with GPS
|
|
||||||
function fixTime() {
|
|
||||||
Bangle.on("GPS",function cb(g) {
|
|
||||||
Bangle.setGPSPower(0,"time");
|
|
||||||
Bangle.removeListener("GPS",cb);
|
|
||||||
if (!g.time || (g.time.getFullYear()<2000) ||
|
|
||||||
(g.time.getFullYear()>2200)) {
|
|
||||||
} else {
|
|
||||||
// We have a GPS time. Set time
|
|
||||||
setTime(g.time.getTime()/1000);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
Bangle.setGPSPower(1,"time");
|
|
||||||
setTimeout(fixTime, 10*60*1000); // every 10 minutes
|
|
||||||
}
|
|
||||||
// Start time fixing with GPS on next 10 minute interval
|
|
||||||
setTimeout(fixTime, ((60-(new Date()).getMinutes()) % 10) * 60 * 1000);
|
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
"id": "doztime",
|
"id": "doztime",
|
||||||
"name": "Dozenal Time",
|
"name": "Dozenal Time",
|
||||||
"shortName": "Dozenal Time",
|
"shortName": "Dozenal Time",
|
||||||
"version": "0.04",
|
"version": "0.05",
|
||||||
"description": "A dozenal Holocene calendar and dozenal diurnal clock",
|
"description": "A dozenal Holocene calendar and dozenal diurnal clock",
|
||||||
"icon": "app.png",
|
"icon": "app.png",
|
||||||
"type": "clock",
|
"type": "clock",
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue