From 8f030bd3b0ed3a0679d1acf623a214782697b6c2 Mon Sep 17 00:00:00 2001 From: smirko-dev Date: Wed, 9 Mar 2022 08:49:45 +0100 Subject: [PATCH 1/5] Refresh weather with display on --- app/index.js | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/app/index.js b/app/index.js index e20a91c..eb7f5e5 100644 --- a/app/index.js +++ b/app/index.js @@ -33,8 +33,8 @@ const INVISIBLE = 0.0; const VISIBLE = 0.8; // Current weather status -let WeatherIcon = 'thermometer.png'; -let WeatherValue = 'N/A'; +weatherImage.image = 'thermometer.png'; +weatherLabel.text = 'N/A'; // Permissions const CalendarPermissionGranted = appbit.permissions.granted('access_calendar'); @@ -79,7 +79,9 @@ function applySettings(activity, color, info) { weatherImage.style.opacity = INVISIBLE; weatherLabel.style.opacity = INVISIBLE; batteryImage.style.opacity = VISIBLE; - renderBattery(); + if (device.modelId === 27 ) { + batteryLabel.style.opacity = VISIBLE; + } } else if (info === 'weather') { batteryImage.style.opacity = INVISIBLE; @@ -151,12 +153,18 @@ appointment.initialize(() => { // Weather callback weather.initialize(data => { - //DEBUG console.log(`Weather: ${data.icon} - ${data.temperature} ${data.unit} in ${data.location}`); - data = units.temperature === "F" ? toFahrenheit(data) : data; - WeatherValue = `${data.temperature}\u00B0${units.temperature}`; - weatherLabel.text = WeatherValue; - WeatherIcon = `${data.icon}`; - weatherImage.image = WeatherIcon; + renderWeather(); +}); + +// Update weather +function renderWeather() { + let data = weather.current(); + if (data) { + //DEBUG console.log(`Weather: ${data.icon} - ${data.temperature} ${data.unit} in ${data.location}`); + data = units.temperature === "F" ? toFahrenheit(data) : data; + weatherLabel.text = `${data.temperature}\u00B0${units.temperature}`; + weatherImage.image = `${data.icon}`; + } }); // Display callback @@ -165,6 +173,7 @@ display.addEventListener("change", () => { // Update appointment and battery on display on renderAppointment(); renderBattery(); + renderWeather(); } else { // Stop updating activity @@ -197,7 +206,7 @@ function renderAppointment() { // Hide activity function hideActivity() { activityIcon.style.opacity = INVISIBLE; - activityLabel.style.opacity = INVISIBLE; + activityLabelLabel.style.opacity = INVISIBLE; appointmentsLabel.style.opacity = VISIBLE; } @@ -229,12 +238,6 @@ function updateActivity() { function renderBattery() { // Update the battery element every time when battery changed batteryLabel.text = Math.floor(battery.chargeLevel) + "%"; - if (device.modelId != 27 ) { - batteryLabel.style.opacity = INVISIBLE; - } - else { - batteryLabel.style.opacity = VISIBLE; - } // Update battery icon const level = Math.floor(battery.chargeLevel / 10) * 10; From 442f9dda3b8e07576378ff48e3b9d0557c3d25a8 Mon Sep 17 00:00:00 2001 From: smirko-dev Date: Wed, 9 Mar 2022 08:56:31 +0100 Subject: [PATCH 2/5] Fixed wrong changes --- app/index.js | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/app/index.js b/app/index.js index eb7f5e5..80d0b12 100644 --- a/app/index.js +++ b/app/index.js @@ -79,15 +79,14 @@ function applySettings(activity, color, info) { weatherImage.style.opacity = INVISIBLE; weatherLabel.style.opacity = INVISIBLE; batteryImage.style.opacity = VISIBLE; - if (device.modelId === 27 ) { - batteryLabel.style.opacity = VISIBLE; - } + renderBattery(); } else if (info === 'weather') { batteryImage.style.opacity = INVISIBLE; batteryLabel.style.opacity = INVISIBLE; weatherImage.style.opacity = VISIBLE; weatherLabel.style.opacity = VISIBLE; + renderWeather(); } else { batteryImage.style.opacity = INVISIBLE; @@ -170,7 +169,7 @@ function renderWeather() { // Display callback display.addEventListener("change", () => { if (display.on) { - // Update appointment and battery on display on + // Update content on display on renderAppointment(); renderBattery(); renderWeather(); @@ -206,7 +205,7 @@ function renderAppointment() { // Hide activity function hideActivity() { activityIcon.style.opacity = INVISIBLE; - activityLabelLabel.style.opacity = INVISIBLE; + activityLabel.style.opacity = INVISIBLE; appointmentsLabel.style.opacity = VISIBLE; } @@ -238,6 +237,12 @@ function updateActivity() { function renderBattery() { // Update the battery element every time when battery changed batteryLabel.text = Math.floor(battery.chargeLevel) + "%"; + if (device.modelId != 27) { + batteryLabel.style.opacity = INVISIBLE; + } + else { + batteryLabel.style.opacity = VISIBLE; + } // Update battery icon const level = Math.floor(battery.chargeLevel / 10) * 10; From 6b5235019c8a68e35fd704c2a4c6b022cc834a59 Mon Sep 17 00:00:00 2001 From: smirko-dev Date: Wed, 9 Mar 2022 09:00:04 +0100 Subject: [PATCH 3/5] Fixed build --- app/index.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/index.js b/app/index.js index 80d0b12..15c8f99 100644 --- a/app/index.js +++ b/app/index.js @@ -164,7 +164,7 @@ function renderWeather() { weatherLabel.text = `${data.temperature}\u00B0${units.temperature}`; weatherImage.image = `${data.icon}`; } -}); +} // Display callback display.addEventListener("change", () => { @@ -238,10 +238,10 @@ function renderBattery() { // Update the battery element every time when battery changed batteryLabel.text = Math.floor(battery.chargeLevel) + "%"; if (device.modelId != 27) { - batteryLabel.style.opacity = INVISIBLE; + batteryLabel.style.opacity = INVISIBLE; } else { - batteryLabel.style.opacity = VISIBLE; + batteryLabel.style.opacity = VISIBLE; } // Update battery icon From 9c71fb7c0ea53d2a29841b02884b7923103dbf39 Mon Sep 17 00:00:00 2001 From: smirko-dev <64351017+smirko-dev@users.noreply.github.com> Date: Wed, 9 Mar 2022 14:59:44 +0100 Subject: [PATCH 4/5] Update index.js --- app/index.js | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/app/index.js b/app/index.js index 15c8f99..15cea17 100644 --- a/app/index.js +++ b/app/index.js @@ -79,14 +79,14 @@ function applySettings(activity, color, info) { weatherImage.style.opacity = INVISIBLE; weatherLabel.style.opacity = INVISIBLE; batteryImage.style.opacity = VISIBLE; - renderBattery(); + updateBattery(); } else if (info === 'weather') { batteryImage.style.opacity = INVISIBLE; batteryLabel.style.opacity = INVISIBLE; weatherImage.style.opacity = VISIBLE; weatherLabel.style.opacity = VISIBLE; - renderWeather(); + updateWeather(); } else { batteryImage.style.opacity = INVISIBLE; @@ -128,7 +128,7 @@ messaging.peerSocket.onmessage = (evt) => { else if (evt.data.key === "info") { applySettings(settings.activity, settings.color, evt.data.value); } - renderAppointment(); + updateAppointment(); } // Clock callback @@ -137,26 +137,26 @@ clock.initialize("minutes", data => { minuteLabel.text = data.minutes; dateLabel.text = data.date; - renderAppointment(); + updateAppointment(); }); // Battery change callback battery.onchange = (evt) => { - renderBattery(); + updateBattery(); } // Appointment callback appointment.initialize(() => { - renderAppointment(); + updateAppointment(); }); // Weather callback weather.initialize(data => { - renderWeather(); + updateWeather(); }); // Update weather -function renderWeather() { +function updateWeather() { let data = weather.current(); if (data) { //DEBUG console.log(`Weather: ${data.icon} - ${data.temperature} ${data.unit} in ${data.location}`); @@ -170,9 +170,9 @@ function renderWeather() { display.addEventListener("change", () => { if (display.on) { // Update content on display on - renderAppointment(); - renderBattery(); - renderWeather(); + updateAppointment(); + updateBattery(); + updateWeather(); } else { // Stop updating activity @@ -187,7 +187,7 @@ appointmentsLabel.addEventListener("mousedown", () => { }) // Update appointment -function renderAppointment() { +function updateAppointment() { let event = appointment.next(); if (event) { const date = fromEpochSec(event.startDate); @@ -234,7 +234,7 @@ function updateActivity() { } // Update battery -function renderBattery() { +function updateBattery() { // Update the battery element every time when battery changed batteryLabel.text = Math.floor(battery.chargeLevel) + "%"; if (device.modelId != 27) { @@ -254,4 +254,4 @@ function renderBattery() { } } -renderBattery(); +updateBattery(); From c1d9d50245aae0009509884d7fc2c52aa9ef1d79 Mon Sep 17 00:00:00 2001 From: smirko-dev Date: Wed, 9 Mar 2022 16:57:15 +0100 Subject: [PATCH 5/5] Updated version --- CHANGELOG.md | 5 +++++ README.md | 2 +- package.sdk4.json | 2 +- package.sdk6.json | 2 +- 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d7d3386..c34206a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## Version 1.7.1 + +### Changed +- Fixed update of weather info + ## Version 1.7.0 ### Changed diff --git a/README.md b/README.md index 1700d6c..52eda5a 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ [![](https://img.shields.io/badge/Fitbit%20App%20Gallery-%2300B0B9?style=flat&logo=fitbit&logoColor=white)](https://gallery.fitbit.com/details/ae441b73-2660-407f-b796-a98d1d0583a0) ![languages](https://img.shields.io/badge/languages-JavaScript%20|%20CSS-blue) ![platform](https://img.shields.io/badge/platforms-Ionic%20|%20Versa%20|%20Versa%202%20|%20Versa%20Lite%20|%20Versa%203%20|%20Sense-silver) -[![version](https://img.shields.io/badge/version-%201.7.0-blue)](https://github.com/smirko-dev/fitbit-clockface/blob/master/CHANGELOG.md) +[![version](https://img.shields.io/badge/version-%201.7.1-blue)](https://github.com/smirko-dev/fitbit-clockface/blob/master/CHANGELOG.md) [![](https://img.shields.io/badge/license-MIT-blue)](https://github.com/smirko-dev/fitbit-clockface/blob/master/LICENSE) [![FitbitBuild Actions Status](https://github.com/smirko-dev/fitbit-clockface/workflows/FitbitBuild/badge.svg)](https://github.com/smirko-dev/fitbit-clockface/actions) [![CodeQL Actions Status](https://github.com/smirko-dev/fitbit-clockface/workflows/CodeQL/badge.svg)](https://github.com/smirko-dev/fitbit-clockface/actions) diff --git a/package.sdk4.json b/package.sdk4.json index 6d56392..c48f75b 100644 --- a/package.sdk4.json +++ b/package.sdk4.json @@ -1,6 +1,6 @@ { "name": "compactclock", - "version": "1.7.0", + "version": "1.7.1", "license": "MIT", "devDependencies": { "@fitbit/sdk": "~4.3.0", diff --git a/package.sdk6.json b/package.sdk6.json index 38088c6..05525cf 100644 --- a/package.sdk6.json +++ b/package.sdk6.json @@ -1,6 +1,6 @@ { "name": "compactclock", - "version": "1.7.0", + "version": "1.7.1", "license": "MIT", "devDependencies": { "@fitbit/sdk": "~5.0.0",