Create example using WebAssembly #15

Closed
opened 2020-06-02 07:13:47 +00:00 by rafaelcaricio · 17 comments
rafaelcaricio commented 2020-06-02 07:13:47 +00:00 (Migrated from github.com)

Create a WebAssembly demo app using the web simulator of embedded_graphics library. It would be a great way to show the possibilities of lvgl-rs by compiling to WASM. The example can also be a quick start for many people.

Create a WebAssembly demo app using the [web simulator](https://github.com/rahul-thakoor/embedded-graphics-web-simulator) of `embedded_graphics` library. It would be a great way to show the possibilities of `lvgl-rs` by compiling to WASM. The example can also be a quick start for many people.
FloVanGH commented 2020-09-17 08:12:09 +00:00 (Migrated from github.com)

Does anyone managed to run it on WebAssembly? When I try to build it I get the following error:

_core/../lv_font/../lv_misc/lv_area.h:17:10: fatal error: 'string.h' file not found
  cargo:warning=#include <string.h>
Does anyone managed to run it on WebAssembly? When I try to build it I get the following error: ``` _core/../lv_font/../lv_misc/lv_area.h:17:10: fatal error: 'string.h' file not found cargo:warning=#include <string.h> ```
rafaelcaricio commented 2020-09-17 09:57:11 +00:00 (Migrated from github.com)

Hey @FloVanGH , I haven't tried yet. But I'd imagine that to compile to WebAssembly we would need to tweak our build.rs to handle cases like this one.

Hey @FloVanGH , I haven't tried yet. But I'd imagine that to compile to WebAssembly we would need to tweak our `build.rs` to handle cases like this one.
FloVanGH commented 2020-09-17 17:29:43 +00:00 (Migrated from github.com)

Hey @rafaelcaricio.If you can adjust the build.rs I can contribute an example 🙂.

Hey @rafaelcaricio.If you can adjust the `build.rs` I can contribute an example 🙂.
FloVanGH commented 2020-09-18 05:43:03 +00:00 (Migrated from github.com)

I want to add an lvgl example to my crate: https://codeberg.org/morph/canvas-display. I have also a working desktop example for an other crate https://codeberg.org/morph/raqote-display.

I want to add an lvgl example to my crate: https://codeberg.org/morph/canvas-display. I have also a working desktop example for an other crate https://codeberg.org/morph/raqote-display.
rafaelcaricio commented 2020-09-18 08:51:34 +00:00 (Migrated from github.com)

@FloVanGH I can work on updating the build.rs, but I'm pretty tight on free time right now so I cannot compromise when I can do it. I hope to get some time to work on lvgl-rs soon.

@FloVanGH I can work on updating the `build.rs`, but I'm pretty tight on free time right now so I cannot compromise when I can do it. I hope to get some time to work on lvgl-rs soon.
rafaelcaricio commented 2020-09-18 08:51:45 +00:00 (Migrated from github.com)

Awesome work, btw! :)

Awesome work, btw! :)
FloVanGH commented 2020-09-18 11:34:07 +00:00 (Migrated from github.com)

@FloVanGH I can work on updating the build.rs, but I'm pretty tight on free time right now so I cannot compromise when I can do it. I hope to get some time to work on lvgl-rs soon.

Ok I see. It's not urgent. But I hope you'll find some time. And I hope you can continue your work, it's really great 🙂.

> @FloVanGH I can work on updating the `build.rs`, but I'm pretty tight on free time right now so I cannot compromise when I can do it. I hope to get some time to work on lvgl-rs soon. Ok I see. It's not urgent. But I hope you'll find some time. And I hope you can continue your work, it's really great 🙂.
FloVanGH commented 2020-09-18 11:34:18 +00:00 (Migrated from github.com)

Awesome work, btw! :)

Thank you 🙂

> Awesome work, btw! :) Thank you 🙂
rafaelcaricio commented 2020-09-21 16:15:16 +00:00 (Migrated from github.com)

I've tried that this weekend and didn't work yet. I will continue trying to compile for the wasm32-unknown-emscripten target, that one may work (https://github.com/rustwasm/team/issues/291).

I've tried that this weekend and didn't work yet. I will continue trying to compile for the `wasm32-unknown-emscripten` target, that one may work (https://github.com/rustwasm/team/issues/291).
FloVanGH commented 2020-09-21 16:37:31 +00:00 (Migrated from github.com)

Hey, ok thank you for your effort 🙂.

Hey, ok thank you for your effort 🙂.
rafaelcaricio commented 2020-09-21 18:09:57 +00:00 (Migrated from github.com)

@FloVanGH after many hours of trial and error, it's possible to compile lvgl-rs to WASM after those changes https://github.com/rafaelcaricio/lvgl-rs/pull/31

I have an example here: https://github.com/rafaelcaricio/lvgl-rs-wasm (needs Rust nightly)

It compiles, but doesn't work in the browser. It panics at some slice index that supposed to not happen. Works fine when compiled to local binary.

@FloVanGH after many hours of trial and error, it's possible to compile lvgl-rs to WASM after those changes https://github.com/rafaelcaricio/lvgl-rs/pull/31 I have an example here: https://github.com/rafaelcaricio/lvgl-rs-wasm (needs Rust nightly) It compiles, but doesn't work in the browser. It panics at some slice index that supposed to not happen. Works fine when compiled to local binary.
FloVanGH commented 2020-09-21 18:55:45 +00:00 (Migrated from github.com)

@rafaelcaricio that's awesome :-) . Thank you. I will create an example for canvas-display.

@rafaelcaricio that's awesome :-) . Thank you. I will create an example for `canvas-display`.
rafaelcaricio commented 2020-09-21 19:06:33 +00:00 (Migrated from github.com)

@FloVanGH No problem! Let me know if it works for you in the browser. As I said, even though I managed to make the example project compile successfully, it panics when running in the browser for some strange reason.

@FloVanGH No problem! Let me know if it works for you in the browser. As I said, even though I managed to make the example project compile successfully, it panics when running in the browser for some strange reason.
rafaelcaricio commented 2020-09-21 19:18:33 +00:00 (Migrated from github.com)
Screenshot This is the error I get... :/
<img width="1792" alt="Screenshot" src="https://user-images.githubusercontent.com/107613/93810988-bc4cff00-fc4f-11ea-9cf0-8dbd470d07ce.png"> This is the error I get... :/
FloVanGH commented 2020-09-22 04:23:44 +00:00 (Migrated from github.com)

Ok thank you. I will check it.

Ok thank you. I will check it.
rafaelcaricio commented 2020-09-22 08:31:30 +00:00 (Migrated from github.com)

@FloVanGH I managed to make it work! 🥳 The example project is running here: https://rafaelcaricio.github.io/lvgl-rs-wasm/

Example code: https://github.com/rafaelcaricio/lvgl-rs-wasm

@FloVanGH I managed to make it work! 🥳 The example project is running here: https://rafaelcaricio.github.io/lvgl-rs-wasm/ Example code: https://github.com/rafaelcaricio/lvgl-rs-wasm
FloVanGH commented 2020-09-22 08:50:20 +00:00 (Migrated from github.com)

🎉

🎉
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: rafaelcaricio/lvgl-rs#15
No description provided.