11-28-2019 10:30
11-28-2019 10:30
Hi all 😁.
I wonder if somebody could help me, please 😅
I am working on a code based on the open source "Kearsage time for fitbit": (https://github.com/cmspooner/Kearsarge-Time-for-Fitbit-Ionic/blob/master/app/index.js) and, I can not get the alarm to vibrate when the screen is off. I have tried the function setTimeout and It do not seems be working.
I have not done changes in the function wich the alarm vibrates (remaining is the amount of minutes resting for complete a period of time):
function updatePeriodData() {
...
...
if (remaining <= 2)
{
timeRemainingLabel.style.fill = 'fb-red';
if (!didVib){
vibration.start("ring");
didVib = true;
}
else if (remaining > 2 && didVib){
didVib = false;
timeRemainingLabel.style.fill = 'silver';
} else {
timeRemainingLabel.style.fill = 'silver';
}
...
...
}
But I have changed the way of call the functions, I insert "the main" in a function, for example:
function eventHandle() {
background.onclick = function(evt) {
console.log("Click");
console.log("JS memory: " + memory.js.used + "/" + memory.js.total);
...
...
if (inSched){
weatherView.style.display = "none";
updatePeriodData();
periodView.style.display = "inline";
}
...
clock.ontick = () => updateClock();
updateClock();
...
...
} //end function
And the "main" is:
setTimeout(eventHandle, 5000); that is my only line of code on the body.
If you need more detailed information, I would be glade of helping.
Bye!!!
Thanks!!!!!
11-28-2019 11:31
11-28-2019 11:31
I didn't study closely, but did you want setInterval rather than setTimeout?
The only thing that won't happen when display is off is onclick.
11-28-2019 12:20
11-28-2019 12:20
Thanks for your response, let me check, I just hae tried with setTimeout. Thanks!
11-28-2019 12:26
11-28-2019 12:26
I have only tried**
11-28-2019 12:54
11-28-2019 12:54
Hi, sorry.
I have tried both functions now, and setInterval do not fire the alarm.
Is there any other function I can use for activate an alarm at a certain time? I do not find much information, maybe I do not know were to looking for. I still stuck with making the alarm vibrate while the screen is of.
Thanks!!!!!