STM32 +合宙1.54“ 电子墨水屏(e-paper)驱动显示示例
- 📍相关篇《Arduino框架下ESP32/ESP8266+合宙1.54“ 电子墨水屏(e-paper)驱动显示示例》
- 🔖程序是从GooDisplay品牌和微雪电子下同型号规格墨水屏的示例程序参考Arduino框架下的驱动显示代码修改得来的。
- 📍移植参考程序:(GooDisplay)
https://www.good-display.cn/product/380.html
- 📌同类型的,微雪品牌的相关资料参考:
https://www.waveshare.net/wiki/1.54inch_e-Paper_Module
🔖使用
GooDisplay
仅仅是实现刚刚点亮屏幕,点亮屏幕是迈出的重要的第一步,基于标准库,使用STM32f103芯片,软件SPI方式。
- 🌾使用微雪电子同型号规格的墨水屏驱动示例代码成功驱动。内容显示正常,包含完整的对应显示接口函数,完全可以拿来直接使用。(✨推荐✨)
- 🐛使用
GooDisplay
代码移植后,有bug。显示是:上下反置的效果,合宙1.54“ 电子墨水屏(e-paper)没有对应的手册可查询,只能参考Arduino驱动代码进行查找进行修复。测试使用局部刷新指令,来刷全局可以部分显示正常。问题可能还是在全局指令上。
📝GooDisplay参考代码修改位置
- 🌿初始化函数:
EPD_HW_Init()
const unsigned char lut_full_update[] =
{0x02, 0x02, 0x01, 0x11, 0x12, 0x12, 0x22, 0x22, 0x66, 0x69, 0x69, 0x59, 0x58, 0x99, 0x99, 0x88, 0x00, 0x00, 0x00, 0x00, 0xF8, 0xB4, 0x13, 0x51, 0x35, 0x51, 0x51, 0x19, 0x01, 0x00
};
//局部刷新指令
const unsigned char lut_partial_update[] =
{0x10, 0x18, 0x18, 0x08, 0x18, 0x18, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x13, 0x14, 0x44, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
//Full screen refresh initialization
void EPD_HW_Init(void)
{int i;EPD_W21_RST_0; // Module reset delay_xms(20);//At least 10ms delay EPD_W21_RST_1;delay_xms(20); //At least 10ms delay Epaper_READBUSY(); EPD_W21_WriteCMD(0x12); //SWRESETEpaper_READBUSY(); EPD_W21_WriteCMD(0x01); //Driver output control
// EPD_W21_WriteDATA((EPD_HEIGHT-1)%256);
// EPD_W21_WriteDATA((EPD_HEIGHT-1)/256);EPD_W21_WriteDATA((EPD_HEIGHT-1)& 0xFF); EPD_W21_WriteDATA(((EPD_HEIGHT - 1) >> 8) & 0xFF);
// EPD_W21_WriteDATA(0x00);// EPD_W21_WriteCMD(0x11); //data entry mode
// EPD_W21_WriteDATA(0x01);// EPD_W21_WriteCMD(0x44); //set Ram-X address start/end position
// EPD_W21_WriteDATA(0x00);
// EPD_W21_WriteDATA(EPD_WIDTH/8-1); // EPD_W21_WriteCMD(0x45); //set Ram-Y address start/end position
// EPD_W21_WriteDATA((EPD_HEIGHT-1)%256);
// EPD_W21_WriteDATA((EPD_HEIGHT-1)/256);
// EPD_W21_WriteDATA(0x00);
// EPD_W21_WriteDATA(0x00); // EPD_W21_WriteCMD(0x3C); //BorderWavefrom
// EPD_W21_WriteDATA(0x05);
//
// EPD_W21_WriteCMD(0x18); //Read built-in temperature sensor
// EPD_W21_WriteDATA(0x80); // EPD_W21_WriteCMD(0x4E); // set RAM x address count to 0;
// EPD_W21_WriteDATA(0x00);
// EPD_W21_WriteCMD(0x4F); // set RAM y address count to 0X199;
// EPD_W21_WriteDATA((EPD_HEIGHT-1)%256);
// EPD_W21_WriteDATA((EPD_HEIGHT-1)/256);
// Epaper_READBUSY();EPD_W21_WriteCMD(0x0c);EPD_W21_WriteDATA(0xD7);EPD_W21_WriteDATA(0xD6);EPD_W21_WriteDATA(0x9D);EPD_W21_WriteCMD(0x2c);EPD_W21_WriteDATA(0xA8); // VCOM 7C 0xA8EPD_W21_WriteCMD(0x3a);EPD_W21_WriteDATA(0x1A); // 4 dummy lines per gateEPD_W21_WriteCMD(0x3b);EPD_W21_WriteDATA(0x08); // 2us per lineEPD_W21_WriteCMD(0x11);EPD_W21_WriteDATA(0x03); // X increment; Y increment EPD_W21_WriteCMD(0x32);/* the length of look-up table is 30 bytes */for ( i = 0; i < 30; i++) {EPD_W21_WriteDATA(lut_full_update[i]);}
}
- 🌿刷新显示函数:
EPD_Update()
//Full screen refresh update function
void EPD_Update(void)
{ EPD_W21_WriteCMD(0x22); //Display Update Control// EPD_W21_WriteDATA(0xF7);//注释掉该指令
EPD_W21_WriteDATA(0xc4); //新增EPD_W21_WriteCMD(0x20); //Activate Display Update Sequence
// EPD_W21_WriteDATA(0xFF);// 新增 TERMINATE_FRAME_READ_WRITE 不启用,没有发现其他异常Epaper_READBUSY(); }
- 合宙1.54“ 电子墨水屏(e-paper)屏幕不兼容
GooDisplay
的快速刷屏指令,
📄引脚定义
- 在
Display_EPD_W21_spi.h
中:
#define EPD_W21_MOSI_0 GPIO_ResetBits(GPIOD, GPIO_Pin_10)
#define EPD_W21_MOSI_1 GPIO_SetBits(GPIOD, GPIO_Pin_10)#define EPD_W21_CLK_0 GPIO_ResetBits(GPIOD, GPIO_Pin_9)
#define EPD_W21_CLK_1 GPIO_SetBits(GPIOD, GPIO_Pin_9)#define EPD_W21_CS_0 GPIO_ResetBits(GPIOD, GPIO_Pin_8)
#define EPD_W21_CS_1 GPIO_SetBits(GPIOD, GPIO_Pin_8)#define EPD_W21_DC_0 GPIO_ResetBits(GPIOE, GPIO_Pin_15)
#define EPD_W21_DC_1 GPIO_SetBits(GPIOE, GPIO_Pin_15)#define EPD_W21_RST_0 GPIO_ResetBits(GPIOE, GPIO_Pin_14)
#define EPD_W21_RST_1 GPIO_SetBits(GPIOE, GPIO_Pin_14)#define isEPD_W21_BUSY GPIO_ReadInputDataBit(GPIOE, GPIO_Pin_13) // for solomen solutions
📚合宙1.54墨水屏适配程序
- 🔖后续如果修复bug,将更新。
链接:https://pan.baidu.com/s/1_elRESwoOvCxe2ataPG4ug?pwd=em1y
提取码:em1y
📗微雪对应型号驱动程序
- 🔖经测试,完全兼容微雪同型号的V1版本(
EPD_1in54_test
)的程序。 - 📑微雪对应的驱动程序有2套.
-
- 针对带驱动板的程序:
https://www.waveshare.net/wiki/E-Paper_Shield
- 针对带驱动板的程序:
资源地址:https://www.waveshare.net/w/upload/6/69/E-Paper_Shield_Code.7z
/**SPI1 GPIO Configuration PA5 ------> SPI1_SCK SCLPA6 ------> SPI1_MISO不需要接PA7 ------> SPI1_MOSI DIN(SDA)*/
#define SD_CS_Pin GPIO_PIN_10
#define SD_CS_GPIO_Port GPIOB#define EPD_DC_Pin GPIO_PIN_7
#define EPD_DC_GPIO_Port GPIOC#define EPD_BUSY_Pin GPIO_PIN_8
#define EPD_BUSY_GPIO_Port GPIOA#define EPD_RST_Pin GPIO_PIN_9
#define EPD_RST_GPIO_Port GPIOA#define SPIRAM_CS_Pin GPIO_PIN_4
#define SPIRAM_CS_GPIO_Port GPIOB#define EPD_CS_Pin GPIO_PIN_6
#define EPD_CS_GPIO_Port GPIOB
-
- 仅针对屏幕的驱动程序
EPD_1in54_test
版本:https://www.waveshare.net/wiki/1.54inch_e-Paper_Module_Manual#STM32
- 仅针对屏幕的驱动程序
资源地址:https://www.waveshare.net/w/upload/3/39/E-Paper_code.7z
PA5 ------> SPI1_SCKPA7 ------> SPI1_MOSI
#define RST_Pin GPIO_PIN_1
#define RST_GPIO_Port GPIOA
#define DC_Pin GPIO_PIN_2
#define DC_GPIO_Port GPIOA
#define BUSY_Pin GPIO_PIN_3
#define BUSY_GPIO_Port GPIOA
#define SPI_CS_Pin GPIO_PIN_4
#define SPI_CS_GPIO_Port GPIOA
-🔖此文章仅作为个人学习探索知识的总结,不作为他人或引用者的理论依据,由于学识所限,难免会出现错误或纰漏,欢迎大家指正。