Giter VIP home page Giter VIP logo

Comments (6)

ericgundrum avatar ericgundrum commented on September 21, 2024

Unfortunately I have zero experience with what you are trying to do. However, my reading suggests you should be able to wrap your library as a node.js module with a JavaScript interface. Then, with your node module installed, it would be easy to call it from the Node page of a Coder app. With a little more JavaScript and html you could provide the front end and complete your app.

I imagine the hardest part is wrapping your python code in a module. I'd look for existing modules that might serve as examples of wrapping non-js code. I think this is how node is implemented, so there should be plenty of examples. And, maybe the node docs have a detailed explanation.

I found wikipedia a good place to start when learning about node: http://en.wikipedia.org/wiki/Node.js

from coder.

jmstriegel avatar jmstriegel commented on September 21, 2024

@karan259 this is great. I think that if I were going about this, instead of cross compiling, I'd create a little daemon in Python that exposes a simple http/json API on a port on localhost. Then you can talk to that daemon easily from node.js in coder. You could also make a nice bundle in Coder, say "BrickPiLib", that provides a common library/interface for front end and back end javascript to to shuttle commands to the lego modules.

Your Python daemon probably needs to keep track of all the sensors and motors and then expose api endpoints like the following, and any coder node.js -- or a nice wrapper you make in BrickPiLib ;) -- should be able to talk to it fairly easily.

POST /sensor/[0,1,2]
data:
'type': [touch,temp,light,...]

GET /sensors
returned data:
{
sensors: [
{ 'type': 'touch', 'value': 'pressed' },
{ 'type': 'raw', 'value': .0012 },
{ 'type': 'temp', 'value': 101.03 }
]
}

POST /motor/[0,1,2]
data:
'direction': [0,1]
'speed': 50
...

GET /motors
returned data:
{
motors: [
{ 'direction': 0, 'rotation': 3, 'speed': 50 },
{ 'direction': 1, 'rotation': 0, 'speed': 59 },
{ 'direction': 0, 'rotation': 12, 'speed': 0 },
]
}

from coder.

karan259 avatar karan259 commented on September 21, 2024

@ericgundrum Creating a Node.js module is one way of going forward but since I have zero experience in that, it might be too much for me at this time. @jmstriegel using a python daemon with JSON looks like a good way forward. It may even allow us to support other languages too. Thanks for the reply

from coder.

joesanford avatar joesanford commented on September 21, 2024

Hi Karan,

I have developed (and am continuing to develop) a system that works with the BrickPi, which includes using Coder itself as well as another Google tool, Blockly. Feel free to check out our code here: https://github.com/tufts-LPC/blockytalky

from coder.

coffeechug avatar coffeechug commented on September 21, 2024

So, this may sound like a super stupid question so pardon my lack of
awareness, but I am really interested in what you are sharing here. What
actual parts do I need to experiment with this code and your ideas?

On Mon, Nov 18, 2013 at 4:03 PM, Joe [email protected] wrote:

Hi Karan,

I have developed (and am continuing to develop) a system that works with
the BrickPi, which includes using Coder itself as well as another Google
tool, Blockly. Feel free to check out our code here:
https://github.com/tufts-LPC/blockytalky


Reply to this email directly or view it on GitHubhttps://github.com//issues/49#issuecomment-28742704
.

-------------------------------------------------
Aaron Maurer

--------------------------------------------------Q: Why is this email
five sentences or less?A: http://five.sentenc.es http://five.sentenc.es

*MY BLOG *http://coffeeforthebrain.blogspot.com/
*ABOUT ME *
http://coffeeforthebrain.blogspot.com/p/coffee-for-brain-book-swap.html
*TWITTER *https://twitter.com/coffeechugbooks
*GOOGLE + *https://plus.google.com/u/0/113960577497815089175/posts

This email is off the record (blogs and tweets too) unless we agree
otherwise.

from coder.

joesanford avatar joesanford commented on September 21, 2024

If you have the BrickPi (and I'm assuming a Raspberry Pi since you're looking at Coder) you already have everything you need to get going. Just clone the repo, follow the install instructions, and you'll be off and going. BlockyTalky works side by side with Coder, and we hope to soon add functionality in Coder to create interfaces for BlockyTalky.

from coder.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.