2019-01-26 17:02:19 +00:00
|
|
|
/*
|
|
|
|
* rte_wx.h
|
|
|
|
*
|
|
|
|
* Created on: 26.01.2019
|
|
|
|
* Author: mateusz
|
|
|
|
*/
|
|
|
|
|
2020-09-20 12:13:24 +00:00
|
|
|
#ifndef RTE_WX_H_
|
|
|
|
#define RTE_WX_H_
|
|
|
|
|
2020-08-18 21:22:25 +00:00
|
|
|
#include "station_config.h"
|
2022-04-29 14:29:37 +00:00
|
|
|
#include "station_config_target_hw.h"
|
2020-08-18 21:22:25 +00:00
|
|
|
|
2019-01-26 17:02:19 +00:00
|
|
|
#include "drivers/dallas.h"
|
2020-08-18 21:22:25 +00:00
|
|
|
#include "drivers/analog_anemometer.h"
|
2020-09-07 21:25:58 +00:00
|
|
|
#include "davis_vantage/davis_qf_t.h"
|
|
|
|
#include "davis_vantage/davis_loop_t.h"
|
2020-08-18 21:22:25 +00:00
|
|
|
#include "umb_master/umb_master.h"
|
|
|
|
#include "umb_master/umb_qf_t.h"
|
|
|
|
|
2019-01-26 17:02:19 +00:00
|
|
|
#include "drivers/ms5611.h"
|
2020-06-23 22:17:59 +00:00
|
|
|
#include "drivers/bme280.h"
|
2019-01-26 17:02:19 +00:00
|
|
|
|
2022-10-20 07:06:54 +00:00
|
|
|
#include "float_average.h"
|
|
|
|
|
2019-01-26 17:02:19 +00:00
|
|
|
|
2020-01-04 13:15:33 +00:00
|
|
|
#define WIND_AVERAGE_LEN 18
|
|
|
|
|
2020-03-06 19:24:20 +00:00
|
|
|
#define PRESSURE_AVERAGE_LN 4
|
|
|
|
|
2020-04-04 21:09:00 +00:00
|
|
|
#define RTE_WX_MEASUREMENT_WIND 460
|
|
|
|
#define RTE_WX_MEASUREMENT_TEMPERATURE 100
|
|
|
|
#define RTE_WX_MEASUREMENT_PRESSUERE 300
|
|
|
|
|
2021-04-09 10:43:38 +00:00
|
|
|
extern float rte_wx_temperature_average_external_valid;
|
|
|
|
extern float rte_wx_temperature_internal, rte_wx_temperature_internal_valid;
|
2019-01-26 17:02:19 +00:00
|
|
|
extern float rte_wx_pressure, rte_wx_pressure_valid;
|
2020-03-06 19:24:20 +00:00
|
|
|
extern float rte_wx_pressure_history[PRESSURE_AVERAGE_LN];
|
|
|
|
extern uint8_t rte_wx_pressure_it;
|
2019-01-26 17:02:19 +00:00
|
|
|
|
2022-04-29 14:29:37 +00:00
|
|
|
#if defined(STM32L471xx)
|
|
|
|
extern int16_t rte_wx_temperature_average_dallas;
|
|
|
|
extern int16_t rte_wx_temperature_average_pt;
|
|
|
|
extern int16_t rte_wx_temperature_average_internal;
|
2022-05-31 11:31:39 +00:00
|
|
|
extern int16_t rte_wx_temperature_average_modbus;
|
2022-04-29 14:29:37 +00:00
|
|
|
extern uint16_t rte_wx_pressure_average;
|
2022-06-09 13:00:26 +00:00
|
|
|
|
2022-09-18 18:44:41 +00:00
|
|
|
#endif
|
2022-06-09 13:00:26 +00:00
|
|
|
extern uint16_t rte_wx_pm10; // 2.5um
|
|
|
|
extern uint16_t rte_wx_pm2_5; // 1um
|
2022-04-29 14:29:37 +00:00
|
|
|
|
2019-12-27 21:07:24 +00:00
|
|
|
extern uint16_t rte_wx_windspeed_pulses;
|
2020-01-04 13:15:33 +00:00
|
|
|
extern uint16_t rte_wx_windspeed[WIND_AVERAGE_LEN];
|
|
|
|
extern uint8_t rte_wx_windspeed_it;
|
|
|
|
extern uint16_t rte_wx_winddirection[WIND_AVERAGE_LEN];
|
|
|
|
extern uint8_t rte_wx_winddirection_it;
|
2020-02-01 22:20:17 +00:00
|
|
|
extern uint16_t rte_wx_winddirection_last;
|
2020-01-04 13:15:33 +00:00
|
|
|
extern uint16_t rte_wx_average_windspeed;
|
|
|
|
extern uint16_t rte_wx_max_windspeed;
|
2021-09-28 19:34:04 +00:00
|
|
|
extern int16_t rte_wx_average_winddirection;
|
2019-12-27 21:07:24 +00:00
|
|
|
|
2022-05-02 21:07:08 +00:00
|
|
|
inline uint16_t rte_wx_get_minimum_windspeed(void) {
|
|
|
|
uint16_t out = 0xFFFF;
|
|
|
|
|
|
|
|
for (int i = 0 ; i < WIND_AVERAGE_LEN; i++) {
|
|
|
|
if (rte_wx_windspeed[i] < out) {
|
|
|
|
out = rte_wx_windspeed[i];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return out;
|
|
|
|
}
|
|
|
|
|
2020-06-24 16:45:06 +00:00
|
|
|
extern int8_t rte_wx_humidity, rte_wx_humidity_valid;
|
2020-06-21 21:11:16 +00:00
|
|
|
|
2019-05-05 07:48:51 +00:00
|
|
|
extern uint8_t rte_wx_tx20_excessive_slew_rate;
|
|
|
|
|
2020-03-23 20:41:01 +00:00
|
|
|
extern dallas_qf_t rte_wx_current_dallas_qf, rte_wx_error_dallas_qf;
|
2022-10-20 07:06:54 +00:00
|
|
|
extern float_average_t rte_wx_dallas_average;
|
2019-01-26 17:02:19 +00:00
|
|
|
extern ms5611_qf_t rte_wx_ms5611_qf;
|
2020-06-24 16:45:06 +00:00
|
|
|
extern bme280_qf_t rte_wx_bme280_qf;
|
2020-09-07 21:25:58 +00:00
|
|
|
extern analog_wind_qf_t rte_wx_wind_qf;
|
2023-11-01 22:10:51 +00:00
|
|
|
extern uint8_t rte_wx_humidity_available;
|
2023-11-17 05:57:30 +00:00
|
|
|
extern uint8_t rte_wx_dallas_degraded_counter;
|
2019-01-26 17:02:19 +00:00
|
|
|
|
2020-02-23 17:22:37 +00:00
|
|
|
|
2020-02-23 06:50:22 +00:00
|
|
|
extern umb_frame_t rte_wx_umb;
|
2020-03-07 18:13:24 +00:00
|
|
|
extern umb_context_t rte_wx_umb_context;
|
2020-03-20 21:53:24 +00:00
|
|
|
extern uint8_t rte_wx_umb_last_status;
|
|
|
|
extern int16_t rte_wx_umb_channel_values[UMB_CHANNELS_STORAGE_CAPAC][2];
|
2020-04-10 20:54:30 +00:00
|
|
|
// stores the value in 0.1 incremenets
|
|
|
|
extern umb_qf_t rte_wx_umb_qf;
|
2020-02-23 06:50:22 +00:00
|
|
|
|
2020-09-07 21:25:58 +00:00
|
|
|
extern uint8_t rte_wx_davis_station_avaliable;
|
|
|
|
extern uint8_t rte_wx_davis_loop_packet_avaliable;
|
|
|
|
extern davis_loop_t rte_wx_davis_loop_content;
|
|
|
|
|
2020-09-20 12:13:24 +00:00
|
|
|
|
2020-01-04 13:15:33 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C"
|
|
|
|
{
|
|
|
|
#endif
|
|
|
|
|
|
|
|
void rte_wx_init(void);
|
2020-04-04 21:09:00 +00:00
|
|
|
void rte_wx_update_last_measuremenet_timers(uint16_t measurement_type);
|
2020-11-05 21:52:37 +00:00
|
|
|
void rte_wx_reset_last_measuremenet_timers(uint16_t measurement_type);
|
2024-04-18 20:15:54 +00:00
|
|
|
int8_t rte_wx_check_weather_measurements(void);
|
2020-11-05 21:52:37 +00:00
|
|
|
|
2020-01-04 13:15:33 +00:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
2019-01-26 17:02:19 +00:00
|
|
|
|
|
|
|
#endif /* RTE_WX_H_ */
|