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

How would I refresh my clockface

ANSWERED

I made a Watch Face with a time (Example:09:30), a battery level(Example:100%), and a date (Example: APR 25, SAT). Let's say the battery level is 100%. It goes down one, but the Clockface doesn't say 99% it says 100% still... Or today it may say APR 25, SAT and the next day it will still say APR 25, SAT.

 

My question: Is there a way for the Clock Face to refresh every few seconds.

I need it to refresh so the date and the battery level is accurate.

(At the time of posting this the date is APR 25, SAT)This morning it still said APR 24, FRI, I had to change to a different Clock Face then change back to mine, and then it showed the correct date and battery level.

 

 

Here is my index.js:

 

import clock from "clock"; 
import document from "document"; 
import { preferences } from "user-settings";
import * as util from "../common/utils"; 
import { battery } from "power"; 
import userActivity from "user-activity";
import { goals, today } from "user-activity";

 


// The real scripts


const myLabel = document.getElementById("myLabel");
const batteryHandle = document.getElementById("batteryLabel");
const txtDate = document.getElementById("date");

 


let date = new Date();
let month = nameOfMonth(date.getMonth());
let dayofweek = nameOfDayweek(date.getDay());
let day = date.getDate();
txtDate.text = `${month} ${day}, ${dayofweek}`;

clock.granularity = "minutes";

 



clock.ontick = (evt) => {
let today = evt.date;
let hours = today.getHours();
if (preferences.clockDisplay === "12h") {
//12 hour format
hours = hours % 12 || 12;
} else {
// 24h format
hours = util.zeroPad(hours);
}
let mins = util.zeroPad(today.getMinutes());
let today = new Date();
myLabel.text = `${hours}:${mins}`;
}

function nameOfMonth(i) {
switch(i) {
case 0:
return "JAN";
case 1:
return "FEB";
case 2:
return "MAR";
case 3:
return "APR";
case 4:
return "MAY";
case 5:
return "JUN";
case 6:
return "JUL";
case 7:
return "AUG";
case 8:
return "SEP";
case 9:
return "OCT";
case 10:
return "NOV";
case 11:
return "DEC";
}
}

function nameOfDayweek(i) {
switch(i) {
case 0:
return "SUN";
case 1:
return "MON";
case 2:
return "TUE";
case 3:
return "WED";
case 4:
return "THUR";
case 5:
return "FRI";
case 6:
return "SAT";
case 7:
}
}
// Battery Measurement
let batteryValue = battery.chargeLevel;

// Assignment value battery
batteryHandle.text = ` ${batteryValue} %`;

 

Best Answer
0 Votes
1 BEST ANSWER

Accepted Solutions
Best Answer
0 Votes
2 REPLIES 2

If you're familiar with the Fitbit OS Sim, what I need is like an "auto-launch."

Best Answer
0 Votes

FOUND It out

Best Answer
0 Votes