ESPHome 2025.9.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
4namespace esphome {
5namespace ttp229_lsf {
6
7static const char *const TAG = "ttp229_lsf";
8
10 uint8_t data[2];
11 if (this->read(data, 2) != i2c::ERROR_OK) {
12 this->error_code_ = COMMUNICATION_FAILED;
13 this->mark_failed();
14 return;
15 }
16}
18 ESP_LOGCONFIG(TAG, "ttp229:");
19 LOG_I2C_DEVICE(this);
20 switch (this->error_code_) {
22 ESP_LOGE(TAG, ESP_LOG_MSG_COMM_FAIL);
23 break;
24 case NONE:
25 default:
26 break;
27 }
28}
30 uint16_t touched = 0;
31 if (this->read(reinterpret_cast<uint8_t *>(&touched), 2) != i2c::ERROR_OK) {
32 this->status_set_warning();
33 return;
34 }
35 touched = i2c::i2ctohs(touched);
37 touched = reverse_bits(touched);
38 for (auto *channel : this->channels_) {
39 channel->process(touched);
40 }
41}
42
43} // namespace ttp229_lsf
44} // namespace esphome
virtual void mark_failed()
Mark this component as failed.
void status_set_warning(const char *message=nullptr)
void status_clear_warning()
ErrorCode read(uint8_t *data, size_t len)
reads an array of bytes from the device using an I2CBus
Definition i2c.h:164
enum esphome::ttp229_lsf::TTP229LSFComponent::ErrorCode NONE
std::vector< TTP229Channel * > channels_
Definition ttp229_lsf.h:29
uint16_t i2ctohs(uint16_t i2cshort)
Definition i2c.h:128
@ ERROR_OK
No error found during execution of method.
Definition i2c_bus.h:13
Providing packet encoding functions for exchanging data with a remote host.
Definition a01nyub.cpp:7
uint8_t reverse_bits(uint8_t x)
Reverse the order of 8 bits.
Definition helpers.h:212