soonuse / epd-library-stm32 Goto Github PK
View Code? Open in Web Editor NEWSTM32 libraries for Waveshare e-paper series 1.54"/1.54" B/2.13"/2.13" B/2.7"/2.7" B/2.9"/2.9" B/4.2"/4.2" B/7.5"/ 7.5" B
License: GNU General Public License v3.0
STM32 libraries for Waveshare e-paper series 1.54"/1.54" B/2.13"/2.13" B/2.7"/2.7" B/2.9"/2.9" B/4.2"/4.2" B/7.5"/ 7.5" B
License: GNU General Public License v3.0
Hello, I am currently working on a project using a 2.13-inch E-paper display with my STM32F756ZG Nucleo board. I am not using Keil MDK but STM32CubeIDE as an IDE. However, when I program the board, nothing happens on the display and all I get is a screen with white noise and black/white dots. Here are the steps I took:
Created the project using STM32CubeIDE and configured the peripherals/pins exactly as defined in the "epd2in13-demo" PDF file found in the "2.13inch_e-paper" file.
Generated the code and copied the FONTS and BSP C/H files to the project.
Changed the #include "stm32f7xx_hal.h" in the epdif.h file.
Copied the int main function from the example and compiled the code with no errors. Programmed the board, but the screen doesn't show anything at all.
here's the main.c code :
`/* USER CODE BEGIN Header /
/*
/
/ USER CODE END Header /
/ Includes ------------------------------------------------------------------*/
#include "main.h"
/* Private includes ----------------------------------------------------------/
/ USER CODE BEGIN Includes /
#include "epd2in13.h"
#include "epdif.h"
#include "epdpaint.h"
#include "imagedata.h"
#include <stdlib.h>
#include <stdio.h>
/ USER CODE END Includes */
/* Private typedef -----------------------------------------------------------/
/ USER CODE BEGIN PTD */
/* USER CODE END PTD */
/* Private define ------------------------------------------------------------/
/ USER CODE BEGIN PD */
/* USER CODE END PD */
/* Private macro -------------------------------------------------------------/
/ USER CODE BEGIN PM */
/* USER CODE END PM */
/* Private variables ---------------------------------------------------------*/
SPI_HandleTypeDef hspi1;
UART_HandleTypeDef huart3;
/* USER CODE BEGIN PV /
#define COLORED 0
#define UNCOLORED 1
/ USER CODE END PV */
/* Private function prototypes -----------------------------------------------/
void SystemClock_Config(void);
static void MX_GPIO_Init(void);
static void MX_USART3_UART_Init(void);
static void MX_SPI1_Init(void);
/ USER CODE BEGIN PFP */
/* USER CODE END PFP */
/* Private user code ---------------------------------------------------------/
/ USER CODE BEGIN 0 */
int _write(int file, char ptr, int len)
{
HAL_UART_Transmit(&huart3, (uint8_t)ptr, len, HAL_MAX_DELAY);
return len;
}
/* USER CODE END 0 */
/**
/* MCU Configuration--------------------------------------------------------*/
/* Reset of all peripherals, Initializes the Flash interface and the Systick. */
HAL_Init();
/* USER CODE BEGIN Init */
/* USER CODE END Init */
/* Configure the system clock */
SystemClock_Config();
/* USER CODE BEGIN SysInit */
/* USER CODE END SysInit */
/* Initialize all configured peripherals /
MX_GPIO_Init();
MX_USART3_UART_Init();
MX_SPI1_Init();
/ USER CODE BEGIN 2 */
EPD epd;
if (EPD_Init(&epd, lut_full_update) != 0) {
printf("e-Paper init failed\n");
return -1;
}
Paint paint;
Paint_Init(&paint, frame_buffer, epd.width, epd.height);
Paint_Clear(&paint, UNCOLORED);
/* For simplicity, the arguments are explicit numerical coordinates /
/ Write strings to the buffer */
Paint_DrawFilledRectangle(&paint, 0, 10, 128, 30, COLORED);
Paint_DrawStringAt(&paint, 30, 14, "Hello world!", &Font12, UNCOLORED);
Paint_DrawStringAt(&paint, 30, 34, "e-Paper Demo", &Font12, COLORED);
/* Draw something to the frame buffer */
Paint_DrawRectangle(&paint, 10, 60, 50, 100, COLORED);
Paint_DrawLine(&paint, 10, 60, 50, 100, COLORED);
Paint_DrawLine(&paint, 50, 60, 10, 100, COLORED);
Paint_DrawCircle(&paint, 88, 80, 30, COLORED);
Paint_DrawFilledRectangle(&paint, 10, 120, 50, 180, COLORED);
Paint_DrawFilledCircle(&paint, 88, 150, 30, COLORED);
/* Display the frame_buffer */
EPD_SetFrameMemory(&epd, frame_buffer, 0, 0, Paint_GetWidth(&paint), Paint_GetHeight(&paint));
EPD_DisplayFrame(&epd);
EPD_DelayMs(&epd, 2000);
/**
/* EPD_or partial update */
if (EPD_Init(&epd, lut_partial_update) != 0) {
printf("e-Paper init failed\n");
return -1;
}
/**
time_start_ms = HAL_GetTick();
/* USER CODE END 2 */
/* Infinite loop /
/ USER CODE BEGIN WHILE /
while (1)
{
/ USER CODE END WHILE */
/* USER CODE BEGIN 3 */
time_now_s = (HAL_GetTick() - time_start_ms) / 1000;
time_string[0] = time_now_s / 60 / 10 + '0';
time_string[1] = time_now_s / 60 % 10 + '0';
time_string[3] = time_now_s % 60 / 10 + '0';
time_string[4] = time_now_s % 60 % 10 + '0';
Paint_SetWidth(&paint, 32);
Paint_SetHeight(&paint, 96);
Paint_SetRotate(&paint, ROTATE_90);
Paint_Clear(&paint, UNCOLORED);
Paint_DrawStringAt(&paint, 0, 4, time_string, &Font24, COLORED);
EPD_SetFrameMemory(&epd, frame_buffer, 80, 72, Paint_GetWidth(&paint), Paint_GetHeight(&paint));
EPD_DisplayFrame(&epd);
EPD_DelayMs(&epd, 500);
}
/* USER CODE END 3 */
}
/**
/** Configure the main internal regulator output voltage
*/
__HAL_RCC_PWR_CLK_ENABLE();
__HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE3);
/** Initializes the RCC Oscillators according to the specified parameters
/** Initializes the CPU, AHB and APB buses clocks
*/
RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK
|RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2;
RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV2;
RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;
if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_2) != HAL_OK)
{
Error_Handler();
}
}
/**
/* USER CODE BEGIN SPI1_Init 0 */
/* USER CODE END SPI1_Init 0 */
/* USER CODE BEGIN SPI1_Init 1 */
/* USER CODE END SPI1_Init 1 /
/ SPI1 parameter configuration*/
hspi1.Instance = SPI1;
hspi1.Init.Mode = SPI_MODE_MASTER;
hspi1.Init.Direction = SPI_DIRECTION_1LINE;
hspi1.Init.DataSize = SPI_DATASIZE_8BIT;
hspi1.Init.CLKPolarity = SPI_POLARITY_LOW;
hspi1.Init.CLKPhase = SPI_PHASE_1EDGE;
hspi1.Init.NSS = SPI_NSS_SOFT;
hspi1.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_16;
hspi1.Init.FirstBit = SPI_FIRSTBIT_MSB;
hspi1.Init.TIMode = SPI_TIMODE_DISABLE;
hspi1.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE;
hspi1.Init.CRCPolynomial = 7;
hspi1.Init.CRCLength = SPI_CRC_LENGTH_DATASIZE;
hspi1.Init.NSSPMode = SPI_NSS_PULSE_ENABLE;
if (HAL_SPI_Init(&hspi1) != HAL_OK)
{
Error_Handler();
}
/* USER CODE BEGIN SPI1_Init 2 */
/* USER CODE END SPI1_Init 2 */
}
/**
/* USER CODE BEGIN USART3_Init 0 */
/* USER CODE END USART3_Init 0 */
/* USER CODE BEGIN USART3_Init 1 */
/* USER CODE END USART3_Init 1 /
huart3.Instance = USART3;
huart3.Init.BaudRate = 115200;
huart3.Init.WordLength = UART_WORDLENGTH_8B;
huart3.Init.StopBits = UART_STOPBITS_1;
huart3.Init.Parity = UART_PARITY_NONE;
huart3.Init.Mode = UART_MODE_TX_RX;
huart3.Init.HwFlowCtl = UART_HWCONTROL_NONE;
huart3.Init.OverSampling = UART_OVERSAMPLING_16;
huart3.Init.OneBitSampling = UART_ONE_BIT_SAMPLE_DISABLE;
huart3.AdvancedInit.AdvFeatureInit = UART_ADVFEATURE_NO_INIT;
if (HAL_UART_Init(&huart3) != HAL_OK)
{
Error_Handler();
}
/ USER CODE BEGIN USART3_Init 2 */
/* USER CODE END USART3_Init 2 */
}
/**
/* GPIO Ports Clock Enable */
__HAL_RCC_GPIOC_CLK_ENABLE();
__HAL_RCC_GPIOH_CLK_ENABLE();
__HAL_RCC_GPIOA_CLK_ENABLE();
__HAL_RCC_GPIOB_CLK_ENABLE();
__HAL_RCC_GPIOF_CLK_ENABLE();
__HAL_RCC_GPIOD_CLK_ENABLE();
/*Configure GPIO pin Output Level */
HAL_GPIO_WritePin(GPIOB, LD1_Pin|LD3_Pin|SPI_CS_Pin|LD2_Pin, GPIO_PIN_RESET);
/*Configure GPIO pin Output Level */
HAL_GPIO_WritePin(RST_GPIO_Port, RST_Pin, GPIO_PIN_RESET);
/*Configure GPIO pin Output Level */
HAL_GPIO_WritePin(DC_GPIO_Port, DC_Pin, GPIO_PIN_RESET);
/*Configure GPIO pin : USER_Btn_Pin */
GPIO_InitStruct.Pin = USER_Btn_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING;
GPIO_InitStruct.Pull = GPIO_NOPULL;
HAL_GPIO_Init(USER_Btn_GPIO_Port, &GPIO_InitStruct);
/*Configure GPIO pins : LD1_Pin LD3_Pin SPI_CS_Pin LD2_Pin */
GPIO_InitStruct.Pin = LD1_Pin|LD3_Pin|SPI_CS_Pin|LD2_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
/*Configure GPIO pin : BUSY_Pin */
GPIO_InitStruct.Pin = BUSY_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
GPIO_InitStruct.Pull = GPIO_NOPULL;
HAL_GPIO_Init(BUSY_GPIO_Port, &GPIO_InitStruct);
/*Configure GPIO pin : RST_Pin */
GPIO_InitStruct.Pin = RST_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
HAL_GPIO_Init(RST_GPIO_Port, &GPIO_InitStruct);
/*Configure GPIO pin : DC_Pin */
GPIO_InitStruct.Pin = DC_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
HAL_GPIO_Init(DC_GPIO_Port, &GPIO_InitStruct);
/* USER CODE BEGIN MX_GPIO_Init_2 /
/ USER CODE END MX_GPIO_Init_2 */
}
/* USER CODE BEGIN 4 */
/* USER CODE END 4 */
/**
#ifdef USE_FULL_ASSERT
/**
where the assert_param error has occurred.
Can anyone please help me identify what might be going wrong?
Hi, I have been able to display images but I have not been able to figure out how to display texts.
I thought the function "Paint_DrawStringAt(&paint_red, 28, 10, "Hello world!", &Font16, UNCOLORED)"
should do that but I am wrong.
Please how do I display texts?
Thank You
Please I really need help with this. Anyone who has displayed texts on an e-paper, your comments will greatly be appreciated.
Hi!
What parameters do i need to change to use 1.02inch e-paper (GDEW0102I3F)?
I think the resolution is 128x80 but i'm not sure
Could you help me?
Thanks,
Regards,
Hi, can you help me with my issue? I am using a nucleo-32 with the chip: STM32F301K8. I have successfully imported everything inside my project, but when I started it, it immediately go to hardfault_handler. When I debug it, I notice that it went to the hardfault handler when it reached Pain_Clear(). I have also changed the heap and stack size inside the cubeMx project to 0x4000 (heap) and 0x1000 (stack).
Can you help me with my issues? thanks @soonuse !
Hi,
i am using the e-papers but i have a problem. When i use the e-paper in first time, all works ok but only work one time. The next cycles the e-paper don´t show anything.
I am using STM32L053C and stm32cubeIDE with HAL.
I think the SPI not works well after first cycle.
Could you help me?
Thanks,
Regards,
Hello,
I am wondering how do I display a circle or rectangle instead of the waveshare image? I tried removing the EPD_DisplayFrame(&epd,ImageButterfly) but that seems to not work
In the images we can see 7 inch epd with IT8951 driver.
But code does not have any commands for IT8961 driver
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.