03-28-2019 06:33
Fitbit Product Experts Alumni are retired members of the Fitbit Product Expert Program. Learn more
03-28-2019 06:33
I'm developing a clockface where I pass a property to the index.gui from index.js.
If I pass a numeric value I have no problem, however if I'm attempting to pass a % value the SDK gives me an error as it expect a numeric value while it is a string.
An example of such code is
rectHandle.y = startingPoint;
if startingPoint is numeric no problem, if it's for example "20%" it gives me the following error
Unhandled exception: TypeError: Cannot set property to '20%': Unexpected type. Expected a Number
Thanks!
Answered! Go to the Best Answer.
Best Answer03-28-2019 11:44
Fitbit Developers oversee the SDK and API forums. We're here to answer questions about Fitbit developer tools, assist with projects, and make sure your voice is heard by the development team.
03-28-2019 11:44
Sorry, the percentage values aren't currently supported, but you can calculate the pixel value from the device screen dimensions.
import { me as device } from "device";
if (!device.screen) device.screen = { width: 348, height: 250 };
let percent = 40;
let pixels = percent / 100 * device.screen.width;
myVar.x = pixels;
03-28-2019 11:44
Fitbit Developers oversee the SDK and API forums. We're here to answer questions about Fitbit developer tools, assist with projects, and make sure your voice is heard by the development team.
03-28-2019 11:44
Sorry, the percentage values aren't currently supported, but you can calculate the pixel value from the device screen dimensions.
import { me as device } from "device";
if (!device.screen) device.screen = { width: 348, height: 250 };
let percent = 40;
let pixels = percent / 100 * device.screen.width;
myVar.x = pixels;