diff --git a/apps/regattatimer/README.md b/apps/regattatimer/README.md index 2ca05837a..8d906e1d7 100644 --- a/apps/regattatimer/README.md +++ b/apps/regattatimer/README.md @@ -65,6 +65,8 @@ Report bugs or request a feature at [github.com/naden](https://github.com/naden) ## Roadmap * add a seconds coundown layout; mimic a classic regatta chronograph * add recording of gps course and race time +* add icons for light mode +* add flag icons ## Created by © 2021 - 2024 [naden.de](https://naden.de) diff --git a/apps/regattatimer/app-icon.js b/apps/regattatimer/app-icon.js index 8f9c37a94..3c6f27c44 100644 --- a/apps/regattatimer/app-icon.js +++ b/apps/regattatimer/app-icon.js @@ -1 +1 @@ -require("heatshrink").decompress(atob("mEw4n/8H/BAWlsEI0ExkFj0H34GcgHnwGUsHO4H/kEhkGl4He8HeI8dgCyvTiM0ruABxNoxAACwwIC4MRAAMUkAWHgoNCAAMdBIVBBAccuAXGsIXIwtEmIxD0AXFhgXIAAMI6oZCnIXFh1VqtRC44AB2RkCqBiHC5UAhIxBip5KC5EA8gwIyMRiYXKgyWBjIIEhQgBpIXKgEEEwKSEA4MU3IXLhYwBoAHDuMRn8JC5cA8cRi4eDTIOQC5oNBjgFChoFChEx4wXKgApB6BeDiQEBxVgC5chMAeBiM7CZYAD2cRjAEB6L3JAA7oBNwVRJgYANOQMVAgKtBwAXPhDRBAgMxiYDBylEB4lk+C3D6gnBCYYbDrAnFrngIgeUDoKoBgEGC4dHyxWEqgXDXAIXBLYNgC4ldykAhWoIwNk8EL1TIBC4pHEBYOAgV+gFV6mbg13C4hHCMYcGqEMd4fXuhOEC4R3DU4eUpLPFL4kFwCnEa6/RiNQC58FiMdAgOBiM7C5+ziMYMwURiQXPkMRoAEBgURjgXPUwJyDAoOQCxsJFIOwAwVxiM+C5vjiMXY4itBaoYAIgzRBLwQABhUxA4oAHE4MT0AIEyIwMFwRGEYwcRpwXJ8gNBdA9RHIKSIhJVBir3JTIMrBQuyWoIuIAAOTBgMTruAA4MI6otBiM3KZMKNYIZC4lMCoSDBRgoAFg4+CAAscuDjMhoxDFofQfZpaCoYVBmhkDACEGbpQAY")) +require("heatshrink").decompress(atob("qFQ4UB8H/AAIJBoGtqoACDZYPDCRwUGqATNgoTDoATNgISCqhtPio6QHgg6OHggJGn+q1X8PJAHFnwSBAAO8CYxiFgeq1/Agf61XAMgpiFnWvAof61hkFCYkD1YhEgfqAwkFOwk62EAhkCwEwgEOFAkBCYgfCnYTB9gvCCZECDwMshgGBmE4GAOACY8KHQIjBAAQTBh2gCYY6EgHwTIsPgA8EAAeogAeDGAcAlQSGgQRBE5EKKAYdDA4wfGYgo6HHgbKFgHrgB3BAA0OBgQAEDQw0Hcog5IHojyEgWwWAgAFncOOAkO4ATLgZbENYIAMJIk7CZo0ElcDCRfA9AFD9A8M0ErFgjlBABXwJQiyMWgyyMQwrGBmASLhjIDUgPs//wBoc8ZAwTEmGqKQiEDh2shATDdwMA16nE1ADCh4dBeAcCAYJlEgQTDYoQPCAYevFwQfBYAgTH0eqFAcKlATEhQTG2GsgeqgE4CYM6LQITHDoUD/8A9fq4E/SYI7HgfwO4fq1RVDCY2wgevT4krfgqLDWYXqI4IACE4cO1XMY4vsn41DgBSBBgX/bYugmD/HAAcMhQgDYogAJhRWFABk6XQkPCRfwnYFD9AtEAA+gSQgEEABPoAgYsEABLTDNAo8KAgakBDQgAFnbCBAwbwBCZbuDZAayMc4i0NWQgAB9cAIYhbEBgQaGHpCDBGg0KKwgAFgQeGA4XwBIr5BD5GoHg46BlQwH9QnJ1YGDoAeDO4MsBYc4O4IwDgITDgRsBlgiBFgITBnRODCYg8BXgM6gWADIMDHQgTFnQ8BhgTBmA6BTokBqDyE1blEgYvCAAUFCYgoB14FD/TEFgtUAwkD1Wv4ED/WqEwkAitVTIs+1QAC3gLFqoTGgE/CQP8BQwTBPAgALgITBMgoAKgoTBMgoAKMQI8QHQQ8QHQQACCZoSEChoPD")) diff --git a/apps/regattatimer/app.js b/apps/regattatimer/app.js index 9f7c4f1af..30d03daed 100644 --- a/apps/regattatimer/app.js +++ b/apps/regattatimer/app.js @@ -13,14 +13,6 @@ Graphics.prototype.setFontAnton = function(scale) { function Regattatimer() { return { - icons: { - "satellite": function() { - return hs.decompress(atob("jEYxH+AH4Ab6QIIBJAfNAAQtSC4gxSCwgYHHBYYMC6IYPC5AZOC8QYMC5YYLC5inSDH4waVbAYJCpgA/AAI=")); - }, - "battery": function() { - return hs.decompress(atob("jEYxH+AHHSAAgXmCgoaRC/4X/C/4X/C/4X/C64Ap")); - } - }, layout: undefined, /* layouts: { @@ -51,6 +43,33 @@ function Regattatimer() { countdown: 300, // 5 minutes counter: undefined, interval: undefined, + theme: null, + themes: { + "Light": { + "fgColor": "#000000", + "bgColor": "#FFFF00", + "icons": { + "satellites": function() { + return hs.decompress(atob("jEYxH+AH4Ab6QIIBJAfNAAQtSC4gxSCwgYHHBYYMC6IYPC5AZOC8QYMC5YYLC5inSDH4waVbAYJCpgA/AAI=")); + }, + "battery": function() { + return hs.decompress(atob("jEYxH+AHHSAAgXmCgoaRC/4X/C/4X/C/4X/C64Ap")); + } + } + }, + "Dark": { + "fgColor": "#FFFF00", + "bgColor": "#000000", + "icons": { + "satellites": function() { + return hs.decompress(atob("jEYxH+AH4Ab6QIIBJAfNAAQtSC4gxSCwgYHHBYYMC6IYPC5AZOC8QYMC5YYLC5inSDH4waVbAYJCpgA/AAI=")); + }, + "battery": function() { + return hs.decompress(atob("jEYxH+AHHSAAgXmCgoaRC/4X/C/4X/C/4X/C64Ap")); + } + } + } + }, settings: Object.assign({ "debug": false, "buzzer": true, @@ -58,8 +77,6 @@ function Regattatimer() { "gps": true, "record": false, "theme": "Dark", - "fgColor": "#FFFF00", - "bgColor": "#000000" }, require('Storage').readJSON("regattatimer.json", true) || {}), translations: Object.assign({ @@ -79,14 +96,7 @@ function Regattatimer() { this.countdown = 1; } - if(this.settings.theme == "Dark") { - this.settings.fgColor = "#FFFF00"; - this.settings.bgColor = "#000000"; - } - else { - this.settings.fgColor = "#000000"; - this.settings.bgColor = "#FFFF00"; - } + this.theme = this.themes[this.settings.theme]; Bangle.setLCDPower(1); Bangle.setLCDTimeout(0); @@ -202,7 +212,7 @@ function Regattatimer() { this.interval = undefined; } - if(settings.buzzer) { + if(this.settings.buzzer) { Bangle.buzz(); } @@ -232,13 +242,13 @@ function Regattatimer() { this.layout = new Layout({ type: "v", - bgCol: this.settings.bgColor, + bgCol: this.theme.bgColor, c: [ { type: "v", c: [ - {type: "txt", font: "Anton", label: "5", col: this.settings.fgColor, id: "minutes", fillx: 1, filly: 1}, - {type: "txt", font: "20%", label: "--:--", col: this.settings.fgColor, id: "daytime", fillx: 1, filly: 1} + {type: "txt", font: "Anton", label: "5", col: this.theme.fgColor, id: "minutes", fillx: 1, filly: 1}, + {type: "txt", font: "20%", label: "--:--", col: this.theme.fgColor, id: "daytime", fillx: 1, filly: 1} ] } ]}, {lazy: true}); @@ -256,13 +266,13 @@ function Regattatimer() { this.layout = new Layout({ type: "v", - bgCol: this.settings.bgColor, + bgCol: this.theme.bgColor, c: [ { type: "h", c: [ - {type: "txt", font: "Anton", label: "4", col: this.settings.fgColor, id: "minutes", fillx: 1, filly: 1}, - {type: "txt", font: "Anton", label: "59", col: this.settings.fgColor, id: "seconds", fillx: 1, filly: 1}, + {type: "txt", font: "Anton", label: "4", col: this.theme.fgColor, id: "minutes", fillx: 1, filly: 1}, + {type: "txt", font: "Anton", label: "59", col: this.theme.fgColor, id: "seconds", fillx: 1, filly: 1}, ] } ]}, {lazy: true} @@ -273,9 +283,9 @@ function Regattatimer() { this.layout = new Layout({ type: "v", - bgCol: this.settings.bgColor, + bgCol: this.theme.bgColor, c:[ - {type: "txt", font: "Anton", label: "", fillx: true, filly: true, col: this.settings.fgColor, id: "seconds"}, + {type: "txt", font: "Anton", label: "", fillx: true, filly: true, col: this.theme.fgColor, id: "seconds"}, ]}, {lazy: true}); }, setLayoutRace: function() { @@ -283,23 +293,23 @@ function Regattatimer() { this.layout = new Layout({ type: "v", - bgCol: this.settings.bgColor, + bgCol: this.theme.bgColor, c: [ - {type: "txt", font: "20%", label: "00:00:00", col: this.settings.fgColor, pad: 4, filly: 1, fillx: 1, id: "racetime"}, - {type: "txt", font: "15%", label: "-", col: this.settings.fgColor, pad: 4, filly:1, fillx:1, id: "daytime"}, + {type: "txt", font: "20%", label: "00:00:00", col: this.theme.fgColor, pad: 4, filly: 1, fillx: 1, id: "racetime"}, + {type: "txt", font: "15%", label: "-", col: this.theme.fgColor, pad: 4, filly:1, fillx:1, id: "daytime"}, // horizontal {type: "h", c: [ - {type: "txt", font: "10%", label: this.translate("speed"), col: this.settings.fgColor, pad:4, fillx:1, filly:1}, - {type: "txt", font: "20%", label: "0", col: this.settings.fgColor, pad:4, fillx:1, filly:1, id: "speed"}, - {type: "txt", font: "10%", label: this.translate("speed_unit"), col: this.settings.fgColor, pad:4, fillx:1, filly:1}, + {type: "txt", font: "10%", label: this.translate("speed"), col: this.theme.fgColor, pad:4, fillx:1, filly:1}, + {type: "txt", font: "20%", label: "0", col: this.theme.fgColor, pad:4, fillx:1, filly:1, id: "speed"}, + {type: "txt", font: "10%", label: this.translate("speed_unit"), col: this.theme.fgColor, pad:4, fillx:1, filly:1}, ]}, {type: "h", c: [ - {type:"img", pad: 2, src: this.icons.satellite()}, - {type: "txt", font: "10%", label: "0", col: this.settings.fgColor, pad: 2, filly:1, id: "satellites"}, + {type:"img", pad: 2, src: this.theme["icons"].satellites()}, + {type: "txt", font: "10%", label: "0", col: this.theme.fgColor, pad: 2, filly:1, id: "satellites"}, // hacky, use empty element with fillx to push the other elments to the left an right side {type: undefined, pad: 2, fillx: 1}, - {type:"img", pad: 2, src: this.icons.battery()}, - {type: "txt", font: "10%", label: "-", col: this.settings.fgColor, pad: 2, filly: 1, id: "battery"}, + {type:"img", pad: 2, src: this.theme["icons"].battery()}, + {type: "txt", font: "10%", label: "-", col: this.theme.fgColor, pad: 2, filly: 1, id: "battery"}, ]} ]}, {lazy: true}); } diff --git a/apps/regattatimer/icon.png b/apps/regattatimer/icon.png index eb6057305..47712c7ed 100644 Binary files a/apps/regattatimer/icon.png and b/apps/regattatimer/icon.png differ diff --git a/apps/regattatimer/regattatimer.json b/apps/regattatimer/regattatimer.json index d8ed2f2ac..e2ea78f76 100644 --- a/apps/regattatimer/regattatimer.json +++ b/apps/regattatimer/regattatimer.json @@ -4,7 +4,5 @@ "dial": "Numeric", "gps": true, "record": false, - "theme": "Dark", - "fgColor": "#FFFF00", - "bgColor": "#000000" + "theme": "Dark" } diff --git a/apps/regattatimer/screenshot-6.png b/apps/regattatimer/screenshot-6.png index eaa306ba4..391eaafd2 100644 Binary files a/apps/regattatimer/screenshot-6.png and b/apps/regattatimer/screenshot-6.png differ diff --git a/apps/regattatimer/settings.js b/apps/regattatimer/settings.js index c96bc4771..cdcdf53f5 100644 --- a/apps/regattatimer/settings.js +++ b/apps/regattatimer/settings.js @@ -15,8 +15,6 @@ "gps": true, "record": false, "theme": "Dark", - "fgColor": "#FFFF00", - "bgColor": "#000000" }, storage.readJSON(file, true) || {}); function save(key, value) { @@ -77,4 +75,4 @@ } }, }); -}) +})(load)