From 4c651bfc34d71dbbc301290da716efdaa6440c86 Mon Sep 17 00:00:00 2001 From: IOsetting Date: Sun, 12 Mar 2023 14:59:09 +0800 Subject: [PATCH] refactor: update epd lib & example --- Examples/HAL/SPI/Waveshare_1.54_EPaper/main.c | 4 +++- Examples/LL/SPI/Waveshare_1.54_EPaper/main.c | 2 ++ Libraries/EPaper/Examples/EPD_1in54_test.c | 12 ++---------- Libraries/EPaper/Lib/EPD_1in54.c | 3 +++ 4 files changed, 10 insertions(+), 11 deletions(-) diff --git a/Examples/HAL/SPI/Waveshare_1.54_EPaper/main.c b/Examples/HAL/SPI/Waveshare_1.54_EPaper/main.c index 1fd2530..7daf416 100644 --- a/Examples/HAL/SPI/Waveshare_1.54_EPaper/main.c +++ b/Examples/HAL/SPI/Waveshare_1.54_EPaper/main.c @@ -1,6 +1,8 @@ /*** * Demo: Waveshare 1.54' E-Paper * + * This demo requires 7.1 KByte RAM + * * PY32 E-Paper * PA0 ------> Reset * PA1 ------> SCL/SCK @@ -27,7 +29,7 @@ static void APP_SPI_Config(void); int main(void) { HAL_Init(); - BSP_HSI_PLL_48MHzClockConfig(); + BSP_HSI_24MHzClockConfig(); BSP_USART_Config(); printf("SystemClk:%ld\r\n", SystemCoreClock); diff --git a/Examples/LL/SPI/Waveshare_1.54_EPaper/main.c b/Examples/LL/SPI/Waveshare_1.54_EPaper/main.c index e2162ae..97dc034 100644 --- a/Examples/LL/SPI/Waveshare_1.54_EPaper/main.c +++ b/Examples/LL/SPI/Waveshare_1.54_EPaper/main.c @@ -1,6 +1,8 @@ /*** * Demo: Waveshare 1.54' E-Paper * + * This demo requires 7.1 KByte RAM + * * PY32 E-Paper * PA0 ------> Reset * PA1 ------> CLK/SCK diff --git a/Libraries/EPaper/Examples/EPD_1in54_test.c b/Libraries/EPaper/Examples/EPD_1in54_test.c index d32dfed..28f83c1 100644 --- a/Libraries/EPaper/Examples/EPD_1in54_test.c +++ b/Libraries/EPaper/Examples/EPD_1in54_test.c @@ -32,6 +32,8 @@ #ifdef EPD_1IN54 +UBYTE BlackImage[(EPD_1IN54_WIDTH / 8) * EPD_1IN54_HEIGHT]; + int EPD_test(void) { printf("EPD_1IN54_test Demo\r\n"); @@ -42,14 +44,6 @@ int EPD_test(void) EPD_1IN54_Clear(); EPD_Delay_ms(500); - //Create a new image cache - UBYTE *BlackImage; - /* you have to edit the startup_stm32fxxx.s file and set a big enough heap size */ - UWORD Imagesize = ((EPD_1IN54_WIDTH % 8 == 0)? (EPD_1IN54_WIDTH / 8 ): (EPD_1IN54_WIDTH / 8 + 1)) * EPD_1IN54_HEIGHT; - if((BlackImage = (UBYTE *)malloc(Imagesize)) == NULL) { - printf("Failed to apply for black memory...\r\n"); - return -1; - } printf("Paint_NewImage\r\n"); Paint_NewImage(BlackImage, EPD_1IN54_WIDTH, EPD_1IN54_HEIGHT, 270, WHITE); @@ -137,8 +131,6 @@ int EPD_test(void) printf("Goto Sleep...\r\n"); EPD_1IN54_Sleep(); - free(BlackImage); - BlackImage = NULL; // close 5V printf("close 5V, Module enters 0 power consumption ...\r\n"); diff --git a/Libraries/EPaper/Lib/EPD_1in54.c b/Libraries/EPaper/Lib/EPD_1in54.c index 7b8fe55..b67f7cb 100644 --- a/Libraries/EPaper/Lib/EPD_1in54.c +++ b/Libraries/EPaper/Lib/EPD_1in54.c @@ -137,6 +137,7 @@ static void EPD_1IN54_SendData(UBYTE Data) { EPD_Digital_Write(EPD_DC_PIN, 1); EPD_SPI_WriteByte(Data); + __NOP(); } static void EPD_1IN54_SendDataArray(const UBYTE *Data, UWORD len) @@ -145,6 +146,7 @@ static void EPD_1IN54_SendDataArray(const UBYTE *Data, UWORD len) while (len--) { EPD_SPI_WriteByte(*Data++); + __NOP(); } } @@ -154,6 +156,7 @@ static void EPD_1IN54_SendDataBurst(const UBYTE Data, UWORD len) while (len--) { EPD_SPI_WriteByte(Data); + __NOP(); } }