Cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Countdown watch face?

Would it be possible to create a countdown watch face? ”100 years” minus ”the users current age” ticking down.

 

And if so can someone clever help me with the code?

 

Best Answer
0 Votes
19 REPLIES 19

Sould count down to the day that they turn 100 (or any other date)? I think this would be a better app than watch face; but I think it is easy to do. 

Best Answer
0 Votes

Exactly – a countdown to the day they turn 100. I kind of like the idea of having it as a clock face and not an app – a constant reminder of life passing instead of moving forward. Any ideas on where I should start? I’m a designer, but a programming noob.

Best Answer
0 Votes

If you can wait until this evening, I can put the start of a project up on github that you/we can work off of.... Otherwise start the basic clock project on studio.fitbit.com

Best Answer
0 Votes

Here is a basic version of the main code:

import clock from "clock";
import document from "document";
import { preferences } from "user-settings";

import * as util from "../common/utils";

// Update the clock every second
clock.granularity = "seconds";

// Get a handle on the <text> element
const myLabel = document.getElementById("myLabel");

//This is the target
//This could be entered through the settings
// or by using the web API to poll the user DOB and adding 100 to the years. let end = new Date("2082-12-03"); // Update the <text> element every tick with the current time clock.ontick = (evt) => { //Now Date/time let today = evt.date; //Difference in miliseconds let diff = Math.abs(end - today); let years = parseInt(diff / 31536000000); diff -= years * 31536000000; let days = parseInt(diff / 86400000); diff -= days * 86400000 let hours = parseInt(diff / 3600000) diff -= hours * 3600000 let mins = parseInt(diff / 60000) diff -= mins * 60000 let secs = parseInt(diff / 1000) diff -= secs * 1000 console.log() myLabel.text = util.zeroPad(years) + ":" + util.zeroPad(days) + ":" + util.zeroPad(hours) + ":" + util.zeroPad(mins) + ":" + util.zeroPad(secs); }

Let me know if you want to know more, work together, etc.

 

Best Answer

CountDownTime-screenshot.png

Best Answer
0 Votes

Wow! I’m speechless – magic happens when I sleep. I’ll get back to you ...

 

Thanks! 

Best Answer
0 Votes

@Cmspooner

Can I ask what is the purpose of parseInt? 

 

Thanks

Best Answer
0 Votes
It truncates (cuts off, rather than rounds) the number to an integer. I
want just the whole number part of the division, then I remove it and take
the next biggest chunk.
Best Answer
0 Votes

Thanks again! You kickstarted me into actually getting somewhere with the idea – I’ll keep playing with the clock face during the weekend. 

 

So far I’ve mono spaced the digits and I’m toying with animations ... I’ll keep you posted. 

Best Answer
0 Votes

Good to hear. Feel free to message me if you have any questions. If you don't mind; I might work on an app version that does arbitrary events.

Best Answer
0 Votes

Looking forward to see your app.

Best Answer
0 Votes
@hygglobert wrote:

Looking forward to see your app.


any progress has been made?

 

Best Answer
0 Votes

@Cmspooner

I'm using your code from this post in a Christmas countdown app I'm working on. I noticed that it is using UTC time. Is there a quick way to make it use the correct time for the user's timezone? For example it's running 8 hours ahead of my time(PST). Might be a simple fix, I'm not very savvy with writing code. Thanks for the help. 

Ionic, retired Blaze.
Best Answer
0 Votes

It seems that you will have to use the companion to do this:
https://community.fitbit.com/t5/SDK-Development/Force-companion-to-pass-info/m-p/3010132#M6532).%C2%...

 

I can see about writing an example to do this tonight maybe.

Best Answer

@Cmspooner

Thank you, any help is appreciated. 

I don't know much about coding but I learn well from examples, trial/error. 

Ionic, retired Blaze.
Best Answer
0 Votes

Hi, wondering how everything turned out with this code. I have wanted to build the same function as well. Was it successful? Can a newbie successfully implement it?

Best Answer
0 Votes

Hi @JV1019 - since Fitbit discontinued Fitbit Studio setting up a working environment on a PC can be a project in itself, not to mention it may disrupt the functioning of the PC.

It also depends on your level of programming expertise.

Author | ch, passion for improvement.

Best Answer
0 Votes

Pretty easy if I remember correctly – it has been a few years and my fitbit died long before me. 

Best Answer
0 Votes
That’s good to know. Glad that you were able to implement it! Also glad that you aren’t taking life for granted 😉

Sent from my iPhone
Best Answer
0 Votes