Avatar for Mrbbp

Mrbbp

Member since Mar 2017 • Last active May 2017
  • 3 conversations
  • 17 comments

I'm newb with espruino, not with arduino, not with js...
But i'm not a coding ninja

Most recent activity

    • 4 comments
    • 49 views
  • in General
    Avatar for Mrbbp

    Thanks...
    it saves me a lot of time to compare with old versions.

    by the way,
    What is the idea behind the "Project" area?
    I find it's more confuse about the place for code than a real help for storing code...
    I suppose i do not use it in the good way..

    regards

  • in General
    Avatar for Mrbbp

    Hello,

    well, i've read somewhere that the js code is uploaded to the board and interpreted...
    Am i right?
    i've "loose" my source code, is it possible to download the code loaded in the board?

    thanks

    é.

  • in JavaScript
    Avatar for Mrbbp

    ok i've understood.
    i just want to make sequence of actions.
    in that case i play with a servo... there is "normal" sequence and a "special" sequence.
    all the sequence need a different setInterval
    i want to stop one and start the other.
    for sure i could use a flag to stop one action and let's play the other and have 2 setInterval started at the beginning.
    i'm coming from Flash™ and animation software, therefor i'm thinking as an animator not as a developper... ;)

    regards
    thanks for your time.

    éric

  • in JavaScript
    Avatar for Mrbbp

    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

  • in JavaScript
    Avatar for Mrbbp

    I answer that i've understood.
    The id is undefined, therefor there is no id for clearInterval. So it stop all the setInterval...well.
    But it does not resolve my problem to transfer an id to a function to clear it at the end.
    An idea, please?

    Regards

  • in JavaScript
    Avatar for Mrbbp

    Hello,

    well, i'm a bit loose with setInterval et clearInterval...
    I need to repeat 3 time a function with a time of 200ms
    I've tried this

    id = setInterval( function(a,b,c) { console.log(a,b,c);} ,200, "foo", 25, id);
    

    in the console it said

    foo 25 undefined

    i've tried to use the id and it "works" (it stop)

    var idAnim;
    var compteur = 0;
    
    function anim(a,b,c) {
       compteur++;
       console.log(compteur,a,b,c);
       if (compteur >= a.length){ clearInterval(c); }
    }
    
    function onInit() {
      idAnim = setInterval( anim, 500, "foo", 0, idAnim);
    }
    

    and it stops after 3 time.

    i've tried the same in a function in a setInterval and it stops all the setInterval

    var idAnim;
    var compteurAnim = 0;
    var mot = "foo";
    
    function texte(){
        idAnim = setInterval(function(a,y,c){
          console.log(a,y);
          compteurAnim++;
          if (compteurAnim >= a.length) { clearInterval(c);}
        }, 100, mot, 0, idAnim);
        mot+="foo";
    }
    
    function onInit() {
      setInterval( texte, 4000);
    }
    

    where i'm wrong?
    is there a way to pass the id to function?
    or is there a simple way to repeat a definite time a function?
    i want to animate text letter by letter

    regards

    éric

  • in General
    Avatar for Mrbbp

    By the way @Gordon, does the ide use a cache when compile with a new module?
    When update the font, i have to rename the module at each iteration to use the updated version in the espruino board.
    Is there a better/easier way to disable cache?

    Regards

Actions