I have a type I want to use:
typedef struct timeAndLux_ {
long luxValue;
unsigned long timeStamp;
}timeAndLux_t;
and I want to make a class that uses an array of 5 of these
how do I declare it?
header file:
#ifndef _LightSensor_h
#define _LightSensor_h
#if defined(ARDUINO) && ARDUINO >= 100
#include "arduino.h"
#endif
class LightSensor {
public:
LightSensor(int sensorNumber, int minLevel, double calibrationValue, double detectionVariance);
int SensorNumber;
int MinLevel;
long GetReading();
long GetBaseline();
bool GetLowWatch();
bool CheckWarning();
bool EnterNewReadingValue(long reading, unsigned long timeStamp);
private:
double _Calibration;
long _Baseline;
bool _AlarmState;
bool _ObjectDetected;
timeAndLux_t _EmptyLuxReadings[5];
//timeAndLux_t* _EmptyLuxReadings = (timeAndLux_t*)malloc(sizeof(timeAndLux_t) * 5);
unsigned long _LowWatchTimeStamp;
bool _LowWatch;
bool _LowWarning;
long _Reading;
bool _LowLightAlarm;
double _DetectionVariance;
long GetAveFromArray(long* arrayToMean, int len);
};
#endif
and the start of my CPP is:
#include "LightSensor.h"
//#include <Vector-1.2.1>
typedef struct timeAndLux_ {
long luxValue;
unsigned long timeStamp;
}timeAndLux_t;
LightSensor::LightSensor(int sensorNumber, int minLevel, double calibrationValue, double detectionVariance) {
timeAndLux_t _EmptyReadings[5] = {
{0, 0},
{0, 0},
{0, 0},
{0, 0},
{0, 0}
};
SensorNumber = sensorNumber;
MinLevel = minLevel;
_Calibration = calibrationValue;
_DetectionVariance = detectionVariance;
}
but I always get an error 'timeAndLux_t' does not name a type