Optimize performance: 4-bit SD_MMC, write-only SPI, and hardware byte swapping
This commit is contained in:
@@ -35,7 +35,7 @@ void pngDraw(PNGDRAW *pDraw) {
|
||||
png.getLineAsRGB565(pDraw, lineBuffer, PNG_RGB565_BIG_ENDIAN, 0xffffffff);
|
||||
uint32_t size = pDraw->iWidth;
|
||||
for (size_t i = 0; i < size; i++) {
|
||||
lineBuffer[i] = (((lineBuffer[i] >> 8) & 0xFF) | ((lineBuffer[i] << 8) & 0xFF00));
|
||||
lineBuffer[i] = __builtin_bswap16(lineBuffer[i]);
|
||||
}
|
||||
LCD_addWindow(xpos, pDraw->y, xpos + pDraw->iWidth - 1, ypos + pDraw->y, lineBuffer);
|
||||
}
|
||||
|
||||
@@ -202,14 +202,19 @@ parameter :
|
||||
Yend : End uint16_t coordinates
|
||||
color : Set the color
|
||||
******************************************************************************/
|
||||
void LCD_addWindow(uint16_t Xstart, uint16_t Ystart, uint16_t Xend, uint16_t Yend,uint16_t* color)
|
||||
void LCD_addWindow(uint16_t Xstart, uint16_t Ystart, uint16_t Xend, uint16_t Yend, uint16_t* color)
|
||||
{
|
||||
uint16_t Show_Width = Xend - Xstart + 1;
|
||||
uint16_t Show_Height = Yend - Ystart + 1;
|
||||
uint32_t numBytes = Show_Width * Show_Height * sizeof(uint16_t);
|
||||
uint8_t Read_D[numBytes];
|
||||
LCD_SetCursor(Xstart, Ystart, Xend, Yend);
|
||||
LCD_WriteData_nbyte((uint8_t*)color, Read_D, numBytes);
|
||||
|
||||
LCDspi.beginTransaction(SPISettings(SPIFreq, MSBFIRST, SPI_MODE0));
|
||||
digitalWrite(EXAMPLE_PIN_NUM_LCD_CS, LOW);
|
||||
digitalWrite(EXAMPLE_PIN_NUM_LCD_DC, HIGH);
|
||||
LCDspi.writeBytes((uint8_t*)color, numBytes);
|
||||
digitalWrite(EXAMPLE_PIN_NUM_LCD_CS, HIGH);
|
||||
LCDspi.endTransaction();
|
||||
}
|
||||
// backlight
|
||||
void Backlight_Init(void)
|
||||
|
||||
@@ -11,8 +11,8 @@ void SD_Init() {
|
||||
printf("SD MMC: Pin change failed!\r\n");
|
||||
return;
|
||||
}
|
||||
if (SD_MMC.begin("/sdcard", true, true)) {
|
||||
printf("SD card initialization successful!\r\n");
|
||||
if (SD_MMC.begin("/sdcard", false, true)) {
|
||||
printf("SD card initialization successful (4-bit mode)!\r\n");
|
||||
} else {
|
||||
printf("SD card initialization failed!\r\n");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user