issue with cordinates + formatting

This commit is contained in:
Siemon Geeroms 2023-12-07 11:21:38 +01:00
parent 2521029a1b
commit 31287db779
2 changed files with 9 additions and 27 deletions

View file

@ -6,35 +6,13 @@ namespace icnt86 {
static const char *const TAG = "icnt86"; static const char *const TAG = "icnt86";
static const uint8_t MAX_BUTTONS = 4; uint8_t old_X = 0;
static const uint8_t MAX_TOUCH_POINTS = 5; uint8_t old_Y = 0;
static const uint8_t MAX_DATA_LEN = (7 + MAX_TOUCH_POINTS * 10); // 7 Header + (Points * 10 data bytes)
#define UBYTE uint8_t #define UBYTE uint8_t
#define UWORD uint16_t #define UWORD uint16_t
#define UDOUBLE uint32_t #define UDOUBLE uint32_t
struct ICNT86ButtonReport {
uint16_t length; // Always 14 (0x000E)
uint8_t report_id; // Always 0x03
uint16_t timestamp; // Number in units of 100 us
uint8_t btn_value; // Only use bit 0..3
uint16_t btn_signal[MAX_BUTTONS];
} __attribute__((packed));
struct ICNT86TouchRecord {
uint8_t : 5;
uint8_t touch_type : 3;
uint8_t tip : 1;
uint8_t event_id : 2;
uint8_t touch_id : 5;
uint16_t x;
uint16_t y;
uint8_t pressure;
uint16_t major_axis_length;
uint8_t orientation;
} __attribute__((packed));
void ICNT86TouchscreenStore::gpio_intr(ICNT86TouchscreenStore *store) { store->touch = true; } void ICNT86TouchscreenStore::gpio_intr(ICNT86TouchscreenStore *store) { store->touch = true; }
float ICNT86Touchscreen::get_setup_priority() const { return setup_priority::HARDWARE - 1.0f; } float ICNT86Touchscreen::get_setup_priority() const { return setup_priority::HARDWARE - 1.0f; }
@ -91,7 +69,6 @@ void ICNT86Touchscreen::loop() {
touch_count = 0; touch_count = 0;
for (auto *listener : this->touch_listeners_) for (auto *listener : this->touch_listeners_)
listener->release(); listener->release();
return; return;
} }
this->ICNT_Read_(0x1002, buf, touch_count * 7); this->ICNT_Read_(0x1002, buf, touch_count * 7);
@ -103,6 +80,10 @@ void ICNT86Touchscreen::loop() {
UWORD P = buf[5 + 7 * i]; UWORD P = buf[5 + 7 * i];
UWORD TouchEvenid = buf[6 + 7 * i]; UWORD TouchEvenid = buf[6 + 7 * i];
if (old_X == X || old_Y == Y) {
continue;
}
TouchPoint tp; TouchPoint tp;
switch (this->rotation_) { switch (this->rotation_) {
case ROTATE_0_DEGREES: case ROTATE_0_DEGREES:
@ -111,8 +92,8 @@ void ICNT86Touchscreen::loop() {
tp.y = Y; tp.y = Y;
break; break;
case ROTATE_90_DEGREES: case ROTATE_90_DEGREES:
tp.x = Y; tp.x = X;
tp.y = X; tp.y = Y;
break; break;
case ROTATE_180_DEGREES: case ROTATE_180_DEGREES:
tp.x = Y; tp.x = Y;

View file

@ -32,6 +32,7 @@ CONFIG_SCHEMA = touchscreen.TOUCHSCREEN_SCHEMA.extend(
.extend(cv.COMPONENT_SCHEMA) .extend(cv.COMPONENT_SCHEMA)
) )
async def to_code(config): async def to_code(config):
var = cg.new_Pvariable(config[CONF_ID]) var = cg.new_Pvariable(config[CONF_ID])
await cg.register_component(var, config) await cg.register_component(var, config)