Merge branch 'master' of github.com:espruino/BangleApps
commit
e85080e052
|
|
@ -5,3 +5,4 @@
|
|||
0.05: Fix typo in settings - Purple
|
||||
0.06: Added dependancy on Pedometer Widget
|
||||
0.07: Fixed icon and ong file to 48x48
|
||||
0.08: Added theme options and optional lock symbol
|
||||
|
|
|
|||
|
|
@ -4,11 +4,12 @@
|
|||
|
||||
* Designed specifically for Bangle 2
|
||||
* A choice of 6 different background colous through its setting menu. Goto Settings, App/Widget settings, Pebble.
|
||||
* Supports the Light and Dark themes
|
||||
* Supports the Light and Dark themes (or set theme independently)
|
||||
* Uses pedometer widget to get latest step count
|
||||
* Dependant apps are installed when Pebble installs
|
||||
* Uses the whole screen, widgets are made invisible but still run in the background
|
||||
* When battery is less than 30% main screen goes Red
|
||||
* Optionally show a lock symbol when screen is locked (default off, enable in Settings)
|
||||
|
||||

|
||||

|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
"id": "pebble",
|
||||
"name": "Pebble Clock",
|
||||
"shortName": "Pebble",
|
||||
"version": "0.07",
|
||||
"version": "0.08",
|
||||
"description": "A pebble style clock to keep the rebellion going",
|
||||
"dependencies": {"widpedom":"app"},
|
||||
"readme": "README.md",
|
||||
|
|
@ -11,6 +11,7 @@
|
|||
"type": "clock",
|
||||
"tags": "clock",
|
||||
"supports": ["BANGLEJS", "BANGLEJS2"],
|
||||
"allow_emulator": true,
|
||||
"storage": [
|
||||
{"name":"pebble.app.js","url":"pebble.app.js"},
|
||||
{"name":"pebble.settings.js","url":"pebble.settings.js"},
|
||||
|
|
|
|||
|
|
@ -10,9 +10,10 @@ Graphics.prototype.setFontLECO1976Regular22 = function(scale) {
|
|||
|
||||
const SETTINGS_FILE = "pebble.json";
|
||||
let settings;
|
||||
let theme;
|
||||
|
||||
function loadSettings() {
|
||||
settings = require("Storage").readJSON(SETTINGS_FILE,1)|| {'bg': '#0f0', 'color': 'Green'};
|
||||
settings = require("Storage").readJSON(SETTINGS_FILE,1)|| {'bg': '#0f0', 'color': 'Green', 'theme':'System', 'showlock':false};
|
||||
}
|
||||
|
||||
var img = require("heatshrink").decompress(atob("oFAwkEogA/AH4A/AH4A/AH4A/AE8AAAoeXoAfeDQUBmcyD7A+Dh///8QD649CiAfaHwUvD4sEHy0DDYIfEICg+Cn4fHICY+DD4nxcgojOHwgfEIAYfRCIQaDD4ZAFD5r7DH4//kAfRCIZ/GAAnwD5p9DX44fTHgYSBf4ofVDAQEBl4fFUAgfOXoQzBgIfFBAIfPP4RAEAoYAB+cRiK/SG4h/WIBAfXIA7CBAAswD55AHn6fUIBMCD65AHl4gCmcziAfQQJqfQQJpiDgk0IDXxQLRAEECaBM+QgRYRYgUIA0CD4ggSQJiDCiAKBICszAAswD55AHABKBVD7BAFABIqBD5pAFABPxD55AOD6BADiIAJQAyxLABwf/gaAPAH4A/AH4ARA=="));
|
||||
|
|
@ -44,15 +45,15 @@ function draw() {
|
|||
g.fillRect(0, 0, w, h2 - t);
|
||||
|
||||
// contrast bar
|
||||
g.setColor(g.theme.fg);
|
||||
g.setColor(theme.fg);
|
||||
g.fillRect(0, h2 - t, w, h2);
|
||||
|
||||
// day and steps
|
||||
if (settings.color == 'Blue' || settings.color == 'Red')
|
||||
g.setColor('#fff'); // white on blue or red best contrast
|
||||
else
|
||||
g.setColor('#000'); // otherwise black regardless of theme
|
||||
|
||||
//if (settings.color == 'Blue' || settings.color == 'Red')
|
||||
// g.setColor('#fff'); // white on blue or red best contrast
|
||||
//else
|
||||
// g.setColor('#000'); // otherwise black regardless of theme
|
||||
g.setColor(theme.day);
|
||||
g.setFontLECO1976Regular22();
|
||||
g.setFontAlign(0, -1);
|
||||
g.drawString(da[0].toUpperCase(), w/4, ha); // day of week
|
||||
|
|
@ -60,16 +61,16 @@ function draw() {
|
|||
|
||||
// time
|
||||
// white on red for battery warning
|
||||
g.setColor(!batteryWarning ? g.theme.bg : '#f00');
|
||||
g.setColor(!batteryWarning ? theme.bg : '#f00');
|
||||
g.fillRect(0, h2, w, h3);
|
||||
|
||||
g.setFontLECO1976Regular42();
|
||||
g.setFontAlign(0, -1);
|
||||
g.setColor(!batteryWarning ? g.theme.fg : '#fff');
|
||||
g.setColor(!batteryWarning ? theme.fg : '#fff');
|
||||
g.drawString(timeStr, w/2, h2 + 8);
|
||||
|
||||
// contrast bar
|
||||
g.setColor(g.theme.fg);
|
||||
g.setColor(theme.fg);
|
||||
g.fillRect(0, h3, w, h3 + t);
|
||||
|
||||
// the bottom
|
||||
|
|
@ -79,15 +80,17 @@ function draw() {
|
|||
g.setColor(settings.bg);
|
||||
g.drawImage(img, w/2 + ((w/2) - 64)/2, 1, { scale: 1 });
|
||||
drawCalendar(((w/2) - 42)/2, 14, 42, 4, da[2]);
|
||||
|
||||
drawLock();
|
||||
}
|
||||
|
||||
// at x,y width:wi thicknes:th
|
||||
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.setColor(g.theme.bg);
|
||||
g.setColor(theme.bg);
|
||||
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;
|
||||
// first calendar hook, one third in
|
||||
|
|
@ -107,6 +110,38 @@ function getSteps() {
|
|||
return '????';
|
||||
}
|
||||
|
||||
function loadThemeColors() {
|
||||
theme = {fg: g.theme.fg, bg: g.theme.bg, day: g.toColor(0,0,0)};
|
||||
if (settings.theme === "Dark") {
|
||||
theme.fg = g.toColor(1,1,1);
|
||||
theme.bg = g.toColor(0,0,0);
|
||||
}
|
||||
else if (settings.theme === "Light") {
|
||||
theme.fg = g.toColor(0,0,0);
|
||||
theme.bg = g.toColor(1,1,1);
|
||||
}
|
||||
// day and steps
|
||||
if (settings.color == 'Blue' || settings.color == 'Red')
|
||||
theme.day = g.toColor(1,1,1); // white on blue or red best contrast
|
||||
}
|
||||
|
||||
function drawLock(){
|
||||
if (settings.showlock) {
|
||||
if (Bangle.isLocked()){
|
||||
g.setColor(theme.day);
|
||||
g.setBgColor(settings.bg);
|
||||
g.drawImage(atob("DhABH+D/wwMMDDAwwMf/v//4f+H/h/8//P/z///f/g=="), 1, 4);
|
||||
} else {
|
||||
g.setColor(settings.bg);
|
||||
g.fillRect(0, 0, 20, 20);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Bangle.on('lock', function(on) {
|
||||
drawLock();
|
||||
});
|
||||
|
||||
g.clear();
|
||||
Bangle.loadWidgets();
|
||||
/*
|
||||
|
|
@ -116,6 +151,7 @@ Bangle.loadWidgets();
|
|||
*/
|
||||
for (let wd of WIDGETS) {wd.draw=()=>{};wd.area="";}
|
||||
loadSettings();
|
||||
loadThemeColors();
|
||||
setInterval(draw, 15000); // refresh every 15s
|
||||
draw();
|
||||
Bangle.setUI("clock");
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
const SETTINGS_FILE = "pebble.json";
|
||||
|
||||
// initialize with default settings...
|
||||
let s = {'bg': '#0f0', 'color': 'Green'}
|
||||
let s = {'bg': '#0f0', 'color': 'Green', 'theme':'System', 'showlock':false}
|
||||
|
||||
// ...and overwrite them with any saved values
|
||||
// This way saved values are preserved if a new version adds more settings
|
||||
|
|
@ -20,6 +20,7 @@
|
|||
|
||||
var color_options = ['Green','Orange','Cyan','Purple','Red','Blue'];
|
||||
var bg_code = ['#0f0','#ff0','#0ff','#f0f','#f00','#00f'];
|
||||
var theme_options = ['System', 'Light', 'Dark'];
|
||||
|
||||
E.showMenu({
|
||||
'': { 'title': 'Pebble Clock' },
|
||||
|
|
@ -32,7 +33,24 @@
|
|||
s.color = color_options[v];
|
||||
s.bg = bg_code[v];
|
||||
save();
|
||||
},
|
||||
}
|
||||
}
|
||||
},
|
||||
'Theme': {
|
||||
value: 0 | theme_options.indexOf(s.theme),
|
||||
min: 0, max: theme_options.length - 1,
|
||||
format: v => theme_options[v],
|
||||
onchange: v => {
|
||||
s.theme = theme_options[v];
|
||||
save();
|
||||
}
|
||||
},
|
||||
'Show Lock': {
|
||||
value: settings.showlock,
|
||||
format: () => (settings.showlock ? 'Yes' : 'No'),
|
||||
onchange: () => {
|
||||
settings.showlock = !settings.showlock;
|
||||
save();
|
||||
}
|
||||
},
|
||||
});
|
||||
})
|
||||
|
|
|
|||
Loading…
Reference in New Issue