Pebble - long live the rebellion

pull/975/head
hughbarney 2021-11-29 20:12:25 +00:00
parent 3fa435e57d
commit b50faa919a
9 changed files with 159 additions and 1 deletions

View File

@ -4543,5 +4543,21 @@
"storage": [
{"name":"mylocation.settings.js","url":"mylocation.settings.js"}
]
}
},
{
"id": "pebble",
"name": "Pebble Clock",
"shortName": "Pebble",
"version": "0.01",
"description": "A pebble style clock to keep the rebellion going",
"icon": "pebble.png",
"dependencies": {"widpedom":"app"},
"screenshots": [{"url":"screenshot_pebble.png"}],
"type": "clock",
"tags": "clock",
"supports": ["BANGLEJS2"],
"storage": [
{"name":"pebble.app.js","url":"pebble.app.js"},
{"name":"pebble.img","url":"pebble.icon.js","evaluate":true},
}
]

1
apps/pebble/ChangeLog Normal file
View File

@ -0,0 +1 @@
0.01: first release

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

103
apps/pebble/pebble.app.js Normal file
View File

@ -0,0 +1,103 @@
// inspired by
//https://apps.rebble.io/en_US/application/55cf75fc61e031bb4b000025?dev_settings=true&section=watchfaces
Graphics.prototype.setFontQahiri = function(scale) {
// Actual height 60 (60 - 1)
g.setFontCustom(atob("AAAAAAAAfAAAAAAAAAAAAP4AAAAAAAAAAAD/AAAAAAAAAAAB/wAAAAAAAAAAAf8AAAAAAAAAAAH/AAAAAAAAAAAA/wAAAAAAAAAAAH4AAAAAAAAAAAA4AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABwAAAAAAAAAAAB8AAAAAAAAAAAD/gAAAAAAAAAAH/4AAAAAAAAAAP/8AAAAAAAAAAP/4AAAAAAAAAAf/4AAAAAAAAAA//wAAAAAAAAAB//gAAAAAAAAAD//AAAAAAAAAAD//AAAAAAAAAAH/+AAAAAAAAAAP/8AAAAAAAAAAf/4AAAAAAAAAAf/4AAAAAAAAAA//wAAAAAAAAAB//gAAAAAAAAAD//AAAAAAAAAAH/+AAAAAAAAAAH/+AAAAAAAAAAP/8AAAAAAAAAAH/4AAAAAAAAAAB/wAAAAAAAAAAAPwAAAAAAAAAAADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA//////wAAAAAAP/////8AAAAAAD//////AAAAAAA//////wAAAAAAP/////8AAAAAAD//////AAAAAAA//////wAAAAAAP/////8AAAAAAD/AAAD/AAAAAAA/wAAA/wAAAAAAP8AAAP8AAAAAAD/AAAD/AAAAAAA/wAAA/wAAAAAAP8AAAP8AAAAAAD/AAAD/AAAAAAA//////wAAAAAAP/////8AAAAAAD//////AAAAAAA//////wAAAAAAP/////8AAAAAAD//////AAAAAAA//////wAAAAAAP/////8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA//////wAAAAAAP/////8AAAAAAD//////AAAAAAA//////wAAAAAAP/////8AAAAAAD//////AAAAAAA//////wAAAAAAP/////8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA/wH///wAAAAAAP8B///8AAAAAAD/Af///AAAAAAA/wH///wAAAAAAP8B///8AAAAAAD/Af///AAAAAAA/wH///wAAAAAAP8B///8AAAAAAD/Af4D/AAAAAAA/wH+A/wAAAAAAP8B/gP8AAAAAAD/Af4D/AAAAAAA/wH+A/wAAAAAAP8B/gP8AAAAAAD/Af4D/AAAAAAA///+A/wAAAAAAP///gP8AAAAAAD///4D/AAAAAAA///+A/wAAAAAAP///gP8AAAAAAD///4D/AAAAAAA///+A/wAAAAAAH///gH8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA/wH+A/wAAAAAAP8B/gP8AAAAAAD/Af4D/AAAAAAA/wH+A/wAAAAAAP8B/gP8AAAAAAD/Af4D/AAAAAAA/wH+A/wAAAAAAP8B/gP8AAAAAAD/Af4D/AAAAAAA/wH+A/wAAAAAAP8B/gP8AAAAAAD/Af4D/AAAAAAA/wH+A/wAAAAAAP8B/gP8AAAAAAD/Af4D/AAAAAAA//////wAAAAAAP/////8AAAAAAD//////AAAAAAA//////wAAAAAAP/////8AAAAAAD//////AAAAAAA//////wAAAAAAH/////8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA///AAAAAAAAAAP//wAAAAAAAAAD//8AAAAAAAAAA///AAAAAAAAAAP//wAAAAAAAAAD//8AAAAAAAAAA///AAAAAAAAAAP//wAAAAAAAAAAAP8AAAAAAAAAAAD/AAAAAAAAAAAA/wAAAAAAAAAAAP8AAAAAAAAAAAD/AAAAAAAAAAAA/wAAAAAAAAAAAP8AAAAAAAAAA//////wAAAAAAP/////8AAAAAAD//////AAAAAAA//////wAAAAAAP/////8AAAAAAD//////AAAAAAA//////wAAAAAAH/////8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA///+A/wAAAAAAP///gP8AAAAAAD///4D/AAAAAAA///+A/wAAAAAAP///gP8AAAAAAD///4D/AAAAAAA///+A/wAAAAAAP///gP8AAAAAAD/Af4D/AAAAAAA/wH+A/wAAAAAAP8B/gP8AAAAAAD/Af4D/AAAAAAA/wH+A/wAAAAAAP8B/gP8AAAAAAD/Af4D/AAAAAAA/wH///wAAAAAAP8B///8AAAAAAD/Af///AAAAAAA/wH///wAAAAAAP8B///8AAAAAAD/Af///AAAAAAA/wH///wAAAAAAH8A///8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA//////wAAAAAAP/////8AAAAAAD//////AAAAAAA//////wAAAAAAP/////8AAAAAAD//////AAAAAAA//////wAAAAAAP/////8AAAAAAD/Af4D/AAAAAAA/wH+A/wAAAAAAP8B/gP8AAAAAAD/Af4D/AAAAAAA/wH+A/wAAAAAAP8B/gP8AAAAAAD/Af4D/AAAAAAA/wH///wAAAAAAP8B///8AAAAAAD/Af///AAAAAAA/wH///wAAAAAAP8B///8AAAAAAD/Af///AAAAAAA/wH///wAAAAAAH8A///8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA/wAAAAAAAAAAAP8AAAAAAAAAAAD/AAAAAAAAAAAA/wAAAAAAAAAAAP8AAAAAAAAAAAD/AAAAAAAAAAAA/wAAAAAAAAAAAP8AAAAAAAAAAAD/AAAAAAAAAAAA/wAAAAAAAAAAAP8AAAAAAAAAAAD/AAAAAAAAAAAA/wAAAAAAAAAAAP8AAAAAAAAAAAD/AAAAAAAAAAAA//////wAAAAAAP/////8AAAAAAD//////AAAAAAA//////wAAAAAAP/////8AAAAAAD//////AAAAAAA//////wAAAAAAH/////8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA//////wAAAAAAP/////8AAAAAAD//////AAAAAAA//////wAAAAAAP/////8AAAAAAD//////AAAAAAA//////wAAAAAAP/////8AAAAAAD/Af4D/AAAAAAA/wH+A/wAAAAAAP8B/gP8AAAAAAD/Af4D/AAAAAAA/wH+A/wAAAAAAP8B/gP8AAAAAAD/Af4D/AAAAAAA//////wAAAAAAP/////8AAAAAAD//////AAAAAAA//////wAAAAAAP/////8AAAAAAD//////AAAAAAA//////wAAAAAAH/////8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA///+A/wAAAAAAP///gP8AAAAAAD///4D/AAAAAAA///+A/wAAAAAAP///gP8AAAAAAD///4D/AAAAAAA///+A/wAAAAAAP///gP8AAAAAAD/Af4D/AAAAAAA/wH+A/wAAAAAAP8B/gP8AAAAAAD/Af4D/AAAAAAA/wH+A/wAAAAAAP8B/gP8AAAAAAD/Af4D/AAAAAAA//////wAAAAAAP/////8AAAAAAD//////AAAAAAA//////wAAAAAAP/////8AAAAAAD//////AAAAAAA//////wAAAAAAH/////8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA+AAfAAAAAAAAAfwAP4AAAAAAAAP8AD/AAAAAAAAD/gB/wAAAAAAAA/4Af8AAAAAAAAP+AH/AAAAAAAAD/AA/wAAAAAAAAfgAH4AAAAAAAABwAA4AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=="), 46, atob("DR0bDBsbGxsbGxsbDQ=="), 80+(scale<<8)+(1<<16));
}
const SETTINGS_FILE = "pebble.json";
let settings;
function loadSettings() {
settings = require("Storage").readJSON(SETTINGS_FILE,1)|| {'bg': '#0f0', 'color': 'Green'};
}
var img = require("heatshrink").decompress(atob("oFAwkGswA/AH4A/AH4A/AH4A/AFEAD74gdsAfBELlggMhD70iILsAiUAIKQRBgxAHgUiIKQQJUAMSD4JBQsBVBIAq/DEAJBCJ45VHkAxEDwKfDIIUREBq2BmcQCAQeCkczmRBEiAgND4MxSoYGBAAQgCAAohKDARhBG4IeDEAQ8BAA5fJABgpBgFDgEiQgJEHT4IeMmMBkMFAYJJDEQaYDiYfMkECiEEoEDBAX//8ykJsBD4MAWwIALiBeCqAyDn//BoYgBgAeMYAMhgE0CRIOBD58BkEEmCRKkEGD5szkUQqdASJUxD4MAgKBKmUigFEGJZgBAATODFw0CkEBmoOJAAQdB7owBOBDdCgbdED5fd6pRIgDdCeBkxD4fdeAgNEkMFmheLdgIfE6BgGmDdCoDdKDwYfD6gzGiBeBrpLHXYUQXIMgD4NND4SAFZgMRgAKBPwroBBYIeBIAL/CADESL4VmsAcWgMRkQeDAAMAkQAWMAQeCD4MSDqqdBDwgfBAC8GDwiAXDowA/AH4A/AH4A/AH4A/AEA"));
const h = g.getHeight();
const w = g.getWidth();
const ha = 2*h/5 - 8;
const h2 = 3*h/5 - 10;
const h3 = 7*h/8;
function draw() {
var date = new Date();
var da = date.toString().split(" ");
//var timeStr = require("locale").time(date,1); // causes screen corruption ???
var timeStr = da[4].substr(0,5);
const t = 6;
g.reset();
g.setColor(settings.bg);
g.fillRect(0, 0, w, h2 - t);
// contrast bar
g.setColor(g.theme.fg);
g.fillRect(0, h2 - t, w, h2);
// day and steps
g.setColor('#000'); // really needs to be black regardless of theme
g.setFont('Vector', 22);
g.setFontAlign(0, -1);
g.drawString(da[0], w/4, ha); // day of week
g.drawString(getSteps(), 3*w/4, ha);
// time
g.setColor(g.theme.bg);
g.fillRect(0, h2, w, h3);
g.setFontQahiri();
g.setFontAlign(0, -1);
g.setColor(g.theme.fg);
g.drawString(timeStr, w/2, h2 - 8);
// contrast bar
g.setColor(g.theme.fg);
g.fillRect(0, h3, w, h3 + t);
// the bottom
g.setColor(settings.bg);
g.fillRect(0, h3 + t, w, h);
g.setColor(settings.bg);
g.drawImage(img, w/2 + ((w/2) - 64)/2, 10, { scale: 1 });
drawCalendar(((w/2) - 48)/2, 10, 48, 4, da[2]);
}
// at x,y width:wi thicknes:th
function drawCalendar(x,y,wi,th,str) {
g.setColor(g.theme.fg);
g.fillRect(x, y, x + wi, y + wi);
g.setColor(g.theme.bg);
g.fillRect(x + th, y + th, x + wi - th, y + wi - th);
g.setColor(g.theme.fg);
var hook_t = 6;
// first calendar hook, one third in
g.fillRect(x + (wi/3) - (th/2), y - hook_t, x + wi/3 + th - (th/2), y + hook_t);
// second calendar hook, two thirds in
g.fillRect(x + (2*wi/3) -(th/2), y - hook_t, x + 2*wi/3 + th - (th/2), y + hook_t);
g.setFont('Vector', 22);
g.setFontAlign(0, 0);
g.drawString(str, x + wi/2 + th/2, y + wi/2 + th/2);
}
function getSteps() {
if (WIDGETS.wpedom !== undefined) {
return WIDGETS.wpedom.getSteps();
}
return '????';
}
g.clear();
Bangle.loadWidgets();
/*
* we are not drawing the widgets as we are taking over the whole screen
* so we will blank out the draw() functions of each widget
*/
for (var wd of WIDGETS) {wd.draw=()=>{};}
loadSettings();
setInterval(draw, 15000); // refresh every 15s
draw();
Bangle.setUI("clock");

BIN
apps/pebble/pebble.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

@ -0,0 +1,38 @@
(function(back) {
const SETTINGS_FILE = "pebble.json";
// initialize with default settings...
let s = {'bg': '#0f0', 'color': 'Green'}
// ...and overwrite them with any saved values
// This way saved values are preserved if a new version adds more settings
const storage = require('Storage')
let settings = storage.readJSON(SETTINGS_FILE, 1) || s;
const saved = settings || {}
for (const key in saved) {
s[key] = saved[key]
}
function save() {
settings = s
storage.write(SETTINGS_FILE, settings)
}
var color_options = ['Green','Orange','Cyan','Perple','Red','Blue'];
var bg_code = ['#0f0','#ff0','#0ff','#f0f','#f00','#00f'];
E.showMenu({
'': { 'title': 'Pebble Clock' },
'< Back': back,
'Colour': {
value: 0 | color_options.indexOf(s.color),
min: 0, max: 5,
format: v => color_options[v],
onchange: v => {
s.color = color_options[v];
s.bg = bg_code[v];
save();
},
}
});
})

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB