7 static const char *
const TAG =
"fs3000";
10 ESP_LOGCONFIG(TAG,
"Setting up FS3000...");
14 static const uint16_t RAW_DATA_POINTS_1005[9] = {409, 915, 1522, 2066, 2523, 2908, 3256, 3572, 3686};
15 static const float MPS_DATA_POINTS_1005[9] = {0.0, 1.07, 2.01, 3.0, 3.97, 4.96, 5.98, 6.99, 7.23};
17 std::copy(RAW_DATA_POINTS_1005, RAW_DATA_POINTS_1005 + 9, this->
raw_data_points_);
18 std::copy(MPS_DATA_POINTS_1005, MPS_DATA_POINTS_1005 + 9, this->
mps_data_points_);
21 static const uint16_t RAW_DATA_POINTS_1015[13] = {409, 1203, 1597, 1908, 2187, 2400, 2629,
22 2801, 3006, 3178, 3309, 3563, 3686};
23 static const float MPS_DATA_POINTS_1015[13] = {0.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 13.0, 15.0};
25 std::copy(RAW_DATA_POINTS_1015, RAW_DATA_POINTS_1015 + 13, this->
raw_data_points_);
26 std::copy(MPS_DATA_POINTS_1015, MPS_DATA_POINTS_1015 + 13, this->
mps_data_points_);
42 ESP_LOGW(TAG,
"Error reading data from FS3000");
49 for (uint8_t i : data) {
55 ESP_LOGW(TAG,
"Checksum failure when reading from FS3000");
60 uint16_t raw_value = (data[1] << 8) | data[2];
61 ESP_LOGV(TAG,
"Got raw reading=%i", raw_value);
70 ESP_LOGCONFIG(TAG,
"FS3000:");
72 LOG_UPDATE_INTERVAL(
this);
73 LOG_SENSOR(
" ",
"Air Velocity",
this);
87 }
else if (raw_value >= this->raw_data_points_[end]) {
93 while (raw_value > this->raw_data_points_[i]) {
99 (this->raw_data_points_[i] - this->raw_data_points_[i - 1]);
102 return (
float(raw_value - this->raw_data_points_[i - 1])) * slope + this->
mps_data_points_[i - 1];
uint16_t raw_data_points_[13]
void status_set_warning(const char *message="unspecified")
optional< std::array< uint8_t, N > > read_bytes_raw()
float fit_raw_(uint16_t raw_value)
float mps_data_points_[13]
void status_clear_warning()
void publish_state(float state)
Publish a new state to the front-end.
void dump_config() override
Implementation of SPI Controller mode.