10static constexpr uint8_t GET_X = 0xC0;
11static constexpr uint8_t GET_Y = 0xD0;
12static constexpr uint8_t GET_Z = 0xE2;
15 if (!this->
read_byte(GET_Z).has_value()) {
22 if (!data_z.has_value()) {
23 ESP_LOGW(TAG,
"failed to read %s, skipping update", LOG_STR_LITERAL(
"pressure"));
34 ESP_LOGW(TAG,
"failed to read %s, skipping update", LOG_STR_LITERAL(
"X position"));
40 ESP_LOGW(TAG,
"failed to read %s, skipping update", LOG_STR_LITERAL(
"Y position"));
45 ESP_LOGV(TAG,
"X %4d Y %4d Z %3d", *
x, *
y,
z);
51 if (!data.has_value()) {
59 "NS2009 Touchscreen:\n"
void mark_failed()
Mark this component as failed.
bool read_byte(uint8_t a_register, uint8_t *data)
bool read_bytes(uint8_t a_register, uint8_t *data, uint8_t len)
Compat APIs All methods below have been added for compatibility reasons.
optional< uint16_t > read_axis_(uint8_t cmd)
Read a 12 bit axis value, or nothing when the read fails.
uint8_t threshold_
The threshold at which a touch is registered.
void dump_config() override
void update_touches() override
void add_raw_touch_position_(uint8_t id, int16_t x_raw, int16_t y_raw, int16_t z_raw=0)
ESPHOME_LOG_TAG(TAG, "ns2009")
constexpr uint16_t encode_uint16(uint8_t msb, uint8_t lsb)
Encode a 16-bit value given the most and least significant byte.