Hey guys,
is there a way to use other libraries, for example the Ethernet library, in own, custom libraries?
Kind regards
Max
Hey guys,
is there a way to use other libraries, for example the Ethernet library, in own, custom libraries?
Kind regards
Max
Hello Max
is there a way to use other libraries, for example the Ethernet library, in own, custom libraries?
Yes.
For example, I wrote a library which uses the SPI library. In my .h
file, I include this ...
#include <SPI.h>
Then, in the begin()
method of my object class in the .cpp
file, I call the SPI methods I needed ...
ferroResult Hackscribble_Ferro::begin()
{
// Initialize SPI
SPI.begin();
SPI.setBitOrder(MSBFIRST);
SPI.setDataMode (SPI_MODE0);
SPI.setClockDivider(SPI_CLOCK_DIV2);
...
}
EDIT: I include both the SPI library and my library in the .ino
file ...
#include <SPI.h>
#include <Hackscribble_Ferro.h>
Regards
Ray
Due to limitations in the Arduino IDE, any libraries that you include in your own library must also be included in the sketch in which your library is used. Also, any libraries that those included libraries rely on also need manually including in the sketch.
It's a bit of a pain, but that's the Arduino IDE for you...
You could always switch to UECIDE which fixes that issue amongst many others.
Thank you guys for your answers.