mirror of https://github.com/espruino/BangleApps
Merge branch 'master' of github.com:espruino/BangleApps
commit
5fd9c7600a
|
@ -217,7 +217,12 @@ function showEditRepeatMenu(repeat, dow, dowChangeCallback) {
|
|||
function showCustomDaysMenu(dow, dowChangeCallback, originalRepeat, originalDow) {
|
||||
const menu = {
|
||||
"": { "title": /*LANG*/"Custom Days" },
|
||||
"< Back": () => dowChangeCallback(true, dow),
|
||||
"< Back": () => {
|
||||
// If the user unchecks all the days then we assume repeat = once
|
||||
// and we force the dow to every day.
|
||||
var repeat = dow > 0;
|
||||
dowChangeCallback(repeat, repeat ? dow : EVERY_DAY)
|
||||
}
|
||||
};
|
||||
|
||||
require("date_utils").dows(firstDayOfWeek).forEach((day, i) => {
|
||||
|
@ -315,12 +320,12 @@ function showAdvancedMenu() {
|
|||
|
||||
function enableAll(on) {
|
||||
if (alarms.filter(e => e.on == !on).length == 0) {
|
||||
E.showPrompt(on ? /*LANG*/"Nothing to Enable" : /*LANG*/"Nothing to Disable", {
|
||||
title: on ? /*LANG*/"Enable All" : /*LANG*/"Disable All",
|
||||
buttons: { /*LANG*/"Ok": true }
|
||||
}).then(() => showAdvancedMenu());
|
||||
E.showAlert(
|
||||
on ? /*LANG*/"Nothing to Enable" : /*LANG*/"Nothing to Disable",
|
||||
on ? /*LANG*/"Enable All" : /*LANG*/"Disable All"
|
||||
).then(() => showAdvancedMenu());
|
||||
} else {
|
||||
E.showPrompt(/*LANG*/"Are you sure?", { title: on ? "/*LANG*/Enable All" : /*LANG*/"Disable All" }).then((confirm) => {
|
||||
E.showPrompt(/*LANG*/"Are you sure?", { title: on ? /*LANG*/"Enable All" : /*LANG*/"Disable All" }).then((confirm) => {
|
||||
if (confirm) {
|
||||
alarms.forEach(alarm => alarm.on = on);
|
||||
saveAndReload();
|
||||
|
@ -334,7 +339,7 @@ function enableAll(on) {
|
|||
|
||||
function deleteAll() {
|
||||
if (alarms.length == 0) {
|
||||
E.showPrompt(/*LANG*/"Nothing to delete", { title: /*LANG*/"Delete All", buttons: { /*LANG*/"Ok": true } }).then(() => showAdvancedMenu());
|
||||
E.showAlert(/*LANG*/"Nothing to delete", /*LANG*/"Delete All").then(() => showAdvancedMenu());
|
||||
} else {
|
||||
E.showPrompt(/*LANG*/"Are you sure?", {
|
||||
title: /*LANG*/"Delete All"
|
||||
|
|
|
@ -5,4 +5,5 @@
|
|||
0.05: Included icons for information.
|
||||
0.06: Design and usability improvements.
|
||||
0.07: Improved positioning.
|
||||
0.08: Select the color of widgets correctly. Additional settings to hide colon.
|
||||
0.08: Select the color of widgets correctly. Additional settings to hide colon.
|
||||
0.09: Larger font size if colon is hidden to improve readability further.
|
|
@ -44,6 +44,16 @@ Graphics.prototype.setLargeFont = function(scale) {
|
|||
return this;
|
||||
};
|
||||
|
||||
Graphics.prototype.setXLargeFont = function(scale) {
|
||||
// Actual height 53 (55 - 3)
|
||||
this.setFontCustom(
|
||||
E.toString(require('heatshrink').decompress(atob('AHM/8AIG/+AA4sD/wQGh/4EWQA/AC8YA40HNA0BRY8/RY0P/6LFgf//4iFA4IiFj4HBEQkHCAQiDHIIZGv4HCFQY5BDAo5CAAIpDDAfACA3wLYv//hsFKYxcCMgoiBOooiBQwwiBS40AHIgA/ACS/DLYjYCBAjQEBAYQDBAgHDUAbyDZQi3CegoHEVQQZFagUfW4Y0DaAgECaIJSEFYMPbIYNDv5ACGAIrBCgJ1EFYILCAAQWCj4zDGgILCegcDEQRNDHIIiCHgZ2BEQShFIqUDFYidCh5ODg4NCn40DAgd/AYR5BDILZEAAIMDAAYVCh7aHdYhKDbQg4Dv7rGBAihFCAwIDCAgA/AB3/eoa7GAAk/dgbVGDJrvCDK67DDIjaGdYpbCdYonCcQjjDEVUBEQ4A/AEMcAYV/NAUHcYUDawd/cYUPRYSmBBgaLBToP8BgYiBSgIiCj4iCg//EQSuDW4IMDVwYiCBgIiBBgrRDCATeBaIYqCv70DCgT4CEQMfIgQZBBoRnDv/3EQIvBDIffEQMHFwReBRYUfOgX/+IiDKI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XIQZCgYUBv7jEh4uBZAscewZ8CgEgUYT0EEoQIBA4gICFQQIEHYQA+KQzdDAArdCAArpCEScHaIQiEvwiGe4QiFUwQiEbgIiFYIL0DEQTkBEQrJEEQc/cYYiCg4HBDIQiCfoRoEHQLaDEQQHBbQYiBCAT8Dn/BCAoXBJYP/OgZKC/6OEEARLCEQZLEEQZLEEQjKFEQI6EEQZLDEQbsGEQLjGYYYA/JIxzEg/AfgJSDAoPgfgiDC8COFAoPnaQj6CAAR+CW4TCFA4i6CDIqhCDIfwHoYHCYIN/GgKuBJ4JDBFYUf/C5CBYIZBv/Ag4ZBg4rBBYQTBAQIcBg4FBn5UBAQUfFwIfCEQeAgYfBAQUBFAKbCAQQiCGwIiE+A2BwBFNwE/AoM/EQJoIWwKCCh4cBFYKUERYV/W46uHFYIZGaJA0B/glBGYT0JIITiEMIJvCFQQAEHYQA/ABBlEOIhdGQAIRFSgQIBgQICn4IB8EAjiBCUYglCbQYeBEoQZCTwM/CYIZD/gEBUwIzBJ4UHYAU/EwIrBh4rCAoIXCn4rBCgUDAQN/FYMfBYIXBCYJnCBYXggf8HgQLCwEPEQQuBgJOECwILDCwgiLHIUHBYJFGD4IxBgYWCn4rBBwJoFDIYNBCgPADgKHBRYfDBQN/GAIrBToTLDVwYACDILiCWAb8DAAYzBYAjTCAAI9BAARNCBAoqCBAgQDFgbYCAH4AufgQACf4T8CAAT/CfgQACBwITCAAYOBCYQioh4iEAHQA=='))),
|
||||
46,
|
||||
atob("FR4uHyopKyksJSssGA=="),
|
||||
70+(scale<<8)+(1<<16)
|
||||
);
|
||||
};
|
||||
|
||||
Graphics.prototype.setMediumFont = function(scale) {
|
||||
// Actual height 41 (42 - 2)
|
||||
this.setFontCustom(atob("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA/AAAAAAAA/AAAAAAAA/AAAAAAAA/AAAAAAAA/AAAAAAAA/AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA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AAAAAAAAAAPwAAAAAAAPwAAAAAAAPwAAAAAAAPwAAAAAAAPwAAAAHAAPwAAAA/AAPwAAAD/AAPwAAAf/AAPwAAB//AAPwAAP//AAPwAA//8AAPwAH//wAAPwAf/+AAAPwB//4AAAPwP//AAAAPw//8AAAAP3//gAAAAP//+AAAAAP//wAAAAAP//AAAAAAP/4AAAAAAP/gAAAAAAP+AAAAAAAHwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP+AAAAH+A//gAAAf/h//4AAA//z//8AAB/////+AAD/////+AAD///+H/AAH+H/4B/AAH8B/wA/gAH4A/gAfgAH4A/gAfgAPwA/AAfgAPwA/AAfgAPwA/AAfgAPwA/AAfgAH4A/gAfgAH4A/gAfgAH8B/wA/gAH/H/4B/AAD///+H/AAD/////+AAB/////+AAA//z//8AAAf/h//4AAAH+A//gAAAAAAH+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA/gAAAAAAD/8AAAAAAP/+AAAAAAf//AAcAAA///gA8AAB///wB+AAD/x/4B/AAD+AP4B/AAH8AH8A/gAH4AH8A/gAH4AD8AfgAP4AD8AfgAPwAB8AfgAPwAB8AfgAPwAB8AfgAPwAB8AfgAH4AD8AfgAH4AD4A/gAH8AH4B/AAD+APwD/AAD/g/wP+AAB/////+AAA/////8AAAf////4AAAP////wAAAH////AAAAA///8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD8APwAAAAD8APwAAAAD8APwAAAAD8APwAAAAD8APwAAAAD8APwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=="), 46, atob("DxcjFyAfISAiHCAiEg=="), 54+(scale<<8)+(1<<16));
|
||||
|
@ -304,17 +314,13 @@ function drawTime(){
|
|||
g.setColor(g.theme.bg);
|
||||
g.setFontAlign(0,0);
|
||||
|
||||
var timeStr;
|
||||
if(settings.hideColon){
|
||||
var hours = date.getHours();
|
||||
hours -= hours >=12 ? 12 : 0;
|
||||
var minutes = date.getMinutes();
|
||||
minutes = minutes < 10 ? String("0") + minutes : minutes;
|
||||
timeStr = String(hours) + minutes;
|
||||
} else {
|
||||
timeStr = locale.time(date,1);
|
||||
}
|
||||
var hours = String(date.getHours());
|
||||
var minutes = date.getMinutes();
|
||||
minutes = minutes < 10 ? String("0") + minutes : minutes;
|
||||
var colon = settings.hideColon ? "" : ":";
|
||||
var timeStr = hours + colon + minutes;
|
||||
|
||||
// Set y coordinates correctly
|
||||
y += parseInt((H - y)/2) + 5;
|
||||
|
||||
var infoEntry = getInfoEntry();
|
||||
|
@ -324,7 +330,11 @@ function drawTime(){
|
|||
|
||||
// Show large or small time depending on info entry
|
||||
if(infoStr == null){
|
||||
g.setLargeFont();
|
||||
if(settings.hideColon){
|
||||
g.setXLargeFont();
|
||||
} else {
|
||||
g.setLargeFont();
|
||||
}
|
||||
} else {
|
||||
y -= 15;
|
||||
g.setMediumFont();
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"id": "bwclk",
|
||||
"name": "BW Clock",
|
||||
"version": "0.08",
|
||||
"version": "0.09",
|
||||
"description": "BW Clock.",
|
||||
"readme": "README.md",
|
||||
"icon": "app.png",
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 2.8 KiB After Width: | Height: | Size: 2.7 KiB |
Binary file not shown.
Before Width: | Height: | Size: 3.1 KiB After Width: | Height: | Size: 3.0 KiB |
Binary file not shown.
Before Width: | Height: | Size: 3.4 KiB After Width: | Height: | Size: 3.1 KiB |
|
@ -1,2 +1,4 @@
|
|||
0.01: New Clock Nifty A
|
||||
0.02: Shows the current week number (ISO8601), can be disabled via settings ""
|
||||
0.02: Shows the current week number (ISO8601), can be disabled via settings
|
||||
0.03: Call setUI before loading widgets
|
||||
Improve settings page
|
||||
|
|
|
@ -1,13 +1,12 @@
|
|||
# Nifty-A Clock
|
||||
|
||||
Colors are black/white - photos have non correct camera color "blue"
|
||||
Colors are black/white - photos have non correct camera color "blue".
|
||||
|
||||
## This is the clock
|
||||
This is the clock:
|
||||
|
||||

|
||||
|
||||
## The week number (ISO8601) can be turned of in settings
|
||||
(default is **"On"**)
|
||||
The week number (ISO8601) can be turned off in settings (default is `On`)
|
||||
|
||||

|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
const locale = require("locale");
|
||||
const is12Hour = (require("Storage").readJSON("setting.json", 1) || {})["12hour"];
|
||||
const CFG = require('Storage').readJSON("ffcniftya.json", 1) || {showWeekNum: true};
|
||||
const is12Hour = Object.assign({ "12hour": false }, require("Storage").readJSON("setting.json", true))["12hour"];
|
||||
const showWeekNum = Object.assign({ showWeekNum: true }, require('Storage').readJSON("ffcniftya.json", true))["showWeekNum"];
|
||||
|
||||
/* Clock *********************************************/
|
||||
const scale = g.getWidth() / 176;
|
||||
|
@ -17,16 +17,17 @@ const center = {
|
|||
y: Math.round(((viewport.height - widget) / 2) + widget),
|
||||
}
|
||||
|
||||
function ISO8601_week_no(date) { //copied from: https://gist.github.com/IamSilviu/5899269#gistcomment-3035480
|
||||
var tdt = new Date(date.valueOf());
|
||||
var dayn = (date.getDay() + 6) % 7;
|
||||
tdt.setDate(tdt.getDate() - dayn + 3);
|
||||
var firstThursday = tdt.valueOf();
|
||||
tdt.setMonth(0, 1);
|
||||
if (tdt.getDay() !== 4) {
|
||||
tdt.setMonth(0, 1 + ((4 - tdt.getDay()) + 7) % 7);
|
||||
}
|
||||
return 1 + Math.ceil((firstThursday - tdt) / 604800000);
|
||||
// copied from: https://gist.github.com/IamSilviu/5899269#gistcomment-3035480
|
||||
function ISO8601_week_no(date) {
|
||||
var tdt = new Date(date.valueOf());
|
||||
var dayn = (date.getDay() + 6) % 7;
|
||||
tdt.setDate(tdt.getDate() - dayn + 3);
|
||||
var firstThursday = tdt.valueOf();
|
||||
tdt.setMonth(0, 1);
|
||||
if (tdt.getDay() !== 4) {
|
||||
tdt.setMonth(0, 1 + ((4 - tdt.getDay()) + 7) % 7);
|
||||
}
|
||||
return 1 + Math.ceil((firstThursday - tdt) / 604800000);
|
||||
}
|
||||
|
||||
function d02(value) {
|
||||
|
@ -59,7 +60,7 @@ function draw() {
|
|||
g.drawString(year, centerDatesScaleX, center.y - 62 * scale);
|
||||
g.drawString(month, centerDatesScaleX, center.y - 44 * scale);
|
||||
g.drawString(day, centerDatesScaleX, center.y - 26 * scale);
|
||||
if (CFG.showWeekNum) g.drawString(d02(ISO8601_week_no(now)), centerDatesScaleX, center.y + 15 * scale);
|
||||
if (showWeekNum) g.drawString(weekNum, centerDatesScaleX, center.y + 15 * scale);
|
||||
g.drawString(monthName, centerDatesScaleX, center.y + 48 * scale);
|
||||
g.drawString(dayName, centerDatesScaleX, center.y + 66 * scale);
|
||||
}
|
||||
|
@ -79,7 +80,6 @@ function clearTickTimer() {
|
|||
function queueNextTick() {
|
||||
clearTickTimer();
|
||||
tickTimer = setTimeout(tick, 60000 - (Date.now() % 60000));
|
||||
// tickTimer = setTimeout(tick, 3000);
|
||||
}
|
||||
|
||||
function tick() {
|
||||
|
@ -91,21 +91,16 @@ function tick() {
|
|||
|
||||
// Clear the screen once, at startup
|
||||
g.clear();
|
||||
// Start ticking
|
||||
tick();
|
||||
|
||||
// Stop updates when LCD is off, restart when on
|
||||
Bangle.on('lcdPower', (on) => {
|
||||
if (on) {
|
||||
tick(); // Start ticking
|
||||
tick();
|
||||
} else {
|
||||
clearTickTimer(); // stop ticking
|
||||
clearTickTimer();
|
||||
}
|
||||
});
|
||||
|
||||
// Load widgets
|
||||
Bangle.setUI("clock");
|
||||
Bangle.loadWidgets();
|
||||
Bangle.drawWidgets();
|
||||
|
||||
// Show launcher when middle button pressed
|
||||
Bangle.setUI("clock");
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"id": "ffcniftya",
|
||||
"name": "Nifty-A Clock",
|
||||
"version": "0.02",
|
||||
"version": "0.03",
|
||||
"description": "A nifty clock with time and date",
|
||||
"icon": "app.png",
|
||||
"screenshots": [{"url":"screenshot_nifty.png"}],
|
||||
|
|
|
@ -1,23 +1,15 @@
|
|||
(function(back) {
|
||||
var FILE = "ffcniftya.json";
|
||||
// Load settings
|
||||
var cfg = require('Storage').readJSON(FILE, 1) || { showWeekNum: true };
|
||||
(function (back) {
|
||||
const settings = Object.assign({ showWeekNum: true }, require("Storage").readJSON("ffcniftya.json", true));
|
||||
|
||||
function writeSettings() {
|
||||
require('Storage').writeJSON(FILE, cfg);
|
||||
}
|
||||
|
||||
// Show the menu
|
||||
E.showMenu({
|
||||
"" : { "title" : "Nifty-A Clock" },
|
||||
"< Back" : () => back(),
|
||||
'week number?': {
|
||||
value: cfg.showWeekNum,
|
||||
format: v => v?"On":"Off",
|
||||
"": { "title": "Nifty-A Clock" },
|
||||
"< Back": () => back(),
|
||||
/*LANG*/"Show Week Number": {
|
||||
value: settings.showWeekNum,
|
||||
onchange: v => {
|
||||
cfg.showWeekNum = v;
|
||||
writeSettings();
|
||||
settings.showWeekNum = v;
|
||||
require("Storage").writeJSON("ffcniftya.json", settings);
|
||||
}
|
||||
}
|
||||
});
|
||||
})
|
||||
})
|
||||
|
|
|
@ -1,2 +1,5 @@
|
|||
0.01: New Clock Nifty B
|
||||
0.02: Added configuration
|
||||
0.02: Added configuration
|
||||
0.03: Call setUI before loading widgets
|
||||
Fix bug with black being unselectable
|
||||
Improve settings page
|
||||
|
|
|
@ -1,9 +1,6 @@
|
|||
# Nifty Series B Clock
|
||||
|
||||
- Display Time and Date
|
||||
- Color Configuration
|
||||
|
||||
##
|
||||
- Colour Configuration
|
||||
|
||||

|
||||
|
||||
|
|
|
@ -1,9 +1,5 @@
|
|||
const locale = require("locale");
|
||||
const storage = require('Storage');
|
||||
|
||||
const is12Hour = (storage.readJSON("setting.json", 1) || {})["12hour"];
|
||||
const color = (storage.readJSON("ffcniftyb.json", 1) || {})["color"] || 63488 /* red */;
|
||||
|
||||
const is12Hour = Object.assign({ "12hour": false }, require("Storage").readJSON("setting.json", true))["12hour"];
|
||||
const color = Object.assign({ color: 63488 }, require("Storage").readJSON("ffcniftyb.json", true)).color; // Default to RED
|
||||
|
||||
/* Clock *********************************************/
|
||||
const scale = g.getWidth() / 176;
|
||||
|
@ -19,7 +15,7 @@ const center = {
|
|||
};
|
||||
|
||||
function d02(value) {
|
||||
return ('0' + value).substr(-2);
|
||||
return ("0" + value).substr(-2);
|
||||
}
|
||||
|
||||
function renderEllipse(g) {
|
||||
|
@ -35,8 +31,8 @@ function renderText(g) {
|
|||
const month = d02(now.getMonth() + 1);
|
||||
const year = now.getFullYear();
|
||||
|
||||
const month2 = locale.month(now, 3);
|
||||
const day2 = locale.dow(now, 3);
|
||||
const month2 = require("locale").month(now, 3);
|
||||
const day2 = require("locale").dow(now, 3);
|
||||
|
||||
g.setFontAlign(1, 0).setFont("Vector", 90 * scale);
|
||||
g.drawString(hour, center.x + 32 * scale, center.y - 31 * scale);
|
||||
|
@ -96,7 +92,6 @@ function startTick(run) {
|
|||
stopTick();
|
||||
run();
|
||||
ticker = setTimeout(() => startTick(run), 60000 - (Date.now() % 60000));
|
||||
// ticker = setTimeout(() => startTick(run), 3000);
|
||||
}
|
||||
|
||||
/* Init **********************************************/
|
||||
|
@ -104,7 +99,7 @@ function startTick(run) {
|
|||
g.clear();
|
||||
startTick(draw);
|
||||
|
||||
Bangle.on('lcdPower', (on) => {
|
||||
Bangle.on("lcdPower", (on) => {
|
||||
if (on) {
|
||||
startTick(draw);
|
||||
} else {
|
||||
|
@ -112,7 +107,6 @@ Bangle.on('lcdPower', (on) => {
|
|||
}
|
||||
});
|
||||
|
||||
Bangle.setUI("clock");
|
||||
Bangle.loadWidgets();
|
||||
Bangle.drawWidgets();
|
||||
|
||||
Bangle.setUI("clock");
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
{
|
||||
"id": "ffcniftyb",
|
||||
"name": "Nifty-B Clock",
|
||||
"version": "0.02",
|
||||
"description": "A nifty clock (series B) with time, date and color configuration",
|
||||
"version": "0.03",
|
||||
"description": "A nifty clock (series B) with time, date and colour configuration",
|
||||
"icon": "app.png",
|
||||
"screenshots": [{"url":"screenshot.png"}],
|
||||
"type": "clock",
|
||||
|
|
|
@ -1,49 +1,31 @@
|
|||
(function (back) {
|
||||
const storage = require('Storage');
|
||||
const SETTINGS_FILE = "ffcniftyb.json";
|
||||
const settings = Object.assign({ color: 63488 }, require("Storage").readJSON("ffcniftyb.json", true));
|
||||
|
||||
const colors = {
|
||||
65535: 'White',
|
||||
63488: 'Red',
|
||||
65504: 'Yellow',
|
||||
2047: 'Cyan',
|
||||
2016: 'Green',
|
||||
31: 'Blue',
|
||||
0: 'Black',
|
||||
65535: /*LANG*/"White",
|
||||
63488: /*LANG*/"Red",
|
||||
65504: /*LANG*/"Yellow",
|
||||
2047: /*LANG*/"Cyan",
|
||||
2016: /*LANG*/"Green",
|
||||
31: /*LANG*/"Blue",
|
||||
0: /*LANG*/"Black"
|
||||
}
|
||||
|
||||
function load(settings) {
|
||||
return Object.assign(settings, storage.readJSON(SETTINGS_FILE, 1) || {});
|
||||
}
|
||||
const menu = {};
|
||||
menu[""] = { title: "Nifty-B Clock" };
|
||||
menu["< Back"] = back;
|
||||
|
||||
function save(settings) {
|
||||
storage.write(SETTINGS_FILE, settings)
|
||||
}
|
||||
|
||||
const settings = load({
|
||||
color: 63488 /* red */,
|
||||
Object.keys(colors).forEach(color => {
|
||||
var label = colors[color];
|
||||
menu[label] = {
|
||||
value: settings.color == color,
|
||||
onchange: () => {
|
||||
settings.color = color;
|
||||
require("Storage").write("ffcniftyb.json", settings);
|
||||
setTimeout(load, 10);
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
const saveColor = (color) => () => {
|
||||
settings.color = color;
|
||||
save(settings);
|
||||
back();
|
||||
};
|
||||
|
||||
function showMenu(items, opt) {
|
||||
items[''] = opt || {};
|
||||
items['< Back'] = back;
|
||||
E.showMenu(items);
|
||||
}
|
||||
|
||||
showMenu(
|
||||
Object.keys(colors).reduce((menu, color) => {
|
||||
menu[colors[color]] = saveColor(color);
|
||||
return menu;
|
||||
}, {}),
|
||||
{
|
||||
title: 'Color',
|
||||
selected: Object.keys(colors).indexOf(settings.color)
|
||||
}
|
||||
);
|
||||
E.showMenu(menu);
|
||||
});
|
||||
|
|
|
@ -4,4 +4,5 @@
|
|||
0.04: Fixed icon and png to 48x48 pixels
|
||||
0.05: added charging icon
|
||||
0.06: Add 12h support and autocycle control
|
||||
0.07: added localization; removed deprecated code
|
||||
0.07: added localization, removed deprecated code
|
||||
0.08: removed unused font, fix autocycle, imported suncalc and trimmed, removed pedometer dependency, "tap to cycle" setting
|
||||
|
|
Binary file not shown.
|
@ -2,11 +2,11 @@
|
|||
"id": "rebble",
|
||||
"name": "Rebble Clock",
|
||||
"shortName": "Rebble",
|
||||
"version": "0.07",
|
||||
"version": "0.08",
|
||||
"description": "A Pebble style clock, with configurable background, three sidebars including steps, day, date, sunrise, sunset, long live the rebellion",
|
||||
"readme": "README.md",
|
||||
"icon": "rebble.png",
|
||||
"dependencies": {"mylocation":"app", "widpedom":"app"},
|
||||
"dependencies": {"mylocation":"app"},
|
||||
"screenshots": [{"url":"screenshot_rebble.png"}],
|
||||
"type": "clock",
|
||||
"tags": "clock",
|
||||
|
@ -14,6 +14,7 @@
|
|||
"storage": [
|
||||
{"name":"rebble.app.js","url":"rebble.app.js"},
|
||||
{"name":"rebble.settings.js","url":"rebble.settings.js"},
|
||||
{"name":"rebble.img","url":"rebble.icon.js","evaluate":true}
|
||||
{"name":"rebble.img","url":"rebble.icon.js","evaluate":true},
|
||||
{"name":"suncalc","url":"suncalc.js"}
|
||||
]
|
||||
}
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -2,12 +2,14 @@
|
|||
const SETTINGS_FILE = "rebble.json";
|
||||
|
||||
// initialize with default settings...
|
||||
let localSettings = {'bg': '#0f0', 'color': 'Green', 'autoCycle': true}
|
||||
let localSettings = {'bg': '#0f0', 'color': 'Green', 'autoCycle': true, 'sideTap':0};
|
||||
//sideTap 0 = on| 1= sideBar1 | 2 = ...
|
||||
|
||||
// ...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) || localSettings;
|
||||
|
||||
const saved = settings || {}
|
||||
for (const key in saved) {
|
||||
localSettings[key] = saved[key]
|
||||
|
@ -21,26 +23,55 @@
|
|||
var color_options = ['Green','Orange','Cyan','Purple','Red','Blue'];
|
||||
var bg_code = ['#0f0','#ff0','#0ff','#f0f','#f00','#00f'];
|
||||
|
||||
E.showMenu({
|
||||
'': { 'title': 'Rebble Clock' },
|
||||
'< Back': back,
|
||||
'Colour': {
|
||||
value: 0 | color_options.indexOf(localSettings.color),
|
||||
min: 0, max: 5,
|
||||
format: v => color_options[v],
|
||||
onchange: v => {
|
||||
localSettings.color = color_options[v];
|
||||
localSettings.bg = bg_code[v];
|
||||
save();
|
||||
function showMenu()
|
||||
{
|
||||
const menu={
|
||||
'': { 'title': 'Rebble Clock' },
|
||||
'< Back': back,
|
||||
'Colour': {
|
||||
value: 0 | color_options.indexOf(localSettings.color),
|
||||
min: 0, max: 5,
|
||||
format: v => color_options[v],
|
||||
onchange: v => {
|
||||
localSettings.color = color_options[v];
|
||||
localSettings.bg = bg_code[v];
|
||||
save();
|
||||
},
|
||||
},
|
||||
},
|
||||
'Auto Cycle': {
|
||||
value: "autoCycle" in localSettings ? localSettings.autoCycle : true,
|
||||
format: () => (localSettings.autoCycle ? 'Yes' : 'No'),
|
||||
onchange: () => {
|
||||
localSettings.autoCycle = !localSettings.autoCycle;
|
||||
save();
|
||||
'Auto Cycle': {
|
||||
value: localSettings.autoCycle,
|
||||
onchange: (v) => {
|
||||
localSettings.autoCycle = v;
|
||||
save();
|
||||
showMenu();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
if( !localSettings.autoCycle)
|
||||
{
|
||||
menu['Tap to Cycle']= {
|
||||
value: localSettings.sideTap,
|
||||
min: 0,
|
||||
max: 3,
|
||||
step: 1,
|
||||
format: v => NumberToSideTap(v),
|
||||
onchange: v => {
|
||||
localSettings.sideTap=v
|
||||
save();
|
||||
setTimeout(showMenu, 10);
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
})
|
||||
E.showMenu(menu);
|
||||
}
|
||||
|
||||
function NumberToSideTap(Number)
|
||||
{
|
||||
if(Number==0)
|
||||
return 'on';
|
||||
return Number+"";
|
||||
}
|
||||
|
||||
showMenu();
|
||||
})
|
|
@ -0,0 +1,143 @@
|
|||
/*
|
||||
(c) 2011-2015, Vladimir Agafonkin
|
||||
SunCalc is a JavaScript library for calculating sun/moon position and light phases.
|
||||
https://github.com/mourner/suncalc
|
||||
|
||||
edit for banglejs
|
||||
*/
|
||||
|
||||
(function () { 'use strict';
|
||||
|
||||
// shortcuts for easier to read formulas
|
||||
|
||||
var PI = Math.PI,
|
||||
sin = Math.sin,
|
||||
cos = Math.cos,
|
||||
tan = Math.tan,
|
||||
asin = Math.asin,
|
||||
atan = Math.atan2,
|
||||
acos = Math.acos,
|
||||
rad = PI / 180;
|
||||
|
||||
// sun calculations are based on http://aa.quae.nl/en/reken/zonpositie.html formulas
|
||||
|
||||
|
||||
// date/time constants and conversions
|
||||
|
||||
var dayMs = 1000 * 60 * 60 * 24,
|
||||
J1970 = 2440588,
|
||||
J2000 = 2451545;
|
||||
|
||||
function toJulian(date) { return date.valueOf() / dayMs - 0.5 + J1970; }
|
||||
function fromJulian(j) { return new Date((j + 0.5 - J1970) * dayMs); }
|
||||
function toDays(date) { return toJulian(date) - J2000; }
|
||||
|
||||
|
||||
// general calculations for position
|
||||
|
||||
var e = rad * 23.4397; // obliquity of the Earth
|
||||
|
||||
function declination(l, b) { return asin(sin(b) * cos(e) + cos(b) * sin(e) * sin(l)); }
|
||||
|
||||
|
||||
// general sun calculations
|
||||
|
||||
function solarMeanAnomaly(d) { return rad * (357.5291 + 0.98560028 * d); }
|
||||
|
||||
function eclipticLongitude(M) {
|
||||
|
||||
var C = rad * (1.9148 * sin(M) + 0.02 * sin(2 * M) + 0.0003 * sin(3 * M)), // equation of center
|
||||
P = rad * 102.9372; // perihelion of the Earth
|
||||
|
||||
return M + C + P + PI;
|
||||
}
|
||||
|
||||
var SunCalc = {};
|
||||
|
||||
|
||||
// sun times configuration (angle, morning name, evening name)
|
||||
|
||||
var times = SunCalc.times = [
|
||||
[-0.833, 'sunrise', 'sunset' ],
|
||||
[ -0.3, 'sunriseEnd', 'sunsetStart' ],
|
||||
[ -6, 'dawn', 'dusk' ],
|
||||
[ -12, 'nauticalDawn', 'nauticalDusk'],
|
||||
[ -18, 'nightEnd', 'night' ],
|
||||
[ 6, 'goldenHourEnd', 'goldenHour' ]
|
||||
];
|
||||
|
||||
|
||||
|
||||
// calculations for sun times
|
||||
|
||||
var J0 = 0.0009;
|
||||
|
||||
function julianCycle(d, lw) { return Math.round(d - J0 - lw / (2 * PI)); }
|
||||
|
||||
function approxTransit(Ht, lw, n) { return J0 + (Ht + lw) / (2 * PI) + n; }
|
||||
function solarTransitJ(ds, M, L) { return J2000 + ds + 0.0053 * sin(M) - 0.0069 * sin(2 * L); }
|
||||
|
||||
function hourAngle(h, phi, d) { return acos((sin(h) - sin(phi) * sin(d)) / (cos(phi) * cos(d))); }
|
||||
function observerAngle(height) { return -2.076 * Math.sqrt(height) / 60; }
|
||||
|
||||
// returns set time for the given sun altitude
|
||||
function getSetJ(h, lw, phi, dec, n, M, L) {
|
||||
|
||||
var w = hourAngle(h, phi, dec),
|
||||
a = approxTransit(w, lw, n);
|
||||
return solarTransitJ(a, M, L);
|
||||
}
|
||||
|
||||
|
||||
// calculates sun times for a given date, latitude/longitude, and, optionally,
|
||||
// the observer height (in meters) relative to the horizon
|
||||
|
||||
SunCalc.getTimes = function (date, lat, lng, height) {
|
||||
|
||||
height = height || 0;
|
||||
|
||||
var lw = rad * -lng,
|
||||
phi = rad * lat,
|
||||
|
||||
dh = observerAngle(height),
|
||||
|
||||
d = toDays(date),
|
||||
n = julianCycle(d, lw),
|
||||
ds = approxTransit(0, lw, n),
|
||||
|
||||
M = solarMeanAnomaly(ds),
|
||||
L = eclipticLongitude(M),
|
||||
dec = declination(L, 0),
|
||||
|
||||
Jnoon = solarTransitJ(ds, M, L),
|
||||
|
||||
i, len, time, h0, Jset, Jrise;
|
||||
|
||||
|
||||
var result = {
|
||||
solarNoon: fromJulian(Jnoon),
|
||||
nadir: fromJulian(Jnoon - 0.5)
|
||||
};
|
||||
|
||||
for (i = 0, len = times.length; i < len; i += 1) {
|
||||
time = times[i];
|
||||
h0 = (time[0] + dh) * rad;
|
||||
|
||||
Jset = getSetJ(h0, lw, phi, dec, n, M, L);
|
||||
Jrise = Jnoon - (Jset - Jnoon);
|
||||
|
||||
result[time[1]] = fromJulian(Jrise);
|
||||
result[time[2]] = fromJulian(Jset);
|
||||
}
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
|
||||
// export as Node module / AMD module / browser variable
|
||||
if (typeof exports === 'object' && typeof module !== 'undefined') module.exports = SunCalc;
|
||||
else if (typeof define === 'function' && define.amd) define(SunCalc);
|
||||
else window.SunCalc = SunCalc;
|
||||
|
||||
|
||||
}());
|
|
@ -192,7 +192,15 @@
|
|||
"Notifications": "Notifiche",
|
||||
"Scheduler": "Schedulatore",
|
||||
"Stop": "Stop",
|
||||
"Min Font": "Dimensione minima del font"
|
||||
"Min Font": "Dimensione minima del font",
|
||||
"White": "Bianco",
|
||||
"Red": "Rosso",
|
||||
"Yellow": "Giallo",
|
||||
"Cyan": "Ciano",
|
||||
"Green": "Verde",
|
||||
"Blue": "Blu",
|
||||
"Black": "Nero",
|
||||
"Show Week Number": "Mostra numero settimana"
|
||||
},
|
||||
"//2": "App-specific overrides",
|
||||
"alarm": {
|
||||
|
|
Loading…
Reference in New Issue