esphome/esphome/components/fs3000/fs3000.h
kahrendt 6ecf4ecac6
FS3000 sensor (#4502)
* Add support for FS3000 sensor.

* add fs3000 to test yaml

* Clean up code with clang.

* Clean up sensor.py file.

* Update CODEOWNERS file.

* Apply suggestions from code review regarding sensor.py

Co-authored-by: Jesse Hills <3060199+jesserockz@users.noreply.github.com>

* Apply suggestions from code review for basic issues regarding C++ code

- removed unnecessary default for FS3000Model
- use "this->" before any sensor update

Co-authored-by: Jesse Hills <3060199+jesserockz@users.noreply.github.com>

* Move model setup to overall setup function.

* Remove unneeded CONF_ID from sensor.py

* Run clang-format

* Move set_model code to header file now that it is simplified

* Update fs3000.h

---------

Co-authored-by: Jesse Hills <3060199+jesserockz@users.noreply.github.com>
2023-03-07 04:25:14 +00:00

35 lines
865 B
C++

#pragma once
#include "esphome/core/component.h"
#include "esphome/components/sensor/sensor.h"
#include "esphome/components/i2c/i2c.h"
namespace esphome {
namespace fs3000 {
// FS3000 has two models, 1005 and 1015
// 1005 has a max speed detection of 7.23 m/s
// 1015 has a max speed detection of 15 m/s
enum FS3000Model { FIVE, FIFTEEN };
class FS3000Component : public PollingComponent, public i2c::I2CDevice, public sensor::Sensor {
public:
void setup() override;
void update() override;
void dump_config() override;
float get_setup_priority() const override { return setup_priority::DATA; }
void set_model(FS3000Model model) { this->model_ = model; }
protected:
FS3000Model model_{};
uint16_t raw_data_points_[13];
float mps_data_points_[13];
float fit_raw_(uint16_t raw_value);
};
} // namespace fs3000
} // namespace esphome