Description
Hi, sorry, maybe I shouldn’t have written to this topic.
I have problems with displaying the image on the screen.
I think the problem is in the functions:
flush_cb
rounder_cb
set_px_cb
MCU/Processor/Board.
STM32F446
LVGL version.
8.0.2
What do you want to achieve?
Maybe someone will give a link to the correct code.
But for now, I’m using this
#define SSD1306_HEIGHT 64
#define SSD1306_WIDTH 128
#define SSD1306_BUFFER_SIZE ((SSD1306_WIDTH * SSD1306_HEIGHT) / 8)
static void flush_cb(struct _lv_disp_drv_t *disp_drv, const lv_area_t *area, lv_color_t *color_p)
{
/*The most simple case (but also the slowest) to put all pixels to the screen one-by-one*/
uint8_t row1 = area->y1 >> 3;
uint8_t row2 = area->y2 >> 3;
uint8_t *buf = (uint8_t *)color_p;
for (uint8_t row = row1; row <= row2; row++)
{
writeCommandSsd1306(0xB0 | row); // Set the page start address
writeCommandSsd1306(0x00 | (area->x1 & 0xF)); // Set the lower start column address
writeCommandSsd1306(0x10 | ((area->x1 >> 4) & 0xF)); // Set the upper start column address
for (uint16_t x = area->x1; x <= area->x2; x++)
{
writeDataSsd1306(buf, 1);
buf++;
}
}
/* IMPORTANT!!!
* Inform the graphics library that you are ready with the flushing. */
lv_disp_flush_ready(disp_drv);
}
static void set_px_cb(struct _lv_disp_drv_t *disp_drv, uint8_t *buf, lv_coord_t buf_w, lv_coord_t x, lv_coord_t y, lv_color_t color, lv_opa_t opa)
{
(void)disp_drv;
(void)opa;
(void)buf_w;
if (x >= SSD1306_WIDTH || y >= SSD1306_HEIGHT)
{
// Don't write outside the buffer
return;
}
// Draw in the right color
if (color.full == 0)
{
buf[x + (y / 8) * SSD1306_WIDTH] |= 1 << (y % 8);
}
else
{
buf[x + (y / 8) * SSD1306_WIDTH] &= ~(1 << (y % 8));
}
}