Merge branch 'master' of github.com:espruino/BangleApps

master
Gordon Williams 2022-03-31 11:40:24 +01:00
commit e85080e052
5 changed files with 75 additions and 18 deletions

View File

@ -5,3 +5,4 @@
0.05: Fix typo in settings - Purple 0.05: Fix typo in settings - Purple
0.06: Added dependancy on Pedometer Widget 0.06: Added dependancy on Pedometer Widget
0.07: Fixed icon and ong file to 48x48 0.07: Fixed icon and ong file to 48x48
0.08: Added theme options and optional lock symbol

View File

@ -4,11 +4,12 @@
* Designed specifically for Bangle 2 * Designed specifically for Bangle 2
* A choice of 6 different background colous through its setting menu. Goto Settings, App/Widget settings, Pebble. * 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 * Uses pedometer widget to get latest step count
* Dependant apps are installed when Pebble installs * Dependant apps are installed when Pebble installs
* Uses the whole screen, widgets are made invisible but still run in the background * Uses the whole screen, widgets are made invisible but still run in the background
* When battery is less than 30% main screen goes Red * When battery is less than 30% main screen goes Red
* Optionally show a lock symbol when screen is locked (default off, enable in Settings)
![](pebble_screenshot.png) ![](pebble_screenshot.png)
![](pebble_screenshot2.png) ![](pebble_screenshot2.png)

View File

@ -2,7 +2,7 @@
"id": "pebble", "id": "pebble",
"name": "Pebble Clock", "name": "Pebble Clock",
"shortName": "Pebble", "shortName": "Pebble",
"version": "0.07", "version": "0.08",
"description": "A pebble style clock to keep the rebellion going", "description": "A pebble style clock to keep the rebellion going",
"dependencies": {"widpedom":"app"}, "dependencies": {"widpedom":"app"},
"readme": "README.md", "readme": "README.md",
@ -11,6 +11,7 @@
"type": "clock", "type": "clock",
"tags": "clock", "tags": "clock",
"supports": ["BANGLEJS", "BANGLEJS2"], "supports": ["BANGLEJS", "BANGLEJS2"],
"allow_emulator": true,
"storage": [ "storage": [
{"name":"pebble.app.js","url":"pebble.app.js"}, {"name":"pebble.app.js","url":"pebble.app.js"},
{"name":"pebble.settings.js","url":"pebble.settings.js"}, {"name":"pebble.settings.js","url":"pebble.settings.js"},

View File

@ -10,9 +10,10 @@ Graphics.prototype.setFontLECO1976Regular22 = function(scale) {
const SETTINGS_FILE = "pebble.json"; const SETTINGS_FILE = "pebble.json";
let settings; let settings;
let theme;
function loadSettings() { 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==")); 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); 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
if (settings.color == 'Blue' || settings.color == 'Red') //if (settings.color == 'Blue' || settings.color == 'Red')
g.setColor('#fff'); // white on blue or red best contrast // g.setColor('#fff'); // white on blue or red best contrast
else //else
g.setColor('#000'); // otherwise black regardless of theme // g.setColor('#000'); // otherwise black regardless of theme
g.setColor(theme.day);
g.setFontLECO1976Regular22(); g.setFontLECO1976Regular22();
g.setFontAlign(0, -1); g.setFontAlign(0, -1);
g.drawString(da[0].toUpperCase(), w/4, ha); // day of week g.drawString(da[0].toUpperCase(), w/4, ha); // day of week
@ -60,16 +61,16 @@ function draw() {
// time // time
// white on red for battery warning // 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.fillRect(0, h2, w, h3);
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
@ -79,15 +80,17 @@ function draw() {
g.setColor(settings.bg); g.setColor(settings.bg);
g.drawImage(img, w/2 + ((w/2) - 64)/2, 1, { scale: 1 }); g.drawImage(img, w/2 + ((w/2) - 64)/2, 1, { scale: 1 });
drawCalendar(((w/2) - 42)/2, 14, 42, 4, da[2]); drawCalendar(((w/2) - 42)/2, 14, 42, 4, da[2]);
drawLock();
} }
// 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,6 +110,38 @@ function getSteps() {
return '????'; 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(); g.clear();
Bangle.loadWidgets(); Bangle.loadWidgets();
/* /*
@ -116,6 +151,7 @@ Bangle.loadWidgets();
*/ */
for (let wd of WIDGETS) {wd.draw=()=>{};wd.area="";} for (let wd of WIDGETS) {wd.draw=()=>{};wd.area="";}
loadSettings(); loadSettings();
loadThemeColors();
setInterval(draw, 15000); // refresh every 15s setInterval(draw, 15000); // refresh every 15s
draw(); draw();
Bangle.setUI("clock"); Bangle.setUI("clock");

View File

@ -2,7 +2,7 @@
const SETTINGS_FILE = "pebble.json"; const SETTINGS_FILE = "pebble.json";
// initialize with default settings... // 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 // ...and overwrite them with any saved values
// This way saved values are preserved if a new version adds more settings // 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 color_options = ['Green','Orange','Cyan','Purple','Red','Blue'];
var bg_code = ['#0f0','#ff0','#0ff','#f0f','#f00','#00f']; var bg_code = ['#0f0','#ff0','#0ff','#f0f','#f00','#00f'];
var theme_options = ['System', 'Light', 'Dark'];
E.showMenu({ E.showMenu({
'': { 'title': 'Pebble Clock' }, '': { 'title': 'Pebble Clock' },
@ -32,7 +33,24 @@
s.color = color_options[v]; s.color = color_options[v];
s.bg = bg_code[v]; s.bg = bg_code[v];
save(); 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();
}
},
}); });
}) })