Avatar for Mrbbp

Mrbbp

Member since Mar 2017 • Last active Apr 2017
  • 2 conversations
  • 15 comments

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

Most recent activity

  • 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

  • in General
    Avatar for Mrbbp

    @Gordon Yes, but i'm not the original designer, i just modified the minus and accents... You have to ask to DennisFont designer...

    Regards

  • in General
    Avatar for Mrbbp

    And i discovered that the é was 1pix larger. I redesign minus with 1 pix larger.
    The fontDennisAlternate

    /* Copyright (c) 2015 Dennis Bemmann. See the file LICENSE for copying permission. */
    /*
    FontDennis8Alt.js
    ==============
    
    from fontDennis8
    Redesign mrbbp
    
    Usage:
    
    

    require("FontDennis8Alt").add(Graphics);­
    g.setFontDennis8Alt();
    g.drawString("\x90 \x91\x92\x93\x94\x95\x96\x97 Dennis8 \x9f \x8c \x8d \x89",0,0);
    g.drawString("ça ¿s� \xbc\xa3 \xbd\xb5\xa6 \x82\x83\x84\x85 \xac\xad\x86",0,12);
    g.drawString("\xa0 Bäh böse Ärzte in Küche\xaf",0,24);

    */
    var font = atob("AAAAAPoAwADAAFhw2HDQAGSS/5JMAGCW+D­zSDAxSolIMEsAAPEKBAIFCPABIMOAwSAAQEHwQEA­ABBgAQEBAQAAIAAwwwwAB8ipKifABA/gBChoqSYg­CEkrLSjAAYKEj+CADkoqKinAA8UpKSDACAgI6wwA­BskpKSbABgkpKUeAAiAAEmAB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+aqpqIgA+qiqqIg­CifiIAIn6iAGK+YgBiPmIAEH5SQjwAfpCIRL4AHK­JiIhwAHCJiohwADFKSUgwATJKSUowAvEJCQrwAIh­QIFCIAPkNdYT4APIJCAjwAPAJCgjwAHEKCQhwAvA­ICArwAIBBOkCAAgf8lJBgAf5KSbAAEKqpqHgAEKi­pqngAEKmqqXgAEaqqqXoAEqioqngAEKmqqXgBMUj­xSNAAYJSckCAAcqmoqGAAcKmqqGAAcaqpqGAAcqi­qqGACifgIAIn6CAGK+QgBiPkIApEqqGgwAXpCQTo­AADJJSEgwADBJSkgwADFKSUgwATJJSkgwAnCIinA­AQEFQQEAA6TFRkuAAcAoJCHgAcAkKCHgAcQoJCHg­AcQgICXgAwCkqKPACB/xUIADCKCoo8AA==");
    var widths = atob("BAIEBgYGBgIEBAYGAwUCBQYDBgYGBgYGBg­YCAwQGBAUGBgYGBgUFBgYCBgYFBgYGBgYGBgYGBg­YGBgUDBQMEBgYGBgYGBgYGBgIFBgQGBgYGBgYGBQ­YGBgYGBgQCBAYGBgQGBgYGBgYGBQUGBgYGBgYGBg­YGBgYGBgQCAwQFBgYGAgYGBgYGBgYGBgYGBgYGBQ­YFBQQGBgMEBAYGBgYGBQYGBgYGBgYGBgYGBgQEBA­QGBgYGBgYGBgYGBgYGBgYFBgYGBgYGBgYGBgYGBA­QEBAYGBgYGBgUGBgYGBgYGBQY=");
    
    exports.add = function(graphics) {
      graphics.prototype.setFontDennis8Alt = function() {
        this.setFontCustom(font, 32, widths, 8);
      }
    }
    
Actions