{"id":3907,"date":"2025-10-31T12:19:39","date_gmt":"2025-10-31T12:19:39","guid":{"rendered":"https:\/\/blog.embeddedexpert.io\/?p=3907"},"modified":"2025-10-31T12:19:40","modified_gmt":"2025-10-31T12:19:40","slug":"working-with-stm32-and-e-ink-display-part-2-displaying-full-screen-color","status":"publish","type":"post","link":"https:\/\/blog.embeddedexpert.io\/?p=3907","title":{"rendered":"Working with STM32 and E-Ink Display Part 2: Displaying Full Screen Color"},"content":{"rendered":"\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"683\" src=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/image-4-1024x683.png\" alt=\"\" class=\"wp-image-3908\" srcset=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/image-4-1024x683.png 1024w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/image-4-300x200.png 300w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/image-4-768x512.png 768w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/image-4-1150x767.png 1150w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/image-4-750x500.png 750w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/image-4-400x267.png 400w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/image-4-250x167.png 250w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/image-4.png 1536w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<p>Displaying a full-screen color image on an E-Ink display demonstrates the device\u2019s ability to render rich visuals using its reflective, low-power technology. In this guide, we will cover how to send and refresh full-frame image data to achieve a complete color update on the E-Paper screen.<\/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>Developing header and source files.<\/li>\n\n\n\n<li>Main code development.<\/li>\n\n\n\n<li>Results.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">1. Developing Header and Source Files:<\/h2>\n\n\n\n<p>First, we need to create new source and header files.<\/p>\n\n\n\n<p>To create Source file, 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 epaper.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\/10\/2025-10-30_15-00-12-1024x734.jpg\" alt=\"\" class=\"wp-image-3909\" srcset=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/2025-10-30_15-00-12-1024x734.jpg 1024w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/2025-10-30_15-00-12-300x215.jpg 300w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/2025-10-30_15-00-12-768x550.jpg 768w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/2025-10-30_15-00-12-1150x824.jpg 1150w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/2025-10-30_15-00-12-750x538.jpg 750w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/2025-10-30_15-00-12-400x287.jpg 400w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/2025-10-30_15-00-12-250x179.jpg 250w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/2025-10-30_15-00-12.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 epaper.h.<\/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\/10\/2025-10-30_15-00-30-1024x734.jpg\" alt=\"\" class=\"wp-image-3910\" srcset=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/2025-10-30_15-00-30-1024x734.jpg 1024w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/2025-10-30_15-00-30-300x215.jpg 300w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/2025-10-30_15-00-30-768x550.jpg 768w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/2025-10-30_15-00-30-1150x824.jpg 1150w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/2025-10-30_15-00-30-750x538.jpg 750w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/2025-10-30_15-00-30-400x287.jpg 400w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/2025-10-30_15-00-30-250x179.jpg 250w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/2025-10-30_15-00-30.jpg 1172w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<p>In the header file, include 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;C&quot;,&quot;language&quot;:&quot;C&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;c&quot;}\">#include &quot;stdint.h&quot;\n#include &quot;main.h&quot;\n#include &quot;spi.h&quot;<\/pre><\/div>\n\n\n\n<p>Next, declare the size of the display as follows:<\/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;C&quot;,&quot;language&quot;:&quot;C&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;c&quot;}\">\/\/ Display resolution\n#define ePaper_WIDTH       160\n#define ePaper_HEIGHT      296<\/pre><\/div>\n\n\n\n<p><\/p>\n\n\n\n<p>Declare the following enumeration for bust IDLE state as follows:<\/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;C&quot;,&quot;language&quot;:&quot;C&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;c&quot;}\">typedef enum\n{\n\tIDLE=0,\n\tBUSY=1\n}StateTypedef;<\/pre><\/div>\n\n\n\n<p><\/p>\n\n\n\n<p>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;C&quot;,&quot;language&quot;:&quot;C&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;c&quot;}\">void ePaper_Init(void);\nvoid ePaper_Clear(void);\nvoid ePaper_Clear_Black(void);\nvoid ePaper_Clear_Red(void);\nvoid ePaper_Sleep(void);<\/pre><\/div>\n\n\n\n<p>The functions are as follows:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Display initialization which will initialize the display.<\/li>\n\n\n\n<li>Clear the display, it will clear the display and make it into while color.<\/li>\n\n\n\n<li>Clear red and black, as name suggests, it will clear the display into red and black color respectively.<\/li>\n<\/ul>\n\n\n\n<p>Hence, the entire header file as follows:<\/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;C&quot;,&quot;language&quot;:&quot;C&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;c&quot;}\">#ifndef INC_EPAPER_H_\n#define INC_EPAPER_H_\n\n#include &quot;stdint.h&quot;\n#include &quot;main.h&quot;\n#include &quot;spi.h&quot;\n\n\/\/ Display resolution\n#define ePaper_WIDTH       160\n#define ePaper_HEIGHT      296\n\n\ntypedef enum\n{\n\tIDLE=0,\n\tBUSY=1\n}StateTypedef;\n\nvoid ePaper_Init(void);\nvoid ePaper_Clear(void);\nvoid ePaper_Clear_Black(void);\nvoid ePaper_Clear_Red(void);\n\nvoid ePaper_Sleep(void);\n\n\n#endif \/* INC_EPAPER_H_ *\/<\/pre><\/div>\n\n\n\n<p><\/p>\n\n\n\n<p>Next, we shall develop the source file.<\/p>\n\n\n\n<p>In the source file, include epaper.h header file as follows:<\/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;C&quot;,&quot;language&quot;:&quot;C&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;c&quot;}\">#include &quot;epaper.h&quot;<\/pre><\/div>\n\n\n\n<p>Next, we need two functions that will write either data or command to the display.<\/p>\n\n\n\n<p>To write data, first, set DC line to high, pull CS line low, transmit data and pul CS line high. Hence the function as follows:<\/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;C&quot;,&quot;language&quot;:&quot;C&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;c&quot;}\">static void ePaper_WriteData(uint8_t data)\n{\n\tHAL_GPIO_WritePin(DC_GPIO_Port, DC_Pin,1);\n\n\tHAL_GPIO_WritePin(CS_GPIO_Port, CS_Pin, 0);\n\n\tHAL_SPI_Transmit(&amp;hspi1, &amp;data, 1, 10);\n\n\tHAL_GPIO_WritePin(CS_GPIO_Port, CS_Pin, 1);\n}<\/pre><\/div>\n\n\n\n<p><\/p>\n\n\n\n<p>Next, we need to write command, similar to writing data, just DC line to low, hence the function as follows:<\/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;C&quot;,&quot;language&quot;:&quot;C&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;c&quot;}\">static void ePaper_WriteCmd(uint8_t cmd)\n{\n\tHAL_GPIO_WritePin(DC_GPIO_Port, DC_Pin,0);\n\n\tHAL_GPIO_WritePin(CS_GPIO_Port, CS_Pin, 0);\n\n\tHAL_SPI_Transmit(&amp;hspi1, &amp;cmd, 1, 10);\n\n\tHAL_GPIO_WritePin(CS_GPIO_Port, CS_Pin, 1);\n\n}<\/pre><\/div>\n\n\n\n<p><\/p>\n\n\n\n<p>Next, we need to reset the display physically as follows:<\/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;C&quot;,&quot;language&quot;:&quot;C&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;c&quot;}\">static void ePaper_Reset(void)\n{\n\tHAL_GPIO_WritePin(RST_GPIO_Port, RST_Pin, 1);\n\n\tHAL_Delay(200);\n\n\tHAL_GPIO_WritePin(RST_GPIO_Port, RST_Pin, 0);\n\n\tHAL_Delay(10);\n\n\tHAL_GPIO_WritePin(RST_GPIO_Port, RST_Pin, 1);\n\n\tHAL_Delay(200);\n\n}<\/pre><\/div>\n\n\n\n<p><\/p>\n\n\n\n<p>Next, we need a function that will read BUSY pin status as follows:<\/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;C&quot;,&quot;language&quot;:&quot;C&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;c&quot;}\">static StateTypedef ePaper_State(void)\n{\n\treturn HAL_GPIO_ReadPin(BUSY_GPIO_Port, BUSY_Pin);\n}<\/pre><\/div>\n\n\n\n<p><\/p>\n\n\n\n<p>Next, we need a function to update the display after filling the GRAM of the display. This can be done by sending command 0x20 and wait until BUSY line becomes low:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"230\" src=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/2025-10-31_14-42-19-1024x230.jpg\" alt=\"\" class=\"wp-image-3911\" srcset=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/2025-10-31_14-42-19-1024x230.jpg 1024w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/2025-10-31_14-42-19-300x67.jpg 300w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/2025-10-31_14-42-19-768x173.jpg 768w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/2025-10-31_14-42-19-1536x345.jpg 1536w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/2025-10-31_14-42-19-2048x460.jpg 2048w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/2025-10-31_14-42-19-1150x258.jpg 1150w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/2025-10-31_14-42-19-750x169.jpg 750w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/2025-10-31_14-42-19-400x90.jpg 400w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/2025-10-31_14-42-19-250x56.jpg 250w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\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;C&quot;,&quot;language&quot;:&quot;C&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;c&quot;}\">static void ePaper_Display_On(void)\n{\n\tePaper_WriteCmd(0x20);\n\twhile(ePaper_State()==BUSY)\n\t{\n\t\tHAL_Delay(1);\n\t}\n\n}<\/pre><\/div>\n\n\n\n<p><\/p>\n\n\n\n<p>Next, set the address window, this is necessarily when drawing an image:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"322\" src=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/2025-10-31_14-44-32-1024x322.jpg\" alt=\"\" class=\"wp-image-3912\" srcset=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/2025-10-31_14-44-32-1024x322.jpg 1024w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/2025-10-31_14-44-32-300x94.jpg 300w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/2025-10-31_14-44-32-768x242.jpg 768w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/2025-10-31_14-44-32-1536x484.jpg 1536w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/2025-10-31_14-44-32-2048x645.jpg 2048w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/2025-10-31_14-44-32-1150x362.jpg 1150w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/2025-10-31_14-44-32-750x236.jpg 750w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/2025-10-31_14-44-32-400x126.jpg 400w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/2025-10-31_14-44-32-250x79.jpg 250w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\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;C&quot;,&quot;language&quot;:&quot;C&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;c&quot;}\">static void ePaper_SetWindows(uint16_t Xstart, uint16_t Ystart, uint16_t Xend, uint16_t Yend)\n{\n\tePaper_WriteCmd(0x44); \/\/ SET_RAM_X_ADDRESS_START_END_POSITION\n\tePaper_WriteData((Xstart&gt;&gt;3) &amp; 0x1F);\n\tePaper_WriteData((Xend&gt;&gt;3) &amp; 0x1F);\n\n    ePaper_WriteCmd(0x45); \/\/ SET_RAM_Y_ADDRESS_START_END_POSITION\n    ePaper_WriteData(Ystart &amp; 0xFF);\n    ePaper_WriteData((Ystart &gt;&gt; 8) &amp; 0x01);\n    ePaper_WriteData(Yend &amp; 0xFF);\n    ePaper_WriteData((Yend &gt;&gt; 8) &amp; 0x01);\n}\n<\/pre><\/div>\n\n\n\n<p>Next, set cursor function:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"212\" src=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/2025-10-31_14-45-55-1024x212.jpg\" alt=\"\" class=\"wp-image-3913\" srcset=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/2025-10-31_14-45-55-1024x212.jpg 1024w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/2025-10-31_14-45-55-300x62.jpg 300w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/2025-10-31_14-45-55-768x159.jpg 768w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/2025-10-31_14-45-55-1536x319.jpg 1536w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/2025-10-31_14-45-55-2048x425.jpg 2048w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/2025-10-31_14-45-55-1150x239.jpg 1150w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/2025-10-31_14-45-55-750x156.jpg 750w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/2025-10-31_14-45-55-400x83.jpg 400w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/2025-10-31_14-45-55-250x52.jpg 250w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\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;C&quot;,&quot;language&quot;:&quot;C&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;c&quot;}\">static void ePaper_SetCursor(uint16_t Xstart, uint16_t Ystart)\n{\n\tePaper_WriteCmd(0x4E); \/\/ SET_RAM_X_ADDRESS_COUNTER\n\tePaper_WriteData(Xstart &amp; 0x1F);\n\n    ePaper_WriteCmd(0x4F); \/\/ SET_RAM_Y_ADDRESS_COUNTER\n    ePaper_WriteData(Ystart &amp; 0xFF);\n    ePaper_WriteData((Ystart &gt;&gt; 8) &amp; 0x01);\n}<\/pre><\/div>\n\n\n\n<p><\/p>\n\n\n\n<p>These function shall be used when drawing some pictures on the display.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>Next, the initialization:<\/p>\n\n\n\n<p>First, reset the display and wait for the display to be IDLE as follows:<\/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;C&quot;,&quot;language&quot;:&quot;C&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;c&quot;}\">void ePaper_Init(void)\n{\n\tePaper_Reset();\n\twhile(ePaper_State()==BUSY)\n\t{\n\t\tHAL_Delay(1);\n\t}<\/pre><\/div>\n\n\n\n<p>Soft reset the display and wait until it becomes idle:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"233\" src=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/2025-10-31_14-48-49-1024x233.jpg\" alt=\"\" class=\"wp-image-3914\" srcset=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/2025-10-31_14-48-49-1024x233.jpg 1024w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/2025-10-31_14-48-49-300x68.jpg 300w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/2025-10-31_14-48-49-768x175.jpg 768w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/2025-10-31_14-48-49-1536x350.jpg 1536w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/2025-10-31_14-48-49-2048x467.jpg 2048w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/2025-10-31_14-48-49-1150x262.jpg 1150w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/2025-10-31_14-48-49-750x171.jpg 750w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/2025-10-31_14-48-49-400x91.jpg 400w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/2025-10-31_14-48-49-250x57.jpg 250w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\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;C&quot;,&quot;language&quot;:&quot;C&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;c&quot;}\">\tePaper_WriteCmd(0x12);\n\twhile(ePaper_State()==BUSY)\n\t{\n\t\tHAL_Delay(1);\n\t}<\/pre><\/div>\n\n\n\n<p>Enable automatic address incrementing:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"529\" src=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/2025-10-31_14-50-15-1024x529.jpg\" alt=\"\" class=\"wp-image-3915\" srcset=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/2025-10-31_14-50-15-1024x529.jpg 1024w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/2025-10-31_14-50-15-300x155.jpg 300w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/2025-10-31_14-50-15-768x397.jpg 768w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/2025-10-31_14-50-15-1536x794.jpg 1536w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/2025-10-31_14-50-15-2048x1059.jpg 2048w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/2025-10-31_14-50-15-1150x594.jpg 1150w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/2025-10-31_14-50-15-750x388.jpg 750w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/2025-10-31_14-50-15-400x207.jpg 400w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/2025-10-31_14-50-15-250x129.jpg 250w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\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;C&quot;,&quot;language&quot;:&quot;C&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;c&quot;}\">\tePaper_WriteCmd(0x11);\t\/\/0x00\n\tePaper_WriteData(0x03);<\/pre><\/div>\n\n\n\n<p>Set the address the window to be the entire display as follows:<\/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;C&quot;,&quot;language&quot;:&quot;C&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;c&quot;}\">ePaper_SetWindows(0,0,ePaper_WIDTH-1,ePaper_HEIGHT-1);<\/pre><\/div>\n\n\n\n<p>Set the Boarder Wave control to 0:<\/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;C&quot;,&quot;language&quot;:&quot;C&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;c&quot;}\">\tePaper_WriteCmd(0x3C);\t\/\/0x00\n\tePaper_WriteData(0x00);<\/pre><\/div>\n\n\n\n<p>Set the cursor to 0,0:<\/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;C&quot;,&quot;language&quot;:&quot;C&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;c&quot;}\">ePaper_SetCursor(0,0);<\/pre><\/div>\n\n\n\n<p>Wait for the display to be idle:<\/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;C&quot;,&quot;language&quot;:&quot;C&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;c&quot;}\">\twhile(ePaper_State()==BUSY)\n\t{\n\t\tHAL_Delay(1);\n\t}<\/pre><\/div>\n\n\n\n<p>Hence, the function as follows:<\/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;C&quot;,&quot;language&quot;:&quot;C&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;c&quot;}\">void ePaper_Init(void)\n{\n\tePaper_Reset();\n\twhile(ePaper_State()==BUSY)\n\t{\n\t\tHAL_Delay(1);\n\t}\n\n\tePaper_WriteCmd(0x12);\n\twhile(ePaper_State()==BUSY)\n\t{\n\t\tHAL_Delay(1);\n\t}\n\n\tePaper_WriteCmd(0x11);\t\/\/0x00\n\tePaper_WriteData(0x03);\n\n\tePaper_SetWindows(0,0,ePaper_WIDTH-1,ePaper_HEIGHT-1);\n\n\tePaper_WriteCmd(0x3C);\t\/\/0x00\n\tePaper_WriteData(0x00);\n\n\tePaper_SetCursor(0,0);\n\n\n\twhile(ePaper_State()==BUSY)\n\t{\n\t\tHAL_Delay(1);\n\t}\n\n\n}<\/pre><\/div>\n\n\n\n<p><\/p>\n\n\n\n<p>To set certain pixel to one of the three colors Black, White or Red, you need to set the register 0x24 to 0 for black and 1 for white and register 0x26 for red, 0x00 will be no color and 0x01 will be red.<\/p>\n\n\n\n<p>Hence, the filling functions as follows:<\/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;C&quot;,&quot;language&quot;:&quot;C&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;c&quot;}\">void ePaper_Clear(void)\n{\n    uint16_t Width, Height;\n    Width = (ePaper_WIDTH % 8 == 0)? (ePaper_WIDTH \/ 8 ): (ePaper_WIDTH \/ 8 + 1);\n    Height = ePaper_HEIGHT;\n\n    ePaper_WriteCmd(0x24);\n    for (uint16_t j = 0; j &lt; Height; j++) {\n        for (uint16_t i = 0; i &lt; Width; i++) {\n        \tePaper_WriteData(0xff);\n        }\n    }\n    ePaper_WriteCmd(0x26);\n    for (uint16_t j = 0; j &lt; Height; j++) {\n        for (uint16_t i = 0; i &lt; Width; i++) {\n        \tePaper_WriteData(0x00);\n        }\n    }\n    ePaper_Display_On();\n}\n\nvoid ePaper_Clear_Black(void)\n{\n\n    uint16_t Width, Height;\n    Width = (ePaper_WIDTH % 8 == 0)? (ePaper_WIDTH \/ 8 ): (ePaper_WIDTH \/ 8 + 1);\n    Height = ePaper_HEIGHT;\n\n    ePaper_WriteCmd(0x24);\n    for (uint16_t j = 0; j &lt; Height; j++) {\n        for (uint16_t i = 0; i &lt; Width; i++) {\n        \tePaper_WriteData(0x00);\n        }\n    }\n    ePaper_WriteCmd(0x26);\n    for (uint16_t j = 0; j &lt; Height; j++) {\n        for (uint16_t i = 0; i &lt; Width; i++) {\n        \tePaper_WriteData(0x00);\n        }\n    }\n    ePaper_Display_On();\n}\n\nvoid ePaper_Clear_Red(void)\n{\n\tuint16_t Width, Height;\n    Width = (ePaper_WIDTH % 8 == 0)? (ePaper_WIDTH \/ 8 ): (ePaper_WIDTH \/ 8 + 1);\n    Height = ePaper_HEIGHT;\n\n    ePaper_WriteCmd(0x24);\n    for (uint16_t j = 0; j &lt; Height; j++) {\n        for (uint16_t i = 0; i &lt; Width; i++) {\n        \tePaper_WriteData(0x00);\n        }\n    }\n    ePaper_WriteCmd(0x26);\n    for (uint16_t j = 0; j &lt; Height; j++) {\n        for (uint16_t i = 0; i &lt; Width; i++) {\n        \tePaper_WriteData(0xFF);\n        }\n    }\n    ePaper_Display_On();\n}<\/pre><\/div>\n\n\n\n<p><\/p>\n\n\n\n<p>Finally, sleep function:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"283\" src=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/2025-10-31_15-13-35-1024x283.jpg\" alt=\"\" class=\"wp-image-3916\" srcset=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/2025-10-31_15-13-35-1024x283.jpg 1024w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/2025-10-31_15-13-35-300x83.jpg 300w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/2025-10-31_15-13-35-768x212.jpg 768w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/2025-10-31_15-13-35-1536x425.jpg 1536w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/2025-10-31_15-13-35-2048x566.jpg 2048w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/2025-10-31_15-13-35-1150x318.jpg 1150w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/2025-10-31_15-13-35-750x207.jpg 750w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/2025-10-31_15-13-35-400x111.jpg 400w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/2025-10-31_15-13-35-250x69.jpg 250w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\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;C&quot;,&quot;language&quot;:&quot;C&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;c&quot;}\">void ePaper_Sleep(void)\n{\n\tePaper_WriteCmd(0x10); \/\/ POWER_OFF\n\tePaper_WriteData(0X01);\n\n}<\/pre><\/div>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>Hence the entire source as follows:<\/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;C&quot;,&quot;language&quot;:&quot;C&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;c&quot;}\">#include &quot;epaper.h&quot;\n\nstatic void ePaper_WriteData(uint8_t data)\n{\n\tHAL_GPIO_WritePin(DC_GPIO_Port, DC_Pin,1);\n\n\tHAL_GPIO_WritePin(CS_GPIO_Port, CS_Pin, 0);\n\n\tHAL_SPI_Transmit(&amp;hspi1, &amp;data, 1, 10);\n\n\tHAL_GPIO_WritePin(CS_GPIO_Port, CS_Pin, 1);\n}\n\nstatic void ePaper_WriteCmd(uint8_t cmd)\n{\n\tHAL_GPIO_WritePin(DC_GPIO_Port, DC_Pin,0);\n\n\tHAL_GPIO_WritePin(CS_GPIO_Port, CS_Pin, 0);\n\n\tHAL_SPI_Transmit(&amp;hspi1, &amp;cmd, 1, 10);\n\n\tHAL_GPIO_WritePin(CS_GPIO_Port, CS_Pin, 1);\n\n}\n\nstatic void ePaper_Reset(void)\n{\n\tHAL_GPIO_WritePin(RST_GPIO_Port, RST_Pin, 1);\n\n\tHAL_Delay(200);\n\n\tHAL_GPIO_WritePin(RST_GPIO_Port, RST_Pin, 0);\n\n\tHAL_Delay(10);\n\n\tHAL_GPIO_WritePin(RST_GPIO_Port, RST_Pin, 1);\n\n\tHAL_Delay(200);\n\n}\n\nstatic StateTypedef ePaper_State(void)\n{\n\treturn HAL_GPIO_ReadPin(BUSY_GPIO_Port, BUSY_Pin);\n}\n\n\nstatic void ePaper_Display_On(void)\n{\n\tePaper_WriteCmd(0x20);\n\twhile(ePaper_State()==BUSY)\n\t{\n\t\tHAL_Delay(1);\n\t}\n\n}\n\n\n\nstatic void ePaper_SetWindows(uint16_t Xstart, uint16_t Ystart, uint16_t Xend, uint16_t Yend)\n{\n\tePaper_WriteCmd(0x44); \/\/ SET_RAM_X_ADDRESS_START_END_POSITION\n\tePaper_WriteData((Xstart&gt;&gt;3) &amp; 0x1F);\n\tePaper_WriteData((Xend&gt;&gt;3) &amp; 0x1F);\n\n    ePaper_WriteCmd(0x45); \/\/ SET_RAM_Y_ADDRESS_START_END_POSITION\n    ePaper_WriteData(Ystart &amp; 0xFF);\n    ePaper_WriteData((Ystart &gt;&gt; 8) &amp; 0x01);\n    ePaper_WriteData(Yend &amp; 0xFF);\n    ePaper_WriteData((Yend &gt;&gt; 8) &amp; 0x01);\n}\n\n\nstatic void ePaper_SetCursor(uint16_t Xstart, uint16_t Ystart)\n{\n\tePaper_WriteCmd(0x4E); \/\/ SET_RAM_X_ADDRESS_COUNTER\n\tePaper_WriteData(Xstart &amp; 0x1F);\n\n    ePaper_WriteCmd(0x4F); \/\/ SET_RAM_Y_ADDRESS_COUNTER\n    ePaper_WriteData(Ystart &amp; 0xFF);\n    ePaper_WriteData((Ystart &gt;&gt; 8) &amp; 0x01);\n}\n\nvoid ePaper_Init(void)\n{\n\tePaper_Reset();\n\twhile(ePaper_State()==BUSY)\n\t{\n\t\tHAL_Delay(1);\n\t}\n\n\tePaper_WriteCmd(0x12);\n\twhile(ePaper_State()==BUSY)\n\t{\n\t\tHAL_Delay(1);\n\t}\n\n\tePaper_WriteCmd(0x11);\t\/\/0x00\n\tePaper_WriteData(0x03);\n\n\tePaper_SetWindows(0,0,ePaper_WIDTH-1,ePaper_HEIGHT-1);\n\n\tePaper_WriteCmd(0x3C);\t\/\/0x00\n\tePaper_WriteData(0x00);\n\n\tePaper_SetCursor(0,0);\n\n\n\twhile(ePaper_State()==BUSY)\n\t{\n\t\tHAL_Delay(1);\n\t}\n\n\n}\n\nvoid ePaper_Clear(void)\n{\n    uint16_t Width, Height;\n    Width = (ePaper_WIDTH % 8 == 0)? (ePaper_WIDTH \/ 8 ): (ePaper_WIDTH \/ 8 + 1);\n    Height = ePaper_HEIGHT;\n\n    ePaper_WriteCmd(0x24);\n    for (uint16_t j = 0; j &lt; Height; j++) {\n        for (uint16_t i = 0; i &lt; Width; i++) {\n        \tePaper_WriteData(0xff);\n        }\n    }\n    ePaper_WriteCmd(0x26);\n    for (uint16_t j = 0; j &lt; Height; j++) {\n        for (uint16_t i = 0; i &lt; Width; i++) {\n        \tePaper_WriteData(0x00);\n        }\n    }\n    ePaper_Display_On();\n}\n\nvoid ePaper_Clear_Black(void)\n{\n\n    uint16_t Width, Height;\n    Width = (ePaper_WIDTH % 8 == 0)? (ePaper_WIDTH \/ 8 ): (ePaper_WIDTH \/ 8 + 1);\n    Height = ePaper_HEIGHT;\n\n    ePaper_WriteCmd(0x24);\n    for (uint16_t j = 0; j &lt; Height; j++) {\n        for (uint16_t i = 0; i &lt; Width; i++) {\n        \tePaper_WriteData(0x00);\n        }\n    }\n    ePaper_WriteCmd(0x26);\n    for (uint16_t j = 0; j &lt; Height; j++) {\n        for (uint16_t i = 0; i &lt; Width; i++) {\n        \tePaper_WriteData(0x00);\n        }\n    }\n    ePaper_Display_On();\n}\n\nvoid ePaper_Clear_Red(void)\n{\n\tuint16_t Width, Height;\n    Width = (ePaper_WIDTH % 8 == 0)? (ePaper_WIDTH \/ 8 ): (ePaper_WIDTH \/ 8 + 1);\n    Height = ePaper_HEIGHT;\n\n    ePaper_WriteCmd(0x24);\n    for (uint16_t j = 0; j &lt; Height; j++) {\n        for (uint16_t i = 0; i &lt; Width; i++) {\n        \tePaper_WriteData(0x00);\n        }\n    }\n    ePaper_WriteCmd(0x26);\n    for (uint16_t j = 0; j &lt; Height; j++) {\n        for (uint16_t i = 0; i &lt; Width; i++) {\n        \tePaper_WriteData(0xFF);\n        }\n    }\n    ePaper_Display_On();\n}\n\n\n\n\nvoid ePaper_Sleep(void)\n{\n\tePaper_WriteCmd(0x10); \/\/ POWER_OFF\n\tePaper_WriteData(0X01);\n\n}\n\n<\/pre><\/div>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">3. Main file:<\/h2>\n\n\n\n<p>In main.c in user code begin 2 in main function:<\/p>\n\n\n\n<p>First, set PWR pin to high as follows:<\/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;C&quot;,&quot;language&quot;:&quot;C&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;c&quot;}\">HAL_GPIO_WritePin(PWR_GPIO_Port, PWR_Pin, 1);<\/pre><\/div>\n\n\n\n<p>Initialize the display:<\/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;C&quot;,&quot;language&quot;:&quot;C&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;c&quot;}\">ePaper_Init();<\/pre><\/div>\n\n\n\n<p>In while 1 loop:<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>We shall loop through the clear display 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;C&quot;,&quot;language&quot;:&quot;C&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;c&quot;}\">\t  ePaper_Clear();\n\t  HAL_Delay(5000);\n\t  ePaper_Clear_Black();\n\t  HAL_Delay(5000);\n\t  ePaper_Clear_Red();\n\t  HAL_Delay(5000);<\/pre><\/div>\n\n\n\n<p><\/p>\n\n\n\n<p>Thats all.<\/p>\n\n\n\n<p>Save the project, build it and run it on your board as following:<br><\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"28\" src=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/image-5-1024x28.png\" alt=\"\" class=\"wp-image-3917\" srcset=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/image-5-1024x28.png 1024w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/image-5-300x8.png 300w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/image-5-768x21.png 768w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/image-5-1536x43.png 1536w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/image-5-1150x32.png 1150w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/image-5-750x21.png 750w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/image-5-400x11.png 400w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/image-5-250x7.png 250w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/image-5.png 1734w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">4. Results:<\/h2>\n\n\n\n<p>You should get the following:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"800\" height=\"450\" src=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2025\/10\/ezgif-7f204d4873c6d4.gif\" alt=\"\" class=\"wp-image-3918\" \/><\/figure>\n\n\n\n<p>Note: It requires almost half minute to update the display. The video is accelerated.<\/p>\n\n\n\n<p>Happy coding \ud83d\ude09<\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Displaying a full-screen color image on an E-Ink display demonstrates the device\u2019s ability to render rich visuals using its reflective, low-power technology. In this guide, we will cover how to send and refresh full-frame image data to achieve a complete color update on the E-Paper screen. In this guide, we shall cover the following: 1. [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2,11,12],"tags":[],"class_list":["post-3907","post","type-post","status-publish","format-standard","hentry","category-embedded-systems","category-peripheral-drivers","category-stm32"],"_links":{"self":[{"href":"https:\/\/blog.embeddedexpert.io\/index.php?rest_route=\/wp\/v2\/posts\/3907"}],"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=3907"}],"version-history":[{"count":1,"href":"https:\/\/blog.embeddedexpert.io\/index.php?rest_route=\/wp\/v2\/posts\/3907\/revisions"}],"predecessor-version":[{"id":3919,"href":"https:\/\/blog.embeddedexpert.io\/index.php?rest_route=\/wp\/v2\/posts\/3907\/revisions\/3919"}],"wp:attachment":[{"href":"https:\/\/blog.embeddedexpert.io\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3907"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.embeddedexpert.io\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3907"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.embeddedexpert.io\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3907"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}