Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(wayland): Wayland useability improvements #204

Merged
merged 1 commit into from Apr 12, 2022
Merged

feat(wayland): Wayland useability improvements #204

merged 1 commit into from Apr 12, 2022

Conversation

ghost
Copy link

@ghost ghost commented Apr 10, 2022

Adds/stubs out a few functions allowing for a proper event-driven LVGL usage (when using the Wayland backend).

@ghost
Copy link
Author

ghost commented Apr 10, 2022

Example usage:

#include <stdint.h>
#include <errno.h>
#include <time.h>
#include <limits.h>
#include <poll.h>
#include "lvgl.h"
#include "lv_drivers/wayland/wayland.h"

int main(void)
{
   struct pollfd pfd;
   uint32_t time_till_next;
   int sleep;
   lv_disp_t *disp;
   lv_obj_t * label;

   lv_init();
   lv_wayland_init();

   pfd.fd = lv_wayland_get_fd();
   pfd.events = POLLIN;

   disp = lv_wayland_create_window(320, 240, "My Window", NULL);
   label = lv_label_create(lv_scr_act());
   lv_obj_align(label, LV_ALIGN_BOTTOM_MID, 0, 0);

   while (1) {
      time_till_next = lv_wayland_timer_handler();

      /* Check that there's still a window to wait on */
      if (!lv_wayland_window_is_open(NULL)) {
         break;
      }

      /* Wait for something interesting to happen */
      if (time_till_next == LV_NO_TIMER_READY) {
         sleep = -1;
      } else if (time_till_next > INT_MAX) {
         sleep = INT_MAX;
      } else {
         sleep = time_till_next;
      }

      while ((poll(&pfd, 1, sleep) < 0) && (errno == EINTR));
   }

   lv_wayland_deinit();
   return 0x00;
}

LVGL still needs to be configured appropriately (i.e. lv_conf.h/lv_drv_conf.h)
** Recommended to use a high (>10 seconds) read polling rate (LV_INDEV_DEF_READ_PERIOD) as lv_wayland_timer_handler() will ready all input timers when Wayland input is received

@kisvegabor
Copy link
Member

kisvegabor commented Apr 11, 2022

I'm afraid people won't know about this feature if it's not documented in the README of the Wayland driver. So could a you add a few lines about it?

…ific lv_timer_handler)

Adds/stubs out a few functions allowing for a proper event-driven LVGL usage (when using the Wayland backend).
@ghost
Copy link
Author

ghost commented Apr 11, 2022

Updated.

@kisvegabor
Copy link
Member

Thank you!

@kisvegabor kisvegabor merged commit f46cf5a into lvgl:master Apr 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant