Skip to content

Commit 1ed4940

Browse files
committed
Change to fetch
1 parent a37f032 commit 1ed4940

File tree

3 files changed

+166
-227
lines changed

3 files changed

+166
-227
lines changed

README.md

+76-123
Original file line numberDiff line numberDiff line change
@@ -959,131 +959,84 @@ https://github.com/lupyuen/pinephone-lvgl-zig/blob/d584f43c6354f12bdc15bdb8632cd
959959
Here's the log...
960960

961961
```text
962-
lvglwasm.js:72 main: start
963-
lvglwasm.js:76 loop: start
964-
lvglwasm.js:51 lv_demo_widgets: start
965-
lvglwasm.js:51 [Info] (0.001, +1) lv_init: begin (in lv_obj.c line #102)
966-
967-
lvglwasm.js:51 [Warn] (0.003, +2) lv_init: Log level is set to 'Trace' which makes LVGL much slower (in lv_obj.c line #176)
968-
969-
lvglwasm.js:51 [Trace] (0.004, +1) lv_init: finished (in lv_obj.c line #183)
970-
971-
lvglwasm.js:51 [Info] (0.006, +2) lv_obj_create: begin (in lv_obj.c line #206)
972-
973-
lvglwasm.js:51 [Trace] (0.007, +1) lv_obj_class_create_obj: Creating object with 0x174cc class on 0 parent (in lv_obj_class.c line #45)
974-
975-
lvglwasm.js:51 [Trace] (0.008, +1) lv_obj_class_create_obj: creating a screen (in lv_obj_class.c line #55)
976-
977-
[Trace] (0.009, +1) lv_obj_constructor: begin (in lv_obj.c line #403)
978-
979-
[Trace] (0.010, +1) lv_obj_constructor: finished (in lv_obj.c line #428)
980-
981-
[Info] (0.011, +1) lv_obj_create: begin (in lv_obj.c line #206)
982-
983-
[Trace] (0.012, +1) lv_obj_class_create_obj: Creating object with 0x174cc class on 0 parent (in lv_obj_class.c line #45)
984-
985-
[Trace] (0.013, +1) lv_obj_class_create_obj: creating a screen (in lv_obj_class.c line #55)
986-
987-
[Trace] (0.014, +1) lv_obj_constructor: begin (in lv_obj.c line #403)
988-
989-
[Trace] (0.015, +1) lv_obj_constructor: finished (in lv_obj.c line #428)
990-
991-
[Info] (0.016, +1) lv_obj_create: begin (in lv_obj.c line #206)
992-
993-
[Trace] (0.017, +1) lv_obj_class_create_obj: Creating object with 0x174cc class on 0 parent (in lv_obj_class.c line #45)
994-
995-
[Trace] (0.018, +1) lv_obj_class_create_obj: creating a screen (in lv_obj_class.c line #55)
996-
997-
[Trace] (0.019, +1) lv_obj_constructor: begin (in lv_obj.c line #403)
998-
999-
[Trace] (0.020, +1) lv_obj_constructor: finished (in lv_obj.c line #428)
1000-
1001-
createWidgetsWrapped: start
1002-
[Info] (0.022, +2) lv_label_create: begin (in lv_label.c line #75)
1003-
1004-
[Trace] (0.023, +1) lv_obj_class_create_obj: Creating object with 0x174b0 class on 0x39dfd0 parent (in lv_obj_class.c line #45)
1005-
1006-
[Trace] (0.024, +1) lv_obj_class_create_obj: creating normal object (in lv_obj_class.c line #82)
1007-
1008-
[Trace] (0.025, +1) lv_obj_constructor: begin (in lv_obj.c line #403)
1009-
1010-
[Trace] (0.026, +1) lv_obj_constructor: finished (in lv_obj.c line #428)
1011-
1012-
[Trace] (0.027, +1) lv_label_constructor: begin (in lv_label.c line #691)
1013-
1014-
[Trace] (0.028, +1) lv_label_constructor: finished (in lv_label.c line #721)
1015-
1016-
createWidgetsWrapped: end
1017-
lv_timer_handler: start
1018-
[Trace] (0.029, +1) lv_timer_handler: begin (in lv_timer.c line #69)
1019-
1020-
[Trace] (0.033, +4) lv_timer_exec: calling timer callback: 0x19 (in lv_timer.c line #312)
1021-
1022-
[Info] (0.035, +2) lv_obj_update_layout: Layout update begin (in lv_obj_pos.c line #314)
1023-
1024-
[Trace] (0.036, +1) lv_obj_update_layout: Layout update end (in lv_obj_pos.c line #317)
1025-
1026-
[Info] (0.037, +1) lv_obj_update_layout: Layout update begin (in lv_obj_pos.c line #314)
1027-
1028-
[Trace] (0.038, +1) lv_obj_update_layout: Layout update end (in lv_obj_pos.c line #317)
1029-
1030-
[Info] (0.039, +1) lv_obj_update_layout: Layout update begin (in lv_obj_pos.c line #314)
1031-
1032-
[Trace] (0.040, +1) lv_obj_update_layout: Layout update end (in lv_obj_pos.c line #317)
1033-
1034-
[Info] (0.041, +1) lv_obj_update_layout: Layout update begin (in lv_obj_pos.c line #314)
1035-
1036-
[Trace] (0.042, +1) lv_obj_update_layout: Layout update end (in lv_obj_pos.c line #317)
1037-
1038-
[Info] (0.043, +1) lv_obj_update_layout: Layout update begin (in lv_obj_pos.c line #314)
1039-
1040-
[Trace] (0.044, +1) lv_obj_update_layout: Layout update end (in lv_obj_pos.c line #317)
1041-
1042-
flushDisplay: start
1043-
render: start
1044-
lvglwasm.js:51 get_canvas_buffer: 1782 non-empty pixels
1045-
lvglwasm.js:51 canvas_buffer: 0x17e70
1046-
lvglwasm.js:27 {bufferOffset: 97904}
1047-
lvglwasm.js:39 render: end
1048-
lvglwasm.js:51 flushDisplay: end
1049-
lvglwasm.js:51 [Trace] (0.046, +2) lv_timer_exec: timer callback 0x19 finished (in lv_timer.c line #314)
1050-
1051-
lvglwasm.js:51 [Trace] (0.050, +4) lv_timer_handler: finished (15 ms until the next timer call) (in lv_timer.c line #144)
1052-
1053-
lvglwasm.js:51 lv_timer_handler: end
1054-
lvglwasm.js:51 lv_timer_handler: start
1055-
lvglwasm.js:51 [Trace] (0.051, +1) lv_timer_handler: begin (in lv_timer.c line #69)
1056-
1057-
lvglwasm.js:51 [Trace] (0.057, +6) lv_timer_handler: finished (8 ms until the next timer call) (in lv_timer.c line #144)
1058-
1059-
lvglwasm.js:51 lv_timer_handler: end
1060-
lvglwasm.js:51 lv_timer_handler: start
1061-
lvglwasm.js:51 [Trace] (0.058, +1) lv_timer_handler: begin (in lv_timer.c line #69)
1062-
1063-
lvglwasm.js:51 [Trace] (0.064, +6) lv_timer_handler: finished (1 ms until the next timer call) (in lv_timer.c line #144)
1064-
1065-
lvglwasm.js:51 lv_timer_handler: end
1066-
lvglwasm.js:51 lv_timer_handler: start
1067-
lvglwasm.js:51 [Trace] (0.065, +1) lv_timer_handler: begin (in lv_timer.c line #69)
1068-
1069-
lvglwasm.js:51 [Trace] (0.069, +4) lv_timer_exec: calling timer callback: 0x19 (in lv_timer.c line #312)
1070-
1071-
lvglwasm.js:51 [Trace] (0.071, +2) lv_timer_exec: timer callback 0x19 finished (in lv_timer.c line #314)
1072-
1073-
lvglwasm.js:51 [Trace] (0.074, +3) lv_timer_handler: finished (-1 ms until the next timer call) (in lv_timer.c line #144)
1074-
1075-
lvglwasm.js:51 lv_timer_handler: end
1076-
lvglwasm.js:51 lv_timer_handler: start
1077-
lvglwasm.js:51 [Trace] (0.075, +1) lv_timer_handler: begin (in lv_timer.c line #69)
1078-
1079-
lvglwasm.js:51 [Trace] (0.079, +4) lv_timer_handler: finished (-1 ms until the next timer call) (in lv_timer.c line #144)
1080-
1081-
lvglwasm.js:51 lv_timer_handler: end
1082-
lvglwasm.js:51 lv_demo_widgets: end
1083-
lvglwasm.js:84 loop: end
1084-
lvglwasm.js:87 main: end
962+
main: start
963+
loop: start
964+
lv_demo_widgets: start
965+
[Info] lv_init: begin (in lv_obj.c line #102)
966+
[Warn] lv_init: Log level is set to 'Trace' which makes LVGL much slower (in lv_obj.c line #176)
967+
[Trace] lv_init: finished (in lv_obj.c line #183)
968+
[Info] lv_obj_create: begin (in lv_obj.c line #206)
969+
[Trace] lv_obj_class_create_obj: Creating object with 0x174cc class on 0 parent (in lv_obj_class.c line #45)
970+
[Trace] lv_obj_class_create_obj: creating a screen (in lv_obj_class.c line #55)
971+
[Trace] lv_obj_constructor: begin (in lv_obj.c line #403)
972+
[Trace] lv_obj_constructor: finished (in lv_obj.c line #428)
973+
[Info] lv_obj_create: begin (in lv_obj.c line #206)
974+
[Trace] lv_obj_class_create_obj: Creating object with 0x174cc class on 0 parent (in lv_obj_class.c line #45)
975+
[Trace] lv_obj_class_create_obj: creating a screen (in lv_obj_class.c line #55)
976+
[Trace] lv_obj_constructor: begin (in lv_obj.c line #403)
977+
[Trace] lv_obj_constructor: finished (in lv_obj.c line #428)
978+
[Info] lv_obj_create: begin (in lv_obj.c line #206)
979+
[Trace] lv_obj_class_create_obj: Creating object with 0x174cc class on 0 parent (in lv_obj_class.c line #45)
980+
[Trace] lv_obj_class_create_obj: creating a screen (in lv_obj_class.c line #55)
981+
[Trace] lv_obj_constructor: begin (in lv_obj.c line #403)
982+
[Trace] lv_obj_constructor: finished (in lv_obj.c line #428)
983+
createWidgetsWrapped: start
984+
[Info] lv_label_create: begin (in lv_label.c line #75)
985+
[Trace] lv_obj_class_create_obj: Creating object with 0x174b0 class on 0x39dfd0 parent (in lv_obj_class.c line #45)
986+
[Trace] lv_obj_class_create_obj: creating normal object (in lv_obj_class.c line #82)
987+
[Trace] lv_obj_constructor: begin (in lv_obj.c line #403)
988+
[Trace] lv_obj_constructor: finished (in lv_obj.c line #428)
989+
[Trace] lv_label_constructor: begin (in lv_label.c line #691)
990+
[Trace] lv_label_constructor: finished (in lv_label.c line #721)
991+
createWidgetsWrapped: end
992+
lv_timer_handler: start
993+
[Trace] lv_timer_handler: begin (in lv_timer.c line #69)
994+
[Trace] lv_timer_exec: calling timer callback: 0x19 (in lv_timer.c line #312)
995+
[Info] lv_obj_update_layout: Layout update begin (in lv_obj_pos.c line #314)
996+
[Trace] lv_obj_update_layout: Layout update end (in lv_obj_pos.c line #317)
997+
[Info] lv_obj_update_layout: Layout update begin (in lv_obj_pos.c line #314)
998+
[Trace] lv_obj_update_layout: Layout update end (in lv_obj_pos.c line #317)
999+
[Info] lv_obj_update_layout: Layout update begin (in lv_obj_pos.c line #314)
1000+
[Trace] lv_obj_update_layout: Layout update end (in lv_obj_pos.c line #317)
1001+
[Info] lv_obj_update_layout: Layout update begin (in lv_obj_pos.c line #314)
1002+
[Trace] lv_obj_update_layout: Layout update end (in lv_obj_pos.c line #317)
1003+
[Info] lv_obj_update_layout: Layout update begin (in lv_obj_pos.c line #314)
1004+
[Trace] lv_obj_update_layout: Layout update end (in lv_obj_pos.c line #317)
1005+
flushDisplay: start
1006+
render: start
1007+
get_canvas_buffer: 1782 non-empty pixels
1008+
canvas_buffer: 0x17e70
1009+
{bufferOffset: 97904}
1010+
render: end
1011+
flushDisplay: end
1012+
[Trace] lv_timer_exec: timer callback 0x19 finished (in lv_timer.c line #314)
1013+
[Trace] lv_timer_handler: finished (15 ms until the next timer call) (in lv_timer.c line #144)
1014+
lv_timer_handler: end
1015+
lv_timer_handler: start
1016+
[Trace] lv_timer_handler: begin (in lv_timer.c line #69)
1017+
[Trace] lv_timer_handler: finished (8 ms until the next timer call) (in lv_timer.c line #144)
1018+
lv_timer_handler: end
1019+
lv_timer_handler: start
1020+
[Trace] lv_timer_handler: begin (in lv_timer.c line #69)
1021+
[Trace] lv_timer_handler: finished (1 ms until the next timer call) (in lv_timer.c line #144)
1022+
lv_timer_handler: end
1023+
lv_timer_handler: start
1024+
[Trace] lv_timer_handler: begin (in lv_timer.c line #69)
1025+
[Trace] lv_timer_exec: calling timer callback: 0x19 (in lv_timer.c line #312)
1026+
[Trace] lv_timer_exec: timer callback 0x19 finished (in lv_timer.c line #314)
1027+
[Trace] lv_timer_handler: finished (-1 ms until the next timer call) (in lv_timer.c line #144)
1028+
lv_timer_handler: end
1029+
lv_timer_handler: start
1030+
[Trace] lv_timer_handler: begin (in lv_timer.c line #69)
1031+
[Trace] lv_timer_handler: finished (-1 ms until the next timer call) (in lv_timer.c line #144)
1032+
lv_timer_handler: end
1033+
lv_demo_widgets: end
1034+
loop: end
1035+
main: end
10851036
```
10861037

1038+
# TODO
1039+
10871040
TODO: How to disassemble Compiled WebAssembly with cross-reference to Source Code? Like `objdump --source`? See [wabt](https://github.com/WebAssembly/wabt) and [binaryen](https://github.com/WebAssembly/binaryen)
10881041

10891042
# LVGL Screen Not Found

demo/game.js

+10-7
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
// Render Zig Program in WebAssembly. Based on...
1+
// Render Mandelbrot Set with a Zig Function in WebAssembly. Based on...
22
// https://dev.to/sleibrock/webassembly-with-zig-pt-ii-ei7
33
// https://github.com/daneelsan/zig-wasm-logger/blob/master/script.js
44

55
// References to Exported Zig Functions
66
let Game;
77

88
// Export JavaScript Functions to Zig
9-
let importObject = {
10-
// JavaScript Environment exported to Zig
9+
const importObject = {
10+
// JavaScript Functions exported to Zig
1111
env: {
1212
// JavaScript Print Function exported to Zig
1313
print: function(x) { console.log(x); }
@@ -59,16 +59,19 @@ function main() {
5959
console.log("main: end");
6060
};
6161

62-
// Load the WebAssembly Module
63-
// https://developer.mozilla.org/en-US/docs/WebAssembly/JavaScript_interface/instantiateStreaming
62+
// Load the WebAssembly Module and start the Main Function
6463
async function bootstrap() {
6564

66-
// Store references to WebAssembly Functions and Memory exported by Zig
67-
Game = await WebAssembly.instantiateStreaming(
65+
// Load the WebAssembly Module
66+
// https://developer.mozilla.org/en-US/docs/WebAssembly/JavaScript_interface/instantiateStreaming
67+
const result = await WebAssembly.instantiateStreaming(
6868
fetch("mandelbrot.wasm"),
6969
importObject
7070
);
7171

72+
// Store references to WebAssembly Functions and Memory exported by Zig
73+
Game = result;
74+
7275
// Start the Main Function
7376
main();
7477
}

0 commit comments

Comments
 (0)