Lag in code or skipping ahead in code? #335
Replies: 18 comments
-
Posted at 2014-12-09 by @gfwilliams That is strange - I'm not sure what to suggest. I'm not sure these will help with the problem you're having, but could you try:
What happens if you comment out the Do you have an up to date version of Espruino? It should show a little warning icon in the top right if not. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2014-12-09 by Hellis It's the latest version. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2014-12-10 by Hellis Ok! Now I have tried that new code also but I'm not sure it made any difference at all :-/ Code:
|
Beta Was this translation helpful? Give feedback.
-
Posted at 2014-12-10 by @gfwilliams Thanks for the video! I'm a bit busy right now, but when I get a moment I'll run the code here and see if I can figure out what the problem is. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2014-12-10 by @gfwilliams Right, just got it. The issue is that right after the board starts up, the real-time clock takes a second or so to sort itself out. For instance doing:
You'd expect the green LED to light up and the red one to start flashing immediately - but instead the green LED lights, there's about a second delay, and then the red starts flashing. I'll see what I can do about this in later firmwares - I guess I can delay execution until the clock starts working correctly. In the mean time, you could do your erasing when you press a button:
or maybe just start it after a 1 sec delay:
|
Beta Was this translation helpful? Give feedback.
-
Posted at 2014-12-10 by Hellis Sure! Thank you for helping! I have an idea I will test tonight when I get home. If the code can loop through 39 files and the sound is in sync, but not loop through 9 files and delet 6 of them and cause a delay then there must be something in the code when the if returns true. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2014-12-10 by Hellis Just read your second reply. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2014-12-10 by Hellis But if the clock takes one second to start up, that does not explain the 9 second delay between green light and sound. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2014-12-10 by @gfwilliams Ok, I've just looked into the interpreter code and it turns out it's actually a very specific problem, which I've just fixed (so it'll be in 1v72). Basically timeouts are stored with the 'time until timeout'. Each time around the 'idle loop' that time gets checked and decremented by the time that has passed since the last iteration. So when you create a timeout, Espruino says Only |
Beta Was this translation helpful? Give feedback.
-
Posted at 2014-12-10 by Hellis So a easy fix would be to load the code after onInit, as you say btn1 push. So if I wish to use it I use a pushbutton connect one end to B12 and the other end to ??? 3.3 volt? |
Beta Was this translation helpful? Give feedback.
-
Posted at 2014-12-10 by @gfwilliams Yes, connecting between B12 and 3.3 would work great. You could also add |
Beta Was this translation helpful? Give feedback.
-
Posted at 2014-12-10 by Hellis I don't use a battery. I have enough things with battery that needs to be charged :-) |
Beta Was this translation helpful? Give feedback.
-
Posted at 2014-12-10 by Hellis Seems to work nice! |
Beta Was this translation helpful? Give feedback.
-
Posted at 2014-12-11 by @gfwilliams Great! Glad it's working! I've got a bug open for the delay problems so I'll see what I can do to fix it for the next release. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2014-12-18 by Hellis Any idea why this is happening? Without the push button I don't need to keep the BTN1 pushed down to boot the Espruino. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2014-12-18 by @gfwilliams Ahh, ok - it's a normally closed button as you said before. B12 - the button on the Espruino board - has a special function. If you hold it down when you boot, the device goes into bootloader mode so you can update the firmware. I guess that's what is happening. Did you think of just connecting your button to another pin? You can use |
Beta Was this translation helpful? Give feedback.
-
Posted at 2014-12-18 by Hellis Oh sorry forgot to write that, this is a new button normally open. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2014-12-18 by Hellis I could probably use a different pin also.... |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Posted at 2014-12-09 by Hellis
I'm not sure what the problem is, if it's hardware or software.
Feel free to move the thread if it's in the wrong place.
I have a code that deletes files of GoPro SD cards that are not needed. (THM and LRV- files)
The code switch the red LED on and off during the delete process to show that it's running.
Then it should play a sound, and then after the sound turn on the green LED.
If there is no SD card in the SD-slot the LEDs should flash and play a "error-sound". And that part of the code works as it should without the lag.
Video
The code:
Beta Was this translation helpful? Give feedback.
All reactions