Hi,
I'd like to write a class that inherits from another class I've written. This works partly. Problem is that I cannot use functions in a function of the inherited class. I get this error:
/Users/macbook/Dropbox/code/_arduino/libraries/ColorLight/ColorLight_effect.cpp:27: error: 'lerpf' was not declared in this scope
/Users/macbook/Dropbox/code/_arduino/libraries/ColorLight/ColorLight_effect.cpp:32: error: 'colorInt' was not declared in this scope
I couldn't find any information on this. There is a tutorial, but thats partly finished:
http://www.arduino.cc/playground/Code/Hierarchy
This is the .h file of the "main" class
#ifndef ColorLight_h
#define ColorLight_h
#include "WProgram.h"
class ColourBase
{
public:
ColourBase();
float interpolation;
int baseHue;
unsigned long wheelColor[4];
unsigned long tintColor[4];
unsigned long shadeColor[4];
unsigned long interpolatedColor[4];
};
class ColourPalette
{
public:
ColourPalette();
void setHue(int);
void setComplementOffset(int);
void setHueAngle(int);
unsigned long getColour(byte);
unsigned long colorInt(unsigned long, unsigned long, unsigned long, unsigned long);
unsigned long colorInt(unsigned long, unsigned long, unsigned long);
int mainHue;
int complementOffset;
int hueAngle;
int complementAngle;
int minSaturation;
int maxSaturation;
int minBrightness;
int maxBrightness;
ColourBase cArray[6];
void updatePalette();
void calculateShadeTint(ColourBase&);
void updateInterpolation(ColourBase&);
void calculateRGB(ColourBase &);
void getRGB(unsigned long*);
int lerpf(int, int, float);
};
#endif
And the .h of the effect class that inherits from the ColourPalette.
#include "WProgram.h"
#ifndef ColorLight_effect_h
#define ColorLight_effect_h
#include "ColorLight.h"
class Effect : public ColourPalette
{ public:
Effect();
float time; // time
float contrast;
byte noiseArray[23];
int colorArray[23];
unsigned long colorMap[256];
unsigned long lerpColorRGB(unsigned long, unsigned long, float);
};
#endif
In the lerpColorRGB function I'd like to use two functions of the ColourPalette class.
lerpf and colorInt
The .cpp file.
#include "WProgram.h"
#include "ColorLight_effect.h"
Effect::Effect()
{ for (int i=0;i<23; i++)
{ noiseArray[i] = 0;
colorArray[i] = 0;
};
for (int i=0;i<256; i++)
{ colorMap[i] = 0;
};
}
unsigned long lerpColorRGB(unsigned long c1, unsigned long c2, float amt)
{
unsigned long a1 = (c1 >> 24) & 0xFF;
unsigned long r1 = (c1 >> 16) & 0xff;
unsigned long g1 = (c1 >> 8) & 0xff;
unsigned long b1 = c1 & 0xff;
unsigned long a2 = (c2 >> 24) & 0xFF;
unsigned long r2 = (c2 >> 16) & 0xff;
unsigned long g2 = (c2 >> 8) & 0xff;
unsigned long b2 = c2 & 0xff;
unsigned long ao = lerpf(a1, a2, amt);
unsigned long ro = lerpf(r1, r2, amt);
unsigned long go = lerpf(g1, g2, amt);
unsigned long bo = lerpf(b1, b2, amt);
return colorInt(ao,ro,go,bo);
}