-
• #2
Neat! Best of both worlds! ...and answer to some performance challenges.
-
• #3
Oh shit, that's something I didn't see coming! Inline motherfucking c!
-
• #4
It's been possible for a while but I never enabled it because there didn't seem to be a nice way of mixing C with JS - but templated strings are perfect as backtick and dollar aren't part of the C language, so you can just paste code in verbatim - you just have to be a bit careful about using them in strings.
-
• #5
Very nice and usefull.
New post opend in main forum. -
• #6
Post above was moved.
IF ANYONE HAS TROUBLE WITH THIS, PLEASE POST IN THE MAIN FORUM - I'd prefer this news thread didn't turn into a massive troubleshooting thread :)
-
• #7
I'm using Raspberry Pi and EspruinoHub to connect to Puck, if I understand it correctly I should update EspruinoHub to get the new IDE on my browser (Chrome). What's the safest way to do that without breaking anything? Thanks.
-
• #8
Yes - if you followed the GitHub instructions to install then on the Pi you want:
cd EspruinoHub git pull cd EspruinoWebIDE git pull cd EspruinoTools git pull
Then restart and you're sorted!
I've just pushed out a new IDE (0.68.5) - across Chrome, Native, Website and NPM.
There are a few nice improvements:
Leaving the best till last:
You can now dynamically add C functions into Espruino, as part of JS code
As a totally random example, here's a function to calculate Fibonacci numbers, written in C, JavaScript, and compiled JavaScript:
This is still extremely early days, so expect some things not to work. However importantly you can upload multiple C functions that can interact... You just put the prototype (as used for the Assembler) for each function you want to export at the top:
In the example above, a C function is called from an interrupt when a pin changes state (so runs very quickly), and it then changes a variable which can then be read back with normal JavaScript.
You can even access data stored in flat strings:
Hope you have fun with this! It could potentially be used to create modules for all kind of things - for example MP3 decoders, realtime audio effects, or accessing on-chip peripherals that aren't exposed in Espruino normally.