-
• #2
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.
-
• #3
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. -
• #4
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). -
• #5
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 -
• #6
No worries Gordon. It doesn't make me any less happy than I was :)
Certainly something good to be aware of though. -
• #7
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 likesave();
=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? -
• #8
update: moved to the Ver1.44. - everything the same.
-
• #9
See this post: http://forum.espruino.com/conversations/252/#comment3791
-
• #10
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? -
• #11
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.
-
• #12
Yea, It lights immediately after downloading. i use VLDISCOVERY board and supply it from the USB-TTL converter.
-
• #13
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...
- Write the code you pasted above
-
• #14
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... -
• #15
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_stm32vldiscovery.bin, and done exactly as you say, and it works.
-
• #16
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!!!
-
• #17
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? -
• #18
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 -
• #19
:) 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? -
• #20
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.
-
• #21
ok, It starts working after
load() -
• #22
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__global_save
-
• #23
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.
-
• #24
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.
-
• #25
Just wanted to say, if you look at the reference page for your board, eg: http://www.espruino.com/ReferenceSTM32VLDISCOVERY
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 :)
but
var1=true;
save();
saves var1.....