Including external libraries
- This topic has 6 replies, 2 voices, and was last updated 8 years, 11 months ago by soundanalogous.
-
AuthorPosts
-
April 25, 2014 at 1:39 PM #980nikolasParticipant
Hey! Great work guys!
I’ve been trying to implement an application in which I am reading over serial the data from a PS2 mouse.
This is relatively straightforward using the ps2 library.However, I cannot figure out how to include the ps2 library in my breakout code, to be able to use the same functionality.
Is this possible?
Thanks in advance for the help!
Nikolas
April 25, 2014 at 2:04 PM #982soundanalogousMemberI need more info to understand exactly what it is you are trying to do. By “ps2 library” are you referring to an arduino ps2 library or a JavaScript ps2 library (which would require some sort of a proxy)?
Are you trying to include a ps2 library in the Arduino code or in the Breakout JavaScript code?
April 25, 2014 at 3:05 PM #983nikolasParticipantThanks for the reply!
I already have a working sketch for arduino for getting the input, using this arduino library: http://playground.arduino.cc/ComponentLib/Ps2mouse
The way it works is that at the beginning of the sketch, you do:
#include <ps2.h>
PS2 mouse(6, 5);so that later on you can do:
mouse.write(0xff); // reset
mouse.read(); // ack byte
etc…So basically I could port this code to Breakout Javascript, as long as I can include the Arduino library ps2.h.
Thanks again!
April 25, 2014 at 11:13 PM #984soundanalogousMemberYou will need to create a custom Firmata sketch that mixes the ps2 functionality with any other functionality you may need for your application (analog i/o, digital i/o, i2c, etc).
This is not easy however. Do you know which functionality you need other than the ps2 device or is the ps2 device the only component you’re connecting to the Arduino?
April 25, 2014 at 11:13 PM #985soundanalogousMemberYou will need to create a custom Firmata sketch that mixes the ps2 functionality with any other functionality you may need for your application (analog i/o, digital i/o, i2c, etc).
This is not easy however. Do you know which functionality you need other than the ps2 device or is the ps2 device the only component you’re connecting to the Arduino?
April 25, 2014 at 11:25 PM #986nikolasParticipantI ended up just modifying the ps2 library into normal arduino code that I can have inside a single script.
However this might be an interesting feature request in general, i.e. the ability to load external libraries, without having to customize Firmata.April 25, 2014 at 11:34 PM #987soundanalogousMemberIt would be impossible to load an external library without writing custom firmware unless that external library already conforms to the Firmata protocol. Most libraries do not (there is really no reason to) so you have to write a wrapper to make it conform to the protocol (wrapping the sysex send and receive methods of the Arduino Firmata library). You then need to add support to the client side (JavaScript) code as well.
That said, there is work being done to make adding custom features easier: https://github.com/firmata/arduino/tree/configurable/examples/ConfigurableFirmata. ConfigurableFirmata is like a plugin system for Firmata that makes it easier to mix and match custom and standard features. You would still have to wrap an external library using the proper Firmata methods.
-
AuthorPosts
- The forum ‘Forum’ is closed to new topics and replies.