-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
Convert Micropython to JavaScript in order to create an online simulator #792
Comments
@amirgon That port of Micropython builds properly but I ran into errors while trying to run it. I think that Emscripten has evolved since it was made. |
@embeddedt Did you see micropython-ports-wasm? |
@amirgon That's working out a lot better. Thanks! I'll let you know about my progress. |
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. |
I haven't had a lot of time to work on this lately, but I hope to get to it at some point. |
Shall we "pin" this issue to leave it opened as a reminder? |
@kisvegabor Sure. |
micropython/micropython#3575 lvgl+micropython could make a nice interactive lvgl demo on lvgl web page. |
@amirgon I'll see what I can do, but I have limited time right now. |
@amirgon Awesome! It should be much easier with this. |
@embeddedt Did you have a chance to make some experiments with Emscripten and Micropython? |
@kisvegabor I tried to work with it but I found that I don't understand Micropython well enough to be able to make it work with LittlevGL. I haven't had time to look at it again lately. |
Would you like to warm it up? Probably @amirgon could help to understand the Mpy specific parts. |
I will try to experiment with it again this week. |
Awesome! |
@amirgon I made some more progress on this, but it looks like Emscripten doesn't support SDL threads properly at the moment... could you figure out if the binding can be modified to avoid the need for another thread? |
@embeddedt The micropython binding was designed to be single threaded. You can run everything (micropython+lvgl+display driver) on the same thread. |
@amirgon Emscripten uses SDL2 for graphics.
Is |
@embeddedt The only purpose of the SDL thread over there is to call |
@amirgon Okay, I'll see what I can do. |
@embeddedt How do you call SDL main loop ( |
@amirgon I'm now using an Emscripten callback function to call the Of course, I don't fully understand the Micropython architecture yet, so it's possible this will all fall apart shortly. 😄 |
@embeddedt |
Nice progress @embeddedt ! 👍 |
It seems to work for me now as well; I think the problem is fixed. |
@amirgon @embeddedt |
I need to update the simulator to work with the latest version of The init script feature should be supported in lvgl/lv_micropython#15. |
@embeddedt what about lvgl/lv_micropython#17? I think it's important to include this as well. Did you get a chance to make some progress with other features we discussed? |
@amirgon, regarding lvgl/lv_micropython#17 |
No problem @stepansnigirev, we can add this later. |
I haven't had a chance to work on them yet. |
@embeddedt @amirgon @embeddedt I'll write to the hackaday too. They were already interested in the Micropythin binding once. |
You guys ever heard of moddable.com?
Maybe emscripten?
…On Sat, Dec 7, 2019, 04:07 Gabor Kiss-Vamosi ***@***.***> wrote:
@embeddedt <https://github.com/embeddedt>
Are there any difficulties with updating the project or is it just a
simple submodule update?
@amirgon <https://github.com/amirgon> @embeddedt
<https://github.com/embeddedt>
It'd be great to add a blog post and an Announcement on the forum about
the simulator. You know it much better than me, so can you help with that?
I'll write to the hackaday too. They were already interested in the
Micropythin binding once.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#792>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABYLTJF5DINM475NNB5G2DLQXM4TVANCNFSM4GT6XZWA>
.
|
@barbiani while wasm is now an official standard https://www.w3.org/2019/12/pressrelease-wasm-rec.html.en and emscripten uses clang 10. The javascript simulator actually uses the (soon to be deprecated) emscripten fastcomp compiler (clang 8) because the project wants to match what official micropython javascript port may do. |
Could be interesting in other context - js binding to lvgl. If anyone is willing to take this effort, because I'm too invested in Micropython for now... |
For some reason it doesn't seem to work properly if I just merge
I thought of this as well, but then I realized that most people using JavaScript with a user interface will be using it in a web browser, where LittlevGL isn't very necessary or practical.
We're trying to remain aligned with upstream MicroPython as much as possible to ease the merging process. |
@embeddedt I think that JavaScript in this context is used like Micopython and Lua on embedded device, where there is no web browser. |
Moddable js is great and fast as it runs precompiled bytecode.
There is also a preliminary web simulator built by another user.
…On Sat, Dec 7, 2019, 18:06 Amir Gonnen ***@***.***> wrote:
I thought of this as well, but then I realized that most people using
JavaScript with a user interface will be using it in a web browser, where
LittlevGL isn't very necessary or practical.
@embeddedt <https://github.com/embeddedt> I think that JavaScript in this
context is used like Micopython and Lua on *embedded device*, where there
is *no web browser*.
It's part of the trend these days to move from C to higher level languages
(python, js) on embedded devices. I've seen multiple js implementations for
embedded such as low.js <https://github.com/neonious/lowjs>, Espruino
<https://www.espruino.com/>, and now moddable.
On each of these, JavaScript is used on an embedded device with no web
browser, so lvgl binding is applicable just like we did for Micropython.
I don't know how popular JavaScript-on-embedded-devices is going to get,
but it definitely gaining some momentum.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#792>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABYLTJFMS34BP57DZYLGUJTQXP64TANCNFSM4GT6XZWA>
.
|
QuickJS is another small and fast implementation of JS. Someone was able to make React run on a Raspberry Pi using it. I think it would fit for sure on an STM32F7 and probably even an F4. I'd be willing to work on making a JS binding for LittlevGL if there was substantial interest. The main problem I see is that there are so many different implementations (JerryScript, QuickJS, etc.) which don't use the same API for bindings. I suppose using a script like what you use for MicroPython would help with that.
It's useful because it enables IoT developers to write the same type of code for both the browser interface and the device backend. |
If you are thinking about this, I suggest taking a close look at the other options. Which devices are supported? ROM/RAM requirements? Performance? One great thing about Micropython is that it can run in a variety of ways:
I wonder if any of the Javascript engines above expose such range of options.
Probably, but I'm not sure how much you could reuse the existing Micropython binding script for that. It's really geared towards Micropython. |
I'm pretty sure it can compile to bytecode as well. See page 3 of this PDF.
Much of that "auxiliary environment" is compilation infrastructure which won't be in the final bytecode/script. JavaScript keeps compilers and libraries together in one folder; his measurement includes both.
Most of that is probably React (which is fairly large). The author of QuickJS claims that it takes up "190 KiB of x86 code for a simple hello world program."
My point is that it could easily be run on a smaller device, just like how MicroPython runs on Linux but can also run on STM32, ESP32, etc.
Of course. I would have to write a new script that does the same type of thing, but for JavaScript instead. |
I also see great potential in a JS binding. As Python and JavaScript are the two most popular languages it'd be great to have bindings to them. BTW, JerryScript also claims that it runs with 64k RAM, 200 kB ROM.
At least the parser of the MicroPython can be used, can't it? And we already know lvgl has the conventions to generate a binding. Next year lvgl will have a new website where the bindings (and the simulator(s)) should be clearly highlighted. Some videos and tutorials also will be created as the bindings and the simulator really makes a difference compared to other gui libraries. Actually I don't know about any serious embedded UI library which has binding to any higher-level languages. |
Selecting the right js engine is a critical decision, since there are so many options.
The parser itself (pycparser) can be used, of course. |
We need to take into account lvgl versions on https://sim.littlevgl.com/. So I suggest something like:
What do you think? |
As long as it's not a requirement to continue updating the "v6" folder once "v7" is released, it shouldn't be any extra work. It just means adding some subdirectories to https://github.com/littlevgl/sim. I've moved the existing |
Once you deploy it - it will break existing links. (I fixed the one I posted today on lvgl/blog#20) You would also need to update the html on https://sim.littlevgl.com/, because micropython link is now broken. |
Good point. I will put back the old |
How about using a symbolic link to v6 instead?
…On Wed, Dec 18, 2019, 03:12 embeddedt ***@***.***> wrote:
Once you deploy it - it will break existing links.
Got it. I will put back the old micropython in the root directory, but it
will be permanently fixed at v6, for backwards compatibility. All changes
will only happen in the subdirectories.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#792>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACZS3LQ3Q3CPH5VINTBNM3DQZF2GVANCNFSM4GT6XZWA>
.
|
Yes; that would probably be a lot easier. |
I've added the symlink; it seems to work properly. |
Great! Is there any major things with the simulator? |
Ok. The simulator is usable, but I think should be polished and styled a little. |
Opened #1320. |
In continue of #687
Discuss how to concert micropython to javascript to have an online simulator where people can easily try LittlevGL in their browser without downloading anything.
Summarizing what's left before release:
import
support for scripts (waiting on py: handle builtins.__import__ micropython/micropython#4929)Later (once the initial version is up on https://littlevgl.com):
The text was updated successfully, but these errors were encountered: