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/app/index.js b/app/index.js index e20a91c..15cea17 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,13 +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; + updateWeather(); } else { batteryImage.style.opacity = INVISIBLE; @@ -127,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 @@ -136,35 +137,42 @@ 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 => { - //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; + updateWeather(); }); +// Update weather +function updateWeather() { + 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 display.addEventListener("change", () => { if (display.on) { - // Update appointment and battery on display on - renderAppointment(); - renderBattery(); + // Update content on display on + updateAppointment(); + updateBattery(); + updateWeather(); } else { // Stop updating activity @@ -179,7 +187,7 @@ appointmentsLabel.addEventListener("mousedown", () => { }) // Update appointment -function renderAppointment() { +function updateAppointment() { let event = appointment.next(); if (event) { const date = fromEpochSec(event.startDate); @@ -226,10 +234,10 @@ 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 ) { + if (device.modelId != 27) { batteryLabel.style.opacity = INVISIBLE; } else { @@ -246,4 +254,4 @@ function renderBattery() { } } -renderBattery(); +updateBattery(); 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",