A bug in an oobject using an other objet
hey guys,
i m trying program arduino mega 2560.
i created 2 libraries : 1 called "relay" , other called "shutter".
the second library use first library in code. ve got message error :
i think don't have error in library called ralay because have tested it. think it's error in constructor of class shutter.
i let @ general code :
then let @ library "shutter"
shutter.h :
shutter.cpp :
if have questions project or code can answer you.
thank you,
frank
i m trying program arduino mega 2560.
i created 2 libraries : 1 called "relay" , other called "shutter".
the second library use first library in code. ve got message error :
code: [select]
shutter\shutter.cpp.o: in function `shutter':
c:\program files (x86)\arduino\libraries\shutter/shutter.cpp:11: undefined reference `relay::relay(int)'
c:\program files (x86)\arduino\libraries\shutter/shutter.cpp:11: undefined reference `relay::relay(int)'
i think don't have error in library called ralay because have tested it. think it's error in constructor of class shutter.
i let @ general code :
code: [select]
#include <shutter.h>
/*
shutter shutertest(pin_of_the_relay1, pin_of_the_relay2, pin_of_the_button);
*/
shutter shuttertest(1,2,3);
void setup()
{
}
void loop()
{
}
then let @ library "shutter"
shutter.h :
code: [select]
#ifndef shutter_h
#define shutter_h
#include "arduino.h"
#include "..\relay\relay.h"
class shutter // object shutter
{
public :
shutter(int pinrelay1, int pinrelay2, int pinbouton);
void open(); //open shutter
void close(); //close shutter
bool ispushed(); //is button of shutter pushed ? 1 if yes 0 if no
bool isactivated(); //is button of shutter activated ? 1 if yes 0 if no
void setactivated(boolean a); //change value of _activated
void stopaction(); //some times after using open or close method, should use method.
private :
boolean _activated;
int _pinbouton;
relay _relay1;
relay _relay2;
};
#endif
shutter.cpp :
code: [select]
/*
shutter.cpp - bibliothèque pour gérer les volets. | shutter.cpp - library manage shutters
_________ |
auteur frank filoda |
création : 19/12/2014 |
*/
#include "shutter.h"
shutter::shutter(int pinrelay1, int pinrelay2, int pinbouton) : _pinbouton(pinbouton), _activated(1), _relay1(pinrelay1), _relay2(pinrelay2)
{
}
void shutter::open()
{
_relay2.off();
_relay1.on();
_relay2.on();
}
void shutter::close()
{
_relay2.off();
_relay1.off();
_relay2.on();
}
bool shutter::ispushed()
{
return 1;
}
bool shutter::isactivated()
{
return _activated;
}
void shutter::setactivated(boolean a)
{
if(a)
{
_activated = 1;
}
else
{
_activated = 0;
}
}
void shutter::stopaction()
{
_relay2.off();
}
if have questions project or code can answer you.
thank you,
frank
you including relay.h wrong. sketch copied location compile , relay lib not exist there. need ide import shutter library. more info: http://arduino.land/faq/content/1/3/en/what-does-the-ide-change-in-my-sketch.html << third bullet point explains.
also ensure lib.h same folder, case matters ( relay or relay ):
in sketch need include both libs:
and shutter.h
also ensure lib.h same folder, case matters ( relay or relay ):
in sketch need include both libs:
code: [select]
#include <shutter.h>
#include <relay.h>
/*
shutter shutertest(pin_of_the_relay1, pin_of_the_relay2, pin_of_the_button);
*/
shutter shuttertest(1,2,3);
void setup()
{
}
void loop()
{
}
and shutter.h
code: [select]
#ifndef shutter_h
#define shutter_h
#include "arduino.h"
#include <relay.h>
class shutter // object shutter
{
Arduino Forum > Using Arduino > Programming Questions > A bug in an oobject using an other objet
arduino
Comments
Post a Comment