@@ -222,6 +222,7 @@ int main(void)
222222 struct display_buffer_descriptor buf_desc ;
223223 size_t buf_size = 0 ;
224224 fill_buffer fill_buffer_fnc = NULL ;
225+ int ret ;
225226
226227 display_dev = DEVICE_DT_GET (DT_CHOSEN (zephyr_display ));
227228 if (!device_is_ready (display_dev )) {
@@ -362,7 +363,15 @@ int main(void)
362363 if ((capabilities .y_resolution - idx ) < h_step ) {
363364 buf_desc .height = (capabilities .y_resolution - idx );
364365 }
365- display_write (display_dev , 0 , idx , & buf_desc , buf );
366+ ret = display_write (display_dev , 0 , idx , & buf_desc , buf );
367+ if (ret < 0 ) {
368+ LOG_ERR ("Failed to write to display (error %d)" , ret );
369+ #ifdef CONFIG_ARCH_POSIX
370+ posix_exit_main (1 );
371+ #else
372+ return 0 ;
373+ #endif
374+ }
366375 }
367376
368377 buf_desc .pitch = rect_w ;
@@ -372,12 +381,28 @@ int main(void)
372381 fill_buffer_fnc (TOP_LEFT , 0 , buf , buf_size );
373382 x = 0 ;
374383 y = 0 ;
375- display_write (display_dev , x , y , & buf_desc , buf );
384+ ret = display_write (display_dev , x , y , & buf_desc , buf );
385+ if (ret < 0 ) {
386+ LOG_ERR ("Failed to write to display (error %d)" , ret );
387+ #ifdef CONFIG_ARCH_POSIX
388+ posix_exit_main (1 );
389+ #else
390+ return 0 ;
391+ #endif
392+ }
376393
377394 fill_buffer_fnc (TOP_RIGHT , 0 , buf , buf_size );
378395 x = capabilities .x_resolution - rect_w ;
379396 y = 0 ;
380- display_write (display_dev , x , y , & buf_desc , buf );
397+ ret = display_write (display_dev , x , y , & buf_desc , buf );
398+ if (ret < 0 ) {
399+ LOG_ERR ("Failed to write to display (error %d)" , ret );
400+ #ifdef CONFIG_ARCH_POSIX
401+ posix_exit_main (1 );
402+ #else
403+ return 0 ;
404+ #endif
405+ }
381406
382407 /*
383408 * This is the last write of the frame, so turn this off.
@@ -389,9 +414,25 @@ int main(void)
389414 fill_buffer_fnc (BOTTOM_RIGHT , 0 , buf , buf_size );
390415 x = capabilities .x_resolution - rect_w ;
391416 y = capabilities .y_resolution - rect_h ;
392- display_write (display_dev , x , y , & buf_desc , buf );
417+ ret = display_write (display_dev , x , y , & buf_desc , buf );
418+ if (ret < 0 ) {
419+ LOG_ERR ("Failed to write to display (error %d)" , ret );
420+ #ifdef CONFIG_ARCH_POSIX
421+ posix_exit_main (1 );
422+ #else
423+ return 0 ;
424+ #endif
425+ }
393426
394- display_blanking_off (display_dev );
427+ ret = display_blanking_off (display_dev );
428+ if (ret < 0 && ret != - ENOSYS ) {
429+ LOG_ERR ("Failed to turn blanking off (error %d)" , ret );
430+ #ifdef CONFIG_ARCH_POSIX
431+ posix_exit_main (1 );
432+ #else
433+ return 0 ;
434+ #endif
435+ }
395436
396437 grey_count = 0 ;
397438 x = 0 ;
@@ -400,7 +441,16 @@ int main(void)
400441 LOG_INF ("Display starts" );
401442 while (1 ) {
402443 fill_buffer_fnc (BOTTOM_LEFT , grey_count , buf , buf_size );
403- display_write (display_dev , x , y , & buf_desc , buf );
444+ ret = display_write (display_dev , x , y , & buf_desc , buf );
445+ if (ret < 0 ) {
446+ LOG_ERR ("Failed to write to display (error %d)" , ret );
447+ #ifdef CONFIG_ARCH_POSIX
448+ posix_exit_main (1 );
449+ #else
450+ return 0 ;
451+ #endif
452+ }
453+
404454 ++ grey_count ;
405455 k_msleep (grey_scale_sleep );
406456#if CONFIG_TEST
0 commit comments