From 001780419373bc1fddf7f74031dd5416e76dde21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cle=CC=81ment=20Grennerat?= Date: Sun, 14 Sep 2025 22:53:11 +0200 Subject: [PATCH] Char write using burst --- Core/Src/font.c | 37 +++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/Core/Src/font.c b/Core/Src/font.c index 18bb37b..6ffb57d 100644 --- a/Core/Src/font.c +++ b/Core/Src/font.c @@ -22,7 +22,7 @@ void GFX_DrawChar( if (startX + glyph->width <= 0 || startX >= LCD_WIDTH) return; if (startY + glyph->height <= 0 || startY >= LCD_HEIGHT) return; -// LCD_Set_Address(startX, startY, startX + glyph->width - 1, startY + glyph->height - 1); + LCD_Set_Address(startX, startY, startX + glyph->width - 1, startY + glyph->height - 1); uint16_t pendingPixelCount = 0; uint8_t pendingPixelBit = 0; @@ -33,25 +33,26 @@ void GFX_DrawChar( uint8_t bitIndex = bitPos % 8; uint8_t pixelBit = font->bitmaps[byteIndex] & (0x80 >> bitIndex); -// if(pixelBit == pendingPixelBit) { -// pendingPixelCount++; -// }else { -// if(pendingPixelCount != 0) { -// LCD_Draw_Colour_Burst(pendingPixelBit ? fg_color : bg_color, pendingPixelCount); -// pendingPixelCount = 0; -// } -// pendingPixelBit = pixelBit; -// } - - uint16_t pixelColor = pixelBit ? fg_color : bg_color; - - int16_t absX = startX + col; - int16_t absY = startY + row; - - if (absX >= 0 && absX < LCD_WIDTH && absY >= 0 && absY < LCD_HEIGHT) { - LCD_Draw_Pixel(absX, absY, pixelColor); + if(pixelBit == pendingPixelBit) { + pendingPixelCount++; + }else { + if(pendingPixelCount != 0) { + LCD_Draw_Colour_Burst(pendingPixelBit ? fg_color : bg_color, pendingPixelCount); + pendingPixelCount = 1; + } + pendingPixelBit = pixelBit; } +// Per pixel way: slower +// uint16_t pixelColor = pixelBit ? fg_color : bg_color; +// +// int16_t absX = startX + col; +// int16_t absY = startY + row; +// +// if (absX >= 0 && absX < LCD_WIDTH && absY >= 0 && absY < LCD_HEIGHT) { +// LCD_Draw_Pixel(absX, absY, pixelColor); +// } + bitPos++; } }