Skip to content

Commit 5e4d661

Browse files
committed
LVGL render OK yay!
1 parent 2e1c97e commit 5e4d661

File tree

3 files changed

+14
-7
lines changed

3 files changed

+14
-7
lines changed

display.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,12 @@ lv_color_t *get_canvas_buffer(void)
1818
int count = 0;
1919
for (int i = 0; i < BUFFER_SIZE; i++) {
2020
if (canvas_buffer[i].full != 0xfff5f5f5) { // TODO
21-
lv_log("get_canvas_buffer: 0x%x", canvas_buffer[i].full);
21+
// lv_log("get_canvas_buffer: 0x%x", canvas_buffer[i].full);
2222
count++;
2323
}
2424
}
25-
lv_log("get_canvas_buffer: %d", count);
25+
lv_log("get_canvas_buffer: %d non-empty pixels", count);
26+
lv_log("canvas_buffer: %p", canvas_buffer);
2627
return canvas_buffer;
2728
}
2829

lvglwasm.js

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,20 @@ request.onload = function() {
2121
env: {
2222
// Render the LVGL Canvas from Zig to HTML
2323
// https://github.com/daneelsan/minimal-zig-wasm-canvas/blob/master/script.js
24-
render: function() {
24+
render: function() { // TODO: Add ptr, width, height
2525
console.log("render: start");
2626
const bufferOffset = wasm.instance.exports.getCanvasBuffer();
2727
console.log({ bufferOffset });
28-
const imageDataArray = wasmMemoryArray.slice(
29-
bufferOffset,
30-
bufferOffset + (canvas.width * canvas.height) * 4
31-
);
28+
29+
// const imageDataArray = wasmMemoryArray.slice(
30+
// bufferOffset,
31+
// bufferOffset + (canvas.width * canvas.height) * 4
32+
// );
33+
34+
const memory = wasm.instance.exports.memory;
35+
const ptr = bufferOffset;
36+
const len = (canvas.width * canvas.height) * 4;
37+
const imageDataArray = new Uint8Array(memory.buffer, ptr, len)
3238
imageData.data.set(imageDataArray);
3339

3440
context.clearRect(0, 0, canvas.width, canvas.height);

lvglwasm.wasm

4 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)