PINE64
Article: Inside a Smartphone Accelerometer: PinePhone with NuttX RTOS - Printable Version

+- PINE64 (https://forum.pine64.org)
+-- Forum: PinePhone (https://forum.pine64.org/forumdisplay.php?fid=120)
+--- Forum: PinePhone Software (https://forum.pine64.org/forumdisplay.php?fid=121)
+--- Thread: Article: Inside a Smartphone Accelerometer: PinePhone with NuttX RTOS (/showthread.php?tid=18236)

Pages: 1 2 3


RE: Article: Inside a Smartphone Accelerometer: PinePhone with NuttX RTOS - lupyuen - 05-25-2023

Haha no worries @WhiteHexagon , I'm now working on something really interesting: Simulate PinePhone UI with Zig, LVGL and WebAssembly :-)


RE: Article: Inside a Smartphone Accelerometer: PinePhone with NuttX RTOS - WhiteHexagon - 05-26-2023

Nice! @lupyuen  btw when you are missing functions in Zig/WASM it is often easier to make a call into the javascript world, unless you are on a performance critical path.  For my wasm stuff I also keep the render loop on the JS side using requestAnimationFrame but with a custom callback into Zig (once per frame) passing over a frame number, timestamp and canvas2d context.


roughly:

     
Code:
  WebAssembly.instantiateStreaming(fetch('app.wasm'),{env}).then(wa=>{             zex=wa.instance.exports;             zmb=zex.memory.buffer;             zex.run();             let fn=0;      //frame number             function frame(ts) {                 zex.drawFrame(ctx,fn,timestamp);                 fn++;                 globalThis.requestAnimationFrame(frame);             }             globalThis.requestAnimationFrame(frame);         })



RE: Article: Inside a Smartphone Accelerometer: PinePhone with NuttX RTOS - lupyuen - 05-28-2023

Thanks @WhiteHexagon for the tips, we now have LVGL rendering OK in the Web Browser, compiled with Zig yay! :-)

LVGL renders OK in WebAssembly with Zig Compiler