From 4f60a450227c840f7f7faa9e358eda14f485bf5f Mon Sep 17 00:00:00 2001 From: Paul Cockrell Date: Fri, 3 Apr 2020 09:16:22 +0100 Subject: [PATCH 1/2] Bug fix - use 12 / 24 hr clock based on user settings --- apps.json | 2 +- apps/marioclock/ChangeLog | 1 + apps/marioclock/marioclock-app.js | 15 +++++++++------ 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/apps.json b/apps.json index e0f5142af..3bdc55f07 100644 --- a/apps.json +++ b/apps.json @@ -892,7 +892,7 @@ { "id": "marioclock", "name": "Mario Clock", "icon": "marioclock.png", - "version":"0.04", + "version":"0.05", "description": "Animated Mario clock, jumps to change the time!", "tags": "clock,mario,retro", "type": "clock", diff --git a/apps/marioclock/ChangeLog b/apps/marioclock/ChangeLog index 4334ad92c..74db9bc18 100644 --- a/apps/marioclock/ChangeLog +++ b/apps/marioclock/ChangeLog @@ -2,3 +2,4 @@ 0.02: Fix day of the week and add padding 0.03: use short date format from locale, take timeout from settings 0.04: modify date to display to be more at the original idea but still localized +0.05: use 12/24 hour clock from settings diff --git a/apps/marioclock/marioclock-app.js b/apps/marioclock/marioclock-app.js index ecbaba38a..49ae20b76 100644 --- a/apps/marioclock/marioclock-app.js +++ b/apps/marioclock/marioclock-app.js @@ -1,14 +1,15 @@ /********************************** - BangleJS MARIO CLOCK V0.1.0 + BangleJS MARIO CLOCK + Based on Espruino Mario Clock V3 https://github.com/paulcockrell/espruino-mario-clock + Converting images to 1bit BMP: Image > Mode > Indexed and tick the "Use black and white (1-bit) palette", Then export as BMP. + Online Image convertor: https://www.espruino.com/Image+Converter **********************************/ -var locale = require("locale"); +const locale = require("locale"); const storage = require('Storage'); -const settings = (storage.readJSON('setting.json',1)||{}); -const timeout = settings.timeout||10; +const settings = (storage.readJSON('setting.json',1) || {}); +const timeout = settings.timeout || 10; +const is12Hour = settings["12hour"] || false; // Screen dimensions let W, H; @@ -273,7 +274,8 @@ function drawTime() { drawBrick(42, 25); const t = new Date(); - const hours = ("0" + t.getHours()).substr(-2); + const h = t.getHours(); + const hours = ("0" + ((is12Hour && h > 12) ? h - 12 : h)).substr(-2); const mins = ("0" + t.getMinutes()).substr(-2); g.setFont("6x8"); @@ -374,8 +376,9 @@ function init() { Bangle.setLCDPower(true); } }); + + startTimers(); } // Initialise! init(); -startTimers(); From 50322a0f05b4d152b66740fed12f3018ddc83593 Mon Sep 17 00:00:00 2001 From: Paul Cockrell Date: Fri, 3 Apr 2020 09:18:05 +0100 Subject: [PATCH 2/2] Lint --- apps/marioclock/marioclock-app.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/marioclock/marioclock-app.js b/apps/marioclock/marioclock-app.js index 49ae20b76..2eeb21c97 100644 --- a/apps/marioclock/marioclock-app.js +++ b/apps/marioclock/marioclock-app.js @@ -7,7 +7,7 @@ const locale = require("locale"); const storage = require('Storage'); -const settings = (storage.readJSON('setting.json',1) || {}); +const settings = (storage.readJSON('setting.json', 1) || {}); const timeout = settings.timeout || 10; const is12Hour = settings["12hour"] || false;