• hi, All! look:

    function lampOnOff(out,q){ 
      if (q==1)out.set();
      else if (q==2){ // flashes for 3 sec's
        out.reset();
        setTimeout(function(){out.set()  ;},500);
        setTimeout(function(){out.reset();},1000­);
        setTimeout(function(){out.set();  },1500);
        setTimeout(function(){out.reset();},2000­);
        setTimeout(function(){out.set();}  ,2500);
        setTimeout(function(){out.reset();},3000­);
      }
      else out.reset();
    }
    function onInit(){
    	setInterval(function(){lampOnOff(B5,2);}­,4000);
    	setInterval(function(){lampOnOff(B6,2);}­,4000);
    	Serial3.setConsole();
    }
    

    if I plug USB cable, both B5 and B6 flash simultaneously.
    if USB cable unplugged, periods of outputs shift relative to each other.
    and start working synchronously again if I put USB back.
    I can explain it.. console moved from USB. And I have even no webIDE launched.
    How i can make flashing
    outputs synchronously without USB?
    thanks!
    ps: board F4Discovery; Espruino ver 1.67

  • Hi Andey,

    It'll be this bug: https://github.com/espruino/Espruino/iss­ues/415

    I noticed this a week or so ago, but I'm not sure if it's recent or not. If you're compiling your own you could just disable what happens in jshSleep

  • I helped Andrey change project to fix this.
    1) In \Espruino\targets\linux\jshardware.c we cut function

    bool jshSleep(JsSysTime timeUntilWake)  {
    ...
    ...
    ...
    }
    

    to

    bool jshSleep(JsSysTime timeUntilWake) {
      return false;
    }
    

    2) In \Espruino\targets\mbed\jshardware.cpp

    bool jshSleep(JsSysTime timeUntilWake) {
       __WFI(); // Wait for Interrupt
       return true;
    }
    

    to

    bool jshSleep(JsSysTime timeUntilWake) {
       return true;
    }
    

    3) In \Espruino\targets\stm32\jshardware.c

    bool jshSleep(JsSysTime timeUntilWake) {
    ...
    ...
    ...
    }
    

    to

    bool jshSleep(JsSysTime timeUntilWake) {
       return true;
    }
    

    We have a working result. Thank you!

  • Great! Just so you know, as you are compiling for stm32, the only file that you need to change is the last one - stm32/jshardware.c

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

Some interesting USB console behavior, I can't understand.

Posted by Avatar for Andrey @Andrey

Actions