You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 with Display.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 for lv_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 replace lv_obj_t * screen_black = lv_obj_create(NULL); with lv_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);
}
The text was updated successfully, but these errors were encountered:
Hi @littlejohn657,
You don't need to implement the my_disp_flush callback in your sketch program, as the library already includes it.
Additionally, the Display.begin() function takes care of everything needed to get LVGL running correctly, including LVGL library initialization, buffer setup, and flushing function declaration.
Take a look at this example, LVGLDemo.ino, and this tutorial to get started with Arduino_H7_Video and LVGL on the Giga Display Shield.
Here’s a minimal sketch to display a black screen with a "Hello world" label centered on it:
#include "Arduino_H7_Video.h"
#include "Arduino_GigaDisplayTouch.h"
#include "lvgl.h" // LVGL v9.2.2
Arduino_H7_Video Display(800, 480, GigaDisplayShield);
Arduino_GigaDisplayTouch TouchDetector;
/* "Hello World" example, source: https://docs.lvgl.io/master/examples.html */
void setup() {
Display.begin();
TouchDetector.begin();
/* Change the active screen's background color */
lv_obj_set_style_bg_color(lv_screen_active(), lv_color_black(), LV_PART_MAIN);
/* Create a white label, set its text and align it to the center */
lv_obj_t * label = lv_label_create(lv_screen_active());
lv_label_set_text(label, "Hello world");
lv_obj_set_style_text_color(lv_screen_active(), lv_color_hex(0xffffff), LV_PART_MAIN);
lv_obj_align(label, LV_ALIGN_CENTER, 0, 0);
}
void loop() {
lv_timer_handler();
}
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 with
Display.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 replace
lv_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?
The text was updated successfully, but these errors were encountered: