9static const char *
const TAG =
"mpl3115a2";
12 uint8_t whoami = 0xFF;
34 ESP_LOGCONFIG(TAG,
"MPL3115A2:");
37 switch (this->error_code_) {
39 ESP_LOGE(TAG, ESP_LOG_MSG_COMM_FAIL);
42 ESP_LOGE(TAG,
"MPL3115A2 has invalid id");
45 ESP_LOGE(TAG,
"Setting up MPL3115A2 registers failed!");
49 LOG_UPDATE_INTERVAL(
this);
51 LOG_SENSOR(
" ",
"Pressure", this->
pressure_);
52 LOG_SENSOR(
" ",
"Altitude", this->
altitude_);
73 uint8_t buffer[5] = {0, 0, 0, 0, 0};
78 int32_t alt =
encode_uint32(buffer[0], buffer[1], buffer[2], 0);
79 altitude = float(alt) / 65536.0;
82 uint32_t p =
encode_uint32(0, buffer[0], buffer[1], buffer[2]);
92 ESP_LOGD(TAG,
"Got Temperature=%.1f°C Altitude=%.1f Pressure=%.1f",
temperature, altitude,
pressure);
BedjetMode mode
BedJet operating mode.
virtual void mark_failed()
Mark this component as failed.
void status_clear_warning()
bool write_byte(uint8_t a_register, uint8_t data, bool stop=true)
ErrorCode read_register(uint8_t a_register, uint8_t *data, size_t len, bool stop=true)
reads an array of bytes from a specific register in the I²C device
bool read_byte(uint8_t a_register, uint8_t *data, bool stop=true)
sensor::Sensor * temperature_
void dump_config() override
sensor::Sensor * altitude_
sensor::Sensor * pressure_
void publish_state(float state)
Publish a new state to the front-end.
@ MPL3115A2_REGISTER_STATUS_PDR
@ MPL3115A2_CTRL_REG1_OST
@ MPL3115A2_CTRL_REG1_ALT
@ MPL3115A2_CTRL_REG1_RST
@ MPL3115A2_REGISTER_PRESSURE_MSB
@ MPL3115A2_REGISTER_STATUS
@ MPL3115A2_CTRL_REG1_OS128
@ MPL3115A2_PT_DATA_CFG_TDEFE
@ MPL3115A2_PT_DATA_CFG_PDEFE
@ MPL3115A2_PT_DATA_CFG_DREM
Providing packet encoding functions for exchanging data with a remote host.
constexpr uint32_t encode_uint32(uint8_t byte1, uint8_t byte2, uint8_t byte3, uint8_t byte4)
Encode a 32-bit value given four bytes in most to least significant byte order.
constexpr uint16_t encode_uint16(uint8_t msb, uint8_t lsb)
Encode a 16-bit value given the most and least significant byte.
void IRAM_ATTR HOT delay(uint32_t ms)