diff --git a/apps/slidingtext/slidingtext.dtfmt.js b/apps/slidingtext/slidingtext.dtfmt.js index 582d5f1a5..2543610c1 100644 --- a/apps/slidingtext/slidingtext.dtfmt.js +++ b/apps/slidingtext/slidingtext.dtfmt.js @@ -6,8 +6,6 @@ class DateFormatter { * and the date formatDate method will return the time formated * to the lines of text on the screen */ - name(){ return "no name";} - shortName(){ return "no short name" } formatDate(date){ return ["no","date","defined"]; } /** diff --git a/apps/slidingtext/slidingtext.js b/apps/slidingtext/slidingtext.js index 8f8e1b711..8ad045335 100644 --- a/apps/slidingtext/slidingtext.js +++ b/apps/slidingtext/slidingtext.js @@ -309,7 +309,7 @@ const row_types = { }; let row_displays; -function init_display(settings) { +function initDisplay(settings) { if(row_displays != null){ return; } @@ -466,8 +466,8 @@ function nextColorTheme(){ } //console.log("changing color scheme to " + color_schemes[color_scheme_index].name) updateColorScheme(); - reset_clock(true); - draw_clock(); + resetClock(true); + drawClock(); } function updateColorScheme(){ @@ -480,7 +480,7 @@ function updateColorScheme(){ g.fillRect(0, 24, g.getWidth(), g.getHeight()); } -function reset_clock(hard_reset){ +function resetClock(hard_reset){ console.log("reset_clock hard_reset:" + hard_reset); updateColorScheme(); @@ -525,7 +525,7 @@ function display_time(date){ } } -function draw_clock(){ +function drawClock(){ var date = new Date(); // we don't want the time to be displayed @@ -607,7 +607,7 @@ function display_row(display,txt){ * called from load_settings on startup to * set the color scheme to named value */ -function set_colorscheme(colorscheme_name){ +function setColorScheme(colorscheme_name){ console.log("setting color scheme:" + colorscheme_name); for (var i=0; i < color_schemes.length; i++) { if(color_schemes[i].name === colorscheme_name){ @@ -651,8 +651,6 @@ class DigitDateTimeFormatter { } ]; } - name(){return "Digital";} - shortName(){return "digit";} format00(num){ var value = (num | 0); @@ -678,7 +676,7 @@ class DigitDateTimeFormatter { } var date_formatter; -function set_dateformat(shortname){ +function setDateformat(shortname){ console.log("setting date format:" + shortname); try { if (date_formatter == null || date_formatter.shortName() !== shortname) { @@ -698,21 +696,22 @@ const PREFERENCE_FILE = "slidingtext.settings.json"; /** * Called on startup to set the watch to the last preference settings */ -function load_settings() { - var setScheme = false; +function loadSettings() { try { var settings = require("Storage").readJSON(PREFERENCE_FILE); - settings = { date_format: 'dgt'}; if (settings != null) { console.log("loaded settings:" + JSON.stringify(settings)); if (settings.date_format != null) { - set_dateformat(settings.date_format); - init_display(settings); + var format = setting.date_format; + if(settings.date_formatter != null) + format = settings.date_format; + + setDateformat(format); + initDisplay(settings); } if (settings.color_scheme != null) { - set_colorscheme(settings.color_scheme); - setScheme = true; + setColorScheme(settings.color_scheme); } if (settings.enable_live_controls == null) { settings.enable_live_controls = (bangleVersion() <= 1); @@ -727,36 +726,21 @@ function load_settings() { console.log("failed to load settings:" + e); } // just set up as default - console.log("set_schema:" + setScheme); - if (!setScheme) { - set_dateformat("default"); - init_display(); + if (row_displays === undefined) { + setDateformat("default"); + initDisplay(); updateColorScheme(); } - init_display(); enable_live_controls = true; } -/** - * Called on button press to save down the last preference settings - */ -function save_settings(){ - var settings = { - date_format : date_formatter.shortName(), - color_scheme : color_schemes[color_scheme_index].name, - enable_live_controls: enable_live_controls - }; - console.log("saving:" + JSON.stringify(settings)); - require("Storage").writeJSON(PREFERENCE_FILE,settings); -} function button3pressed() { console.log("button3pressed enable_live_controls=" + enable_live_controls); if (enable_live_controls) { nextColorTheme(); - reset_clock(true); - draw_clock(); - save_settings(); + resetClock(true); + drawClock(); } } @@ -776,7 +760,7 @@ function startTimers(){ var nextMinuteStart = 60 - secs; //console.log("scheduling clock draw in " + nextMinuteStart + " seconds"); setTimeout(scheduleDrawClock,nextMinuteStart * 1000); - draw_clock(); + drawClock(); } /** @@ -799,13 +783,13 @@ function scheduleDrawClock(){ console.log("draw clock callback - skipped redraw"); } else { console.log("draw clock callback"); - draw_clock(); + drawClock(); } }, 60 * 1000 ); if (shouldRedraw()) { - draw_clock(); + drawClock(); } else { console.log("scheduleDrawClock - skipped redraw"); } @@ -818,17 +802,17 @@ Bangle.on('lcdPower', (on) => { if (on) { console.log("lcdPower: on"); Bangle.drawWidgets(); - reset_clock(false); + resetClock(false); startTimers(); } else { console.log("lcdPower: off"); - reset_clock(false); + resetClock(false); clearTimers(); } }); g.clear(); -load_settings(); +loadSettings(); // Show launcher when button pressed Bangle.setUI("clockupdown", d=>{ if (d>0) button3pressed(); diff --git a/apps/slidingtext/slidingtext.locale.de.js b/apps/slidingtext/slidingtext.locale.de.js index 29b70889e..abd917ec0 100644 --- a/apps/slidingtext/slidingtext.locale.de.js +++ b/apps/slidingtext/slidingtext.locale.de.js @@ -86,8 +86,6 @@ class GermanDateFormatter extends DateFormatter { } ]; } - name(){return "German";} - shortName(){return "de"} formatDate(date){ var mins = date.getMinutes(); var hourOfDay = date.getHours(); diff --git a/apps/slidingtext/slidingtext.locale.en.js b/apps/slidingtext/slidingtext.locale.en.js index bb1636d16..4a05f4f96 100644 --- a/apps/slidingtext/slidingtext.locale.en.js +++ b/apps/slidingtext/slidingtext.locale.en.js @@ -60,8 +60,6 @@ class EnglishDateFormatter extends DateFormatter { } ]; } - name(){return "English";} - shortName(){return "en"} formatDate(date){ var hours_txt = hoursToText(date.getHours()); var mins_txt = numberToText(date.getMinutes()); diff --git a/apps/slidingtext/slidingtext.locale.en2.js b/apps/slidingtext/slidingtext.locale.en2.js index 92134bef2..3b64df6a5 100644 --- a/apps/slidingtext/slidingtext.locale.en2.js +++ b/apps/slidingtext/slidingtext.locale.en2.js @@ -99,8 +99,6 @@ class EnglishTraditionalDateFormatter extends DateFormatter { }, ]; } - name(){return "English (Traditional)";} - shortName(){return "en2"} formatDate(date){ var date_txt = Locale.dow(date,1).toUpperCase() + " " + numberToText(date.getDate()); var mins = date.getMinutes(); diff --git a/apps/slidingtext/slidingtext.locale.es.js b/apps/slidingtext/slidingtext.locale.es.js index 6354021fa..e320f6e8e 100644 --- a/apps/slidingtext/slidingtext.locale.es.js +++ b/apps/slidingtext/slidingtext.locale.es.js @@ -63,8 +63,6 @@ class SpanishDateFormatter extends DateFormatter { } ]; } - name(){return "Spanish";} - shortName(){return "es"} formatDate(date){ var mins = date.getMinutes(); var hourOfDay = date.getHours(); diff --git a/apps/slidingtext/slidingtext.locale.fr.js b/apps/slidingtext/slidingtext.locale.fr.js index 7bc6b2ce8..c0098bb55 100644 --- a/apps/slidingtext/slidingtext.locale.fr.js +++ b/apps/slidingtext/slidingtext.locale.fr.js @@ -47,8 +47,6 @@ class FrenchDateFormatter extends DateFormatter { } ]; } - name(){return "French";} - shortName(){return "fr"} formatDate(date){ var hours = frenchHoursToText(date.getHours()); var heures = frenchHeures(date.getHours()); diff --git a/apps/slidingtext/slidingtext.locale.jp.js b/apps/slidingtext/slidingtext.locale.jp.js index 8432c1a16..164f285fd 100644 --- a/apps/slidingtext/slidingtext.locale.jp.js +++ b/apps/slidingtext/slidingtext.locale.jp.js @@ -28,16 +28,16 @@ const japaneseMinuteStr = [ ["", "PUN"], function japaneseHoursToText(hours){ hours = hours % 12; - if(hours == 0){ + if(hours === 0){ hours = 12; } return japaneseHourStr[hours]; } function japaneseMinsToText(mins){ - if(mins == 0){ + if(mins === 0){ return ["",""]; - } else if(mins == 30) + } else if(mins === 30) return ["HAN",""]; else { var units = mins % 10; @@ -77,8 +77,6 @@ class JapaneseDateFormatter extends DateFormatter { } ]; } - name(){return "Japanese (Romanji)";} - shortName(){return "jp"} formatDate(date){ var hours_txt = japaneseHoursToText(date.getHours()); var mins_txt = japaneseMinsToText(date.getMinutes()); diff --git a/apps/slidingtext/slidingtext.settings.js b/apps/slidingtext/slidingtext.settings.js index d87dfce26..caced6868 100644 --- a/apps/slidingtext/slidingtext.settings.js +++ b/apps/slidingtext/slidingtext.settings.js @@ -8,13 +8,85 @@ } console.log("loaded:" + JSON.stringify(settings)); var locale_mappings = { - 'English Time':'en', - 'English Date + Time': 'en3', - 'English Time (Trad)': 'en2', - 'French': 'fr', - 'German': 'de', - 'Spanish': 'es', - 'Japanese': 'jp', + 'en' : { date_format: 'en' }, + 'en patchwork': { + date_format: 'en patchwork', + date_formatter: 'en', + row_types: { + large:{ + angle_to_horizontal: 90 + } + }, + row_defs: [ + { + type: 'large', + init_coords: [0.05,0.95], + row_direction: [1.0,0.0], + rows: 1 + }, + { + type: 'medium', + init_coords: [0.3,0.1], + row_direction: [0.0,1.0], + rows: 2 + }, + { + type: 'small', + init_coords: [0.3,0.9], + row_direction: [0.0,1.0], + rows: 1 + } + ] + }, + 'en2': { date_format: 'en2' }, + 'en2 patchwork': { date_format: 'en2 patchwork', + date_formatter: 'en2', + row_types: { + vsmall: { + scroll_off: ['right'], + scroll_in: ['right'], + angle_to_horizontal: 0 + }, + large: { + size: 'vlarge', + angle_to_horizontal: 90, + speed: 'slow', + color: 'major', + scroll_off: ['down'], + scroll_in: ['up'] + } + }, + row_defs: [ + { + type: 'large', + init_coords: [0.7,0.9], + row_direction: [0.0,1.0], + rows: 1 + }, + { + type: 'small', + init_coords: [0.05,0.35], + row_direction: [0.0,1.0], + rows: 3 + }, + { + type: 'large', + init_coords: [0.7,0.9], + row_direction: [0.0,1.0], + rows: 1 + }, + { + type: 'vsmall', + init_coords: [0.05,0.1], + row_direction: [0.0,1.0], + rows: 1 + }, + ] + }, + 'French': { date_format:'fr'}, + 'German': { date_format: 'de'}, + 'Spanish': { date_format: 'es'}, + 'Japanese': { date_format: 'jp'}, } var locales = Object.keys(locale_mappings); @@ -50,7 +122,7 @@ "" : { "title" : "Sliding Text" }, "< Back" : () => back(), "Colour": stringInSettings("color_scheme", ["white", "black", "red","grey","purple","blue"]), - "Languages": stringInSettings("date_format", locales, (l)=>locale_mappings[l] ), + "Style": stringInSettings("date_format", locales, (l)=>locale_mappings[l] ), "Live Control": { value: (settings.enable_live_controls !== undefined ? settings.enable_live_controls : true), format: v => v ? "On" : "Off",