<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[⚠️ HELP: LVGL on M5Stack CoreS3 not detecting touch events ⚠️]]></title><description><![CDATA[<p dir="auto">Hello community,</p>
<p dir="auto">I'm trying to integrate LVGL 9.3.0 with the touch screen on M5Stack CoreS3, but I'm facing an issue: touch events are not being registered correctly in LVGL, even though the touch screen works fine when tested using M5Stack's official example code.</p>
<p dir="auto">📌 Software versions I'm using: ✅ M5Stack CoreS3 (ESP32-S3-based hardware) ✅ LVGL version: 9.3.0 ✅ M5Unified library version: Latest available version (checked via Arduino IDE) ✅ LovyanGFX library version: Latest available version ✅ Arduino IDE version: 1.8.19 ✅ ESP32 Board Support Package: Latest version installed via Board Manager</p>
<p dir="auto">📌 What I’ve tested so far: ✅ The touch screen works correctly using CoreS3.Touch.getDetail(). ✅ LVGL is not detecting touches, suggesting a possible misconfiguration in lv_indev_t. ✅ I've implemented synchronization with CoreS3.update(), but LVGL still does not process touch events.</p>
<p dir="auto">📜 Current code I'm using:</p>
<pre><code class="language-cpp">#include &lt;M5CoreS3.h&gt;
#include &lt;lvgl.h&gt;

// 🛠 Screen instance
M5GFX display;

// 🛠 Callback function for display update in LVGL
void flush_cb(lv_display_t *disp_drv, const lv_area_t *area, uint8_t *color_p) {
    display.pushImage(area-&gt;x1, area-&gt;y1, area-&gt;x2 - area-&gt;x1 + 1, area-&gt;y2 - area-&gt;y1 + 1, (uint16_t*)color_p);
    lv_display_flush_ready(disp_drv);
}

// 🛠 Touch event handling using CoreS3 and advanced debugging
void my_input_read(lv_indev_t *indev, lv_indev_data_t *data) {
    CoreS3.update();
    auto t = CoreS3.Touch.getDetail();

    data-&gt;point.x = t.x;
    data-&gt;point.y = t.y;

    Serial.print("📍 Touch state: "); Serial.println((int)t.state);
    Serial.print("📍 Coordinates → X: "); Serial.print(t.x);
    Serial.print(" Y: "); Serial.println(t.y);

    if (t.state == m5::touch_state_t::touch_begin || t.state == m5::touch_state_t::hold_begin || t.state == m5::touch_state_t::drag_begin) {
        data-&gt;state = LV_INDEV_STATE_PR;
        Serial.println("✅ LVGL has detected the touch!");
    } else {
        data-&gt;state = LV_INDEV_STATE_REL;
    }
}

// 🛠 Creating a test button in LVGL
void create_button(lv_obj_t *parent) {
    lv_obj_t *btn = lv_btn_create(parent);
    lv_obj_set_size(btn, 100, 50);
    lv_obj_align(btn, LV_ALIGN_CENTER, 0, 0);

    lv_obj_t *label = lv_label_create(btn);
    lv_label_set_text(label, "Press");
    lv_obj_center(label);

    lv_obj_add_flag(btn, LV_OBJ_FLAG_CLICKABLE);
}

// 🛠 System initial setup
void setup() {
    auto cfg = M5.config();
    CoreS3.begin(cfg);
    Serial.begin(115200);
    Serial.println("\n🚀 M5Stack CoreS3 initialized with LVGL 9.3.0 🚀\n");

    display.init();
    lv_init();
    display.begin();
    display.setColorDepth(16);

    static lv_display_t *disp_drv = lv_display_create(320, 240);
    lv_display_set_flush_cb(disp_drv, flush_cb);

    // 🚀 Dynamic memory allocation to optimize RAM usage
    static lv_color_t *buf1 = (lv_color_t*)malloc(320 * 50 * sizeof(lv_color_t));
    if (buf1 == NULL) {
        Serial.println("❌ Error: Failed to allocate memory.");
        return;
    }
    lv_display_set_buffers(disp_drv, buf1, NULL, 320 * 50 * sizeof(lv_color_t), LV_DISPLAY_RENDER_MODE_PARTIAL);

    // 🛠 Properly initialize the touch input handler in LVGL
    lv_indev_t *indev = lv_indev_create();
    lv_indev_set_type(indev, LV_INDEV_TYPE_POINTER);
    lv_indev_set_read_cb(indev, my_input_read);

    // 🛠 Create a test button in LVGL
    create_button(lv_scr_act());

    Serial.println("✅ LVGL initialized correctly, waiting for interaction...");
}

// 🛠 Main loop for touch updates and LVGL handling
void loop() {
    CoreS3.update();
    lv_timer_handler();
    delay(5);
}
</code></pre>
<p dir="auto">💡 Has anyone successfully enabled touch detection in LVGL with M5Stack CoreS3? If you have any suggestions, insights, or working code examples, I’d really appreciate your help. 🙏</p>
<p dir="auto">Thanks in advance for any assistance! 🚀 Let’s get this working! 💪🔥</p>
]]></description><link>https://community.m5stack.com/topic/7612/help-lvgl-on-m5stack-cores3-not-detecting-touch-events</link><generator>RSS for Node</generator><lastBuildDate>Thu, 30 Apr 2026 20:37:40 GMT</lastBuildDate><atom:link href="https://community.m5stack.com/topic/7612.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 12 Jun 2025 19:12:51 GMT</pubDate><ttl>60</ttl></channel></rss>