Sorry @Gordon i do not understand the difference between the 2 versions..
what do you mean by callback? is it the function define in the setInterval?
I've tried reinitiate a setInterval at the end of 8 "danse"move but does not works... i've got an unknown interval error! I'm confused
function mecatronique(myId) { var tirage = Math.random(); if (tirage >0.95) { clearInterval(myId); var tm = 800; var compteurDanse = 0; var idDanse = setInterval( function(id) { console.log("danse"); compteurDanse ++; if (compteurDanse >= 8) {clearInterval(id);var idM = setInterval(mecatronique, 500, idM);} }, tm, idDanse); } else { if (tirage >0.6) { console.log("bouge"); } } } function onInit() { var idMeca = setInterval(mecatronique, 500, idMeca); }
sorry for my ugly code
@Mrbbp started
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
Sorry @Gordon i do not understand the difference between the 2 versions..
what do you mean by callback? is it the function define in the setInterval?
I've tried reinitiate a setInterval at the end of 8 "danse"move but does not works... i've got an unknown interval error!
I'm confused
sorry for my ugly code