You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by "pkarashchenko (via GitHub)" <gi...@apache.org> on 2023/02/22 08:11:16 UTC

[GitHub] [nuttx-apps] pkarashchenko commented on a diff in pull request #1585: lvgl/port: add libuv porting

pkarashchenko commented on code in PR #1585:
URL: https://github.com/apache/nuttx-apps/pull/1585#discussion_r1113965614


##########
graphics/lvgl/port/lv_port_libuv.c:
##########
@@ -0,0 +1,175 @@
+/****************************************************************************
+ * apps/graphics/lvgl/port/lv_port_libuv.c
+ *
+ * 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 <errno.h>
+#include <fcntl.h>
+#include <inttypes.h>
+#include <uv.h>
+#include <stdlib.h>
+#include <lvgl/lvgl.h>
+#include "lv_port_libuv.h"
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Private Type Declarations
+ ****************************************************************************/
+
+struct lv_uv_ctx_s
+{
+  int fd;
+  uv_timer_t ui_timer;
+  uv_poll_t ui_refr;
+};
+
+/****************************************************************************
+ * Private Function Prototypes
+ ****************************************************************************/
+
+/****************************************************************************
+ * Private Data
+ ****************************************************************************/
+
+static struct lv_uv_ctx_s g_uv_ctx;
+
+/****************************************************************************
+ * Private Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: ui_timer_cb
+ ****************************************************************************/
+
+static void ui_timer_cb(FAR uv_timer_t *handle)
+{
+  uint32_t sleep_ms;
+  LV_LOG_TRACE("start");
+
+  sleep_ms = lv_timer_handler();
+
+  /* Prevent busy loops. */
+
+  if (sleep_ms == 0)
+    {
+      sleep_ms = 1;
+    }
+
+  uv_timer_start(handle, ui_timer_cb, sleep_ms, 0);
+  LV_LOG_TRACE("stop, sleep %" PRIu32 " ms", sleep_ms);
+}
+
+/****************************************************************************
+ * Name: ui_refr_cb
+ ****************************************************************************/
+
+static void ui_refr_cb(FAR uv_poll_t *handle, int status, int events)
+{
+  LV_LOG_TRACE("start");
+  _lv_disp_refr_timer(NULL);
+  LV_LOG_TRACE("stop");
+}
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: lv_port_libuv_init
+ *
+ * Description:
+ *   Add the UI event loop to the uv_loop.
+ *
+ * Input Parameters:
+ *   loop - Pointer to uv_loop.
+ *
+ ****************************************************************************/
+
+void lv_port_libuv_init(FAR void *loop)
+{
+  int fd;
+  FAR uv_loop_t *ui_loop = loop;
+  FAR lv_disp_t *disp;
+
+  LV_LOG_INFO("dev: " CONFIG_LV_PORT_UV_POLL_DEVICEPATH " opening...");
+  fd = open(CONFIG_LV_PORT_UV_POLL_DEVICEPATH, O_WRONLY);
+

Review Comment:
   ```suggestion
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org