ESPHome 2026.11.0-dev
Loading...
Searching...
No Matches
ttp229_lsf.cpp
Go to the documentation of this file.
1#include "ttp229_lsf.h"
2#include "esphome/core/log.h"
3
5
6ESPHOME_LOG_TAG(TAG, "ttp229_lsf");
7
9 uint8_t data[2];
10 if (this->read(data, 2) != i2c::ERROR_OK) {
11 this->mark_failed(LOG_STR(ESP_LOG_MSG_COMM_FAIL));
12 return;
13 }
14}
16 ESP_LOGCONFIG(TAG, "ttp229:");
17 LOG_I2C_DEVICE(this);
18}
20 uint16_t touched = 0;
21 if (!this->status_comm_result(this->read(reinterpret_cast<uint8_t *>(&touched), 2) == i2c::ERROR_OK))
22 return;
23 touched = i2c::i2ctohs(touched);
24 touched = reverse_bits(touched);
25 for (auto *channel : this->channels_) {
26 channel->process(touched);
27 }
28}
29
30} // namespace esphome::ttp229_lsf
void mark_failed()
Mark this component as failed.
bool status_comm_result(bool ok)
Clears the warning when ok, else sets it with message (default "Communication failed"); returns ok.
ErrorCode read(uint8_t *data, size_t len) const
reads an array of bytes from the device using an I2CBus
Definition i2c.h:175
std::vector< TTP229Channel * > channels_
Definition ttp229_lsf.h:28
uint16_t i2ctohs(uint16_t i2cshort)
Definition i2c.h:139
@ ERROR_OK
No error found during execution of method.
Definition i2c_bus.h:15
ESPHOME_LOG_TAG(TAG, "ttp229_lsf")
uint8_t reverse_bits(uint8_t x)
Reverse the order of 8 bits.
Definition helpers.h:1081