MDBT42Q code lost upon power cycle

Posted on
  • I tried out the demo code on the individually addressable led page listed at http://www.espruino.com/Individually+Add­ressable+LEDs
    The code worked great, but when I disconnect/reconnect power, the code does not run. I can upload the code again, but it doesn't appear to save the code when its power cycled. Is this normal behavior of the MDBT42Q?

    Thanks for your help

  • Did you enter save() in the console - left side in the IDE after upload?

  • ...one more thing:

    make the last two lines of the your code like this (put the original last two lines into onInit() {...}; function in order to not save messed status.

    onInit() {
      setWatch(changePattern, BTN, { repeat: true, edge:'falling' });
      setInterval(doLights,50);
    }
    

    With that change though, the code will not start on upload. This is annoying while you devleop... If you add this line as a very last line while you develop and when ready to save it, just comment this line before the upload.

    setTimeout(onInit,500); // while dev'g - comment before upload for save()
    

    I hope this helps.

    PS: How do you get rid of saved code - prevent it from automatically starting?

    When connected, inter in the console reset(1) . This will not only stop the code but also remove it from FLASH, so that a next time you power cycle, it is not there anymore to be run.

    If you want stop a piece of code, you just say reset() without argument.

  • http://www.espruino.com/Saving will explain the whole save process in a bit more detail if you're interested

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

MDBT42Q code lost upon power cycle

Posted by Avatar for Drc3p0 @Drc3p0

Actions