@@ -44,7 +44,9 @@ pub export fn lv_demo_widgets() void {
4444 c .lv_log_register_print_cb (custom_logger );
4545
4646 // Init LVGL
47+ debug ("before lv_init" , .{}); ////
4748 c .lv_init ();
49+ debug ("after lv_init" , .{}); ////
4850
4951 // Fetch pointers to Display Driver and Display Buffer
5052 const disp_drv = c .get_disp_drv ();
@@ -177,40 +179,16 @@ export fn millis() u32 {
177179/// Number of elapsed milliseconds
178180var elapsed_ms : u32 = 0 ;
179181
180- /// TODO: Print a Stack Trace on Assertion Failure and halt
182+ /// On Assertion Failure, print a Stack Trace and halt
181183export fn lv_assert_handler () void {
182- wasmlog . Console . log ("*** lv_assert_handler: ASSERTION FAILED" , .{} );
184+ @panic ("*** lv_assert_handler: ASSERTION FAILED" );
183185}
184186
185187/// Custom Logger for LVGL that writes to JavaScript Console
186188export fn custom_logger (buf : [* c ]const u8 ) void {
187189 wasmlog .Console .log ("{s}" , .{buf });
188190}
189191
190- ///////////////////////////////////////////////////////////////////////////////
191- // Panic Handler
192-
193- /// Called by Zig when it hits a Panic. We print the Panic Message, Stack Trace and halt. See
194- /// https://andrewkelley.me/post/zig-stack-traces-kernel-panic-bare-bones-os.html
195- /// https://github.com/ziglang/zig/blob/master/lib/std/builtin.zig#L763-L847
196- pub fn panic (message : []const u8 , _stack_trace : ? * std.builtin.StackTrace ) noreturn {
197- // Print the Panic Message
198- _ = _stack_trace ;
199- wasmlog .Console .log ("\n !ZIG PANIC!\n {s}" , .{message });
200-
201- // TODO: Print the Stack Trace
202- wasmlog .Console .log ("Stack Trace:" , .{});
203- var it = std .debug .StackIterator .init (@returnAddress (), null );
204- while (it .next ()) | return_address | {
205- wasmlog .Console .log ("{}" , .{@intCast (i32 , return_address )});
206- }
207-
208- // Halt
209- while (true ) {
210- wasmlog .Console .log ("Halted" , .{});
211- }
212- }
213-
214192///////////////////////////////////////////////////////////////////////////////
215193// Logging
216194
0 commit comments