• If it's getting slower over time, is it possible you're not doing a
    clearInterval(..) for your intervalRefSec = setInterval(readCompass,
    200);?

    This compass code seems to get slower over time. There is a stopTimer() call which gets called everytime the LCD screen goes off.

    function stopTimer() {
          if(intervalRefSec) {intervalRefSec=clearInterval(intervalRe­fSec);}
          if(intervalPerf) {intervalPerf=clearInterval(intervalPerf­);}
        }
    

    Overtime, or sometimes fairly quickly the Buttons become unresponsive as it the edge detection did not kick in. Not sure if the firmware is interrupt driven or just polls the state of the buttons. Clearly something is going on with the readCompass() (the code is copied from the Navigation Compass - I think the problem maybe the tilt correction code as it has a lot of Math.sin tan etc in it.

    The intervalPerf timer is acting a bit like a watchdog for the purpose of me understanding what load is being run on the CPU. So if this time is delayed by 300+ms then something is seriously wrong.

    Changing perfCheck() to switch LED1 on/off if we detect that the timer was delayed has allowed me to see that when there is a lot of arm movement then the 1000ms timer gets delayed and that is pointing me at the tilt correction code in the Magnav compass.

    I will also profile the times for the different funtions.

       function perfCheck() {
          var tNow  = getTime();
          var tDiff = 1000*(tNow - tPerf) - 1000;
          tPerf = tNow;
          //console.log("perf=" + tDiff);
          LED1.write((tDiff > 50));
        }
    
About

Avatar for HughB @HughB started