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
Hello,
function ST7789_Fill_Color is not correct because memset is not working with uint16_t data, and the uint16_t buffer should be swap 2 byte high and low . So, we have to modify this function to working correct:
`void MemsetBuffer(uint16_t buf, uint16_t data, uint32_t size)
{
while(size--)
{ buf++ = data;
}
}
/
I could not get MemsetBuffer to compile using STMCubeIDE so I changed it to:
`
void MemsetBuffer(void *m, uint16_t val, size_t count) {
{
char *buf = m;
union
{
uint8_t d8[2];
uint16_t d16;
}u16 = {.d16 = val};
} I then called it using this slightly modified code:
MemsetBuffer(disp_buf, convert_color, ST7789_WIDTH * HOR_LEN);
for (i = 0; i < ST7789_HEIGHT / HOR_LEN; i++) {
ST7789_WriteData(&disp_buf, sizeof(disp_buf));
}
`
I moved the call to 'MemsetBuffer' out of the for loop as the buffer already contains what it needs to so we are just wasting clock cycles filling it up again.
Hello,
function ST7789_Fill_Color is not correct because memset is not working with uint16_t data, and the uint16_t buffer should be swap 2 byte high and low . So, we have to modify this function to working correct:
`void MemsetBuffer(uint16_t buf, uint16_t data, uint32_t size)
{
while(size--)
{
buf++ = data;
}
}
/
*/
void ST7789_Fill_Color(uint16_t color)
{
uint16_t i;
uint16_t convert_color;
ST7789_SetAddressWindow(0, 0, ST7789_WIDTH - 1, ST7789_HEIGHT - 1);
ST7789_Select();
convert_color = ((color & 0xFF) << 8) | ((color & 0xFF00) >> 8);
#ifdef LCD_USE_DMA
for (i = 0; i < ST7789_HEIGHT / HOR_LEN; i++)
{
MemsetBuffer(disp_buf, convert_color, ST7789_WIDTH * HOR_LEN);
ST7789_WriteData((uint8_t *)disp_buf, sizeof(disp_buf));
}
#else
uint16_t j;
for (i = 0; i < ST7789_WIDTH; i++)
for (j = 0; j < ST7789_HEIGHT; j++) {
uint8_t data[] = {color >> 8, color & 0xFF};
ST7789_WriteData(data, sizeof(data));
}
#endif
ST7789_UnSelect();
}`
The text was updated successfully, but these errors were encountered: