46 #include "lib/sensors.h"
49 #ifndef WEATHER_METER_H_
50 #define WEATHER_METER_H_
56 #define WEATHER_METER_RAIN_GAUGE 0x01
57 #define WEATHER_METER_WIND_VANE 0x02
58 #define WEATHER_METER_WIND_VANE_AVG_X 0x03
59 #define WEATHER_METER_ANEMOMETER 0x04
60 #define WEATHER_METER_ANEMOMETER_AVG 0x05
61 #define WEATHER_METER_ANEMOMETER_AVG_X 0x06
62 #define WEATHER_METER_ANEMOMETER_MAX 0x07
65 #ifdef WEATHER_METER_CONF_AVG_PERIOD
66 #define WEATHER_METER_AVG_PERIOD WEATHER_METER_CONF_AVG_PERIOD
68 #define WEATHER_METER_AVG_PERIOD 120
71 #define WEATHER_METER_ACTIVE SENSORS_ACTIVE
72 #define WEATHER_METER_ANEMOMETER_INT_OVER HW_INT_OVER_THRS
73 #define WEATHER_METER_ANEMOMETER_INT_DIS HW_INT_DISABLE
74 #define WEATHER_METER_RAIN_GAUGE_INT_OVER (HW_INT_OVER_THRS << 1)
75 #define WEATHER_METER_RAIN_GAUGE_INT_DIS (HW_INT_DISABLE << 1)
77 #define WEATHER_METER_SUCCESS 0
78 #define WEATHER_METER_ERROR (-1)
81 #define WEATHER_METER_ANEMOMETER_SPEED_1S (1200)
84 #define WEATHER_METER_AUX_RAIN_MM 2794
87 #ifdef WEATHER_METER_RAIN_CONF_RETURN
88 #define WEATHER_METER_RAIN_RETURN_TICKS WEATHER_METER_RAIN_CONF_RETURN
90 #define WEATHER_METER_RAIN_RETURN_TICKS 1
98 #define WEATHER_METER_REGISTER_ANEMOMETER_INT(ptr) anemometer_int_callback = ptr;
99 #define WEATHER_METER_REGISTER_RAIN_GAUGE_INT(ptr) rain_gauge_int_callback = ptr;
100 extern void (*anemometer_int_callback)(uint16_t value);
101 extern void (*rain_gauge_int_callback)(uint16_t value);
108 #ifdef WEATHER_METER_CONF_ANEMOMETER_PIN
109 #define ANEMOMETER_SENSOR_PIN WEATHER_METER_CONF_ANEMOMETER_PIN
111 #define ANEMOMETER_SENSOR_PIN 1
113 #ifdef WEATHER_METER_CONF_ANEMOMETER_PORT
114 #define ANEMOMETER_SENSOR_PORT WEATHER_METER_CONF_ANEMOMETER_PORT
116 #define ANEMOMETER_SENSOR_PORT GPIO_D_NUM
118 #ifdef WEATHER_METER_CONF_ANEMOMETER_VECTOR
119 #define ANEMOMETER_SENSOR_VECTOR WEATHER_METER_CONF_ANEMOMETER_VECTOR
121 #define ANEMOMETER_SENSOR_VECTOR NVIC_INT_GPIO_PORT_D
129 #ifdef WEATHER_METER_CONF_RAIN_GAUGE_PIN
130 #define RAIN_GAUGE_SENSOR_PIN WEATHER_METER_CONF_RAIN_GAUGE_PIN
132 #define RAIN_GAUGE_SENSOR_PIN 2
134 #ifdef WEATHER_METER_CONF_RAIN_GAUGE_PORT
135 #define RAIN_GAUGE_SENSOR_PORT WEATHER_METER_CONF_RAIN_GAUGE_PORT
137 #define RAIN_GAUGE_SENSOR_PORT GPIO_D_NUM
139 #ifdef WEATHER_METER_CONF_RAIN_GAUGE_VECTOR
140 #define RAIN_GAUGE_SENSOR_VECTOR WEATHER_METER_CONF_RAIN_GAUGE_VECTOR
142 #define RAIN_GAUGE_SENSOR_VECTOR NVIC_INT_GPIO_PORT_D
150 #ifdef WEATHER_METER_CONF_RAIN_WIND_VANE_ADC
151 #define WIND_VANE_ADC WEATHER_METER_CONF_RAIN_WIND_VANE_ADC
153 #define WIND_VANE_ADC ZOUL_SENSORS_ADC3
157 #define WEATHER_METER_SENSOR "Sparkfun weather meter"
159 extern const struct sensors_sensor weather_meter;
Implementation of a generic module controlling Zoul sensors.