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

Trouble in make the alarm vibrate: setTimeOut and Onclick

Hi all,

I wonder if somebody could help me, I am trying to set an alarm at a certain hour, the problem is that the clock vibrates only if the screen is on. I have tried this:

 

clock.granularity = "minutes";
const myLabel = document.getElementById("myLabel");


function procedimiento()
{
    clock.ontick = (evt) => {
    let today = evt.date;
    let hours = today.getHours();
    hours = util.zeroPad(hours);
    let mins = util.zeroPad(today.getMinutes());
    myLabel.text = `${hours}:${mins}`;
    if(hours == 15 && mins == 28) {
         vibration.start("ring");
    }
  }
}
setTimeout(procedimiento(), 5000);

 

Is there something I am not considering?

Thanks in advance to all of you.

Best Answer
0 Votes
2 REPLIES 2

If it only vibrates if the screen is on, turn it on just for the vibrate and then turn it off again.

 

import { display } from "display";
display.on = true;
vibration.start("ring");
display.on = false;

 

 

Best Answer

Thanks for your response, I will try 🙂

Best Answer
0 Votes