Create own libraries

Hi,

I recently downloaded a librarie to control the Wii-Nunchuk(https://github.com/timtro/wiinunchuck-h). Now I want to implement this librarie into my project.

I found this article but it wasn’t that helpful. https://xod.io/docs/guide/creating-libraries/

Do I have to add a new Patch and paste the code of the librarie into a “not-implemented-in-xod” node?

regards AarZeon

Rather than manually downloading the library, In XOD go to File > Add Library to install it. The alternative is to manually install the library in your XOD workspace under __lib__

Hi gweimer

I’ confused with the _ _lib _ _

I placed the .h document into the workspace folder and now?

Regards AarZeon

Sorry. I mis-read the original post. You did not download a XOD library, you downloaded Arduino C++ code.

You can probably re-use most of the code in XOD nodes, but you will not be able to just copy the code as-is into a XOD node.

Looks like what you downloaded is a header file defining a bunch of functions. You will need to manually install the header file in your local XOD (and re-copy it every time you upgrade/re-install XOD; unfortunately, there is not yet a good way to handle adding header files to XOD). Then you will need to figure out which of the function calls you need to be able to use and create XOD nodes for them, but it probably won’t be a direct one-to-one mapping (for instance, the init function will probably be part of a node implementing other actions). Deciding how to map these functions to XOD nodes may not be a trivial exercise.

If you are new to programming and/or XOD, this is probably not a good place to start. It would be much better to get comfortable working with XOD with easier projects before attempting this. You can look at some of the existing I2C nodes or the servo node to get an idea of how nodes can make use of header files like the one you are trying to use.

gweimer/ir-remote is an example of creating a node from headers that are not native to XOD. It contains a folder that must be manually copied into the XOD directory in the USER folder (under AppData\Local\Programs\xod-client-electron\resources\arduino-libraries)

2 Likes