diff --git a/doc/pic1.jpg b/doc/pic1.jpg index 1bf7306..22aae97 100644 Binary files a/doc/pic1.jpg and b/doc/pic1.jpg differ diff --git a/readme.md b/readme.md index 4f96d78..5ee23a3 100644 --- a/readme.md +++ b/readme.md @@ -21,7 +21,7 @@ tools 下提供 bwr_gray8.act 调色板,便于在 Photoshop 里生成 BWR 色 ## 编译 -IAR 9.40 或 CCS 12.5 +CCS 12.4 SDK: simplelink_cc2640r2_sdk_1_40_00_45 diff --git a/src/app/epd_2in13.c b/src/app/epd_2in13.c index d7a66af..b30295e 100644 --- a/src/app/epd_2in13.c +++ b/src/app/epd_2in13.c @@ -16,6 +16,7 @@ #include // time #include // uint8_t +#include // memset // OBD #include "OneBitDisplay.h" @@ -24,7 +25,7 @@ #include "font16.h" // One Bit Display -OBDISP obd; +OBDISP obd = {0}; extern const uint8_t ucMirror[]; @@ -44,6 +45,41 @@ extern const uint8_t ucMirror[]; #define BW__ V(VH1, VSL, VSS, VSS) #define RW__ V(VH2, VSL, VSS, VSS) +// fast refresh for clock. +static const uint8_t lut_fast_bw[] = { +// VS [0-11] phase [ABCD] +// 0 1 2 3 4 5 6 7 8 9 10 11 + B___, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // LUT0 B + _W__, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // LUT1 W + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // LUT2 R + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // LUT3 NC? + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // LUT4 VCOM +// 60: +// TP A, TP B, SRAB, TP C, TP D, SRCD, RP + 0x04, 0x10, 0x03, 0x00, 0x00, 0x00, 0x02, // 0 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 1 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 2 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 3 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 4 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 5 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 6 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 7 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 8 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 9 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 10 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 11 +// 144: FR 25-200Hz + 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, +// 150: XON + 0x00, 0x00, 0x00, +// 153: +// EOPT VGH VSH1 VSH2 VSL VCOM +// 3F 03 04 2C +// 22 -20v 15v 3v -15v + 0x22, 0x17, 0x41, 0x94, 0x32, 0x36 +}; + +// fast full refresh. static const uint8_t lut_full_bwr[] = { // VS [0-11] phase [ABCD] // 0 1 2 3 4 5 6 7 8 9 10 11 @@ -107,7 +143,7 @@ static int8_t EPD_2IN13_ReadTemp() // soft reset EPD_SSD_SendCommand(0x12); - EPD_SSD_WaitBusy(); + EPD_SSD_WaitBusy(100); // Border Waveform EPD_SSD_SendCommand(0x3C); @@ -123,7 +159,7 @@ static int8_t EPD_2IN13_ReadTemp() // Master Activation EPD_SSD_SendCommand(0x20); - EPD_SSD_WaitBusy(); + EPD_SSD_WaitBusy(100); // read temperature EPD_SSD_SendCommand(0x1b); @@ -151,8 +187,8 @@ static void EPD_2IN13_BWR(int width, int height, int left, int top) int h1 = h0 + height/8 - 1; // soft reset - EPD_SSD_SendCommand(0x12); - EPD_SSD_WaitBusy(); + //EPD_SSD_SendCommand(0x12); + //EPD_SSD_WaitBusy(); // Border Waveform EPD_SSD_SendCommand(0x3C); @@ -226,16 +262,47 @@ void EPD_2IN13_Sleep(void) EPD_SSD_SendData(0x01); // 01: mode 1, 11: mode 2 } -void EPD_SSD_Update(void) +void EPD_2IN13_Clear(void) { - static time_t last = 0; - time_t now = time(NULL); - if (last && ((now % 60) != 0)) { + // wakeup EPD + EPD_SSD_Reset(); + + // do reset + EPD_2IN13_SoftReset(); + + // write white to ram + EPD_2IN13_BWR(EPD_WIDTH, EPD_HEIGHT, 0, 0); + EPD_2IN13_WriteRam(NULL, EPD_WIDTH, EPD_HEIGHT, 0, 0, 0); + EDP_2IN13_WriteRam(NULL, EPD_WIDTH, EPD_HEIGHT, 0, 0, 1); + + // full display + EPD_2IN13_Display(0xf7); + + // wait & sleep + EPD_SSD_WaitBusy(15*1000); + EPD_2IN13_Sleep(); +} + +void EPD_SSD_Update_Clock(void) +{ + time_t now; + time(&now); + + // adjust TZ offset + now += utc_offset_mins * 60; + + // get localtime + struct tm *l = localtime(&now); + + if (clock_last == l->tm_min) { return; } - last = now; - now += utc_offset_mins * 60; - struct tm *l = localtime(&now); + + // full update on every hour. + bool full_upd = (clock_last > 60 || (l->tm_min == 0)) ? true : false; + + // clock started. + clock_last = l->tm_min; // wakeup EPD EPD_SSD_Reset(); @@ -271,41 +338,45 @@ void EPD_SSD_Update(void) System_snprintf(buf, 32, "%02d:%02d", l->tm_hour, l->tm_min); obdWriteStringCustom(&obd, (GFXfont *)&DSEG7_Classic_Regular_64, 12, 28+70, buf, 1); - // endian and invent + // date + const char *wstr[]={"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"}; + System_snprintf(buf, 32, "%u-%02u-%02u %s", 1900+l->tm_year, l->tm_mon+1, l->tm_mday, wstr[l->tm_wday]); + obdWriteStringCustom(&obd, (GFXfont *)&Dialog_plain_24, 0, 24, buf, 1); + + // edian and invent for (int i=0; itm_min == 0 || l->tm_min == 30) ? true : false; + // full or fast update EPD_2IN13_BWR(EPD_WIDTH, EPD_HEIGHT, 0, 0); - if (!full_upd) EPD_2IN13_Lut(lut_full_bwr); + if (!full_upd) + EPD_2IN13_Lut(lut_fast_bw); + else + EPD_2IN13_Lut(lut_full_bwr); EPD_2IN13_WriteRam(epd_buffer, EPD_WIDTH, EPD_HEIGHT, 0, 0, 0); - - // red - obdFill(&obd, 0, 0); - - // date - const char *wstr[]={"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"}; - System_snprintf(buf, 32, "%u-%02u-%02u %s", 1900+l->tm_year, l->tm_mon+1, l->tm_mday, wstr[l->tm_wday]); - obdWriteStringCustom(&obd, (GFXfont *)&Dialog_plain_24, 0, 24, buf, 1); - for (int i=0; i