05-25-2023, 10:20 PM
Haha no worries @WhiteHexagon , I'm now working on something really interesting: Simulate PinePhone UI with Zig, LVGL and WebAssembly :-)
|
Article: Inside a Smartphone Accelerometer: PinePhone with NuttX RTOS
|
|
05-25-2023, 10:20 PM
Haha no worries @WhiteHexagon , I'm now working on something really interesting: Simulate PinePhone UI with Zig, LVGL and WebAssembly :-)
05-26-2023, 04:32 AM
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);
})
05-28-2023, 06:09 AM
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 |