You are reading a single comment by @JumJum and its replies. Click here to read the full conversation.
  • During testing a rotary phone, I ran into problems recognizing pulses.

    After some testing brought it down to following samples.
    Duration is always much more than expected (by me).

    Interesting is last example where only first timeout is wrong.

    Testing is done with WebIde. First examples use terminal window for input.
    Last testing is uploaded from editor window and called from terminal.
    Board is MDBT42Q with 2v06, downloaded from binary

    for(var i = 0; i < 10; i++) {var dt = new Date();setTimeout(function(){console.log­(new Date() - dt);},1000);}
    =undefined
    2159.7900390625
    2161.0107421875
    2162.90283203125
    2164.21508789062
    2165.67993164062
    .....
    
    var dt = new Date();setTimeout(function(){console.log­(new Date() - dt);},100);
    =1
    958.46557617187
    >var dt = new Date();setTimeout(function(){console.log­(new Date() - dt);},100);
    =1
    1476.01318359375
    >var dt = new Date();setTimeout(function(){console.log­(new Date() - dt);},100);
    =1
    1280.94482421875
    >var dt = new Date();setTimeout(function(){console.log­(new Date() - dt);},1000);
    =1
    1865.69213867187
    >var dt = new Date();setTimeout(function(){console.log­(new Date() - dt);},1000);
    =1
    2315.673828125
    
    function tst(duration){
      var pnt = 0;
      function tstTimeout(){
        var dt = new Date();
        setTimeout(function(){ 
          console.log(new Date() - dt);
          if(pnt++ < 4) tstTimeout();
        },duration);
      }
      clearTimeout();
      tstTimeout();
    }
    tst(1000);
    =undefined
    1828.857421875
    1001.43432617187
    1001.46484375
    1001.43432617187
    1001.46484375
    
About

Avatar for JumJum @JumJum started