-
Isn't there still a need to add mylib to make file ?
At the moment, yes. As I'd said above, the ideal solution would be to have something in the Makefile that scanned the
libs
(or another) folder and included any files that it found.How would this help to share mylib ?
You'd have to stick it on GitHub - I'd be happy to add a page to the website with instructions and a link to your (and others') code.
Is Virtualbox a placeholder for any virtual tool ?
Yes - assuming you can run a recent version of Linux on something (whatever) then it should be quite easy to make a script to install everything (in fact as @tve pointed out, you can pretty much just copy what
.travis.yml
does.crypto
The crypto libs shouldn't use up any RAM until they're used - they're really not that bad at all. It's HTTPS that's the killer (it can be compiled in separately), although even that doesn't use RAM until you use it.
... having said that, due to the way the ESP8266 works, the crypto libs could end up using some RAM as any constant arrays will be stored there by default :(
-
-
Vagrant would be the way to go if it works. To be honest even a script that installed the relevant tools on a basic Linux install would be good - then all you'd need is Virtualbox.
I was experimenting with jslinux and almost got it working (Fabrice Bellard gave the Ok to use it as well) - it'd be great to be able to point users at a website with the VM already on it.
On the other hand, I would like to share them to others
Maybe put them on GitHub with a script a bit like this?
git clone https://github.com/espruino/Espruino.git cp -r mylib Espruino/libs cd Espruino PICO_1V3=1 make
The only thing missing for that to work is something in the Makefile that would automatically search for and include sub-makefiles in the
libs
folder. That could tidy a lot of things up anyway.next project will be an SHA1 implementation
:( You know there is already
require("crypto").SHA1(...)
? IMO it'd make more sense to just #ifdef out SHAxxx and AES if you don't want them, rather than just reimplementing what is already there?I think the crypto library (without HTTPS) would 'just work' on ESP8266 anyway. Worth a try - just add
USE_CRYPTO=1 RELEASE=1
to the Make command-line. -
I guess things like
getAPIP
,getIP
,getHostByName
.So they could all return null/undefined on error - maybe that's good enough? But if you want to return an error message then there really needs to be another way of doing it - and the way most NodeJS things do it (for better or worse) is
function(err, data)
-
-
It's really not that hard to compile your own firmware - especially with Docker/Vagrant. Basically if you have the tools to compile a library for Espruino, you can compile the full firmware - and it'll be easier to understand than if you have to get your head around a homebrew DLL system :)
About the only thing that'd help (IMO) is a
make menuconfig
sort of thing that could automatically scan thelibs
folder for modules that you could choose whether you wanted to include or not.Of course you can use
nativeCall
relatively easily to add your own compiled code like this, but you're pretty limited with how much you can interact with Espruino as you don't have access to that many of its internal functions. -
Sounds like a good plan!
Wrt fatal errors - what would that actually mean? Since most of the socket handling is done on idle, if there's an error we can't really do much.
But definitely, if there is no error handler we should at least print the error message. Maybe
jsiQueueEvents
(or whatever it's called) can returnfalse
if no callbacks were found (if it doesn't already). -
-
The comments haven't really bothered me personally - and unfortunately because I don't host the forum I don't get to change the CSS myself, so I'd have to get the forum hosts to do it.
If you don't like the colours, why don't you write a Chrome Extension? I believe it's trivial to make one that would change CSS colours for one specific form of URL, and then you could do whatever you wanted.
You could even add a 'send to Espruino' button and links to Espruino's reference documentation :)
-
You can do:
JsVar* v = jsvArrayBufferGet(arrayBuffer, 30); jsvArrayBufferSet(arrayBuffer, 60, v); jsvUnLock(v);
But that's not as fast. The ideal thing is to read or write data sequentially:
JsvArrayBufferIterator it; jsvArrayBufferIteratorNew(&it, start_index); while (pixels--) { jsvArrayBufferIteratorSetByteValue(&it, value); jsvArrayBufferIteratorNext(&it); } jsvArrayBufferIteratorFree(&it);
Your other option is to use 'flat strings' - if you can use them then when you use
JSV_GET_AS_CHAR_ARRAY
you'll get a pointer to the underlying data, so there is no need to copy back.The ability to scroll with the Graphics library would actually be really useful, although that's a bit tricker to deal with as you need to cope with bit-based graphics where the pixels are in strange formats...
No problem if you're doing this for fun yourself - but I don't see I'll be able to include this code in Espruino itself - there's just too little flash memory available for me to be be able to use it on something that's very single-purpose.
-
JSON wrapper with more than 4 parameters
You can use
JsVarArray
and can decode all the arguments manually if you want more - it's not worth me wasting another byte (or more) for each function, as 99% of them have 4 or less arguments.main problem is right now how to read my pixelbuffer (uint8array), change some values and store back.
Instead of trying to get a memory area I'd use
jsvArrayBufferIterator
-JSV_GET_AS_CHAR_ARRAY
was added as a bit of a hack to allow other non-espruino bits of code to access data. All of Espruino's stuff is written to access the data in-place rather than copying it onto the stack first.However... what are you trying to accomplish? Espruino already lets you access 8x8 RGB matrices of WS2812 really easily: http://www.espruino.com/RGB123
The Graphics library has everything built in, so realistically what you're doing can be accomplished in JS with:
SPI2.setup({baud:3200000, mosi:B15}); var leds = Graphics.createArrayBuffer(8,8,24,{zigzag:true}); leds.flip = function() { SPI2.send4bit(leds.buffer, 0b0001, 0b0011); }; leds.clear(); leds.setColor(r,g,b); leds.fillRect(0,0,7,7); leds.flip();
-
That looks like a really nice LCD! I'll drop you a message with my address.
Looking at that other post I'm not sure if anyone did get it running in the end, but it does seem nice and easy - the code posted there just needs a bit of tweaking to 'inline' the
#define
statements. -
@bigplik you can't use a
for
loop for that kind of thing - becausegetADC
is asynchronous.You need to use callbacks, so that you issue the next reading only after you got the last one. For instance:
var idx = 0; var array = new Float32Array(10); function getValue(value) { array[idx] = value; idx++; if (idx<array.length) ads.getADC(0, getValue); } ads.getADC(0, getValue);
-
How do I teach the IDE that Wifi is a built-in module?
It'll 'just happen' next time I update the website with a new release (it gets listed in the
json/ESP8266_BOARD.json
file on espruino.com).wrt callback parameters: It's a pretty standard JS/NodeJS thing to have:
function (err, data) { if (err) { console.log("Oh no!"); return; } // ... }
It's not pretty, but it's what everyone does. It'd be nice to be able to keep that kind of thing wherever possible.
-
@tve sounds like for you, the best solution would be if the Web IDE issues a
load()
call rather than areset()
one...A simple hack is just to do
reset=load;
, and then next time the IDE tries to reset it'll actually end up loading your saved code.There was a post a while back about adding something like
E.setBootUpCode
that'd save code that would always be executed - even on reset. That could be an option - but on the whole the idea ofreset
is to reset the board to a totally fresh state so you always know where you start from. -
Oh, sorry - I should update the page with some info. It's either 1206 or 1210 - so something like this is good: http://uk.farnell.com/murata/grm31cr60j476ke19l/cap-mlcc-x5r-47uf-6-3v-1206/dp/1828809
-
@tve there's nothing in there for text errors at the moment - you just have to return a negative number, so you could have different numbers for different errors. Maybe a
errorNumberToString
type function could be added? Or maybe justgetLastErrorString
is easier - but then it probably requires a string buffer in RAM somewhere. -
@tve it'd need to implement
jshUSARTSetup
- I don't know if that's actually done right now?You can move the console out of the way with something like
LoopbackA.setConsole()
and then you can use Serial1 for whetever you want... -
Just for anyone else, you can write functions that get called on
init
andkill
.kill
is called before the reset happens, andinit
happens after.../*JSON{ "type" : "init", "generate" : "jswrap_net_init" }*/ void jswrap_net_init() { } /*JSON{ "type" : "kill", "generate" : "jswrap_net_kill" }*/ void jswrap_net_kill() { }
-
I'd set it only if there's a connection, but on things like Linux I just leave it set.
It was a while ago but IIRC it'll give you errors if you try and make an HTTP request/etc without having set up a connection, and the hope was that at some point I'd add something that would automatically look on the net for referenced modules if there was a network connection.
-
onInit
will get called automatically, so no need to addE.on('init', function() { onInit(); });
Your main problem though is you're not initialising the oled display in onInit.
Try:
var g; function onInit() { I2C2.setup({scl:B10,sda:B3}); g = require("SSD1306").connect(I2C2, function() { oled(); }); }
-
-
Looking at this now - seems everything is working but there's an issue with the ordering of module initialisation. Easiest solution for now is to just do:
require("HC-SR04"); var mymodule = require("mymodule")...;
... Or, I guess you're doing something like this in your module:
var foo = require("HC-SR04"); exports.abc = function() { };
But if you did this, it'd all work:
exports.abc = function() { var foo = require("HC-SR04"); };
... just to add, I don't think there's anything different with the projects code at all - all modules are handled the same right now. It's just that if modules use other modules, they're generally written not to use them in the global scope.
-
Yes, those look good - especially something like this: http://www.alibaba.com/product-detail/128x64-st7565r-lcd-module-with-white_60275759596.html
It looks like a very good nokia replacement. I guess worst case if they stop being produced then you could get a new board made with the same pinout.
If you'd be willing to send one of those (or whatever you decide on) over I'll make sure I get a driver that works.
It looks like the ones that have more pins on them do require quite a few capacitors on the board they connect to though.
Wow, I didn't see that!
That's crazy. Yes, I get paid the same - so Seeed are actually losing money on that!