I have the following code that will not compile and I cannot figure out what I am doing wrong:
I get the following errors when attempting to compile:
Serial_Output.cpp: In function ‘void setup()’:
Serial_Output:6: error: ‘FreqMeasure’ was not declared in this scope
Serial_Output.cpp: In function ‘void loop()’:
Serial_Output:13: error: ‘FreqMeasure’ was not declared in this scope
#include <FreqMeasure.h>
void setup()
{
Serial.begin(57600);
FreqMeasure.begin();
}
double sum=0;
int count=0;
void loop() {
if (FreqMeasure.available()) {
// average several reading together
sum = sum + FreqMeasure.read();
count = count + 1;
if (count > 30) {
double frequency = F_CPU / (sum / count);
Serial.println(frequency);
sum = 0;
count = 0;
}
}
}
In the same folder are capture.h, FreqMeasure.cpp, and FreqMeasure.h
FreqMeasure.h:
#ifndef FreqMeasure_h
#define FreqMeasure_h
#include <inttypes.h>
class FreqMeasureClass {
public:
static void begin(void);
static uint8_t available(void);
static uint32_t read(void);
static void end(void);
};
extern FreqMeasureClass FreqMeasure;
#endif
FreqMeasure.cpp (I removed the contents of the procedures/functions to save space, but I can post them if needed):
#include "FreqMeasure.h"
#include "capture.h"
#define FREQMEASURE_BUFFER_LEN 12
static volatile uint32_t buffer_value[FREQMEASURE_BUFFER_LEN];
static volatile uint8_t buffer_head;
static volatile uint8_t buffer_tail;
static uint16_t capture_msw;
static uint32_t capture_previous;
void FreqMeasureClass::begin(void)
{ ... }
uint8_t FreqMeasureClass::available(void)
{ ... }
uint32_t FreqMeasureClass::read(void)
{ ... }
void FreqMeasureClass::end(void)
{ ... }
ISR(TIMER_OVERFLOW_VECTOR)
{ ... }
ISR(TIMER_CAPTURE_VECTOR)
{ ... }
FreqMeasureClass FreqMeasure;
Sure I must be doing something stupid, but this has my project stalled so any help would be appreciated.
Dpicts