{"id":3219,"date":"2025-02-08T13:50:45","date_gmt":"2025-02-08T13:50:45","guid":{"rendered":"https:\/\/blog.embeddedexpert.io\/?p=3219"},"modified":"2025-02-08T13:54:47","modified_gmt":"2025-02-08T13:54:47","slug":"interfacing-the-128x64-st7920-glcd-with-stm32f4-via-spi-part-2-lcd-initialization-and-drawing","status":"publish","type":"post","link":"https:\/\/blog.embeddedexpert.io\/?p=3219","title":{"rendered":"Interfacing the 128\u00d764 ST7920 GLCD with STM32F4 via SPI \u2013 Part 2: LCD Initialization and Drawing"},"content":{"rendered":"<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"1024\" src=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/02\/DALL\u00b7E-2025-02-01-16.09.09-A-technical-illustration-of-a-128\u00d764-graphical-LCD-GLCD-module-with-an-ST7920-controller-connected-to-an-STM32F4-microcontroller-via-SPI.-The-diagra-1.webp\" alt=\"\" class=\"wp-image-3220\" srcset=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/02\/DALL\u00b7E-2025-02-01-16.09.09-A-technical-illustration-of-a-128\u00d764-graphical-LCD-GLCD-module-with-an-ST7920-controller-connected-to-an-STM32F4-microcontroller-via-SPI.-The-diagra-1.webp 1024w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/02\/DALL\u00b7E-2025-02-01-16.09.09-A-technical-illustration-of-a-128\u00d764-graphical-LCD-GLCD-module-with-an-ST7920-controller-connected-to-an-STM32F4-microcontroller-via-SPI.-The-diagra-1-300x300.webp 300w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/02\/DALL\u00b7E-2025-02-01-16.09.09-A-technical-illustration-of-a-128\u00d764-graphical-LCD-GLCD-module-with-an-ST7920-controller-connected-to-an-STM32F4-microcontroller-via-SPI.-The-diagra-1-150x150.webp 150w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/02\/DALL\u00b7E-2025-02-01-16.09.09-A-technical-illustration-of-a-128\u00d764-graphical-LCD-GLCD-module-with-an-ST7920-controller-connected-to-an-STM32F4-microcontroller-via-SPI.-The-diagra-1-768x768.webp 768w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/02\/DALL\u00b7E-2025-02-01-16.09.09-A-technical-illustration-of-a-128\u00d764-graphical-LCD-GLCD-module-with-an-ST7920-controller-connected-to-an-STM32F4-microcontroller-via-SPI.-The-diagra-1-750x750.webp 750w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/02\/DALL\u00b7E-2025-02-01-16.09.09-A-technical-illustration-of-a-128\u00d764-graphical-LCD-GLCD-module-with-an-ST7920-controller-connected-to-an-STM32F4-microcontroller-via-SPI.-The-diagra-1-400x400.webp 400w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/02\/DALL\u00b7E-2025-02-01-16.09.09-A-technical-illustration-of-a-128\u00d764-graphical-LCD-GLCD-module-with-an-ST7920-controller-connected-to-an-STM32F4-microcontroller-via-SPI.-The-diagra-1-250x250.webp 250w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure><\/div>\n\n\n<p><\/p>\n\n\n\n<p>In the second part of the ST7920 GLCD guide, we shall start the initialization sequence and display some strings and display pictures.<\/p>\n\n\n\n<p>In this guide, we shall cover the following:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Creating source and header file.<\/li>\n\n\n\n<li>Header file development.<\/li>\n\n\n\n<li>Source file development.<\/li>\n\n\n\n<li>Testing the library.<\/li>\n\n\n\n<li>Source code download.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">5. Creating Source and Header File:<\/h2>\n\n\n\n<p><\/p>\n\n\n\n<p>After the project has been generated by STM32CubeMX within STM32CubeIDE, we shall add new source file and header file.<\/p>\n\n\n\n<p>Right click on Src folder and add new source file as following:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"486\" src=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2024\/11\/2024-11-07_07-03-43-1024x486.jpg\" alt=\"\" class=\"wp-image-2972\" srcset=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2024\/11\/2024-11-07_07-03-43-1024x486.jpg 1024w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2024\/11\/2024-11-07_07-03-43-300x142.jpg 300w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2024\/11\/2024-11-07_07-03-43-768x364.jpg 768w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2024\/11\/2024-11-07_07-03-43-1536x729.jpg 1536w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2024\/11\/2024-11-07_07-03-43-2048x972.jpg 2048w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2024\/11\/2024-11-07_07-03-43-1150x546.jpg 1150w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2024\/11\/2024-11-07_07-03-43-750x356.jpg 750w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2024\/11\/2024-11-07_07-03-43-400x190.jpg 400w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2024\/11\/2024-11-07_07-03-43-250x119.jpg 250w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>Give a name for the source file, we shall name it as ST7920.c as following:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"734\" src=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/02\/2025-02-08_16-18-58-1024x734.jpg\" alt=\"\" class=\"wp-image-3221\" srcset=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/02\/2025-02-08_16-18-58-1024x734.jpg 1024w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/02\/2025-02-08_16-18-58-300x215.jpg 300w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/02\/2025-02-08_16-18-58-768x550.jpg 768w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/02\/2025-02-08_16-18-58-1150x824.jpg 1150w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/02\/2025-02-08_16-18-58-750x538.jpg 750w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/02\/2025-02-08_16-18-58-400x287.jpg 400w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/02\/2025-02-08_16-18-58-250x179.jpg 250w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/02\/2025-02-08_16-18-58.jpg 1172w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>In similar manner, right click on Inc folder and add new header file with name of ST7920.h.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">6. Developing the Header File:<\/h2>\n\n\n\n<p><\/p>\n\n\n\n<p>Open the newest created header file.<\/p>\n\n\n\n<p>We start with off by including the stdint.h header as following:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;clike&quot;,&quot;mime&quot;:&quot;text\/x-csrc&quot;,&quot;theme&quot;:&quot;dracula&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;C&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;c&quot;}\">#include &quot;stdint.h&quot;<\/pre><\/div>\n\n\n\n<p>Next, we shall declare the following functions:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;clike&quot;,&quot;mime&quot;:&quot;text\/x-csrc&quot;,&quot;theme&quot;:&quot;dracula&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;C&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;c&quot;}\">void ST7920_init();\nvoid ST7920_Clear();\nvoid ST7920_SendString(int row, int col, char* string);\nvoid ST7920_GraphicMode (int enable) ;\nvoid ST7920_DrawBitmap(const unsigned char* graphic);\nvoid ST7920_Update(void);\nvoid DrawLine(uint8_t x0, uint8_t y0, uint8_t x1, uint8_t y1);\nvoid DrawRectangle(uint16_t x, uint16_t y, uint16_t w, uint16_t h);\nvoid DrawFilledRectangle(uint16_t x, uint16_t y, uint16_t w, uint16_t h);\nvoid DrawCircle(uint8_t x0, uint8_t y0, uint8_t radius);\nvoid DrawFilledCircle(int16_t x0, int16_t y0, int16_t r);\nvoid DrawTriangle(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t x3, uint16_t y3);\nvoid DrawFilledTriangle(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t x3, uint16_t y3);<\/pre><\/div>\n\n\n\n<p><\/p>\n\n\n\n<p>Hence, the entire header file as following:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;clike&quot;,&quot;mime&quot;:&quot;text\/x-csrc&quot;,&quot;theme&quot;:&quot;dracula&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;C&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;c&quot;}\">#ifndef INC_ST7920_H_\n#define INC_ST7920_H_\n\n#include &quot;stdint.h&quot;\n\n\nvoid ST7920_init();\nvoid ST7920_Clear();\nvoid ST7920_SendString(int row, int col, char* string);\nvoid ST7920_GraphicMode (int enable) ;\nvoid ST7920_DrawBitmap(const unsigned char* graphic);\nvoid ST7920_Update(void);\nvoid DrawLine(uint8_t x0, uint8_t y0, uint8_t x1, uint8_t y1);\nvoid DrawRectangle(uint16_t x, uint16_t y, uint16_t w, uint16_t h);\nvoid DrawFilledRectangle(uint16_t x, uint16_t y, uint16_t w, uint16_t h);\nvoid DrawCircle(uint8_t x0, uint8_t y0, uint8_t radius);\nvoid DrawFilledCircle(int16_t x0, int16_t y0, int16_t r);\nvoid DrawTriangle(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t x3, uint16_t y3);\nvoid DrawFilledTriangle(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t x3, uint16_t y3);\n\n\n\n\n\n\n#endif \/* INC_ST7920_H_ *\/<\/pre><\/div>\n\n\n\n<p>Thats all for the header file.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">7. Developing the Source File:<\/h2>\n\n\n\n<p>Open ST7920 source file and we start by including the following header files:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;clike&quot;,&quot;mime&quot;:&quot;text\/x-csrc&quot;,&quot;theme&quot;:&quot;dracula&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;C&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;c&quot;}\">#include &quot;ST7920.h&quot;\n#include &quot;main.h&quot;\n#include &quot;spi.h&quot;<\/pre><\/div>\n\n\n\n<ul class=\"wp-block-list\">\n<li>ST7920 header file which is already created by us.<\/li>\n\n\n\n<li>main.h to access HAL API.<\/li>\n\n\n\n<li>spi.h to access SPI peripheral.<\/li>\n<\/ul>\n\n\n\n<p>Since the GLCD has two extra pins to control, we can create macros to handle the state of them as following:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;clike&quot;,&quot;mime&quot;:&quot;text\/x-csrc&quot;,&quot;theme&quot;:&quot;dracula&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;C&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;c&quot;}\">#define RS_LOW \t\tHAL_GPIO_WritePin(RS_GPIO_Port,RS_Pin,GPIO_PIN_RESET);\n#define RS_HIGH\t\tHAL_GPIO_WritePin(RS_GPIO_Port,RS_Pin,GPIO_PIN_SET);\n\n#define RST_LOW \tHAL_GPIO_WritePin(RST_GPIO_Port,RST_Pin,GPIO_PIN_RESET);\n#define RST_HIGH\tHAL_GPIO_WritePin(RST_GPIO_Port,RST_Pin,GPIO_PIN_SET);<\/pre><\/div>\n\n\n\n<p><\/p>\n\n\n\n<p>Next, declare an array that holds three variables to be send over SPI as following:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;clike&quot;,&quot;mime&quot;:&quot;text\/x-csrc&quot;,&quot;theme&quot;:&quot;dracula&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;C&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;c&quot;}\">uint8_t lcd_data[3];<\/pre><\/div>\n\n\n\n<p>Needed variable for the graphics:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;clike&quot;,&quot;mime&quot;:&quot;text\/x-csrc&quot;,&quot;theme&quot;:&quot;dracula&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;C&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;c&quot;}\">uint8_t startRow, startCol, endRow, endCol; \/\/ coordinates of the dirty rectangle\nuint8_t numRows = 64;\nuint8_t numCols = 128;\nuint8_t Graphic_Check = 0;\nuint8_t image[(128 * 64)\/8];<\/pre><\/div>\n\n\n\n<p>Next, we need two functions to send either command or data.<\/p>\n\n\n\n<p>In order to send data\/command, the datasheet clearly states the following:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Set CS pin to high.<\/li>\n\n\n\n<li>Send 5bits of 1 to sync the display.<\/li>\n\n\n\n<li>Send RW and RS state.<\/li>\n\n\n\n<li>Followed by zero.<\/li>\n\n\n\n<li>Then send data\/command as two byte as shown in figure below:<\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"989\" src=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2023\/10\/Screenshot-2023-10-08-at-7.37.35-AM-1024x989.png\" alt=\"\" class=\"wp-image-2037\" srcset=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2023\/10\/Screenshot-2023-10-08-at-7.37.35-AM-1024x989.png 1024w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2023\/10\/Screenshot-2023-10-08-at-7.37.35-AM-300x290.png 300w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2023\/10\/Screenshot-2023-10-08-at-7.37.35-AM-768x742.png 768w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2023\/10\/Screenshot-2023-10-08-at-7.37.35-AM-1536x1483.png 1536w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2023\/10\/Screenshot-2023-10-08-at-7.37.35-AM-2048x1978.png 2048w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2023\/10\/Screenshot-2023-10-08-at-7.37.35-AM-1150x1111.png 1150w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2023\/10\/Screenshot-2023-10-08-at-7.37.35-AM-750x724.png 750w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2023\/10\/Screenshot-2023-10-08-at-7.37.35-AM-400x386.png 400w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2023\/10\/Screenshot-2023-10-08-at-7.37.35-AM-250x241.png 250w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>Hence, the functions as following:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;clike&quot;,&quot;mime&quot;:&quot;text\/x-csrc&quot;,&quot;theme&quot;:&quot;dracula&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;C&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;c&quot;}\">static void ST7920_SendCmd (uint8_t cmd)\n{\n\tRS_HIGH;  \/\/ PUll the CS high\n\n\tlcd_data[0]=0xF8;\n\tlcd_data[1]=(cmd&amp;0xf0);\n\tlcd_data[2]=((cmd&lt;&lt;4)&amp;0xf0);\n\n\tHAL_SPI_Transmit(&amp;hspi1, lcd_data, 3, 100);\n\n\tRS_LOW;  \/\/ PUll the CS LOW\n\n}\n\nstatic void ST7920_SendData (uint8_t data)\n{\n\n\tRS_HIGH;\n\n\tlcd_data[0]=0xFA;\n\tlcd_data[1]=(data&amp;0xf0);\n\tlcd_data[2]=((data&lt;&lt;4)&amp;0xf0);\n\n\tHAL_SPI_Transmit(&amp;hspi1, lcd_data, 3, 100);\n\n\n\tRS_LOW;  \/\/ PUll the CS LOW\n}\n<\/pre><\/div>\n\n\n\n<p>Notice they are also static since they only being used in the current source file.<\/p>\n\n\n\n<p>To intialize the LCD, we need the following steps:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Wait for 100ms to for power stability,<\/li>\n\n\n\n<li>Reset the LCD by pulling RST pin to low for 50ms then high and wait for 100.<\/li>\n\n\n\n<li>Send the command 0x03 to enter 8-bit mode (repeat twice to ensure the GLCD in SPI mode).<\/li>\n\n\n\n<li>Turn off the display, cursor and blinking cursor.<\/li>\n\n\n\n<li>Clear the display.<\/li>\n\n\n\n<li>Increment the cursor after each character.<\/li>\n\n\n\n<li>Turn on the display.<\/li>\n\n\n\n<li>Return to home (set cursor back to 0,0).<\/li>\n<\/ul>\n\n\n\n<p><\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;clike&quot;,&quot;mime&quot;:&quot;text\/x-csrc&quot;,&quot;theme&quot;:&quot;dracula&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;C&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;c&quot;}\">void ST7920_init()\n{\n\tHAL_Delay(100);\n\tRST_LOW;\n\tHAL_Delay(50);\n\tRST_HIGH;\n\tHAL_Delay(100);\n\tST7920_SendCmd(0x30);  \t\t\/\/ 8bit mode\n\tHAL_Delay(1);  \t\t\t\t\/\/  &gt;100us delay\n\n\tST7920_SendCmd(0x30);  \t\t\/\/ 8bit mode\n\tHAL_Delay(1);  \t\t\t\t\/\/ &gt;37us delay\n\n\tST7920_SendCmd(0x08);  \/\/ D=0, C=0, B=0\n\tHAL_Delay(1);  \/\/ &gt;100us delay\n\n\tST7920_SendCmd(0x01);  \/\/ clear screen\n\tHAL_Delay(12);  \/\/ &gt;10 ms delay\n\n\n\tST7920_SendCmd(0x06);  \/\/ cursor increment right no shift\n\tHAL_Delay(1);  \/\/ 1ms delay\n\n\tST7920_SendCmd(0x0C);  \/\/ D=1, C=0, B=0\n\tHAL_Delay(1);  \/\/ 1ms delay\n\n\tST7920_SendCmd(0x02);  \/\/ return to home\n\tHAL_Delay(1);  \/\/ 1ms delay\n\n}<\/pre><\/div>\n\n\n\n<p><\/p>\n\n\n\n<p>Support functions:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;clike&quot;,&quot;mime&quot;:&quot;text\/x-csrc&quot;,&quot;theme&quot;:&quot;dracula&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;C&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;c&quot;}\">void ST7920_SendString(int row, int col, char* string)\n{\n    switch (row)\n    {\n        case 0:\n            col |= 0x80;\n            break;\n        case 1:\n            col |= 0x90;\n            break;\n        case 2:\n            col |= 0x88;\n            break;\n        case 3:\n            col |= 0x98;\n            break;\n        default:\n            col |= 0x80;\n            break;\n    }\n\n    ST7920_SendCmd(col);\n\n    while (*string)\n    \t{\n    \t\tST7920_SendData(*string++);\n    \t}\n}\n\n\n\n\/\/ switch to graphic mode or normal mode::: enable = 1 -&gt; graphic mode enable = 0 -&gt; normal mode\n\nvoid ST7920_GraphicMode (int enable)   \/\/ 1-enable, 0-disable\n{\n\tif (enable == 1)\n\t{\n\t\tST7920_SendCmd(0x30);  \/\/ 8 bit mode\n\t\tHAL_Delay (1);\n\t\tST7920_SendCmd(0x34);  \/\/ switch to Extended instructions\n\t\tHAL_Delay (1);\n\t\tST7920_SendCmd(0x36);  \/\/ enable graphics\n\t\tHAL_Delay (1);\n\t\tGraphic_Check = 1;  \/\/ update the variable\n\t}\n\n\telse if (enable == 0)\n\t{\n\t\tST7920_SendCmd(0x30);  \/\/ 8 bit mode\n\t\tHAL_Delay (1);\n\t\tGraphic_Check = 0;  \/\/ update the variable\n\t}\n}\n\nvoid ST7920_DrawBitmap(const unsigned char* graphic)\n{\n\tuint8_t x, y;\n\tfor(y = 0; y &lt; 64; y++)\n\t{\n\t\tif(y &lt; 32)\n\t\t{\n\t\t\tfor(x = 0; x &lt; 8; x++)\t\t\t\t\t\t\t\/\/ Draws top half of the screen.\n\t\t\t{\t\t\t\t\t\t\t\t\t\t\t\t\/\/ In extended instruction mode, vertical and horizontal coordinates must be specified before sending data in.\n\t\t\t\tST7920_SendCmd(0x80 | y);\t\t\t\t\/\/ Vertical coordinate of the screen is specified first. (0-31)\n\t\t\t\tST7920_SendCmd(0x80 | x);\t\t\t\t\/\/ Then horizontal coordinate of the screen is specified. (0-8)\n\t\t\t\tST7920_SendData(graphic[2*x + 16*y]);\t\t\/\/ Data to the upper byte is sent to the coordinate.\n\t\t\t\tST7920_SendData(graphic[2*x+1 + 16*y]);\t\/\/ Data to the lower byte is sent to the coordinate.\n\t\t\t}\n\t\t}\n\t\telse\n\t\t{\n\t\t\tfor(x = 0; x &lt; 8; x++)\t\t\t\t\t\t\t\/\/ Draws bottom half of the screen.\n\t\t\t{\t\t\t\t\t\t\t\t\t\t\t\t\/\/ Actions performed as same as the upper half screen.\n\t\t\t\tST7920_SendCmd(0x80 | (y-32));\t\t\t\/\/ Vertical coordinate must be scaled back to 0-31 as it is dealing with another half of the screen.\n\t\t\t\tST7920_SendCmd(0x88 | x);\n\t\t\t\tST7920_SendData(graphic[2*x + 16*y]);\n\t\t\t\tST7920_SendData(graphic[2*x+1 + 16*y]);\n\t\t\t}\n\t\t}\n\n\t}\n}\n\n\n\/\/ Update the display with the selected graphics\nvoid ST7920_Update(void)\n{\n\tST7920_DrawBitmap(image);\n}\n\n\n\nvoid ST7920_Clear()\n{\n\tif (Graphic_Check == 1)  \/\/ if the graphic mode is set\n\t{\n\t\tuint8_t x, y;\n\t\tfor(y = 0; y &lt; 64; y++)\n\t\t{\n\t\t\tif(y &lt; 32)\n\t\t\t{\n\t\t\t\tST7920_SendCmd(0x80 | y);\n\t\t\t\tST7920_SendCmd(0x80);\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tST7920_SendCmd(0x80 | (y-32));\n\t\t\t\tST7920_SendCmd(0x88);\n\t\t\t}\n\t\t\tfor(x = 0; x &lt; 8; x++)\n\t\t\t{\n\t\t\t\tST7920_SendData(0);\n\t\t\t\tST7920_SendData(0);\n\t\t\t}\n\t\t}\n\t}\n\n\telse\n\t{\n\t\tST7920_SendCmd(0x01);   \/\/ clear the display using command\n\t\tHAL_Delay(20); \/\/ delay &gt;1.6 ms\n\t}\n}\n\n\n\n\nstatic void SetPixel(uint8_t x, uint8_t y)\n{\n  if (y &lt; numRows &amp;&amp; x &lt; numCols)\n  {\n    uint8_t *p = image + ((y * (numCols\/8)) + (x\/8));\n    *p |= 0x80u &gt;&gt; (x%8);\n\n    *image = *p;\n\n    \/\/ Change the dirty rectangle to account for a pixel being dirty (we assume it was changed)\n    if (startRow &gt; y) { startRow = y; }\n    if (endRow &lt;= y)  { endRow = y + 1; }\n    if (startCol &gt; x) { startCol = x; }\n    if (endCol &lt;= x)  { endCol = x + 1; }\n\n\n  }\n\n}\n\n\/* draw a line\n * start point (X0, Y0)\n * end point (X1, Y1)\n *\/\nvoid DrawLine(uint8_t x0, uint8_t y0, uint8_t x1, uint8_t y1)\n{\n  int dx = (x1 &gt;= x0) ? x1 - x0 : x0 - x1;\n  int dy = (y1 &gt;= y0) ? y1 - y0 : y0 - y1;\n  int sx = (x0 &lt; x1) ? 1 : -1;\n  int sy = (y0 &lt; y1) ? 1 : -1;\n  int err = dx - dy;\n\n  for (;;)\n  {\n    SetPixel(x0, y0);\n    if (x0 == x1 &amp;&amp; y0 == y1) break;\n    int e2 = err + err;\n    if (e2 &gt; -dy)\n    {\n      err -= dy;\n      x0 += sx;\n    }\n    if (e2 &lt; dx)\n    {\n      err += dx;\n      y0 += sy;\n    }\n  }\n}\n\n\n\n\n\/* Draw rectangle\n * start point (x,y)\n * w -&gt; width\n * h -&gt; height\n *\/\nvoid DrawRectangle(uint16_t x, uint16_t y, uint16_t w, uint16_t h)\n{\n\t\/* Check input parameters *\/\n\tif (\n\t\tx &gt;= numCols ||\n\t\ty &gt;= numRows\n\t) {\n\t\t\/* Return error *\/\n\t\treturn;\n\t}\n\n\t\/* Check width and height *\/\n\tif ((x + w) &gt;= numCols) {\n\t\tw = numCols - x;\n\t}\n\tif ((y + h) &gt;= numRows) {\n\t\th = numRows - y;\n\t}\n\n\t\/* Draw 4 lines *\/\n\tDrawLine(x, y, x + w, y);         \/* Top line *\/\n\tDrawLine(x, y + h, x + w, y + h); \/* Bottom line *\/\n\tDrawLine(x, y, x, y + h);         \/* Left line *\/\n\tDrawLine(x + w, y, x + w, y + h); \/* Right line *\/\n}\n\n\n\n\n\/* Draw filled rectangle\n * Start point (x,y)\n * w -&gt; width\n * h -&gt; height\n *\/\nvoid DrawFilledRectangle(uint16_t x, uint16_t y, uint16_t w, uint16_t h)\n{\n\tuint8_t i;\n\n\t\/* Check input parameters *\/\n\tif (\n\t\tx &gt;= numCols ||\n\t\ty &gt;= numRows\n\t) {\n\t\t\/* Return error *\/\n\t\treturn;\n\t}\n\n\t\/* Check width and height *\/\n\tif ((x + w) &gt;= numCols) {\n\t\tw = numCols - x;\n\t}\n\tif ((y + h) &gt;= numRows) {\n\t\th = numRows - y;\n\t}\n\n\t\/* Draw lines *\/\n\tfor (i = 0; i &lt;= h; i++) {\n\t\t\/* Draw lines *\/\n\t\tDrawLine(x, y + i, x + w, y + i);\n\t}\n}\n\n\n\n\n\/* draw circle\n * centre (x0,y0)\n * radius = radius\n *\/\nvoid DrawCircle(uint8_t x0, uint8_t y0, uint8_t radius)\n{\n  int f = 1 - (int)radius;\n  int ddF_x = 1;\n\n  int ddF_y = -2 * (int)radius;\n  int x = 0;\n\n  SetPixel(x0, y0 + radius);\n  SetPixel(x0, y0 - radius);\n  SetPixel(x0 + radius, y0);\n  SetPixel(x0 - radius, y0);\n\n  int y = radius;\n  while(x &lt; y)\n  {\n    if(f &gt;= 0)\n    {\n      y--;\n      ddF_y += 2;\n      f += ddF_y;\n    }\n    x++;\n    ddF_x += 2;\n    f += ddF_x;\n    SetPixel(x0 + x, y0 + y);\n    SetPixel(x0 - x, y0 + y);\n    SetPixel(x0 + x, y0 - y);\n    SetPixel(x0 - x, y0 - y);\n    SetPixel(x0 + y, y0 + x);\n    SetPixel(x0 - y, y0 + x);\n    SetPixel(x0 + y, y0 - x);\n    SetPixel(x0 - y, y0 - x);\n  }\n}\n\n\n\/\/ Draw Filled Circle\n\nvoid DrawFilledCircle(int16_t x0, int16_t y0, int16_t r)\n{\n\tint16_t f = 1 - r;\n\tint16_t ddF_x = 1;\n\tint16_t ddF_y = -2 * r;\n\tint16_t x = 0;\n\tint16_t y = r;\n\n    SetPixel(x0, y0 + r);\n    SetPixel(x0, y0 - r);\n    SetPixel(x0 + r, y0);\n    SetPixel(x0 - r, y0);\n    DrawLine(x0 - r, y0, x0 + r, y0);\n\n    while (x &lt; y) {\n        if (f &gt;= 0) {\n            y--;\n            ddF_y += 2;\n            f += ddF_y;\n        }\n        x++;\n        ddF_x += 2;\n        f += ddF_x;\n\n        DrawLine(x0 - x, y0 + y, x0 + x, y0 + y);\n        DrawLine(x0 + x, y0 - y, x0 - x, y0 - y);\n\n        DrawLine(x0 + y, y0 + x, x0 - y, y0 + x);\n        DrawLine(x0 + y, y0 - x, x0 - y, y0 - x);\n    }\n}\n\n\n\n\/\/ Draw Traingle with coordimates (x1, y1), (x2, y2), (x3, y3)\nvoid DrawTriangle(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t x3, uint16_t y3)\n{\n\t\/* Draw lines *\/\n\tDrawLine(x1, y1, x2, y2);\n\tDrawLine(x2, y2, x3, y3);\n\tDrawLine(x3, y3, x1, y1);\n}\n\n\n\n\/\/ Draw Filled Traingle with coordimates (x1, y1), (x2, y2), (x3, y3)\nvoid DrawFilledTriangle(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t x3, uint16_t y3)\n{\n\tint16_t deltax = 0, deltay = 0, x = 0, y = 0, xinc1 = 0, xinc2 = 0,\n\tyinc1 = 0, yinc2 = 0, den = 0, num = 0, numadd = 0, numpixels = 0,\n\tcurpixel = 0;\n\n#define ABS(x)   ((x) &gt; 0 ? (x) : -(x))\n\n\tdeltax = ABS(x2 - x1);\n\tdeltay = ABS(y2 - y1);\n\tx = x1;\n\ty = y1;\n\n\tif (x2 &gt;= x1) {\n\t\txinc1 = 1;\n\t\txinc2 = 1;\n\t} else {\n\t\txinc1 = -1;\n\t\txinc2 = -1;\n\t}\n\n\tif (y2 &gt;= y1) {\n\t\tyinc1 = 1;\n\t\tyinc2 = 1;\n\t} else {\n\t\tyinc1 = -1;\n\t\tyinc2 = -1;\n\t}\n\n\tif (deltax &gt;= deltay){\n\t\txinc1 = 0;\n\t\tyinc2 = 0;\n\t\tden = deltax;\n\t\tnum = deltax \/ 2;\n\t\tnumadd = deltay;\n\t\tnumpixels = deltax;\n\t} else {\n\t\txinc2 = 0;\n\t\tyinc1 = 0;\n\t\tden = deltay;\n\t\tnum = deltay \/ 2;\n\t\tnumadd = deltax;\n\t\tnumpixels = deltay;\n\t}\n\n\tfor (curpixel = 0; curpixel &lt;= numpixels; curpixel++)\n\t{\n\t\tDrawLine(x, y, x3, y3);\n\n\t\tnum += numadd;\n\t\tif (num &gt;= den) {\n\t\t\tnum -= den;\n\t\t\tx += xinc1;\n\t\t\ty += yinc1;\n\t\t}\n\t\tx += xinc2;\n\t\ty += yinc2;\n\t}\n}\n\n\n<\/pre><\/div>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">8. Testing the library:<\/h2>\n\n\n\n<p>In main.c, in user begin, include the ST7920 header file as following:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;clike&quot;,&quot;mime&quot;:&quot;text\/x-csrc&quot;,&quot;theme&quot;:&quot;dracula&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;C&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;c&quot;}\">#include &quot;ST7920.h&quot;<\/pre><\/div>\n\n\n\n<p>Extra header files to test:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;clike&quot;,&quot;mime&quot;:&quot;text\/x-csrc&quot;,&quot;theme&quot;:&quot;dracula&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;C&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;c&quot;}\">#include &quot;horse.h&quot;\n#include &quot;bitmap.h&quot;<\/pre><\/div>\n\n\n\n<p>Note: Included in the source file that can be downloaded from the last section.<\/p>\n\n\n\n<p>In user code begin 2 in main function, initlialize the GLCD and start displaying some text and graphics as following:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;clike&quot;,&quot;mime&quot;:&quot;text\/x-csrc&quot;,&quot;theme&quot;:&quot;dracula&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;C&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;c&quot;}\">ST7920_init();\n\n  \tST7920_SendString(0,0, &quot;HELLO WORLD&quot;);\n  \tST7920_SendString(1,0, &quot;FROM&quot;);\n  \tST7920_SendString(2,0, &quot;EmbeddedExpertIO&quot;);\n  \tST7920_SendString(3,0, &quot;1234567890!@#$%^&quot;);\n  \tHAL_Delay(2000);\n  \tST7920_Clear();\n  \tST7920_GraphicMode(1);\n  \tST7920_DrawBitmap(logo);\n  \tHAL_Delay(2000);\n  \tST7920_Clear();\n  \tDrawCircle(110, 31, 12);\n\n  \tDrawCircle(110, 31, 16);\n\n  \tDrawLine(3, 60, 127, 33);\n\n  \tST7920_Update();\n\n  \tHAL_Delay(2000);\n\n  \tDrawRectangle (100, 12, 20, 14);\n\n  \tST7920_Update();\n\n  \tHAL_Delay(2000);\n\n  \tDrawFilledRectangle(30, 20, 30, 10);\n\n  \tST7920_Update();\n\n  \tHAL_Delay(2000);\n\n  \tDrawFilledCircle(15, 30, 6);\n\n  \tST7920_Update();\n\n  \tDrawFilledTriangle(1,5,10,5,6,15);\n\n  \tST7920_Update();\n\n  \tHAL_Delay(2000);\n\n  \tST7920_Clear();<\/pre><\/div>\n\n\n\n<p><\/p>\n\n\n\n<p>In while 1 loop, we shall display horse animation as following:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;clike&quot;,&quot;mime&quot;:&quot;text\/x-csrc&quot;,&quot;theme&quot;:&quot;dracula&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;C&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;c&quot;}\">\t\tST7920_DrawBitmap(horse1);\n\t\tST7920_DrawBitmap(horse2);\n\t\tST7920_DrawBitmap(horse3);\n\t\tST7920_DrawBitmap(horse4);\n\t\tST7920_DrawBitmap(horse5);\n\t\tST7920_DrawBitmap(horse6);\n\t\tST7920_DrawBitmap(horse7);\n\t\tST7920_DrawBitmap(horse8);\n\t\tST7920_DrawBitmap(horse9);\n\t\tST7920_DrawBitmap(horse10);<\/pre><\/div>\n\n\n\n<p>Save the project, build it and run it on your board as following:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"28\" src=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2024\/11\/image-1024x28.png\" alt=\"\" class=\"wp-image-2982\" srcset=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2024\/11\/image-1024x28.png 1024w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2024\/11\/image-300x8.png 300w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2024\/11\/image-768x21.png 768w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2024\/11\/image-1536x43.png 1536w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2024\/11\/image-1150x32.png 1150w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2024\/11\/image-750x21.png 750w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2024\/11\/image-400x11.png 400w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2024\/11\/image-250x7.png 250w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2024\/11\/image.png 1734w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<p>You should get the following:<\/p>\n\n\n\n<figure class=\"wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio\"><div class=\"wp-block-embed__wrapper\">\n<iframe loading=\"lazy\" title=\"ST7920 GLCD Demo on STM32\" width=\"1170\" height=\"658\" src=\"https:\/\/www.youtube.com\/embed\/SWGsmHlYrA0?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen><\/iframe>\n<\/div><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">9. Source Code Download:<\/h2>\n\n\n\n<p>You can download the source code from here:<\/p>\n\n\n\n<div class=\"wp-block-file\"><a id=\"wp-block-file--media-db4c2592-dfc0-4f18-8e7f-3d5b68c4cf5c\" href=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/02\/GLCD_ST7920.zip\">GLCD_ST7920<\/a><a href=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/02\/GLCD_ST7920.zip\" class=\"wp-block-file__button wp-element-button\" download aria-describedby=\"wp-block-file--media-db4c2592-dfc0-4f18-8e7f-3d5b68c4cf5c\">Download<\/a><\/div>\n\n\n\n<p><\/p>\n\n\n\n<p>Happy coding \ud83d\ude09<\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>In the second part of the ST7920 GLCD guide, we shall start the initialization sequence and display some strings and display pictures. In this guide, we shall cover the following: 5. Creating Source and Header File: After the project has been generated by STM32CubeMX within STM32CubeIDE, we shall add new source file and header file. [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-3219","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/blog.embeddedexpert.io\/index.php?rest_route=\/wp\/v2\/posts\/3219"}],"collection":[{"href":"https:\/\/blog.embeddedexpert.io\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.embeddedexpert.io\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.embeddedexpert.io\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.embeddedexpert.io\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3219"}],"version-history":[{"count":3,"href":"https:\/\/blog.embeddedexpert.io\/index.php?rest_route=\/wp\/v2\/posts\/3219\/revisions"}],"predecessor-version":[{"id":3226,"href":"https:\/\/blog.embeddedexpert.io\/index.php?rest_route=\/wp\/v2\/posts\/3219\/revisions\/3226"}],"wp:attachment":[{"href":"https:\/\/blog.embeddedexpert.io\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3219"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.embeddedexpert.io\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3219"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.embeddedexpert.io\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3219"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}