feat: initialize epd with custom slow-refresh

This commit is contained in:
fsender
2025-03-13 08:36:29 +08:00
parent 86e1022ffa
commit 25b9e62f5f
5 changed files with 24 additions and 14 deletions

View File

@@ -199,7 +199,7 @@ void setup(){
//使用guy.guyFS()函数返回可用的文件系统. 默认为SD卡. 当SD卡不可用时, 自动切换到内置的LittleFS.
//显示打开的图片信息(宽度和高度), 和剩余内存
Serial.printf("[%lu] sp.w: %d, h: %d, res: %d.\n",millis(),sp.width(),sp.height(),guy.getFreeMem());
Serial.printf("[%lu] sp.w: %d, h: %d, res: %d.\n",millis(),(int)sp.width(),(int)sp.height(),guy.getFreeMem());
guy.drawImage(sp,10,10); //使用抖动像素的方式显示图片(不是灰度, 只有黑点和白点的那种显示效果)

View File

@@ -55,9 +55,9 @@
ReadguyDriver guy;//新建一个readguy对象, 用于显示驱动.
extern const uint8_t ctg_u8g2_wqy12_chinese1[]; //声明中文字体文件
extern const uint8_t ctg_u8g2_wqy12_gb2312[]; //声明中文字体文件
const lgfx::U8g2font cn_font(ctg_u8g2_wqy12_chinese1); //U8G2格式中文字体转化为LGFX格式字体
const lgfx::U8g2font cn_font(ctg_u8g2_wqy12_gb2312); //U8G2格式中文字体转化为LGFX格式字体
void setup(){
@@ -69,7 +69,7 @@ void setup(){
guy.setCursor(10,10);
guy.print("中文");
guy.print("你好, 中文");
guy.display();
}

View File

@@ -102,17 +102,17 @@ const unsigned char drvSSD168x::VSH_table[32]=
//以下代码均为我 FriendshipEnder 原创, 呵呵哒~~
void drvSSD168x::SetLut() {
unsigned int i;
guy_epdCmd(0x3f);
guy_epdParam(greyScaling?0x07:0x22);
guy_epdParam(greyScaling?0x07:0x02); //greyScaling?0x07:0x22
guy_epdCmd(0x03); // gate voltage
guy_epdParam(0x17);
guy_epdParam(0x17); //0x17 orig
guy_epdCmd(0x04); // source voltage
guy_epdParam(greyScaling?pgm_read_byte(VSH_table+16+iLut):pgm_read_byte(VSH_table+iLut));
guy_epdParam(0xA8); // VSH2
guy_epdParam(0x32); // VSL
guy_epdCmd(0x2c); // VCOM
guy_epdParam(0x28);
unsigned char i;
guy_epdParam(0x20); //0x28 orig
guy_epdCmd(0x32);
if(_part){
for(i=0;i<5;i++){
@@ -160,6 +160,8 @@ void drvSSD168x::drv_dispWriter(std::function<uint8_t(int)> f,uint8_t m){ //单
for(int i=0;i<10;i++) guy_epdParam(i==5?0x40:0x00);
guy_epdCmd(0x3C); //BorderWavefrom
guy_epdParam(0x80);
guy_epdCmd(0x18); //BorderWavefrom
guy_epdParam(0x80);
guy_epdCmd(0x22);
guy_epdParam(0xC0);
@@ -172,9 +174,10 @@ void drvSSD168x::drv_dispWriter(std::function<uint8_t(int)> f,uint8_t m){ //单
epd_PowerOn=1;
_part=0;
iLut=15;
guy_epdBusy(20);
}
guy_epdCmd(0x12); //SWRESET
guy_epdBusy(10);
guy_epdBusy(20);
guy_epdCmd(0x01); //Driver output control
guy_epdParam((epdHeight-1)&0xff);

View File

@@ -704,7 +704,8 @@ void ReadguyDriver::handleFinal(){
#else
uint64_t gotID;
esp_flash_read_unique_chip_id(esp_flash_default_chip,&gotID);
sprintf(cbuf, "%016llx", gotID);
//sprintf(cbuf, "%016llx", gotID);
sprintf(cbuf, "%08x%08x",(unsigned int)(gotID>>32),(unsigned int)(gotID&0xffffffffu));
#endif
s+=cbuf;
s+=F("<br/>闪存容量: ");

View File

@@ -328,7 +328,7 @@ uint8_t ReadguyDriver::checkEpdDriver(){
void ReadguyDriver::setEpdDriver(bool initepd, bool initGFX){
guy_dev->spi_tr_release = in_release;
guy_dev->spi_tr_press = in_press;
if(initepd) guy_dev->drv_init(); //初始化epd驱动层
guy_dev->drv_init(); //初始化epd驱动层
//if(g_width) guy_width = g_width;
//else guy_width = guy_dev->drv_width(); //宽度必须是8的倍数, 但这个可以由GFX自动计算
//if(g_height) guy_height = g_height;
@@ -351,6 +351,7 @@ void ReadguyDriver::setEpdDriver(bool initepd, bool initGFX){
#ifdef READGUY_SERIAL_DEBUG
Serial.printf_P(PSTR("[Guy EPD] EPD init OK(%d): w: %d, h: %d\n"),guy_dev->drv_ID(),guy_dev->drv_width(),guy_dev->drv_height());
#endif
if(initepd) display(READGUY_SLOW); //25/3/13:feat: 如果initepd为true说明墨水屏需要从上电or休眠初始化, 必定慢刷
}
#ifdef READGUY_ENABLE_SD
bool ReadguyDriver::setSDcardDriver(){
@@ -524,12 +525,15 @@ void ReadguyDriver::setButtonDriver(){
analogWrite(READGUY_bl_pin,currentBright);
#else
#if (defined ( ESP_IDF_VERSION_VAL ) && (ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 0)))
ledcAttach(READGUY_bl_pin,8000,8);
//ledcAttach(READGUY_bl_pin,8000,8);
analogWrite(READGUY_bl_pin, currentBright);
analogWriteFrequency(READGUY_bl_pin, 8000); //esp32宜快一些, 减少频闪影响
analogWriteResolution(READGUY_bl_pin, 8); //其实完全可以再快点的
#else
ledcSetup(0, 8000, 8);
ledcAttachPin(READGUY_bl_pin, 0);//稍后加入PWM驱动...
#endif
ledcWrite(0, currentBright);
#endif
#endif
}
else {
@@ -567,10 +571,12 @@ fs::FS &ReadguyDriver::guyFS(uint8_t initSD){
void ReadguyDriver::setBright(int d){
if(currentBright>=0 && d>=0 && d<=255){
currentBright=d;
#ifdef ESP8266
#if ((defined (ESP8266)))
analogWrite(READGUY_bl_pin,d);
#else
#if (defined ( ESP_IDF_VERSION_VAL ) && (ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 0)))
ledcWrite(0, d);
#endif
#endif
}
else if(currentBright>=-2 && currentBright<0){ //-1为不支持PWM的亮起,-2为不支持PWM的熄灭