44 lines
876 B
C++
44 lines
876 B
C++
#ifndef SENSOR_Anemometer_H
|
|
#define SENSOR_Anemometer_H
|
|
|
|
#include "sensordata.h"
|
|
#include <Homie.h>
|
|
|
|
|
|
|
|
class Sensor_Anemometer
|
|
{
|
|
|
|
private:
|
|
HomieNode *sensorNode; //reference to HomieNode
|
|
|
|
int pin;
|
|
|
|
struct sensordata data; //struct values are changed in setup()
|
|
//value in [m/s]
|
|
|
|
bool init_ok;
|
|
|
|
unsigned long anemometer_lasttimereset=0;
|
|
|
|
|
|
#define ANEMOMETER_DEBOUNCETIME 15 //15ms between pulses is approx 85m/s windspeed
|
|
|
|
|
|
public:
|
|
Sensor_Anemometer(int p);
|
|
|
|
|
|
void init();
|
|
void setSettings(float minchange, unsigned long senddelaymax, unsigned long readdelay);
|
|
void advertise(HomieNode& p_sensorNode);
|
|
void sensorloop();
|
|
//void ICACHE_RAM_ATTR interrupt_anemometer();
|
|
|
|
uint16_t anemometer_pulsecounter=0; //counted pulses since last reset
|
|
unsigned long anemometer_lastpulse_fordebounce=0;
|
|
};
|
|
|
|
#endif
|
|
|