hardbap / firmata Goto Github PK
View Code? Open in Web Editor NEWA Ruby implementation of the Firmata protocol.
License: MIT License
A Ruby implementation of the Firmata protocol.
License: MIT License
[This is from an email from Steven Morss]
In board.rb, you have a toggle_pin_reporting() method which turns on/off the reporting for all the analog and digital ports. For the digital ports, this is OK, since they only report on change, so you won't get flooded with events. The analog ports report every sampling interval, which defaults to about 50 times per second. For 16 ports (on the Mega for instance), that can be a lot of samples. More importantly, if the pins are not in analog mode (they can be in digital mode), reading them back only gives back bad data, so they shouldn't be sampled. An easier way to handle things is not to set the report bits on the analog ports at all. In the Arduino C code, when a port is set to analog/digital mode, it's analog report bit is set/cleared automatically (see setPinModeCallback) in the Firmata code. So setting the analog polling bits is done already - no need to do it again
I saw the the serialport support ruby 2.2.0 in gem version 1.3.1
but firmdata still depend on 1.1.x
Do you have plan to update the dependency of serialport?
Read, Write and Config.
Here's my setup:
NOTE: I tried to downgrade to 2.2 (as suggested in the README file) but the Arduino app (v1.0.5) threw some errors (a lot of "was not declared in this scope" for TOTAL_PORTS, Firmata, reportPINs, etc) and I wasn't able to do it.
I know Firmata is working in the Arduino because I used a software called firmata_test
(http://firmata.org/wiki/Main_Page#Firmata_Test_Program) and the arduino_firmata
gem and was able to change the state of the pins.
Here's the code I'm using:
require 'firmata' # v0.1.1
# tried with /dev/tty.usbmodemfa131 too, same results
board = Firmata::Board.new('/dev/cu.usbmodemfa131')
# this does nothing, it gets stuck there, I need to Ctrl-C
board.connect
I put some "puts" in the connect
method (https://github.com/hardbap/firmata/blob/v0.1.1/lib/firmata/board.rb#L96), it never executes once('report_version', ->() do
and it keeps looping in until connected?
forever.
I tried it installing Ubuntu 12.04 in a VirtualBox, same results, even though some linux users have reported this gem works for them.
Any idea?
[This is from an email from Steven Morss]
When I was looking over the Firmata servo code, I noticed there's a SERVO_CONFIG message that allows you to set the max and min angles of the servo. I didn't see the message implemented in your board.rb code.
I didn't see a way to set the Firmata analog sampling Rate. Look in the Firmata code for SAMPLING_INTERVAL (0x7a) to see how it works.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.