Random Vibration
Hello,
I need your help!
I have a metamotionR with an haptic motor. I would like to make it vibrate randomly throughout the day every random minutes. Dose anyone have any suggestion on how I can implement this in the easiest way? Even if it's not random, how can I make it vibrate every 30 minutes?
Thank you very much!
This discussion has been closed.
Comments
((Switch) view.findViewById(R.id.switch_vibration)).setOnCheckedChangeListener((buttonView, isChecked) -> {
final Timer timerVibrate= metawear.getModule(Timer.class);
// scheduling task
Task<Timer.ScheduledTask> taskTask;
taskTask = timerVibrate.scheduleAsync(10000, true, () -> metawear.getModule(Haptic.class).startMotor(50.f, (short) 1000));
// use the created ScheduledTask object
Timer.ScheduledTask Event;
Event= taskTask.getResult();
if (isChecked) {
if ((Event = timerVibrate.lookupScheduledTask((byte) 0) != null){ //not working
Event.start();
}
} else {
Event.stop();
Event.remove();
}
});
getResult. You should check out Bolts Framework's README on how to use asynchronous tasks.