instead of attachInterrupt, use setWatch() - note that they don't actually run as ISRs - an ISR records the pin state and the timestamp, and then the callback is called when the interpreter is idle. And it can queue up... i forget if it was 64 or 128 callbacks waiting to execute before it starts missing things.
It may make sense to use compiled functions if speed is an issue (though afaik this is still a little rough around the edges).
Instead of setup(), your initialization goes in onInit().
There's no concept of loop() like there is in Arduino - instead you might, say, have the watch callback check how many bits are received, and then call a function do do what you want with those bits. Take a look at the DHT modules I wrote (though those don't use compiled watch callbacks, because those didn't exist when I wrote it)
It's interesting to port an Arduino sketch to Espruino - though the grammar of the language is so similar that sometimes you can just copy-paste functions, conceptually, the two are very different.
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
instead of attachInterrupt, use setWatch() - note that they don't actually run as ISRs - an ISR records the pin state and the timestamp, and then the callback is called when the interpreter is idle. And it can queue up... i forget if it was 64 or 128 callbacks waiting to execute before it starts missing things.
It may make sense to use compiled functions if speed is an issue (though afaik this is still a little rough around the edges).
Instead of setup(), your initialization goes in onInit().
There's no concept of loop() like there is in Arduino - instead you might, say, have the watch callback check how many bits are received, and then call a function do do what you want with those bits. Take a look at the DHT modules I wrote (though those don't use compiled watch callbacks, because those didn't exist when I wrote it)
It's interesting to port an Arduino sketch to Espruino - though the grammar of the language is so similar that sometimes you can just copy-paste functions, conceptually, the two are very different.