11-02-2018 05:43
11-02-2018 05:43
Hi there,
I am experiencing a reoccurring issue where the milage displays low (between 1-4 miles) when the user is over 10 miles. Milage works perfectly on ionic, (always displaying as miles how I would like it).
Also, the battery life on this clock face drains very quickly. Is it possible it is updating while idle or repeating a line of code. Any idea what is might be?
Thank you so much. I appreciate your help.
Answered! Go to the Best Answer.
11-02-2018 17:58
11-02-2018 17:58
I can't see anything obvious which would cause battery drain. Have you tried without the hrm module? Perhaps the setTimeout()/clearTimeout() isn't behaving correctly.
Here's what I've been using for distance:
import userActivity from "user-activity";
import { units } from "user-settings";
let distance = userActivity.today.adjusted.distance || 0; let tmp = convertMetersToMilesOrKilometers(distance, "kilometers", "miles");
console.log(`Distance: ${tmp.value}${tmp.units}`); // Convert meters into the user preference for kilometers or miles. /** @description Converts a number in meters into either miles or kilometers. * Returns an object containing a value and units. * @param {number} meters The amount of meters to convert. * @param {string} unitK The units to return if the value is kilometers. * @param {string} unitM The units to return if the value is miles. * @return {object} */ function convertMetersToMilesOrKilometers(meters, unitK, unitM) { let val = (meters || 0) / 1000; let u = unitK; if (units.distance === "us") { val *= 0.621371; u = unitM; } return { value: val.toFixed(2), units: u }; }
You could also compare what the local distance returns:
userActivity.today.local.distance
Does the Fitbit mobile app display the correct distance?
11-02-2018 05:44
11-02-2018 17:58
11-02-2018 17:58
I can't see anything obvious which would cause battery drain. Have you tried without the hrm module? Perhaps the setTimeout()/clearTimeout() isn't behaving correctly.
Here's what I've been using for distance:
import userActivity from "user-activity";
import { units } from "user-settings";
let distance = userActivity.today.adjusted.distance || 0; let tmp = convertMetersToMilesOrKilometers(distance, "kilometers", "miles");
console.log(`Distance: ${tmp.value}${tmp.units}`); // Convert meters into the user preference for kilometers or miles. /** @description Converts a number in meters into either miles or kilometers. * Returns an object containing a value and units. * @param {number} meters The amount of meters to convert. * @param {string} unitK The units to return if the value is kilometers. * @param {string} unitM The units to return if the value is miles. * @return {object} */ function convertMetersToMilesOrKilometers(meters, unitK, unitM) { let val = (meters || 0) / 1000; let u = unitK; if (units.distance === "us") { val *= 0.621371; u = unitM; } return { value: val.toFixed(2), units: u }; }
You could also compare what the local distance returns:
userActivity.today.local.distance
Does the Fitbit mobile app display the correct distance?
11-04-2018 06:15
11-04-2018 06:15
Thank you Jon. The Versa distance corrects its self once the mobile application is opened. Any reason why it may not be displaying correctly until the mobile application is opened? I have an Ionic too which always has the correct distance on the display mobile application opened or not.