From 37a73aebd4a0f3ecb546d4ce6eb5312afcca2dac Mon Sep 17 00:00:00 2001 From: SGE Date: Mon, 1 Apr 2024 18:11:43 +0200 Subject: [PATCH] Clang format --- esphome/components/icnt86/icnt86.cpp | 2 +- esphome/components/icnt86/icnt86.h | 2 -- .../components/touchscreen/touchscreen.cpp | 24 ++++++++----------- 3 files changed, 11 insertions(+), 17 deletions(-) diff --git a/esphome/components/icnt86/icnt86.cpp b/esphome/components/icnt86/icnt86.cpp index 9ec219f8c6..fccf50b57c 100644 --- a/esphome/components/icnt86/icnt86.cpp +++ b/esphome/components/icnt86/icnt86.cpp @@ -48,7 +48,7 @@ void ICNT86Touchscreen::update_touches() { UWORD Y = ((UWORD) buf[4 + 7 * i] << 8) + buf[3 + 7 * i]; UWORD P = buf[5 + 7 * i]; UWORD TouchEvenid = buf[6 + 7 * i]; - ESP_LOGD(TAG, "Touch x: %d, y: %d, p: %d", X, Y, P); + ESP_LOGD(TAG, "Touch x: %d, y: %d, p: %d", X, Y, P); this->set_raw_touch_position_(TouchEvenid, X, Y, P); } diff --git a/esphome/components/icnt86/icnt86.h b/esphome/components/icnt86/icnt86.h index 000096576b..768fb843a3 100644 --- a/esphome/components/icnt86/icnt86.h +++ b/esphome/components/icnt86/icnt86.h @@ -31,8 +31,6 @@ class ICNT86Touchscreen : public touchscreen::Touchscreen, public i2c::I2CDevice void reset_touch_sensor_(); InternalGPIOPin *interrupt_pin_{}; GPIOPin *reset_pin_{nullptr}; - - }; } // namespace icnt86 diff --git a/esphome/components/touchscreen/touchscreen.cpp b/esphome/components/touchscreen/touchscreen.cpp index 511cfdf0a6..da90487dd8 100644 --- a/esphome/components/touchscreen/touchscreen.cpp +++ b/esphome/components/touchscreen/touchscreen.cpp @@ -148,27 +148,23 @@ void Touchscreen::send_touches_() { } int16_t Touchscreen::normalize_(int16_t val, int16_t min_val, int16_t max_val, bool inverted) { - int16_t ret; -//only normalize when min and max value are specified -if(min_val && max_val) -{ - if (val <= min_val) { - ret = 0; - } else if (val >= max_val) { - ret = 0xfff; - } else { + // only normalize when min and max value are specified + if (min_val && max_val) { + if (val <= min_val) { + ret = 0; + } else if (val >= max_val) { + ret = 0xfff; + } else { ret = (int16_t) ((int) 0xfff * (val - min_val) / (max_val - min_val)); } - } - else - { + } else { ret = val; } - ret = (inverted) ? 0xfff - ret : ret; + ret = (inverted) ? 0xfff - ret : ret; - return ret; + return ret; } } // namespace touchscreen