Open googoogagalala opened 4 years ago
Hello,
To add a library, let's say mydriver.h mydriver.cpp you simply add the files to your folder where the main.cpp file is located, and also include the header.
#include <Arduino.h>
#include "mydriver.h"
....
// Your code
Then to compile it do:
g++ -lpiduino main.cpp mydriver.cpp -o output
And to run run it:
sudo ./output
However, PiDuino doesn't support the full Arduino library, so if you are trying to add an Arduino library some functions may not work. Here is a reference of all the Arduino functions that work with PiDuino: http://nvsl.github.io/PiDuino_Library/Reference.html Therefore, if mydriver.cpp includes Arduino functions that are not listed in the PiDuino Library reference then you will need to implement them yourself.
Also, there is a bug in PiDuino that doesn't allow you to add multiple Arduino.h headers. I'm currently working on a version of this library that solves this an many other problems and targets all Linux-based boards, not only the Pi called Linuxduino https://nvsl.github.io/Linuxduino/. However, I still haven't made an official release for the C++ code.
I hope I was able to help you. Feel free to ask any other question.
I love the work you have done on this project. Say someone has created a device along with driver software in .cpp and .h files to use their device. How could you correctly add these libraries to work with PiDuino? say if I wanted to add softwareSerial, hardware serial, print, printable, etc.