-
What code does the web ide decide to load when it starts up?
I assumed it had loaded my last saved file, I made a few changes to the code & saved it (overwriting my source file).
The problem was it was old code that was loaded, not the most recent & I lost some previous changes (not too bad, only took about 30 mins to redo).
It may be better if the IDE opened up with a blank code editor - at least we could be sure what was loaded.
Also: How does the auto-save to Chrome's Cloud Storage function?
-
Just because you have nothing at all connected to an input pin doesn't mean it is a logical zoro.
To ensure that inputs default to expected logic levels you need to use pullup or pulldown resistors. See this link for an explanation:
http://playground.arduino.cc/CommonTopics/PullUpDownResistor
-
I've been using my espruino for a few days now and have been really impressed. The experience has helped improve my JavaScript knowledge and I now really like the async nature of the language.
Although it's great being able to just type a command into the console window and have it execute I tend to use the RHS of the IDE too much which is more like a traditional 'compiled' environment.
It would be extremely useful if it was possible to send just the function currently being edited in the IDE to the console - this could call the 'edit' function and replace the existing function without resetting the running code (I realise the full outer function would probably need replaced).
Another idea would be to highlight a section of code in the IDE and send it to the console where it would be executed.
The IDE could possibly have a right click context menu with the options 'Replace current function' and 'Execute highlighted code'.
Just a couple of ideas which may add to the USP of the espruino platform!
-
The project I am working on needs the Clock to be set to the current Date/Time. Its a bit of a pain doing this every time the device restarts so I now use the following batch file (setClock.bat) from my desktop (assumes COM5 & instance of Clock called clk):
@echo off for /F "usebackq tokens=1,2 delims==" %%i in (`wmic os get LocalDateTime /VALUE 2^>NUL`) do if '.%%i.'=='.LocalDateTime.' set ldt=%%j set ldt=%ldt:~0,4%-%ldt:~4,2%-%ldt:~6,2%T%ldt:~8,2%:%ldt:~10,2%:%ldt:~12,6% echo clk.setClock((new Date("%ldt%")).valueOf())>COM5
(Ensure the IDE isn't connected)
Don't ask me to explain it in any detail (used some googled code!)
Maybe there is an easier way?
-
After a bit more reading I think I now understand - if specified the sck, mosi & miso options MUST always refer to a pin which is marked as being the sck, mosi & miso for that particular SPI.
SPI1 can either use pins B3, B4,B5 or pins A5, A6, A7.
SPI2 & SPI3 only have one set of available pins each.
The purpose of specifying the pins in the tutorial was to ensure A6 was left unused by the SPI1 so that it could be used as a basic GPIO.
I'm getting there gradually I think!!
-
I ordered a Nokia 5100 LCD board with my Espruino and like the idea of having it soldered directly to the board as described in the tutorial.
Just one question - in the tutorial you twist the DC & DIN pins (to get the DIN pin over A7 - SPI1 MOSI, leaving A6 available for the DC pin)
Could the SPI MOSI & MISO have been swapped in SPI1.setup so that the pins didnt need twisted?
i.e. SPI1.setup({ baud: 1000000, sck:A5, mosi:A6 }); Leaving A7 for the DC pin.
(Hopefully I'm not posting too many questions - I'm trying my best to figure things out myself before asking!)
-
-
I was getting errors in some minified code (simple minification) and have identified the issue:
My function had two return statements - one within a loop, the other at the end of the function (sloppy , I know!!).
This caused the minifier to output a labelled break which isn't supported by Espruino.
Refactoring the function to have only one return statement solved the issue - hopefully this is of help to someone else.
(edit: Probably should have been posted this in the Javascript forum)
-
-
Excellent! I should be receiving my board next week and in the meantime have been putting together some code - migrating a central heating timer from delphi to javascript - this will be in its own module.
It may be of use to others (for anything that needs triggered regularly and repeats on a weekly cycle) so I will share it (with documentation) when finished.
I find the following site very useful for developing/testing javascript:
http://repl.it/languages/JavaScript
(hopefully the code I have written will run ok on espruino - I'm doing nothing fancy!)
-
I understand the purpose of require("modulename") but I was wondering if this approach could be used to load my own modules and to help structure my own code.
If I place my own modules in a specific folder can the Web IDE be configured to look for them there or does it always look online for minified versions of the Espruino modules?
(Even if the Web IDE cannot access my local file system it would be good if it could access custom modules via my locally hosted web server)
-
@Gordon - Some details I found regarding the 750ms delay:
Parasite power mode:
When operating in parasite power mode, only two wires are required: one data wire, and ground. At the master, a 4.7k pull-up resistor must be connected to the 1-wire bus. When the line is in a "high" state, the device pulls current to charge an internal capacitor.This current is usually very small, but may go as high as 1.5 mA when doing a temperature conversion or writing EEPROM. When a slave device is performing one these operations, the bus master must keep the bus pulled high to provide power until the operation completes; a delay of 750ms is required for a DS18S20 temperature conversion. The master can't do anything during this time, like issuing commands to other devices, or polling for the slave's operation to be completed. To support this, the OneWire library makes it possible to have the bus held high after the data is written.
Normal (external supply) mode
With an external supply, three wires are required: the bus wire, ground, and power. The 4.7k pull-up resistor is still required on the bus wire. As the bus is free for data transfer, the microcontroller can continually poll the state of a device doing a conversion. This way, a conversion request can finish as soon as the device reports being done, as opposed to having to wait 750ms in "parasite" power mode. -
The reason my DS18B20's appeared slow is because I had them wired for parasitic power (ie power derived from the data line, no separate V+)
I tried powering them directly and they returned the temperature very quickly so I should have no issues with blocking!
I had no idea that the power mode has such an impact on response time.
-
Thanks for all the great responses!
I will definitely investigate the web server approach.
The main reason I was thinking about using the L298d is that the zone valves are reversible - to open & close. If using relays I need 4 of them for 2 valves - I thought the l298d may be more economical!
Just one question - the ds18b20's can take 750ms to take a reading - will I need to wait for the response or does the event based approach allow me to do other things while waiting?
-
Hi Gordon
Thanks for your prompt reply. I'm looking forward to getting started and will place my order tonight with digitalmeans. They don't seem to have everything I need so I will also order some stuff from elsewhere.
Away back in 2008 I developed a central heating control system in Delphi 7 which runs on a PC and uses an excellent little PIC board to control the boiler, pump & two 12v DC zone valves:
http://www.phanderson.com/iom142/iom142.html
I stopped using it because it was too much having a big old pentium PC just to turn a few things on and off!! It would be great to have everything running on an Espruino.
I could use my existing DS18B20's, two Relays for the Boiler/Pump and a L293D for the Zone Valves (I currently use relays for this but like the idea of using the L293D).
My Delphi program currently sends ASCII characters to the PIC board to control things. As a first step I plan to replace the board with the Espruino (plus relay board) and modify the program to send Javascript to the Espruino.
I will then gradually move the logic from the PC to Espruino until the PC is no-longer required.
I would also like to get a second Espruino with a TFT screen to run a user interface which talks to the controller over bluetooth (or wifi) - I'm worried it may be difficult to render a nice GUI though.
All just an idea at present but a nice project for the winter months.
Thanks for all your hard work and I hope things continue to progress well.
-
I'm going to order the Espruino board soon and was wondering what else I should order - I'm just going to be experimenting with it initially but am interested in heating controls. Its really annoying ordering something then realising that additional items are required.
It would be great if someone could have a quick look at what I'm thinking of ordering and suggest best options & any additional items I should think of:
Espruino Board (from digitalmeans)
Header Pins (2.54mm) - Male or Female???
Breadboard - best size???
Jumper Leads (M/M but also M/F if Male Header Pins???)Plus various other electrical components (obviously depends on what I intend to use it for!!):
Nokia 5110 LCD,
DS18B20 Temp Sensor,
Relay BoardI'm assuming most of the Boards (such as Relay Boards) advertised as being for the Arduino should be fine for use with Espruino???
Anything obvious missing?
It would be great if digitalmeans (and the other suppliers) could put together Espruino starter kits based on the various videos Gordon has uploaded).
Any suggestions/ideas welcome!
Thanks Gordon. I've now decided to keep my code in a DropBox folder which automatically stores previous versions so I shouldn't lose anything again (so long as I remember to save!)
Oh - Congratulations on reaching the £15K for the Pico - it didn't take long - 2 days!!!