I must be doing something wrong, or misunderstanding something. I have a library which has a function that calls delay, and this gives a compiler error:
Arduino: 1.5.6-r2 (Windows 7), Board: "Digistump DigiX (standard)"
C:\Users\tastewar\Documents\Arduino\libraries\TESTLIB\TESTLIB.cpp: In function 'void HoldOnAMInute(long unsigned int)':
C:\Users\tastewar\Documents\Arduino\libraries\TESTLIB\TESTLIB.cpp:27: error: 'delay' was not declared in this scope
This report would have more information with
"Show verbose output during compilation"
enabled in File > Preferences.
This is in a stripped down project/library just for reproducing this. Here's the sketch
#include <Stream.h>
#include <TESTLIB.h>
Foo myFoo(Serial2);
void setup() {
// put your setup code here, to run once:
Serial2.begin ( 9600 );
}
void loop() {
// put your main code here, to run repeatedly:
myFoo.bar ( "hello world" );
myFoo.HoldOnAMInute ( 1234 );
}
And the TESTLIB.h file:
class Foo : Stream
{
private:
Stream *_dev; // Somewhere to store the object's pointer
public:
Foo ( Stream& dev );
~Foo ( );
size_t write ( uint8_t val ); // Call a function on the stored object pointer
int available ( ) { return _dev->available ( ); }
int read ( ) { return _dev->read ( ); }
int peek ( ) { return _dev->peek ( ); }
void flush ( ) { return _dev->flush ( ); }
size_t bar ( char *string );
void HoldOnAMInute ( unsigned long ms );
};
and the TESTLIB.cpp file:
#include <Stream.h>
#include "TESTLIB.h"
Foo::Foo ( Stream& dev )
{
_dev = &dev;
}
Foo::~Foo ( )
{
}
size_t Foo::write ( uint8_t val )
{
return _dev->write(val);
}
size_t Foo::bar ( char *string )
{
size_t a;
a=print ( "prefix" );
return a+print ( string );
}
void HoldOnAMInute ( unsigned long ms )
{
delay ( ms );
}
Is there some very generic header file I have to include in my library, or before including the library's .h file?