diff --git a/src/config/user_config.h b/src/config/user_config.h index 3c5e950..c845c15 100644 --- a/src/config/user_config.h +++ b/src/config/user_config.h @@ -55,7 +55,7 @@ **************************************************************************************** */ -#define EPD_VERSION 0xA50f0004 +#define EPD_VERSION 0xA50f0005 /* diff --git a/src/epd/epd.c b/src/epd/epd.c index 56e79a8..0fa4d1f 100644 --- a/src/epd/epd.c +++ b/src/epd/epd.c @@ -11,6 +11,7 @@ int scr_h; int scr_mode; int line_bytes; int scr_padding; +int update_mode; // 窗口参数 @@ -89,7 +90,7 @@ void epd_pos(int x, int y) epd_data(y>>8); } -u8 lut[80] = { +u8 lut_fast[80] = { // RP0 RP1 RP2 RP3 RP4 RP5 RP6 0x80, 0x60, 0x40, 0x00, 0x00, 0x00, 0x00, // LUT0 0x10, 0x60, 0x20, 0x00, 0x00, 0x00, 0x00, // LUT1 @@ -110,16 +111,19 @@ u8 lut[80] = { 0x15, 0x41, 0xa8, 0x32, 0x30, 0x0a, }; -u8 lut_p[80] = { + +// 这里如果B-B和W->W不驱动的话,屏幕很快就会花掉。 +// 但如果驱动的话,这种黑白转换就没有意义了。 +u8 lut_fly[80] = { // RP0 RP1 RP2 RP3 RP4 RP5 RP6 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // LUT0 - 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // LUT1 - 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // LUT2 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // LUT3 + 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // LUT0 B->B + 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // LUT1 B->W + 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // LUT2 W->B + 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // LUT3 W->W 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // LUT4 - 0x0a, 0x00, 0x00, 0x00, 0x01, // Group0 + 0x0f, 0x00, 0x00, 0x00, 0x01, // Group0 0x00, 0x00, 0x00, 0x00, 0x01, // Group1 0x00, 0x00, 0x00, 0x00, 0x01, // Group2 0x00, 0x00, 0x00, 0x00, 0x01, // Group3 @@ -224,15 +228,18 @@ void epd_init(void) printk("epd_init: %dx%d\n", scr_w, scr_h); + update_mode = UPDATE_FULL; epd_power(1); - epd_reset(); + epd_reset(1); +#if 0 epd_wait(); epd_cmd(0x12); // SWRESET delay_ms(10); epd_wait(); - //epd_lut_size(); +// epd_lut_size(); +#endif epd_cmd1(0x74, 0x54); epd_cmd1(0x7e, 0x3b); @@ -245,50 +252,47 @@ void epd_init(void) epd_cmd1(0x3c, 0x05); // border wavefrom epd_window(0, 0, scr_w-1, scr_h-1); - + epd_cmd1(0x18, 0x80); // Read Built-in temperature sensor + #if 0 - - epd_cmd1(0x18, 0x80); // Read Built-in temperature sensor - epd_cmd1(0x22, 0xb1); epd_cmd(0x20); epd_wait(); epd_dump_lut(); - #endif } -void epd_update(int mode) +void epd_update_mode(int mode) +{ + update_mode = mode; +} + + +void epd_update(void) { int seq; - if(mode==0){ + if(update_mode==UPDATE_FULL){ seq = 0xf7; }else{ - seq = mode; + if(update_mode==UPDATE_FAST){ + epd_load_lut(lut_fast); + }else{ + epd_load_lut(lut_fly); + } + seq = 0xc7; } epd_cmd1(0x22, seq); epd_cmd(0x20); - epd_wait(); -// epd_dump_lut(); -} - -void epd_update_lut(u8 *lut) -{ - epd_load_lut(lut); - epd_cmd1(0x22, 0xc4); - epd_cmd(0x20); - epd_wait(); } void epd_sleep(void) { epd_cmd1(0x10, 01); - delay_ms(10); } @@ -305,11 +309,8 @@ void epd_screen_update(void) if(scr_mode&EPD_BWR){ epd_cmd(0x26); for(i=0; i>3); int bit_mask = 0x80>>(nx&7); - if(color==RED){ + if(color!=WHITE){ + fb_bw[byte_pos] &= ~bit_mask; + } + if(scr_mode&EPD_BWR && color==RED){ fb_rr[byte_pos] |= bit_mask; - fb_bw[byte_pos] |= bit_mask; - }else{ - fb_rr[byte_pos] &= ~bit_mask; - if(color==WHITE){ - fb_bw[byte_pos] |= bit_mask; - }else{ - fb_bw[byte_pos] &= ~bit_mask; - } } } @@ -224,11 +219,14 @@ char *wday_str[] = { "日", }; + static int wday = 0; void fb_test(void) { memset(fb_bw, 0xff, scr_h*line_bytes); - memset(fb_rr, 0x00, scr_h*line_bytes); + if(scr_mode&EPD_BWR){ + memset(fb_rr, 0x00, scr_h*line_bytes); + } draw_rect(0, 0, fb_w-1, fb_h-1, BLACK); draw_rect(1, 1, fb_w-2, fb_h-2, BLACK); @@ -246,9 +244,7 @@ void fb_test(void) select_font(0); char tbuf[64]; -// sprintf(tbuf, "%4d年%2d月%2d日 星期%s", 2025, 4, 29, wday_str[wday]); - sprintf(tbuf, "2025年 4月29日 星期%s", wday_str[wday]); - printk("tbuf: %s\n", tbuf); + sprintk(tbuf, "%4d年%2d月%2d日 星期%s", 2025, 4, 29, wday_str[wday]); draw_text(15, 85, tbuf, BLACK); wday += 1; @@ -256,7 +252,8 @@ void fb_test(void) wday = 0; select_font(1); - draw_text(12, 20, "02:34", BLACK); + sprintk(tbuf, "%02d:%02d", 2+wday, 30+wday); + draw_text(12, 20, tbuf, BLACK); epd_screen_update(); } diff --git a/src/epd/epd_hw.c b/src/epd/epd_hw.c index 014dd42..0416c2b 100644 --- a/src/epd/epd_hw.c +++ b/src/epd/epd_hw.c @@ -80,7 +80,7 @@ void epd_hw_init(u32 config0, u32 config1, int w, int h, int mode) epio_cs = (config1>>16)&0xff; epio_clk = (config1>> 8)&0xff; epio_sdi = (config1>> 0)&0xff; - + scr_w = w; scr_h = h; scr_mode = mode; @@ -138,12 +138,9 @@ static int epd_spi_read(void) } -void epd_reset(void) +void epd_reset(int val) { - EPD_RST(0); - delay_ms(20); - EPD_RST(1); - delay_ms(20); + EPD_RST(val); } diff --git a/src/user_custs1_impl.c b/src/user_custs1_impl.c index 52a6bbe..617c55e 100644 --- a/src/user_custs1_impl.c +++ b/src/user_custs1_impl.c @@ -247,14 +247,14 @@ void clock_draw(int full) epd_screen_update(); if(full){ - epd_update(0xf4); + epd_update_mode(UPDATE_FULL); }else{ - epd_load_lut(lut_p); - epd_cmd1(0x2c, 0x55); - epd_update(0xc0); - epd_update(0x04); + epd_update_mode(UPDATE_FLY); } - epd_cmd1(0x10, 0x03); + epd_update(); + epd_wait(); + + epd_cmd1(0x10, 0x01); epd_power(0); epd_hw_close(); } diff --git a/src/user_peripheral.c b/src/user_peripheral.c index 1682f1d..e01ca0b 100644 --- a/src/user_peripheral.c +++ b/src/user_peripheral.c @@ -183,7 +183,7 @@ void user_app_init(void) adv_count = 0; fspi_config(0x00030605); - epd_hw_init(0x23200700, 0x05210006, 104, 212, EPD_BWR|ROTATE_3); // for 2.13 board BW + epd_hw_init(0x23200700, 0x05210006, 104, 212, ROTATE_3); // for 2.13 board BW selflash(otp_boot);