• but
    var1=true;
    save();
    saves var1.....

  • This is expected behaviour. If you want to force LED1 on at startup, do:

    function onInit() {
      LED1.write(1);
    }
    save();
    

    I'd been considering saving pin state, but I'm not sure if it's such a good idea as often connected devices will actually need more complex initialisation done to them than just setting pin state back exactly as it was. I think very often it's actually better to force people to explicitly set the pin state.

    I'd be interested to hear what everyone thinks though.

  • Thanks a lot!
    According to your question, for me, I'd like to have a choice: to do it simple straight way, or using some complete procedure. I'd like to have many possibilities. LED1.write(1); it's ok for noobs like me, because it simple.

  • I suggest NOT saving pin states; at least as a "by default" operation.
    Connected devices often require a specific initialization sequence or in response to sensors which may not have been sampled yet (motor controllers, pumps etc.). Also pins which may be used in a bidirectional manner (eg. I2C, 1-Wire).

  • It's actually been added now - sorry. That's the problem, you can't keep everyone happy.

    In the case of I2C/SPI/OneWire it's fine as they are ignored (and the relevant SPI setup command is added) - it is only when you've set a pin as a simple output or have added pullup/pulldowns to an input.

    For beginners, there is something nice about saying LED1.set();save(); though

  • No worries Gordon. It doesn't make me any less happy than I was :)
    Certainly something good to be aware of though.

  • Gordon, I've uploaded:
    function onInit() {
    LED2.write(1);
    }
    save();
    And Led2 doesn't light after power off - power On.
    I used espruino ver1.43 compiled from github.
    If I upload the code from webIDE not first time, I've got the message like

    save();
    =undefined
    Erasing Flash.....
    Programming 3810 Bytes.......
    Checking...
    There were 257 errors!
    Even after reset(); save();
    What the errors, and how can I manage this situation?

  • update: moved to the Ver1.44. - everything the same.

  • Hi, Gordon,
    thanks for firmware update, there are really no more errors during the saving, but your sample
    function onInit() {
    LED1.write(1);
    }
    save();
    still don't work after power reset. Could you help?

  • Hi Andrey,

    Your initial suggestion should now work as well.

    What happens when you connect to the device with the Web UI? Does the LED light up?

    If you're plugged into the PC then Espruino knows it is connected to a device and has to wait until the device reads the text it's trying to send on bootup (which means it won't run your code immediately). If you're connected to a battery (or even a USB phone charger) then that shouldn't happen.

  • Yea, It lights immediately after downloading. i use VLDISCOVERY board and supply it from the USB-TTL converter.

  • I'm not sure I understand... So you

    • Write the code you pasted above
    • After save is complete, you power off, and power on
    • LED1 doesn't light up
    • you connect web IDE
    • LED1 lights up

    There shouldn't be an issue when connected over USB-TTL. I actually have the board beside me that I used to find the problem. I plugged it in and LED1 lit right away...

  • I write code pasted above, download, LED1 lights, after power off-on It doesn't light. I connect web IDE LED1 doesn't light.
    It stops lighting even without Off/On after reset (by reset button) also...

  • Do you press enter after the save() line?

    I've just downloaded the image from https://espruino-nightly.noda.se/2013-12­-17/stm32vldiscovery/espruino_1v44_stm32­vldiscovery.bin, and done exactly as you say, and it works.

  • sure...I tryed to include save(); on right panel, also tryed to put save() and enter - no effect..
    Tryed erase chip in st-link and erase all the sectors, then download the firmware. After downloading sample code I've got

    =undefined

    save()
    =undefined
    Erasing Flash.......
    Programming 3810 Bytes.......
    Checking...
    Done!

    OMG!!!

  • Did it say 'OMG'?

    Putting save() in the right-hand panel isn't really a good idea, but it should work in the left. After having reset, if you type dump() in the left panel, what does it say?

  • no, no, 'OMG' is my own addition, sorry.
    dump()
    pinMode(A13,input_pullup);
    pinMode(A14,input_pulldown);
    pinMode(A15,input_pullup);
    pinMode(B4,input_pullup);
    =undefined

  • :) Thought not, but you never know!

    Ok, looks like it's not loading the code that you saved to it. When it boots, does it say
    Loading 3810 bytes from flash... Done! ?

    Can you try typing BTN.read() and letting me know what the answer is?

  • No it doesn't, It says:

    save()
    =undefined
    Erasing Flash.......
    Programming 3810 Bytes.......
    Checking...
    Done!
    >BTN.read()
    =true
    >
    

    and

    >
       _____                 _
      |   __|___ ___ ___ _ _|_|___ ___
      |   __|_ -| . |  _| | | |   | . |
      |_____|___|  _|_| |___|_|_|_|___|
                |_|   http://www.espruino.com
      1v44 Copyright 2013 Gordon Williams
    ----------------------------------------­---
                           KickStarter Version
    ----------------------------------------­---
    
    >
    

    after reset button.

  • ok, It starts working after
    load()

  • Hi Andrey,

    I don't know how, but you've got the blue button stuck down.

    When you press the blue button during reset/power up, Espruino doesn't load the saved program, so that you can recover if you save something that stops Espruino working. It says so here: http://www.espruino.com/Reference#l__glo­bal_save

  • Gordon, I didn't say about It, because I didn't think that is affects, but i have LCD pin connected to A0. Yes, I'm an Idiot. Because of my stupidity, I stole a lot of your time. Sorry, I'm sorry.

  • No problem, good to hear it's not a software problem.

    P.S. The STM32VLDISCOVERY has the lowest amount of memory of any board that Espruino runs on - you might find that if you're adding things like LCD screens, you soon run out of available memory.

  • Just wanted to say, if you look at the reference page for your board, eg: http://www.espruino.com/ReferenceSTM32VL­DISCOVERY

    The pins with purple by them are ones that you should try not to use, as they are connected to other things. It's not such a big deal on the VL board, but on boards like the F3 and F4 that have accelerometers and things, it's really handy to know what pins are already in use :)

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

LED1.write(1); save(); didn't save LED1 state after power off. why?

Posted by Avatar for Andrey @Andrey

Actions