Track My Order
Frequently Asked Questions
International Shipping Info
Mon-Fri, 9am to 12pm and
1pm to 5pm U.S. Mountain Time:
Chat With Us
November 5, 2012
Tutorial - Electric Imp: Serial communication between Imp and Arduino
about 4 years ago
Definitely a good question - I did a little research on this one myself!
In your example above, there’s really no need for “.bindenv” anywhere. It’s very handy when you’re doing heavily object-oriented work in squirrel, though. Here’s why:
Many of your library functions have callbacks. In object-oriented development, it often makes sense for these callbacks to be methods off of your object. When you call these callbacks, the dynamic scope of that function is now in question. This is where bindenv is needed - it links to scope of that callback to the particular instance you want it to refer to, instead of having it just get called at global scope.
The fact that squirrel can do very object-oriented stuff is nice, but the imp is really great doing things in a simple, C-like, global-function-based manner, too. Jim, your code above is a much easier read than the RFID example!
I’ve taken note of the lack of more straightforward, simple, building-block examples on the electric imp development wiki, and we’ll be working to get examples more in this vein posted and available. Thanks for your hard work here!
As a matter of fact, the imp planner has a node already included to push data to COSM. Add it to your plan by clicking “Add node”, then click the settings button on the new green COSM node on your plan and input your COSM API Key, Feed number, and datastream name. That’s all! The COSM node will show you the response status of your HTTP request to push data to their service - be careful not to post data more than once every 15 seconds, or their server will cut you off.
No public wish lists :(
Forgot your password?
No account? Register one!