Skip to content

Commit

Permalink
refine clock with complications
Browse files Browse the repository at this point in the history
  • Loading branch information
Indriði Einarsson committed Dec 28, 2023
1 parent fa7a6fb commit 52a33f6
Showing 1 changed file with 14 additions and 57 deletions.
71 changes: 14 additions & 57 deletions apps/ieclock/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,50 +7,7 @@ function log_debug(o) {
//print(o);
}

baro = {};
baro.draw = function draw(x,y,Radius, Settings) {
try {
g.setColor(Settings.Foreground === 'Theme' ? g.theme.fg : Settings.Foreground || '#000000');
g.setFont('Vector', 18);
g.setFontAlign(0,0);
dp = WIDGETS.widbarom.getChange().toFixed(1) ;
p = Math.round(WIDGETS.widbarom.getLastPressure().pressure);
dpsign = (dp<0?"":"+") + dp;
Text = ''+p+dpsign+"Hp";
g.drawString(Text, x,y);
} catch (error) {
//console.error(error)
}
};


let ClockSize = require('https://raw.githubusercontent.com/rozek/banglejs-2-smart-clock-size/main/ClockSize.js');
baro2 = {};
baro2.ClockSize = ClockSize;
baro2.draw = function draw(x,y,Radius, Settings){
g.setColor(Settings.Foreground === 'Theme' ? g.theme.fg : Settings.Foreground || '#000000');
cx = this.ClockSize.CenterX();
cy = this.ClockSize.CenterY();
rad = this.ClockSize.outerRadius();
halfdial = require("https://raw.githubusercontent.com/indridieinarsson/espruino_sandbox/master/halfdial.js");
p = Math.round(WIDGETS.widbarom.getLastPressure().pressure);
k=(p-950)/100;
halfdial.draw(Settings, cx, cy, rad-27, k);
dp = WIDGETS.widbarom.getChange();
let t1=dp.toFixed(0);
let t2=((Math.abs(dp)%1)*10).toFixed();
g.setColor(Settings.Foreground === 'Theme' ? g.theme.fg : Settings.Foreground || '#000000');
g.setFont('Vector',16);
g.setFontAlign(1,1);
g.drawString((t1<0?"":"+") + t1,x+8,y+8);
g.setFont('Vector',12);
g.setFontAlign(0,0);
g.drawString(t2,x+8,y+8);
// dpsign = (dp<0?"":"+") + dp;
// Text = ''+dpsign+"Hp";
// g.drawString(Text, x,y);
}

let ClockSize = require('https://raw.githubusercontent.com/indridieinarsson/espruino_sandbox/master/ClockSize.js');

sunrise = {};
sunrise.quarters = [0, String.fromCharCode(188), String.fromCharCode(189), String.fromCharCode(190), 0];
Expand All @@ -71,8 +28,8 @@ tide.draw = function(x, y, Radius, Settings) {
log_debug("x "+x+" y "+y+" r "+Radius+ " Settings "+Settings);
let halfScreenWidth = g.getWidth() / 2;
let largeComplication = (x === halfScreenWidth);
auxdial = require("https://raw.githubusercontent.com/indridieinarsson/espruino_sandbox/master/auxdial.js");
let rmult = (largeComplication?1.7:1.3);
auxdial = require("https://raw.githubusercontent.com/indridieinarsson/espruino_sandbox/master/24hAuxDial.js");
let rmult = (largeComplication?1.7:1.35);
if (typeof ieclock == 'undefined')
{
return;
Expand All @@ -88,7 +45,7 @@ tide.draw = function(x, y, Radius, Settings) {
let h = ieclock.tides.time.getHours();
let m = ieclock.tides.time.getMinutes();
auxdial.draw(Settings, x, y, Math.round(Radius*rmult),h ,m , true);
if (largeComplication){
// if (largeComplication){
let th = ieclock.tides.height;
let t1=th.toFixed(0);
let t2=((Math.abs(th)%1)*10).toFixed();
Expand All @@ -99,7 +56,7 @@ tide.draw = function(x, y, Radius, Settings) {
g.setFont('Vector',12);
g.setFontAlign(0,0);
g.drawString(t2,x+8,y+8);
}
// }
// let Text = this.compactTime(ieclock.tides.time);
// if (largeComplication){
// Text = Text+" "+ieclock.tides.height.toFixed(1)+"m";
Expand All @@ -122,8 +79,8 @@ tide.draw = function(x, y, Radius, Settings) {
function drawEvent(ev, x, y, Radius, Settings) {
let halfScreenWidth = g.getWidth() / 2;
let largeComplication = (x === halfScreenWidth);
let rmult = (largeComplication?1.65:1.3);
auxdial = require("https://raw.githubusercontent.com/indridieinarsson/espruino_sandbox/master/auxdial.js");
let rmult = (largeComplication?1.65:1.35);
auxdial = require("https://raw.githubusercontent.com/indridieinarsson/espruino_sandbox/master/24hAuxDial.js");
g.setColor(Settings.Foreground === 'Theme' ? g.theme.fg : Settings.Foreground || '#000000');
let h = ieclock[ev].getHours();
let m = ieclock[ev].getMinutes();
Expand All @@ -136,17 +93,17 @@ sunrise.whichevent = function whichevent (ev) {
return { draw:drawEvent.bind(this,ev) };
};

require('https://raw.githubusercontent.com/rozek/banglejs-2-widgets-on-background/main/drawWidgets.js');
let Clockwork = require('https://raw.githubusercontent.com/rozek/banglejs-2-simple-clockwork/main/Clockwork.js');
let Clockwork = require('https://raw.githubusercontent.com/indridieinarsson/espruino_sandbox/master/Clockwork.js');

Clockwork.windUp({
face:require('https://raw.githubusercontent.com/rozek/banglejs-2-twelve-numbered-clock-face/main/ClockFace.js'),
face:require('https://raw.githubusercontent.com/indridieinarsson/espruino_sandbox/master/ClockFace.js'),
size:ClockSize,
hands: require('https://raw.githubusercontent.com/rozek/banglejs-2-hollow-clock-hands/main/ClockHands.js'),
complications: {
l:sunrise.whichevent('sunrise'),
r:sunrise.whichevent('sunset'),
t:tide,
b:baro2
// r:sunrise.whichevent('sunset'),
t:require('https://raw.githubusercontent.com/rozek/banglejs-2-moon-phase-complication/main/Complication.js'),
l:tide,
r:sunrise.whichevent('sunrise'),
b:require('https://raw.githubusercontent.com/rozek/banglejs-2-date-complication/main/Complication.js'),
}
}, {'Foreground':'Theme', 'Background':'Theme'});

0 comments on commit 52a33f6

Please sign in to comment.