This is an automated email from the ASF dual-hosted git repository.

jerpelea pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx-apps.git


The following commit(s) were added to refs/heads/master by this push:
     new e269d1cbe examples/lvgltouch: add touchscreen diagnostics
e269d1cbe is described below

commit e269d1cbe53f412c0a0a841889d01e5050b80377
Author: aviralgarg05 <[email protected]>
AuthorDate: Sat Aug 15 16:32:12 2026 +0530

    examples/lvgltouch: add touchscreen diagnostics
    
    Add a separate LVGL example that reports touchscreen state, presses, and 
coordinates without changing lvgldemo.
    
    Signed-off-by: aviralgarg05 <[email protected]>
---
 examples/lvgltouch/CMakeLists.txt   |  37 ++++++++++
 examples/lvgltouch/Kconfig          |  36 ++++++++++
 examples/lvgltouch/Make.defs        |  25 +++++++
 examples/lvgltouch/Makefile         |  32 +++++++++
 examples/lvgltouch/lvgltouch_main.c | 136 ++++++++++++++++++++++++++++++++++++
 5 files changed, 266 insertions(+)

diff --git a/examples/lvgltouch/CMakeLists.txt 
b/examples/lvgltouch/CMakeLists.txt
new file mode 100644
index 000000000..2ee7196ff
--- /dev/null
+++ b/examples/lvgltouch/CMakeLists.txt
@@ -0,0 +1,37 @@
+# 
##############################################################################
+# apps/examples/lvgltouch/CMakeLists.txt
+#
+# SPDX-License-Identifier: Apache-2.0
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more 
contributor
+# license agreements.  See the NOTICE file distributed with this work for
+# additional information regarding copyright ownership.  The ASF licenses this
+# file to you under the Apache License, Version 2.0 (the "License"); you may 
not
+# use this file except in compliance with the License.  You may obtain a copy 
of
+# the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+# License for the specific language governing permissions and limitations under
+# the License.
+#
+# 
##############################################################################
+
+if(CONFIG_EXAMPLES_LVGLTOUCH)
+  nuttx_add_application(
+    NAME
+    ${CONFIG_EXAMPLES_LVGLTOUCH_PROGNAME}
+    PRIORITY
+    ${CONFIG_EXAMPLES_LVGLTOUCH_PRIORITY}
+    STACKSIZE
+    ${CONFIG_EXAMPLES_LVGLTOUCH_STACKSIZE}
+    MODULE
+    ${CONFIG_EXAMPLES_LVGLTOUCH}
+    DEPENDS
+    lvgl
+    SRCS
+    lvgltouch_main.c)
+endif()
diff --git a/examples/lvgltouch/Kconfig b/examples/lvgltouch/Kconfig
new file mode 100644
index 000000000..6a0607d8f
--- /dev/null
+++ b/examples/lvgltouch/Kconfig
@@ -0,0 +1,36 @@
+#
+# For a description of the syntax of this configuration file,
+# see the file kconfig-language.txt in the NuttX tools repository.
+#
+
+config EXAMPLES_LVGLTOUCH
+       tristate "LVGL touchscreen diagnostic"
+       default n
+       depends on GRAPHICS_LVGL && INPUT_TOUCHSCREEN
+       ---help---
+               Show the touchscreen state and coordinates on the display.
+
+if EXAMPLES_LVGLTOUCH
+
+config EXAMPLES_LVGLTOUCH_PROGNAME
+       string "Program name"
+       default "lvgltouch"
+
+config EXAMPLES_LVGLTOUCH_PRIORITY
+       int "Task priority"
+       default 100
+
+config EXAMPLES_LVGLTOUCH_STACKSIZE
+       int "Stack size"
+       default 8192
+
+config EXAMPLES_LVGLTOUCH_INPUT_DEVPATH
+       string "Touchscreen device path"
+       default "/dev/input0"
+
+config EXAMPLES_LVGLTOUCH_FB_DEVPATH
+       string "Framebuffer device path"
+       default "/dev/fb0"
+       depends on !LV_USE_NUTTX_LCD
+
+endif
diff --git a/examples/lvgltouch/Make.defs b/examples/lvgltouch/Make.defs
new file mode 100644
index 000000000..bba075fa3
--- /dev/null
+++ b/examples/lvgltouch/Make.defs
@@ -0,0 +1,25 @@
+############################################################################
+# apps/examples/lvgltouch/Make.defs
+#
+# SPDX-License-Identifier: Apache-2.0
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.  The
+# ASF licenses this file to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance with the
+# License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+# License for the specific language governing permissions and limitations
+# under the License.
+#
+############################################################################
+
+ifneq ($(CONFIG_EXAMPLES_LVGLTOUCH),)
+CONFIGURED_APPS += $(APPDIR)/examples/lvgltouch
+endif
diff --git a/examples/lvgltouch/Makefile b/examples/lvgltouch/Makefile
new file mode 100644
index 000000000..00174ceec
--- /dev/null
+++ b/examples/lvgltouch/Makefile
@@ -0,0 +1,32 @@
+############################################################################
+# apps/examples/lvgltouch/Makefile
+#
+# SPDX-License-Identifier: Apache-2.0
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.  The
+# ASF licenses this file to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance with the
+# License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+# License for the specific language governing permissions and limitations
+# under the License.
+#
+############################################################################
+
+include $(APPDIR)/Make.defs
+
+PROGNAME = $(CONFIG_EXAMPLES_LVGLTOUCH_PROGNAME)
+PRIORITY = $(CONFIG_EXAMPLES_LVGLTOUCH_PRIORITY)
+STACKSIZE = $(CONFIG_EXAMPLES_LVGLTOUCH_STACKSIZE)
+MODULE = $(CONFIG_EXAMPLES_LVGLTOUCH)
+
+MAINSRC = lvgltouch_main.c
+
+include $(APPDIR)/Application.mk
diff --git a/examples/lvgltouch/lvgltouch_main.c 
b/examples/lvgltouch/lvgltouch_main.c
new file mode 100644
index 000000000..81953ff44
--- /dev/null
+++ b/examples/lvgltouch/lvgltouch_main.c
@@ -0,0 +1,136 @@
+/****************************************************************************
+ * apps/examples/lvgltouch/lvgltouch_main.c
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+#include <lvgl/lvgl.h>
+
+/****************************************************************************
+ * Private Data
+ ****************************************************************************/
+
+static FAR lv_indev_t *g_touch;
+static FAR lv_obj_t *g_status;
+
+/****************************************************************************
+ * Private Functions
+ ****************************************************************************/
+
+static void lvgltouch_update(FAR lv_timer_t *timer)
+{
+  lv_indev_state_t state;
+  lv_point_t point;
+  char text[64];
+
+  UNUSED(timer);
+
+  state = lv_indev_get_state(g_touch);
+  lv_indev_get_point(g_touch, &point);
+  snprintf(text, sizeof(text), "state: %s\nx: %d  y: %d",
+           state == LV_INDEV_STATE_PRESSED ? "pressed" : "released",
+           point.x, point.y);
+  lv_label_set_text(g_status, text);
+}
+
+static void lvgltouch_create(FAR lv_indev_t *indev)
+{
+  FAR lv_obj_t *screen;
+  FAR lv_obj_t *title;
+
+  screen = lv_obj_create(NULL);
+  title = lv_label_create(screen);
+  lv_label_set_text(title, "Touchscreen diagnostic");
+  lv_obj_align(title, LV_ALIGN_TOP_MID, 0, 24);
+
+  g_status = lv_label_create(screen);
+  lv_obj_align(g_status, LV_ALIGN_CENTER, 0, 0);
+
+  if (indev == NULL)
+    {
+      lv_label_set_text(g_status, "Touchscreen device could not be opened");
+    }
+  else
+    {
+      g_touch = indev;
+      lv_label_set_text(g_status, "Touch the display");
+      lv_timer_create(lvgltouch_update, 50, NULL);
+    }
+
+  lv_screen_load(screen);
+}
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+int main(int argc, FAR char *argv[])
+{
+  lv_nuttx_dsc_t info;
+  lv_nuttx_result_t result;
+
+  UNUSED(argc);
+  UNUSED(argv);
+
+  if (lv_is_initialized())
+    {
+      LV_LOG_ERROR("LVGL already initialized");
+      return EXIT_FAILURE;
+    }
+
+  lv_init();
+  lv_nuttx_dsc_init(&info);
+
+#ifdef CONFIG_LV_USE_NUTTX_LCD
+  info.fb_path = "/dev/lcd0";
+#else
+  info.fb_path = CONFIG_EXAMPLES_LVGLTOUCH_FB_DEVPATH;
+#endif
+  info.input_path = CONFIG_EXAMPLES_LVGLTOUCH_INPUT_DEVPATH;
+  lv_nuttx_init(&info, &result);
+
+  if (result.disp == NULL)
+    {
+      LV_LOG_ERROR("display initialization failed");
+      lv_nuttx_deinit(&result);
+      lv_deinit();
+      return EXIT_FAILURE;
+    }
+
+  lvgltouch_create(result.indev);
+
+  for (; ; )
+    {
+      uint32_t idle = lv_timer_handler();
+
+      usleep((idle ? idle : 1) * 1000);
+    }
+
+  return EXIT_SUCCESS;
+}

Reply via email to