Coder Social home page Coder Social logo

soonuse / epd-library-stm32 Goto Github PK

View Code? Open in Web Editor NEW
49.0 49.0 26.0 8.68 MB

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

C 96.37% C++ 0.33% Assembly 2.74% HTML 0.33% Makefile 0.23% D 0.01%

epd-library-stm32's People

Contributors

soonuse avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

epd-library-stm32's Issues

E-paper library using STM32CubeIDE not working

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 /
/
*



  • @attention
  • Copyright (c) 2024 STMicroelectronics.
  • All rights reserved.
  • This software is licensed under terms that can be found in the LICENSE file
  • in the root directory of this software component.
  • If no LICENSE file comes with this software, it is provided AS-IS.

/
/
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 */

/**

  • @brief The application entry point.
  • @RetVal int
    /
    int main(void)
    {
    /
    USER CODE BEGIN 1 /
    /
    you have to edit the startup_stm32fxxx.s file and set a big enough heap size /
    unsigned char
    frame_buffer = (unsigned char*)malloc(EPD_WIDTH * EPD_HEIGHT / 8);
    char time_string[] = {'0', '0', ':', '0', '0', '\0'};
    unsigned long time_start_ms;
    unsigned long time_now_s;
    /* USER CODE END 1 */

/* 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);

/**

  • there are 2 memory areas embedded in the e-paper display
  • and once the display is refreshed, the memory area will be auto-toggled,
  • i.e. the next action of SetFrameMemory will set the other memory area
  • therefore you have to set the frame memory and refresh the display twice.
    */
    EPD_ClearFrameMemory(&epd, 0xFF);
    EPD_DisplayFrame(&epd);
    EPD_ClearFrameMemory(&epd, 0xFF);
    EPD_DisplayFrame(&epd);

/* EPD_or partial update */
if (EPD_Init(&epd, lut_partial_update) != 0) {
printf("e-Paper init failed\n");
return -1;
}

/**

  • there are 2 memory areas embedded in the e-paper display
  • and once the display is refreshed, the memory area will be auto-toggled,
  • i.e. the next action of SetFrameMemory will set the other memory area
  • therefore you have to set the frame memory and refresh the display twice.
    */
    EPD_SetFrameMemory(&epd, IMAGE_DATA, 0, 0, epd.width, epd.height);
    EPD_DisplayFrame(&epd);
    EPD_SetFrameMemory(&epd, IMAGE_DATA, 0, 0, epd.width, epd.height);
    EPD_DisplayFrame(&epd);

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 */
}

/**

  • @brief System Clock Configuration
  • @RetVal None
    */
    void SystemClock_Config(void)
    {
    RCC_OscInitTypeDef RCC_OscInitStruct = {0};
    RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};

/** 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

  • in the RCC_OscInitTypeDef structure.
    */
    RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;
    RCC_OscInitStruct.HSEState = RCC_HSE_ON;
    RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
    RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
    RCC_OscInitStruct.PLL.PLLM = 4;
    RCC_OscInitStruct.PLL.PLLN = 72;
    RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2;
    RCC_OscInitStruct.PLL.PLLQ = 3;
    if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
    {
    Error_Handler();
    }

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

/**

  • @brief SPI1 Initialization Function
  • @param None
  • @RetVal None
    */
    static void MX_SPI1_Init(void)
    {

/* 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 */

}

/**

  • @brief USART3 Initialization Function
  • @param None
  • @RetVal None
    */
    static void MX_USART3_UART_Init(void)
    {

/* 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 */

}

/**

  • @brief GPIO Initialization Function
  • @param None
  • @RetVal None
    /
    static void MX_GPIO_Init(void)
    {
    GPIO_InitTypeDef GPIO_InitStruct = {0};
    /
    USER CODE BEGIN MX_GPIO_Init_1 /
    /
    USER CODE END MX_GPIO_Init_1 */

/* 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 */

/**

  • @brief This function is executed in case of error occurrence.
  • @RetVal None
    /
    void Error_Handler(void)
    {
    /
    USER CODE BEGIN Error_Handler_Debug /
    /
    User can add his own implementation to report the HAL error return state /
    __disable_irq();
    while (1)
    {
    }
    /
    USER CODE END Error_Handler_Debug */
    }

#ifdef USE_FULL_ASSERT
/**

  • @brief Reports the name of the source file and the source line number
  •     where the assert_param error has occurred.
    
  • @param file: pointer to the source file name
  • @param line: assert_param error line source number
  • @RetVal None
    */
    void assert_failed(uint8_t file, uint32_t line)
    {
    /
    USER CODE BEGIN 6 /
    /
    User can add his own implementation to report the file name and line number,
    ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) /
    /
    USER CODE END 6 /
    }
    #endif /
    USE_FULL_ASSERT */
    `

Can anyone please help me identify what might be going wrong?

e-ink 1.54inch B display text

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.

Support to 1.02inch

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,

STM32F301 goes to hardfault_handler

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 !

image

STM32L053C and display only works first cycle

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,

Stm32 display anything other than the image

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

6 inch epd display

In the images we can see 7 inch epd with IT8951 driver.

But code does not have any commands for IT8961 driver

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.