Skip to content

anasvag575/NOKIA5110_LCD

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 

Repository files navigation

STM32 NOKIA5110 LCD Library

A library for the NOKIA5110 LCD (PCD8544) display for STM32 devices (Still in progress).

Description

This library is implemented using the HAL API, in order to have portability and ease of use across all STM32 MCUs. Most of the library is based on other implementations from these repositories (check them out):

Hardware & screen initialization

The user has the option of using SPI in either DMA or polling mode for the transmission of the commands (or image data). The library supports all available commands for:

  • Function set (Power ON, Sleep mode)
  • Display control (Fill, Invert, Blank)
  • Setting XY address coordinates
  • Contrast
  • Temperature coefficient
  • Voltage bias

For the initialization user has to define a screen handle, initialize the fields and make a call to the appropriate initialization routine like below:

uint8_t pcd8544_buffer[PCD8544_BUFFER_SZ];
pcd_8544_t pcd8544_handle ={ // Which GPIOs to use (Pin-port combinations) //
                            .rst_pin = RST_PIN,	
                            .rst_port = RST_PORT,
                            .ce_pin = CE_PIN,
                            .ce_port = CE_PORT,
                            .dc_pin = DC_PIN,
                            .dc_port = DC_PORT,
                            
                            // SPI HAL handle and the buffer to use //
                            .h_spi = &hspi2,
                            .buffer = pcd8544_buffer,

                            // Set contrast/bias values //
                            .contast = PCD8544_VOP_DEFAULT,
                            .bias = PCD8544_BIAS_DEFAULT
                           };
                            
// Initialization routine //
bool status = PCD8544_init(&pcd8544_handle);

Common things to look out for (issues/tips):

  • The correct GPIOs on the MCU correspond to the correct pins on the actual display
  • The needed peripherals are properly initialized
    • For the GPIOs (RST, CE, DC), clock/settings should be enabled/set
    • For the SPI GPIOs(MOSI, CLK), alternate function should be set too
    • For SPI, peripheral clock/settings should be enabled/configured
    • For DMA SPI transfers, DMA should be enabled/configured before SPI
  • Check if the display does not move and the pins are soldered properly
  • If the screen seems dim (or is completely black), adjust the contrast value

Graphics & Text

The library supports multiple shapes, bitmap drawing and character printing. User has to call a drawing routine followed by a screen refresh, just like below:

// Draw shapes on the screen //
PCD8544_draw_line(0, 70 , 0, 10, true);
PCD8544_draw_circle(0, 20 , 10, true);
PCD8544_draw_rectangle(0, 0, 20, 20, true, false);

// Bitmap drawing //
PCD8544_draw_bitmap(bitmap, 0, 0, 25, 25);

// Set XY initial text coordinates and then print string //
PCD8544_coord(0, 0);
PCD8544_print_str("Hello World", LARGE_FONT, false);

// Update the display //
PCD8544_refresh();

For the character printing, 3 fonts are supported with different centering options when calling the printing routines.

Using the library

Inside the example folder, is a small app that testes most of the functionalities of the library and provides some insight into how to enable and use the display. All of the peripheral initialization code is automatically generated by CUBEMX, so it is easy enough to reproduce for a different board.

Inside the src folder, is the core of the library and all the necessary header and source files. Before adding it to your own project, make sure that the correct HAL header is included (around line 17 of file pcd8544.h):

<pcd8544.h> 17: #include "stm32f4xx_hal.h"	// Set your own series (F0, F1, ..) HAL header //

In progress

  • Doxygen documentation
  • Clang formatting
  • Add pins and connectivity

Feel free to inform me, in case any issue is found.

About

Nokia5110 LCD library implemented for STM32 using HAL

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors