From 4ad3f59561c950a0977c33b8a610baf11c23d8d1 Mon Sep 17 00:00:00 2001 From: Paul Cockrell Date: Tue, 7 Apr 2020 09:18:35 +0100 Subject: [PATCH 1/6] Bump version for addition of README and Daisy character --- apps.json | 2 +- apps/marioclock/ChangeLog | 3 +- apps/marioclock/marioclock-app.js | 54 ++++++++++++++++++++----------- 3 files changed, 38 insertions(+), 21 deletions(-) diff --git a/apps.json b/apps.json index 2413febeb..92df7fe93 100644 --- a/apps.json +++ b/apps.json @@ -914,7 +914,7 @@ { "id": "marioclock", "name": "Mario Clock", "icon": "marioclock.png", - "version":"0.07", + "version":"0.08", "description": "Animated retro Mario clock, with Gameboy style 8-bit grey-scale graphics.", "tags": "clock,mario,retro", "type": "clock", diff --git a/apps/marioclock/ChangeLog b/apps/marioclock/ChangeLog index c16d02fc8..f1c332295 100644 --- a/apps/marioclock/ChangeLog +++ b/apps/marioclock/ChangeLog @@ -4,4 +4,5 @@ 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 0.06: Performance refactor, and enhanced graphics! -0.07: Swipe right to change between Mario and Toad characters, swipe left to toggle night mode \ No newline at end of file +0.07: Swipe right to change between Mario and Toad characters, swipe left to toggle night mode +0.08: Add Readme. Add Princes Daisy \ No newline at end of file diff --git a/apps/marioclock/marioclock-app.js b/apps/marioclock/marioclock-app.js index dabe7ad9e..fa424510e 100644 --- a/apps/marioclock/marioclock-app.js +++ b/apps/marioclock/marioclock-app.js @@ -27,6 +27,7 @@ const DARKEST = "#122d3e"; const NIGHT = "#001818"; // Character names +const DAISY = "daisy"; const TOAD = "toad"; const MARIO = "mario"; @@ -65,11 +66,18 @@ function genRanNum(min, max) { function switchCharacter() { const curChar = characterSprite.character; + let newChar; - if (curChar === MARIO) { - newChar = TOAD; - } else { - newChar = MARIO; + switch(curChar) { + case DAISY: + newChar = MARIO; + break; + case TOAD: + newChar = DAISY; + break; + case MARIO: + default: + newChar = TOAD; } characterSprite.character = newChar; @@ -193,6 +201,19 @@ function drawCoin() { drawCoinFrame(coinSprite.x, coinSprite.y); } +function drawDaisyFrame(idx, x, y) { + switch(idx) { + case 0: + const dFr1 = require("heatshrink").decompress(atob("h8UxH+AAsHAIgAI60HAIQOJBYIABDpMHAAwNNB4wOJB4gIEHgQBBBxYQCBwYLDDhIaEBxApEw4qDAgIOHDwiIEBwtcFIRWIUgWHw6TIAQXWrlcWZAqBDQIeBBxQaBDxIcCHIQ8JDAIAFWJLPHA==")); + g.drawImage(dFr1, x, y); + break; + case 1: + default: + const dFr2 = require("heatshrink").decompress(atob("h8UxH+AAsHAIgAI60HAIQOJBYIABDpMHAAwNNB4wOJB4gIEHgQBBBxYQCBwYLDDhIaEBxApEw4qDAgIOHDwiIEBwtcFIRWIUgQvBSZACCBwNcWZQcCAAIPIDgYACFw4YBDYIOCD4waEDYI+HaBQ=")); + g.drawImage(dFr2, x, y); + } +} + function drawMarioFrame(idx, x, y) { switch(idx) { case 0: @@ -200,10 +221,9 @@ function drawMarioFrame(idx, x, y) { g.drawImage(mFr1, x, y); break; case 1: + default: const mFr2 = require("heatshrink").decompress(atob("h8UxH+AAkHAAYKFBolcAAIPIBgYPDBpgfGFIY7EA4YcEBIPWAAYdDC4gLDAII5ECoYOFDogODFgoJCBwYZCAQYOFBAhAFFwZKGHQpMDw+HCQYEBSowOBBQIdCCgTOIFgiVHFwYCBUhA9FBwz8HAo73GACQA=")); // Mario frame 2 g.drawImage(mFr2, x, y); - break; - default: } } @@ -214,10 +234,9 @@ function drawToadFrame(idx, x, y) { g.drawImage(tFr1, x, y); break; case 1: + default: const tFr2 = require("heatshrink").decompress(atob("iEUxH+ACkHAAoNJrnWAAQRGg/WrgACB4QEBCAYOBB44QFB4QICAg4QBBAQbDEgwPCHpAGCGAQ9KAYQPKCYg/EJAoADAwaKFw4BEP4YQCBIIABB468EB4QADYIoQGDwQOGBYQrDb4wcGFxYLDMoYgHRYgwKABAMBA")); // Mario frame 2 g.drawImage(tFr2, x, y); - break; - default: } } @@ -251,10 +270,13 @@ function drawCharacter(date, character) { } switch(characterSprite.character) { - case(TOAD): + case DAISY: + drawDaisyFrame(characterSprite.frameIdx, characterSprite.x, characterSprite.y); + break; + case TOAD: drawToadFrame(characterSprite.frameIdx, characterSprite.x, characterSprite.y); break; - case(MARIO): + case MARIO: default: drawMarioFrame(characterSprite.frameIdx, characterSprite.x, characterSprite.y); } @@ -362,13 +384,7 @@ function init() { Bangle.showLauncher(); }, BTN2, {repeat:false,edge:"falling"}); - Bangle.on('lcdPower', (on) => { - if (on) { - startTimers(); - } else { - clearTimers(); - } - }); + Bangle.on('lcdPower', (on) => on ? startTimers() : clearTimers()); Bangle.on('faceUp', (up) => { if (up && !Bangle.isLCDOn()) { @@ -382,11 +398,11 @@ function init() { switch(sDir) { // Swipe right (1) - change character (on a loop) - case(1): + case 1: switchCharacter(); break; // Swipe left (-1) - change day/night mode (on a loop) - case(-1): + case -1: default: toggleNightMode(); } From 51e0adbc78505cdbaf02122ebf67f1f22c863ffa Mon Sep 17 00:00:00 2001 From: Paul Cockrell Date: Tue, 7 Apr 2020 15:15:11 +0100 Subject: [PATCH 2/6] Add Daisy. Change Date pannel to info-panel with BAT, TEMP, DATE data --- apps/marioclock/ChangeLog | 2 +- apps/marioclock/README.md | 3 +- apps/marioclock/marioclock-app.js | 93 ++++++++++++++++++++++++++++--- 3 files changed, 89 insertions(+), 9 deletions(-) diff --git a/apps/marioclock/ChangeLog b/apps/marioclock/ChangeLog index f1c332295..fa6fdc9ed 100644 --- a/apps/marioclock/ChangeLog +++ b/apps/marioclock/ChangeLog @@ -5,4 +5,4 @@ 0.05: use 12/24 hour clock from settings 0.06: Performance refactor, and enhanced graphics! 0.07: Swipe right to change between Mario and Toad characters, swipe left to toggle night mode -0.08: Add Readme. Add Princes Daisy \ No newline at end of file +0.08: Add Readme. Add Princes Daisy. Update date panel to be info panel toggling between Date, Battery and Temperature \ No newline at end of file diff --git a/apps/marioclock/README.md b/apps/marioclock/README.md index a74c863f8..4eb78b37e 100644 --- a/apps/marioclock/README.md +++ b/apps/marioclock/README.md @@ -7,12 +7,13 @@ Enjoy watching Mario, or one of the other game characters run through a level wh ## Features -* Multiple characters - swipe the screen right to change the character +* Multiple characters - swipe the screen right to change the character between `Mario`, `Toad`, and `Daisy` * Night and Day modes - swipe left to toggle mode * Smooth animation * Awesome 8-bit style grey-scale graphics * Mario jumps to change the time, every minute * You can make Mario jump by pressing the top button (Button 1) on the watch +* Toggle the info pannel bettween `Date`, `Battery level`, and `Temperature` by pressing the bottom button (Button 3). ## Requests diff --git a/apps/marioclock/marioclock-app.js b/apps/marioclock/marioclock-app.js index fa424510e..b167aa6b1 100644 --- a/apps/marioclock/marioclock-app.js +++ b/apps/marioclock/marioclock-app.js @@ -55,10 +55,18 @@ const pyramidSprite = { }; const ONE_SECOND = 1000; +const DATE_MODE = "date"; +const BATT_MODE = "batt"; +const TEMP_MODE = "temp"; let timer = 0; let backgroundArr = []; let nightMode = false; +let infoMode = DATE_MODE; + +// Used to stop values flapping when displayed on screen +let lastBatt = 0; +let lastTemp = 0; function genRanNum(min, max) { return Math.floor(Math.random() * (max - min + 1) + min); @@ -303,13 +311,78 @@ function drawTime(date) { g.drawString(mins, 47, 29); } -function drawDate(date) { - g.setFont("6x8"); - g.setColor(LIGHTEST); +function buildDateStr(date) { let dateStr = locale.date(date, true); dateStr = dateStr.replace(date.getFullYear(), "").trim().replace(/\/$/i,""); dateStr = locale.dow(date, true) + " " + dateStr; - g.drawString(dateStr, (W - g.stringWidth(dateStr))/2, 1); + + return dateStr; +} + +function buildBatStr() { + let batt = parseInt(E.getBattery()); + const battDiff = Math.abs(lastBatt - batt); + + // Suppress flapping values + // Only update batt if it moves greater than +-2 + if (battDiff > 2) { + lastBatt = batt; + } else { + batt = lastBatt; + } + + const battStr = `Bat: ${batt}%`; + + return battStr; +} + +function buildTempStr() { + let temp = parseInt(E.getTemperature()); + const tempDiff = Math.abs(lastTemp - temp); + + // Suppress flapping values + // Only update temp if it moves greater than +-2 + if (tempDiff > 2) { + lastTemp = temp; + } else { + temp = lastTemp; + } + const tempStr = `Temp: ${temp}'c`; + + return tempStr; +} + +function drawInfo(date) { + let str = ""; + switch(infoMode) { + case TEMP_MODE: + str = buildTempStr(); + break; + case BATT_MODE: + str = buildBatStr(); + break; + case DATE_MODE: + default: + str = buildDateStr(date); + } + + g.setFont("6x8"); + g.setColor(LIGHTEST); + g.drawString(str, (W - g.stringWidth(str))/2, 1); +} + +function changeInfoMode() { + switch(infoMode) { + case BATT_MODE: + infoMode = TEMP_MODE; + break; + case TEMP_MODE: + infoMode = DATE_MODE; + break; + case DATE_MODE: + default: + infoMode = BATT_MODE; + } } function redraw() { @@ -324,7 +397,7 @@ function redraw() { drawPyramid(); drawTrees(); drawTime(date); - drawDate(date); + drawInfo(date); drawCharacter(date); drawCoin(); @@ -377,12 +450,18 @@ function init() { setWatch(() => { if (intervalRef && !characterSprite.isJumping) characterSprite.isJumping = true; resetDisplayTimeout(); - }, BTN1, {repeat:true}); + }, BTN1, {repeat: true}); + // Close watch and load launcher app setWatch(() => { Bangle.setLCDMode(); Bangle.showLauncher(); - }, BTN2, {repeat:false,edge:"falling"}); + }, BTN2, {repeat: false, edge: "falling"}); + + // Change info mode + setWatch(() => { + changeInfoMode(); + }, BTN3, {repeat: true}); Bangle.on('lcdPower', (on) => on ? startTimers() : clearTimers()); From b5a9b9306a02c3110bc40ae5b0ed1774d15c537b Mon Sep 17 00:00:00 2001 From: Paul Cockrell Date: Tue, 7 Apr 2020 15:16:31 +0100 Subject: [PATCH 3/6] Update README --- apps/marioclock/ChangeLog | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/marioclock/ChangeLog b/apps/marioclock/ChangeLog index fa6fdc9ed..c95ce3d0d 100644 --- a/apps/marioclock/ChangeLog +++ b/apps/marioclock/ChangeLog @@ -5,4 +5,4 @@ 0.05: use 12/24 hour clock from settings 0.06: Performance refactor, and enhanced graphics! 0.07: Swipe right to change between Mario and Toad characters, swipe left to toggle night mode -0.08: Add Readme. Add Princes Daisy. Update date panel to be info panel toggling between Date, Battery and Temperature \ No newline at end of file +0.08: Update date panel to be info panel toggling between Date, Battery and Temperature. Add Princes Daisy. From b9361c55fe7a193026c057077c80294bf57c3dcf Mon Sep 17 00:00:00 2001 From: Paul Cockrell Date: Tue, 7 Apr 2020 16:41:04 +0100 Subject: [PATCH 4/6] Switch the action buttons around, so the button is next to the part of the screen it affects --- apps/marioclock/README.md | 4 ++-- apps/marioclock/marioclock-app.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/apps/marioclock/README.md b/apps/marioclock/README.md index 4eb78b37e..8b859e031 100644 --- a/apps/marioclock/README.md +++ b/apps/marioclock/README.md @@ -12,8 +12,8 @@ Enjoy watching Mario, or one of the other game characters run through a level wh * Smooth animation * Awesome 8-bit style grey-scale graphics * Mario jumps to change the time, every minute -* You can make Mario jump by pressing the top button (Button 1) on the watch -* Toggle the info pannel bettween `Date`, `Battery level`, and `Temperature` by pressing the bottom button (Button 3). +* You can make Mario jump by pressing the bottom button (Button 3) on the watch +* Toggle the info pannel bettween `Date`, `Battery level`, and `Temperature` by pressing the top button (Button 1). ## Requests diff --git a/apps/marioclock/marioclock-app.js b/apps/marioclock/marioclock-app.js index b167aa6b1..e1937fbe6 100644 --- a/apps/marioclock/marioclock-app.js +++ b/apps/marioclock/marioclock-app.js @@ -450,7 +450,7 @@ function init() { setWatch(() => { if (intervalRef && !characterSprite.isJumping) characterSprite.isJumping = true; resetDisplayTimeout(); - }, BTN1, {repeat: true}); + }, BTN3, {repeat: true}); // Close watch and load launcher app setWatch(() => { @@ -461,7 +461,7 @@ function init() { // Change info mode setWatch(() => { changeInfoMode(); - }, BTN3, {repeat: true}); + }, BTN1, {repeat: true}); Bangle.on('lcdPower', (on) => on ? startTimers() : clearTimers()); From 1bea7a450e1fd8986c6f5ca356aac2272e1e552f Mon Sep 17 00:00:00 2001 From: Richard de Boer Date: Tue, 7 Apr 2020 22:08:29 +0200 Subject: [PATCH 5/6] gbridge: don't turn on screen at start of every song Do draw the notification, so you can still look up what is playing. --- apps.json | 2 +- apps/gbridge/ChangeLog | 1 + apps/gbridge/widget.js | 8 +++++--- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/apps.json b/apps.json index 2413febeb..3c6ab41ca 100644 --- a/apps.json +++ b/apps.json @@ -92,7 +92,7 @@ { "id": "gbridge", "name": "Gadgetbridge", "icon": "app.png", - "version":"0.07", + "version":"0.08", "description": "The default notification handler for Gadgetbridge notifications from Android", "tags": "tool,system,android,widget", "type":"widget", diff --git a/apps/gbridge/ChangeLog b/apps/gbridge/ChangeLog index e02ef176d..d1f9c6a62 100644 --- a/apps/gbridge/ChangeLog +++ b/apps/gbridge/ChangeLog @@ -6,3 +6,4 @@ Optimize animation, limit title length 0.06: Gadgetbridge App 'Connected' state is no longer toggleable 0.07: Move configuration to settings menu +0.08: Don't turn on LCD at start of every song diff --git a/apps/gbridge/widget.js b/apps/gbridge/widget.js index 3f9c7053f..fa44757fc 100644 --- a/apps/gbridge/widget.js +++ b/apps/gbridge/widget.js @@ -16,7 +16,8 @@ Bluetooth.println(JSON.stringify(message)); } - function showNotification(size, render) { + function showNotification(size, render, turnOn) { + if (turnOn === undefined) turnOn = true var oldMode = Bangle.getLCDMode(); Bangle.setLCDMode("direct"); @@ -31,7 +32,7 @@ g.fillRect(238, 240, 239, 319); g.fillRect(2, 318, 238, 319); - Bangle.setLCDPower(1); // light up + if (turnOn) Bangle.setLCDPower(1); // light up Bangle.setLCDMode(oldMode); // clears cliprect function anim() { @@ -97,6 +98,7 @@ } function handleMusicStateUpdate(event) { + const changed = state.music === event.state state.music = event.state if (state.music == "play") { @@ -113,7 +115,7 @@ g.setFont("6x8", 1); g.setColor("#ffffff"); g.drawString(state.musicInfo.track, x, y + 22); - }); + }, changed); } if (state.music == "pause") { From 50e1c3096d4dabdc25aa9897ad12a65822a3f227 Mon Sep 17 00:00:00 2001 From: Paul Cockrell Date: Wed, 8 Apr 2020 03:13:14 +0100 Subject: [PATCH 6/6] Center characters on the screen --- 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 e1937fbe6..81f5616b9 100644 --- a/apps/marioclock/marioclock-app.js +++ b/apps/marioclock/marioclock-app.js @@ -33,7 +33,7 @@ const MARIO = "mario"; const characterSprite = { frameIdx: 0, - x: 35, + x: 33, y: 55, jumpCounter: 0, jumpIncrement: Math.PI / 6,