You are reading a single comment by @jgw and its replies. Click here to read the full conversation.
  • Messed up the code insert - see below

    var lvls = [65535,54038,47824,39322,32768,26526,183­88,11818,5958],
        halfDiff = 2979; //2958/2
    
    function anaGetKey(samples){
      var keys = samples.map(function(v)  {
        var i;
        var val = v + halfDiff;
        for (i=0; i<lvls.length; i++)    {
          if (lvls[i] < val){
            console.log("found : "+i+" for "+v+" - "+val);
            break;
          }
        }
        console.log(" => return "+i);
        return i;
      });
      console.log(keys);
    }
    
    anaGetKey([6000,12000,54000,65000]);
    
    
About

Avatar for jgw @jgw started