-
Notifications
You must be signed in to change notification settings - Fork 317
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
Running Wayland driver based on frame timer? #207
Comments
@simplejack-src has just implemented something similar here. Does it work for your use case? You still run a while loop but the process will suspend completely if there is no event. |
Just to add on, there a quick example in the PR (#204) doing exactly that. poll() is used to wait on the Wayland file-descriptor until a Wayland event arrives. This works best with a high The 5ms timer you referenced is implemented as the original "classic" driver method (wherein everything runs at a constant tick interval). However, if your using Using this I'm able to run a pretty silent application (i.e. sleeps unless there's something worth doing). |
Thanks, I was working from your example which is very helpful. However with Swift I need to integrate with a libdispatch-based event loop, the application calls
|
I don't have any Swift experience (or GCD/libdispatch), but off-hand I'd say the issue (given your snippet above) might be that you need at least a single run through of |
Thanks, I think the issue was that basically if there are no Wayland events, there is nothing triggering a redraw, so the frame timer wasn't coming back to rerun I've settled on scheduling another block to run at the intervals I'm getting back from class WaylandLVGLDriver {
private var _display: UnsafeMutablePointer<lv_disp_t>
private var _tickTimer: DispatchSourceTimer
private var _loopDispatchSource: DispatchSourceRead
private var _lvMinimumTickTime: UInt32 = 10
init () throws {
lv_init()
lv_wayland_init()
guard let display = lv_wayland_create_window(800, 480, "SwiftLVGL", nil) else {
throw Error(message: "Wayland LVGL display creation failed")
}
_display = display
let fd = lv_wayland_get_fd()
_loopDispatchSource = DispatchSource.makeReadSource(fileDescriptor: fd, queue: DispatchQueue.main)
_tickTimer = DispatchSource.makeTimerSource(flags: .strict, queue: DispatchQueue.main)
_loopDispatchSource.setEventHandler() { [self] in
let time = max(lv_wayland_timer_handler(), _lvMinimumTickTime)
_tickTimer.suspend()
_tickTimer.schedule(deadline: .now() + DispatchTimeInterval.milliseconds(Int(time)), leeway: .microseconds(100))
_tickTimer.resume()
}
_loopDispatchSource.resume()
_tickTimer.setEventHandler { [self ] in
let time = max(lv_wayland_timer_handler(), _lvMinimumTickTime)
_tickTimer.schedule(deadline: .now() + DispatchTimeInterval.milliseconds(Int(time)), leeway: .microseconds(100))
}
let time = Int(lv_wayland_timer_handler())
_tickTimer.schedule(deadline: .now() + DispatchTimeInterval.milliseconds(Int(time)), leeway: .microseconds(100))
_tickTimer.resume()
}
deinit {
_tickTimer.cancel()
_loopDispatchSource.cancel()
lv_wayland_deinit()
}
} |
This issue or pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Hi,
I'm working on a Linux app which I'm targeting at an embedded device which will probably render to the framebuffer, however am using the Wayland driver to develop the app on Desktop (and may eventually use Wayland on device).
I'm using Swift which has a good libdispatch-based API to monitor for Wayland input events, and have set up a frame timer callback to monitor for output frame events. However I can't quite seem to get this working well without an additional while loop to call some combination of
lv_wayland_timer_handler()
,_lv_disp_refr_timer()
orlv_tick_inc()
.Ideally input and output would be decoupled so that LVGL events and input would trigger a re-render of the UI, which is then scheduled for a frame callback. However this is somewhat different to the way LVGL and the Wayland driver seems to want to work, which is to just run a timer with a 5ms (or so) interrupt and process both input and output in one function (
lv_wayland_timer_handler
). Ideally input events would be processed as they come, and if there is a need to re-render the screen, this is done no more frequently than in a frame callback to reduce power consumption.Is there appetite to modify the Wayland driver in this way?
The text was updated successfully, but these errors were encountered: