I try using…
lv.refr_now(None)
lv.task_handler()
does not update.
simulator link…
[LVGL/MicroPython Simulator]
I try using…
lv.refr_now(None)
lv.task_handler()
does not update.
simulator link…
[LVGL/MicroPython Simulator]
Your example shows “Hello 3”, as you set it in chng_txt
.
Could you explain the problem?
expect see in display…
‘Hello World!’ for 1 second
‘Hello 2’ for 1 second
‘Hello 3’ for 1 second
Not just ‘Hello 3’
utime.sleep
freezes and does not yield to the javascript event loop, that’s probably why the display is not refreshed on the web simulator (@embeddedt could you confirm or comment?)
To overcome this you can use LVGL timers instead of “sleep” to trigger events at specified times.
That’s correct. In general it is recommended to avoid any blocking code when using the web simulator.
Would it be too much to ask for a micropython sample as the C sample is confusing with (lv_timer_t * timer) in function and using data.
Just would like a pause for each label change.
my simulator attempt…
https://sim.lvgl.io/v8.1/micropython/ports/javascript/index.html?script_direct=e31212bcbb843b278eaab556aafb351e7910b642
So each messages is going to be completely different in the function.
Plus how do you stop this continuing Loop?
All I want is to show consecutive labels that show for x time.
Why doesent the label update and time.sleep work, I get the blocking but can’t the label change before the sleep?
JS mustn’t block - so each function must run to completion. You can’t stop and wait in the middle.
You can call timer.set_repeat_count
after creating the timer.
Because sleep does not yield to the JS event loop therefore doesn’t update the display
Theres got to be a simpler way to do a one shot one second
I hate to beat a dead horse…
but why won’t lv.refr_now(None)
which is to force a screen refresh immediately,
not working before the blocking sleep?
What specifically is the difference between the esp32 port and the JavaScript port
scr = lv.obj()
btn = lv.btn(scr)
btn.align(lv.ALIGN.CENTER, 0, 0)
label = lv.label(btn)
label.set_text('Hello World!')
lv.scr_load(scr)
lv.refr_now(None)
utime.sleep(1)
label.set_text('Hello 1')
lv.refr_now(None)
utime.sleep(1)
label.set_text('Hello 2')
lv.refr_now(None)
utime.sleep(1)
label.set_text('Hello 3')
lv.refr_now(None)
This works for the esp32 port
You can’t block the main thread in JavaScript like you can on a native platform. If you do, rerendering usually stops. This is a limitation of browsers.