Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork219
Description
I am having trouble with the screen turning white immediately on startup and not showing anything. I'm using an Arduino Giga with an Arduino Giga Display Shield, LVGL v9.2.2, and Arduino_H7_Video.
To test the display buffer, I replaced the code in the display buffer to colour the screen red (i.e., replaced the code in the second for loop withDisplay.set(x, y, 255, 0, 0);). I saw the red streak through the display in blocks, and then the blocks be trailed almost immediately by black as the red continued down the screen (whether or not I had the code forlv_obj_t * screen_black = lv_obj_create(NULL); there or not), then the screen turned white. I also put a serial print in the flush callback that was outputting to the monitor. So I know that the flush callback is being called and is working.
If I replacelv_obj_t * screen_black = lv_obj_create(NULL); withlv_obj_t * screen_black = lv_obj_create(lv_screen_active());, leave the rest of the code for the screen obj, and remove the code for creating the display and buffers, the screen does appropriately turn black (with a small white border).
Any ideas of what might be going on here?
#include<Arduino_H7_Video.h>#include<Arduino_GigaDisplay.h>// v1.0.2#include<Arduino_GigaDisplayTouch.h>// v1.0.1#include<lvgl.h>// LVGL v9.2.2#include<ArduinoGraphics.h>Arduino_H7_VideoDisplay(800,480,GigaDisplayShield);Arduino_GigaDisplayTouchTouchDetector;voidsetup() {// put your setup code here, to run once:Serial.begin(115200);Display.begin();lv_init();lv_display_t*display=lv_display_create(800,480);staticuint8_tbuf1[800*480 /10];lv_display_set_buffers(display,buf1,NULL,sizeof(buf1),LV_DISPLAY_RENDER_MODE_PARTIAL);lv_display_set_flush_cb(display,my_disp_flush);lv_disp_set_default(display);lv_obj_t*screen_black=lv_obj_create(NULL);lv_obj_set_size(screen_black,800,480);lv_obj_set_style_bg_color(screen_black,lv_color_black(),LV_PART_MAIN);lv_obj_set_style_bg_opa(screen_black,LV_OPA_COVER,LV_PART_MAIN);lv_screen_load(screen_black);}voidloop() {// put your main code here, to run repeatedly:lv_timer_handler();}voidmy_disp_flush(lv_display_t*disp,constlv_area_t*area,uint8_t*color_p) {// Cast the buffer to lv_color_t for proper interpretationlv_color_t*color_map= (lv_color_t*)color_p;// Start drawing to the framebufferDisplay.beginDraw();// Loop through the area and set pixelsfor (int32_ty=area->y1;y <=area->y2;y++) {for (int32_tx=area->x1;x <=area->x2;x++) {// Extract RGB565 from lv_color_tuint16_tcolor=*((uint16_t*)color_map);// Convert RGB565 to R, G, B componentsuint8_tr= (color >>11)&0x1F;// Extract 5 bits for reduint8_tg= (color >>5)&0x3F;// Extract 6 bits for greenuint8_tb=color&0x1F;// Extract 5 bits for blue// Scale to 8-bit values (0-255)r= (r*255) /31;g= (g*255) /63;b= (b*255) /31;// Set the pixel colorDisplay.set(x,y,r,g,b);// Advance to the next color in the buffercolor_map++; } }// End drawing operationDisplay.endDraw();lv_display_flush_ready(disp);}