Update pebble.app.js

master
sir-indy 2022-03-29 12:45:08 +01:00 committed by GitHub
parent 24689a7684
commit 358e8d18c8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 16 additions and 16 deletions

View File

@ -30,6 +30,8 @@ function draw() {
let da = date.toString().split(" "); let da = date.toString().split(" ");
let timeStr = da[4].substr(0,5); let timeStr = da[4].substr(0,5);
const t = 6; const t = 6;
print('Theme');
print(theme);
// turn the warning on once we have dipped below 30% // turn the warning on once we have dipped below 30%
if (E.getBattery() < 30) if (E.getBattery() < 30)
@ -44,7 +46,7 @@ function draw() {
g.fillRect(0, 0, w, h2 - t); g.fillRect(0, 0, w, h2 - t);
// contrast bar // contrast bar
g.setColor(g.theme.fg); g.setColor(theme.fg);
g.fillRect(0, h2 - t, w, h2); g.fillRect(0, h2 - t, w, h2);
// day and steps // day and steps
@ -65,11 +67,11 @@ function draw() {
g.setFontLECO1976Regular42(); g.setFontLECO1976Regular42();
g.setFontAlign(0, -1); g.setFontAlign(0, -1);
g.setColor(!batteryWarning ? g.theme.fg : '#fff'); g.setColor(!batteryWarning ? theme.fg : '#fff');
g.drawString(timeStr, w/2, h2 + 8); g.drawString(timeStr, w/2, h2 + 8);
// contrast bar // contrast bar
g.setColor(g.theme.fg); g.setColor(theme.fg);
g.fillRect(0, h3, w, h3 + t); g.fillRect(0, h3, w, h3 + t);
// the bottom // the bottom
@ -83,11 +85,11 @@ function draw() {
// at x,y width:wi thicknes:th // at x,y width:wi thicknes:th
function drawCalendar(x,y,wi,th,str) { function drawCalendar(x,y,wi,th,str) {
g.setColor(g.theme.fg); g.setColor(theme.fg);
g.fillRect(x, y, x + wi, y + wi); g.fillRect(x, y, x + wi, y + wi);
g.setColor(g.theme.bg); g.setColor(theme.bg);
g.fillRect(x + th, y + th, x + wi - th, y + wi - th); g.fillRect(x + th, y + th, x + wi - th, y + wi - th);
g.setColor(g.theme.fg); g.setColor(theme.fg);
let hook_t = 6; let hook_t = 6;
// first calendar hook, one third in // first calendar hook, one third in
@ -107,15 +109,13 @@ function getSteps() {
return '????'; return '????';
} }
function set_colors() { function loadThemeColors(style) {
if (settings.theme == 'Light') { if (style === "Dark")
pass theme = {fg: g.toColor(1,1,1), bg: g.toColor(0,0,0)};
} else if (settings.theme == 'Dark') { else if (style === "Light")
pass theme = {fg: g.toColor(0,0,0), bg: g.toColor(1,1,1)};
} else { else
let color_bg = g.theme.bg theme = {fg: g.theme.fg, bg: g.theme.bg};
let color_fg = g.theme.fg
}
} }
g.clear(); g.clear();
@ -127,7 +127,7 @@ Bangle.loadWidgets();
*/ */
for (let wd of WIDGETS) {wd.draw=()=>{};wd.area="";} for (let wd of WIDGETS) {wd.draw=()=>{};wd.area="";}
loadSettings(); loadSettings();
set_colors(); loadThemeColors(settings.theme);
setInterval(draw, 15000); // refresh every 15s setInterval(draw, 15000); // refresh every 15s
draw(); draw();
Bangle.setUI("clock"); Bangle.setUI("clock");