ESPHome 2026.11.0b6
Loading...
Searching...
No Matches
sensor_mlx90393.h
Go to the documentation of this file.
1#pragma once
2
3#ifndef USE_BK72XX
4
5#include <MLX90393.h>
6#include <MLX90393Hal.h>
10#include "esphome/core/hal.h"
11
12namespace esphome::mlx90393 {
13
24
25class MLX90393Cls final : public PollingComponent, public i2c::I2CDevice, public MLX90393Hal {
26 SUB_SENSOR(x)
27 SUB_SENSOR(y)
28 SUB_SENSOR(z)
29 SUB_SENSOR(t)
30
31 public:
32 void setup() override;
33 void dump_config() override;
34 void update() override;
35
36 void set_drdy_gpio(GPIOPin *pin) { drdy_pin_ = pin; }
37
38 void set_oversampling(uint8_t osr) { oversampling_ = osr; }
39 void set_t_oversampling(uint8_t osr2) { temperature_oversampling_ = osr2; }
40 void set_resolution(uint8_t xyz, uint8_t res) { resolutions_[xyz] = res; }
41 void set_filter(uint8_t filter) { filter_ = filter; }
42 void set_gain(uint8_t gain_sel) { gain_ = gain_sel; }
43 void set_temperature_compensation(bool temperature_compensation) {
44 temperature_compensation_ = temperature_compensation;
45 }
46 void set_hallconf(uint8_t hallconf) { hallconf_ = hallconf; }
47 // overrides for MLX library
48
49 // disable lint because it keeps suggesting const uint8_t *response.
50 // this->read() writes data into response, so it can't be const
51 bool transceive(const uint8_t *request, size_t request_size, uint8_t *response,
52 size_t response_size) override; // NOLINT
53 bool has_drdy_pin() override;
54 bool read_drdy_pin() override;
55 void sleep_millis(uint32_t millis) override;
56 void sleep_micros(uint32_t micros) override;
57
58 protected:
59 MLX90393 mlx_;
60 uint8_t gain_;
63 uint8_t filter_;
64 uint8_t resolutions_[3]{0};
66 uint8_t hallconf_{0xC};
67 GPIOPin *drdy_pin_{nullptr};
68
70 uint8_t apply_setting_(MLX90393Setting which);
71
74};
75
76} // namespace esphome::mlx90393
77
78#endif // USE_BK72XX
virtual void setup()
Where the component's initialization should happen.
Definition component.cpp:84
This class simplifies creating components that periodically check a state.
Definition component.h:532
This Class provides the methods to read/write bytes from/to an i2c device.
Definition i2c.h:144
void verify_settings_timeout_(MLX90393Setting stage)
Regularly checks that our settings are still applied.
bool verify_setting_(MLX90393Setting which)
uint8_t apply_setting_(MLX90393Setting which)
bool z
Definition msa3xx.h:1
uint32_t IRAM_ATTR HOT micros()
Definition hal.cpp:43
uint32_t IRAM_ATTR HOT millis()
Definition hal.cpp:25
static void uint32_t
uint16_t x
Definition tt21100.cpp:5
uint16_t y
Definition tt21100.cpp:6