I have the following code. It compiles fine and works in practice but still generates a error in the error list everytime I call my private class functions.
timer.cpp
#include <Arduino.h>
#include <timer.h>
bool MillisTimer::isFinished(int interval, int max_ticks)
{
if (ticks < max_ticks || max_ticks == 0)
{
if ((millis() - previous_ms) > interval)
{
previous_ms = millis();
ticks ++;
interval_trigger = 1;
}
else {interval_trigger = 0;}
}
else {interval_trigger = 0;}
return interval_trigger;
}
void MillisTimer::reset()
{
ticks = 0;
}
unsigned long MillisTimer::returnMillis()
{
return previous_ms;
}
MillisTimer Timer;
timer.h
// timer.h
#ifndef _TIMER_h
#define _TIMER_h
class MillisTimer
{
public:
bool isFinished(int interval, int max_ticks);
void reset();
unsigned long returnMillis();
private:
unsigned long previous_ms;
int ticks;
bool interval_trigger;
};
extern MillisTimer Timer;
#endif
Yet when I create an object MillisTimer myTimer();
I recieve an error, that somehow works when compiled. Am I missing some extra declaration outside of my code? I have all the files in src folder which is defined. Ive already tried moving them to lib or include, reinstalling PlatformIO and VScode.
Thanks in advance for any and all help!