refactor: update epd lib & example

This commit is contained in:
IOsetting 2023-03-12 14:59:09 +08:00
parent 512ff5e4dc
commit 4c651bfc34
4 changed files with 10 additions and 11 deletions

View File

@ -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);

View File

@ -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

View File

@ -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");

View File

@ -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();
}
}