Wendal Chen 3 лет назад
Родитель
Сommit
44131ec4be
4 измененных файлов с 199 добавлено и 131 удалено
  1. 0 1
      components/eink/epdpaint.h
  2. 131 85
      components/eink/luat_lib_eink.c
  3. 66 44
      components/epaper/epd.c
  4. 2 1
      components/epaper/epd.h

+ 0 - 1
components/eink/epdpaint.h

@@ -46,7 +46,6 @@ typedef struct Paint_t {
     uint16_t height;
     uint16_t rotate;
     uint16_t inited;
-    u8g2_t luat_eink_u8g2 ;
 } Paint;
 
 void Paint_Init(Paint* paint, unsigned char* image, int width, int height);

+ 131 - 85
components/eink/luat_lib_eink.c

@@ -38,11 +38,23 @@ uint8_t u8g2_font_decode_get_unsigned_bits(u8g2_font_decode_t *f, uint8_t cnt);
 #define LUAT_LOG_TAG "eink"
 #endif
 
-static uint32_t eink_str_color;
+typedef struct eink_ctx
+{
+  uint32_t str_color;
+  Paint paint;
+  uint8_t fb[];
+}eink_ctx_t;
+
+static uint32_t ctx_index = 0;
+static eink_ctx_t *ctxs[2]; // 暂时只支持2种颜色, 有需要的话后续继续加
+static u8g2_t luat_eink_u8g2;
+
+
+// static uint32_t eink_str_color;
 
 // static EPD epd;
-static Paint paint = {0};
-static unsigned char* frame_buffer = NULL;
+// static Paint paint = {0};
+// static unsigned char* frame_buffer = NULL;
 
 // #ifdef econf
 // #undef econf
@@ -57,6 +69,13 @@ eink_conf_t econf = {0};
 
 #define SPI_ID          (econf.spi_id)
 
+static int check_init(void) {
+    if (ctxs[0] == NULL) {
+      LLOGW("eink NOT init yet");
+      return 0;
+    }
+    return 1;
+}
 
 /**
 初始化eink
@@ -118,33 +137,45 @@ static int l_eink_setup(lua_State *L) {
 
     size_t epd_w = 0;
     size_t epd_h = 0;
+    size_t colors = 0;
     if(status == 0)
     {
         if(econf.full_mode)
-            status = EPD_Init(1, &epd_w, &epd_h);
+            status = EPD_Init(1, &epd_w, &epd_h, &colors);
         else
-            status = EPD_Init(0, &epd_w, &epd_h);
+            status = EPD_Init(0, &epd_w, &epd_h, &colors);
 
         if (status != 0) {
             LLOGD("e-Paper init failed");
             return 0;
         }
         LLOGD("spi setup complete, now setup epd");
-        if (frame_buffer == NULL)
-            frame_buffer = (unsigned char*)luat_heap_malloc(epd_w * epd_h / 8);
-
-        if (frame_buffer == NULL) {
-            LLOGD("e-Paper frame_buffer failed");
+        if (colors > 2) {
+            LLOGE("only 2 color eink supported yet");
             return 0;
         }
-        //   Paint paint;
-        Paint_Init(&paint, frame_buffer, epd_w, epd_h);
-        Paint_Clear(&paint, UNCOLORED);
+        for (size_t i = 0; i < colors; i++)
+        {
+            ctxs[i] = luat_heap_malloc( sizeof(eink_ctx_t) +  (epd_w * epd_h + 7) / 8);
+            if (ctxs[i] == NULL) {
+                LLOGE("out of memory when malloc buff for eink");
+                for (size_t j = 0; j < i - 1; j++)
+                {
+                    luat_heap_free(ctxs[i]);
+                    ctxs[i] = NULL;
+                }
+              return 0;
+            }
+            Paint_Init(&ctxs[i]->paint, ctxs[i]->fb, epd_w, epd_h);
+            Paint_Clear(&ctxs[i]->paint, UNCOLORED);
+            ctxs[i]->paint.inited = 1;
+        }
+
     }
-    u8g2_SetFont(&(paint.luat_eink_u8g2), u8g2_font_opposansm8);
-    u8g2_SetFontMode(&(paint.luat_eink_u8g2), 0);
-    u8g2_SetFontDirection(&(paint.luat_eink_u8g2), 0);
-    paint.inited = 1;
+    u8g2_SetFont(&(luat_eink_u8g2), u8g2_font_opposansm8);
+    u8g2_SetFontMode(&(luat_eink_u8g2), 0);
+    u8g2_SetFontDirection(&(luat_eink_u8g2), 0);
+    //paint.inited = 1;
     //LLOGD("epd init complete");
     lua_pushboolean(L, 1);
     return 1;
@@ -170,11 +201,9 @@ static int l_eink_sleep(lua_State *L)
 static int l_eink_clear(lua_State *L)
 {
     int colored = luaL_optinteger(L, 1, 1);
-    if (paint.inited == 0) {
-      LLOGW("eink NOT init yet");
-      return 0;
-    }
-    Paint_Clear(&paint, colored);
+    if (check_init() == 0)
+        return 0;
+    Paint_Clear(&ctxs[ctx_index]->paint, colored);
     if(lua_toboolean(L, 2))
       EPD_Clear();
     return 0;
@@ -194,9 +223,12 @@ static int l_eink_setWin(lua_State *L)
     int height = luaL_checkinteger(L, 2);
     int rotate = luaL_checkinteger(L, 3);
 
-    Paint_SetWidth(&paint, width);
-    Paint_SetHeight(&paint, height);
-    Paint_SetRotate(&paint, rotate);
+    if (check_init() == 0)
+        return 0;
+
+    Paint_SetWidth(&ctxs[ctx_index]->paint, width);
+    Paint_SetHeight(&ctxs[ctx_index]->paint, height);
+    Paint_SetRotate(&ctxs[ctx_index]->paint, rotate);
     return 0;
 }
 
@@ -209,9 +241,11 @@ static int l_eink_setWin(lua_State *L)
 */
 static int l_eink_getWin(lua_State *L)
 {
-    int width =  Paint_GetWidth(&paint);
-    int height = Paint_GetHeight(&paint);
-    int rotate = Paint_GetRotate(&paint);
+    if (check_init() == 0)
+        return 0;
+    int width =  Paint_GetWidth(&ctxs[ctx_index]->paint);
+    int height = Paint_GetHeight(&ctxs[ctx_index]->paint);
+    int rotate = Paint_GetRotate(&ctxs[ctx_index]->paint);
 
     lua_pushinteger(L, width);
     lua_pushinteger(L, height);
@@ -284,16 +318,16 @@ static void u8g2_draw_hv_line(u8g2_t *u8g2, int16_t x, int16_t y, int16_t len, u
   switch(dir)
   {
     case 0:
-      drawFastHLine(&paint,x,y,len,color);
+      drawFastHLine(&ctxs[ctx_index]->paint,x,y,len,color);
       break;
     case 1:
-        drawFastVLine(&paint,x,y,len,color);
+        drawFastVLine(&ctxs[ctx_index]->paint,x,y,len,color);
       break;
     case 2:
-        drawFastHLine(&paint,x-len+1,y,len,color);
+        drawFastHLine(&ctxs[ctx_index]->paint,x-len+1,y,len,color);
       break;
     case 3:
-        drawFastVLine(&paint,x,y-len+1,len,color);
+        drawFastVLine(&ctxs[ctx_index]->paint,x,y-len+1,len,color);
       break;
   }
 }
@@ -334,7 +368,7 @@ static void u8g2_font_decode_len(u8g2_t *u8g2, uint8_t len, uint8_t is_foregroun
     {
       if ( is_foreground )
       {
-	    u8g2_draw_hv_line(u8g2, x, y, current, decode->dir, eink_str_color);
+	    u8g2_draw_hv_line(u8g2, x, y, current, decode->dir, ctxs[ctx_index]->str_color);
       }
       else if ( decode->is_transparent == 0 )
       {
@@ -423,15 +457,9 @@ static int16_t u8g2_font_draw_glyph(u8g2_t *u8g2, int16_t x, int16_t y, uint16_t
 eink.setFont(eink.font_opposansm12_chinese)
 */
 static int l_eink_set_font(lua_State *L) {
-    if (paint.inited == 0) {
-      LLOGW("eink NOT init yet");
+    if (check_init() == 0) {
       return 0;
     }
-    if (&(paint.luat_eink_u8g2) == NULL) {
-        LLOGI("disp not init yet!!!");
-        lua_pushboolean(L, 0);
-        return 1;
-    }
     if (!lua_islightuserdata(L, 1)) {
         LLOGE("only font pointer is allow");
         return 0;
@@ -441,7 +469,7 @@ static int l_eink_set_font(lua_State *L) {
         LLOGE("only font pointer is allow");
         return 0;
     }
-    u8g2_SetFont(&(paint.luat_eink_u8g2), ptr);
+    u8g2_SetFont(&(luat_eink_u8g2), ptr);
     lua_pushboolean(L, 1);
     return 1;
 }
@@ -471,13 +499,12 @@ static int l_eink_print(lua_State *L)
     int x           = luaL_checkinteger(L, 1);
     int y           = luaL_checkinteger(L, 2);
     const char *str = luaL_checklstring(L, 3, &len);
-    eink_str_color  = luaL_optinteger(L, 4, 0);
 
     
-    if (paint.inited == 0) {
-      LLOGW("eink NOT init yet");
+    if (check_init() == 0) {
       return 0;
     }
+    ctxs[ctx_index]->str_color = luaL_optinteger(L, 4, 0);
 
     uint16_t e;
     int16_t delta, sum;
@@ -489,8 +516,8 @@ static int l_eink_print(lua_State *L)
         break;
         str++;
         if ( e != 0x0fffe ){
-        delta = u8g2_font_draw_glyph(&(paint.luat_eink_u8g2), x, y, e);
-        switch(paint.luat_eink_u8g2.font_decode.dir){
+        delta = u8g2_font_draw_glyph(&(luat_eink_u8g2), x, y, e);
+        switch(luat_eink_u8g2.font_decode.dir){
             case 0:
             x += delta;
             break;
@@ -524,16 +551,18 @@ static int l_eink_show(lua_State *L)
     // int y     = luaL_optinteger(L, 2, 0);
     int no_clear     = lua_toboolean(L, 3);
     /* Display the frame_buffer */
-    //EPD_SetFrameMemory(&epd, frame_buffer, x, y, Paint_GetWidth(&paint), Paint_GetHeight(&paint));
+    //EPD_SetFrameMemory(&epd, frame_buffer, x, y, Paint_GetWidth(&ctxs[ctx_index]->paint), Paint_GetHeight(&ctxs[ctx_index]->paint));
     //EPD_DisplayFrame(&epd);
     
-    if (paint.inited == 0) {
-      LLOGW("eink NOT init yet");
+    if (check_init() == 0) {
       return 0;
     }
     if(!no_clear)
       EPD_Clear();
-    EPD_Display(frame_buffer, NULL);
+    if (ctxs[1] == NULL)
+      EPD_Display(ctxs[0]->fb, NULL);
+    else
+      EPD_Display(ctxs[0]->fb, ctxs[1]->fb);
     return 0;
 }
 
@@ -553,8 +582,7 @@ static int l_eink_draw(lua_State *L)
     if (lua_isuserdata(L, 2)) {
       buff2 = ((luat_zbuff_t *)luaL_checkudata(L, 2, LUAT_ZBUFF_TYPE));
     }
-    if (paint.inited == 0) {
-      LLOGW("eink NOT init yet");
+    if (check_init() == 0) {
       return 0;
     }
     if(!no_clear)
@@ -583,12 +611,11 @@ static int l_eink_line(lua_State *L)
     int y2      = luaL_checkinteger(L, 4);
     int colored = luaL_optinteger(L, 5, 0);
 
-    if (paint.inited == 0) {
-      LLOGW("eink NOT init yet");
+    if (check_init() == 0) {
       return 0;
     }
 
-    Paint_DrawLine(&paint, x, y, x2, y2, colored);
+    Paint_DrawLine(&ctxs[ctx_index]->paint, x, y, x2, y2, colored);
     return 0;
 }
 
@@ -615,15 +642,14 @@ static int l_eink_rect(lua_State *L)
     int colored = luaL_optinteger(L, 5, 0);
     int fill    = luaL_optinteger(L, 6, 0);
   
-    if (paint.inited == 0) {
-      LLOGW("eink NOT init yet");
+    if (check_init() == 0) {
       return 0;
     }
 
     if(fill)
-        Paint_DrawFilledRectangle(&paint, x, y, x2, y2, colored);
+        Paint_DrawFilledRectangle(&ctxs[ctx_index]->paint, x, y, x2, y2, colored);
     else
-        Paint_DrawRectangle(&paint, x, y, x2, y2, colored);
+        Paint_DrawRectangle(&ctxs[ctx_index]->paint, x, y, x2, y2, colored);
     return 0;
 }
 
@@ -648,15 +674,14 @@ static int l_eink_circle(lua_State *L)
     int colored = luaL_optinteger(L, 4, 0);
     int fill    = luaL_optinteger(L, 5, 0);
 
-    if (paint.inited == 0) {
-      LLOGW("eink NOT init yet");
+    if (check_init() == 0) {
       return 0;
     }
 
     if(fill)
-        Paint_DrawFilledCircle(&paint, x, y, radius, colored);
+        Paint_DrawFilledCircle(&ctxs[ctx_index]->paint, x, y, radius, colored);
     else
-        Paint_DrawCircle(&paint, x, y, radius, colored);
+        Paint_DrawCircle(&ctxs[ctx_index]->paint, x, y, radius, colored);
     return 0;
 }
 
@@ -677,8 +702,7 @@ static int l_eink_qrcode(lua_State *L)
     const char* text = luaL_checklstring(L, 3, &len);
     int size        = luaL_optinteger(L, 4,21);
 
-    if (paint.inited == 0) {
-      LLOGW("eink NOT init yet");
+    if (check_init() == 0) {
       return 0;
     }
 
@@ -703,7 +727,7 @@ static int l_eink_qrcode(lua_State *L)
         for (int j = 0; j < qr_size; j++) {
             for (int i = 0; i < qr_size; i++) {
                 if (qrcodegen_getModule(qrcode, i, j))
-                    Paint_DrawFilledRectangle(&paint,x+i*scale,y+j*scale,x+(i+1)*scale,y+(j+1)*scale,0);
+                    Paint_DrawFilledRectangle(&ctxs[ctx_index]->paint,x+i*scale,y+j*scale,x+(i+1)*scale,y+(j+1)*scale,0);
             }
         }
     }
@@ -745,16 +769,15 @@ static int l_eink_bat(lua_State *L)
     if(bat < 3500 && bat > 2500)batnum = 5;
     batnum = 20 - (int)(batnum / 5) + 3;
 
-    if (paint.inited == 0) {
-      LLOGW("eink NOT init yet");
+    if (check_init() == 0) {
       return 0;
     }
 
     // w外框
-    Paint_DrawRectangle(&paint, x+0, y+3, x+2, y+6, COLORED);
-    Paint_DrawRectangle(&paint, x+2, y+0, x+23, y+9, COLORED);
+    Paint_DrawRectangle(&ctxs[ctx_index]->paint, x+0, y+3, x+2, y+6, COLORED);
+    Paint_DrawRectangle(&ctxs[ctx_index]->paint, x+2, y+0, x+23, y+9, COLORED);
     // 3 ~21   100 / 5
-    Paint_DrawFilledRectangle(&paint, x+batnum, y+1, x+22, y+8, COLORED);
+    Paint_DrawFilledRectangle(&ctxs[ctx_index]->paint, x+batnum, y+1, x+22, y+8, COLORED);
 
     return 0;
 }
@@ -794,12 +817,11 @@ static int l_eink_weather_icon(lua_State *L)
     //     for (int j = 0; j < 8; j++)
     //     {
     //         for (int k = 0; k < 8; k++)
-    //             (gImage_103[i*8+j] << k )& 0x80 ? Paint_DrawPixel(&paint, x+j*8+k, y+i, COLORED) : Paint_DrawPixel(&paint, x+j*8+k, y+i, UNCOLORED);
+    //             (gImage_103[i*8+j] << k )& 0x80 ? Paint_DrawPixel(&ctxs[ctx_index]->paint, x+j*8+k, y+i, COLORED) : Paint_DrawPixel(&ctxs[ctx_index]->paint, x+j*8+k, y+i, UNCOLORED);
     //     }
     // }
 
-    if (paint.inited == 0) {
-      LLOGW("eink NOT init yet");
+    if (check_init() == 0) {
       return 0;
     }
 
@@ -857,7 +879,7 @@ static int l_eink_weather_icon(lua_State *L)
         for (int j = 0; j < 6; j++)
         {
             for (int k = 0; k < 8; k++)
-                (icon[i*6+j] << k )& 0x80 ? Paint_DrawPixel(&paint, x+j*8+k, y+i, COLORED) : Paint_DrawPixel(&paint, x+j*8+k, y+i, UNCOLORED);
+                (icon[i*6+j] << k )& 0x80 ? Paint_DrawPixel(&ctxs[ctx_index]->paint, x+j*8+k, y+i, COLORED) : Paint_DrawPixel(&ctxs[ctx_index]->paint, x+j*8+k, y+i, UNCOLORED);
         }
     }
 
@@ -899,7 +921,7 @@ static int l_eink_draw_gtfont_gb2312(lua_State *L) {
 		str = (strhigh<<8)|strlow;
 		fontCode++;
 		get_font(buf, 1, str, size, size, size);
-		gtfont_draw_w(buf , x ,y , size , size,Paint_DrawPixel,&paint,1);
+		gtfont_draw_w(buf , x ,y , size , size,Paint_DrawPixel,&ctxs[ctx_index]->paint,1);
 		x+=size;
 		i+=2;
 	}
@@ -925,7 +947,7 @@ static int l_eink_draw_gtfont_gb2312_gray(lua_State* L) {
 		fontCode++;
 		get_font(buf, 1, str, size*font_g, size*font_g, size*font_g);
 		Gray_Process(buf,size,size,font_g);
-		gtfont_draw_gray_hz(buf, x, y, size , size, font_g, 1,Paint_DrawPixel,&paint,1);
+		gtfont_draw_gray_hz(buf, x, y, size , size, font_g, 1,Paint_DrawPixel,&ctxs[ctx_index]->paint,1);
 		x+=size;
 		i+=2;
 	}
@@ -952,7 +974,7 @@ static int l_eink_draw_gtfont_utf8(lua_State *L) {
       if ( e != 0x0fffe ){
         uint16_t str = unicodetogb2312(e);
         get_font(buf, 1, str, size, size, size);
-        gtfont_draw_w(buf , x ,y , size , size,Paint_DrawPixel,&paint,1);
+        gtfont_draw_w(buf , x ,y , size , size,Paint_DrawPixel,&ctxs[ctx_index]->paint,1);
         x+=size;
       }
     }
@@ -979,7 +1001,7 @@ static int l_eink_draw_gtfont_utf8_gray(lua_State* L) {
 			uint16_t str = unicodetogb2312(e);
 			get_font(buf, 1, str, size*font_g, size*font_g, size*font_g);
 			Gray_Process(buf,size,size,font_g);
-      gtfont_draw_gray_hz(buf, x, y, size , size, font_g, 1,Paint_DrawPixel,&paint,1);
+      gtfont_draw_gray_hz(buf, x, y, size , size, font_g, 1,Paint_DrawPixel,&ctxs[ctx_index]->paint,1);
         	x+=size;
         }
     }
@@ -992,13 +1014,13 @@ static int l_eink_draw_gtfont_utf8_gray(lua_State* L) {
 
 static void eink_DrawHXBM(uint16_t x, uint16_t y, uint16_t len, const uint8_t *b){
   uint8_t mask = 1;
-  if (paint.inited == 0) {
-    LLOGW("eink NOT init yet");
+
+  if (check_init() == 0) {
     return 0;
   }
   while(len > 0) {
-    if ( *b & mask ) drawFastHLine(&paint, x, y, 1,COLORED);
-    else drawFastVLine(&paint, x, y, 1,UNCOLORED);
+    if ( *b & mask ) drawFastHLine(&ctxs[ctx_index]->paint, x, y, 1,COLORED);
+    else drawFastVLine(&ctxs[ctx_index]->paint, x, y, 1,UNCOLORED);
     x++;
     mask <<= 1;
     if ( mask == 0 ){
@@ -1036,8 +1058,7 @@ static int l_eink_drawXbm(lua_State *L){
     if (len*8/h < w) return 0; // 起码要填满一行
     if (len != h*w/8)return 0;
 
-    if (paint.inited == 0) {
-      LLOGW("eink NOT init yet");
+    if (check_init() == 0) {
       return 0;
     }
 
@@ -1055,6 +1076,30 @@ static int l_eink_drawXbm(lua_State *L){
     return 1;
 }
 
+/*
+切换颜色画板, 适合多色墨水屏
+@api eink.setCtx(index)
+@int 颜色索引, 黑色为0, 红色为1
+@usage
+-- 仅适合多色墨水屏, 对单色墨水屏(只有黑白)的无效
+eink.setCtx(1)
+-- 切换后, 所有drawXXX都会操作在指定颜色的画板
+*/
+static int l_eink_set_ctx(lua_State *L) {
+  int index = luaL_checkinteger(L, 1);
+  if (index < 0 || index > 1) {
+    LLOGE("invaild ctx index %d", index);
+    return 0;
+  }
+  if (ctxs[index] == NULL) {
+    LLOGE("invaild ctx index %d", index);
+    return 0;
+  }
+  ctx_index = index;
+  lua_pushboolean(L, 1);
+  return 1;
+}
+
 #include "rotable2.h"
 static const rotable_Reg_t reg_eink[] =
 {
@@ -1077,6 +1122,7 @@ static const rotable_Reg_t reg_eink[] =
     { "model",          ROREG_FUNC(l_eink_model)},
     { "drawXbm",        ROREG_FUNC(l_eink_drawXbm)},
     { "draw",           ROREG_FUNC(l_eink_draw)},
+    { "setCtx",         ROREG_FUNC(l_eink_set_ctx)},
 #ifdef LUAT_USE_GTFONT
     { "drawGtfontGb2312", ROREG_FUNC(l_eink_draw_gtfont_gb2312)},
     { "drawGtfontGb2312Gray", ROREG_FUNC(l_eink_draw_gtfont_gb2312_gray)},

+ 66 - 44
components/epaper/epd.c

@@ -11,9 +11,10 @@ typedef void (*eink_display)(UBYTE *Image, UBYTE *Image2);
 
 typedef struct eink_reg
 {
-    int tp;
-    int w;
-    int h;
+    uint16_t tp;
+    uint16_t colors;
+    uint16_t w;
+    uint16_t h;
     eink_init init;
     eink_clear clear;
     eink_sleep sleep;
@@ -22,45 +23,45 @@ typedef struct eink_reg
 
 
 static const eink_reg_t eink_regs[] = {
-        {.tp=MODEL_1in02d,.init=EPD_1IN02_Init, .w = EPD_1IN02_WIDTH, .h = EPD_1IN02_HEIGHT, .clear = EPD_1IN02_Clear, .sleep =EPD_1IN02_Sleep, .display=EPD_1IN02_Display},
-        {.tp=MODEL_1in54,.init=EPD_1IN54_Init, .w = EPD_1IN54_WIDTH, .h = EPD_1IN54_HEIGHT, .clear = EPD_1IN54_Clear, .sleep =EPD_1IN54_Sleep, .display=EPD_1IN54_Display},
-        {.tp=MODEL_1in54b,.init=EPD_1IN54B_Init, .w = EPD_1IN54B_WIDTH, .h = EPD_1IN54B_HEIGHT, .clear = EPD_1IN54B_Clear, .sleep =EPD_1IN54B_Sleep, .display=EPD_1IN54B_Display},
-        {.tp=MODEL_1in54b_V2,.init=EPD_1IN54B_V2_Init, .w = EPD_1IN54B_V2_WIDTH, .h = EPD_1IN54B_V2_HEIGHT, .clear = EPD_1IN54B_V2_Clear, .sleep =EPD_1IN54B_V2_Sleep, .display=EPD_1IN54B_V2_Display},
-        {.tp=MODEL_1in54c,.init=EPD_1IN54C_Init, .w = EPD_1IN54C_WIDTH, .h = EPD_1IN54C_HEIGHT, .clear = EPD_1IN54C_Clear, .sleep =EPD_1IN54C_Sleep, .display=EPD_1IN54C_Display},
-        {.tp=MODEL_1in54f,.init=EPD_1IN54FF_Init, .w = EPD_1IN54F_WIDTH, .h = EPD_1IN54F_HEIGHT, .clear = EPD_1IN54FF_Clear, .sleep =EPD_1IN54FF_Sleep, .display=EPD_1IN54FF_Display},
-        {.tp=MODEL_1in54_V2,.init=EPD_1IN54_V2_Init, .w = EPD_1IN54_V2_WIDTH, .h = EPD_1IN54_V2_HEIGHT, .clear = EPD_1IN54_V2_Clear, .sleep =EPD_1IN54_V2_Sleep, .display=EPD_1IN54_V2_Display},       
-        {.tp=MODEL_1in54_V3,.init=EPD_1IN54_V3_Init, .w = EPD_1IN54_V3_WIDTH, .h = EPD_1IN54_V3_HEIGHT, .clear = EPD_1IN54_V3_Clear, .sleep =EPD_1IN54_V3_Sleep, .display=EPD_1IN54_V3_Display},       
-        {.tp=MODEL_2in13,.init=EPD_2IN13_Init, .w = EPD_2IN13_WIDTH, .h = EPD_2IN13_HEIGHT, .clear = EPD_2IN13_Clear, .sleep =EPD_2IN13_Sleep, .display=EPD_2IN13_Display},
-        {.tp=MODEL_2in13bc,.init=EPD_2IN13BC_Init, .w = EPD_2IN13BC_WIDTH, .h = EPD_2IN13BC_HEIGHT, .clear = EPD_2IN13BC_Clear, .sleep =EPD_2IN13BC_Sleep, .display=EPD_2IN13BC_Display},
-        {.tp=MODEL_2in13b_V3,.init=EPD_2IN13B_V3_Init, .w = EPD_2IN13B_V3_WIDTH, .h = EPD_2IN13B_V3_HEIGHT, .clear = EPD_2IN13B_V3_Clear, .sleep =EPD_2IN13B_V3_Sleep, .display=EPD_2IN13B_V3_Display},  
-        {.tp=MODEL_2in13d,.init=EPD_2IN13D_Init, .w = EPD_2IN13D_WIDTH, .h = EPD_2IN13D_HEIGHT, .clear = EPD_2IN13D_Clear, .sleep =EPD_2IN13D_Sleep, .display=EPD_2IN13D_Display},
-        {.tp=MODEL_2in13_V2,.init=EPD_2IN13_V2_Init, .w = EPD_2IN13_V2_WIDTH, .h = EPD_2IN13_V2_HEIGHT, .clear = EPD_2IN13_V2_Clear, .sleep =EPD_2IN13_V2_Sleep, .display=EPD_2IN13_V2_Display},
-        {.tp=MODEL_2in66,.init=EPD_2IN66_Init, .w = EPD_2IN66_WIDTH, .h = EPD_2IN66_HEIGHT, .clear = EPD_2IN66_Clear, .sleep =EPD_2IN66_Sleep, .display=EPD_2IN66_Display},
-        {.tp=MODEL_2in66b,.init=EPD_2IN66B_Init, .w = EPD_2IN66B_WIDTH, .h = EPD_2IN66B_HEIGHT, .clear = EPD_2IN66B_Clear, .sleep =EPD_2IN66B_Sleep, .display=EPD_2IN66B_Display},
-        {.tp=MODEL_2in7,.init=EPD_2IN7_Init, .w = EPD_2IN7_WIDTH, .h = EPD_2IN7_HEIGHT, .clear = EPD_2IN7_Clear, .sleep =EPD_2IN7_Sleep, .display=EPD_2IN7_Display},
-        {.tp=MODEL_2in7b,.init=EPD_2IN7B_Init, .w = EPD_2IN7B_WIDTH, .h = EPD_2IN7B_HEIGHT, .clear = EPD_2IN7B_Clear, .sleep =EPD_2IN7B_Sleep, .display=EPD_2IN7B_Display},
-        {.tp=MODEL_2in9,.init=EPD_2IN9_Init, .w = EPD_2IN9_WIDTH, .h = EPD_2IN9_HEIGHT, .clear = EPD_2IN9_Clear, .sleep =EPD_2IN9_Sleep, .display=EPD_2IN9_Display},
-        {.tp=MODEL_2in9bc,.init=EPD_2IN9BC_Init, .w = EPD_2IN9BC_WIDTH, .h = EPD_2IN9BC_HEIGHT, .clear = EPD_2IN9BC_Clear, .sleep =EPD_2IN9BC_Sleep, .display=EPD_2IN9BC_Display},
-        {.tp=MODEL_2in9b_V3,.init=EPD_2IN9B_V3_Init, .w = EPD_2IN9B_V3_WIDTH, .h = EPD_2IN9B_V3_HEIGHT, .clear = EPD_2IN9B_V3_Clear, .sleep =EPD_2IN9B_V3_Sleep, .display=EPD_2IN9B_V3_Display},
-        {.tp=MODEL_2in9d,.init=EPD_2IN9D_Init, .w = EPD_2IN9D_WIDTH, .h = EPD_2IN9D_HEIGHT, .clear = EPD_2IN9D_Clear, .sleep =EPD_2IN9D_Sleep, .display=EPD_2IN9D_Display},
-        {.tp=MODEL_2in9ff,.init=EPD_2IN9FF_Init, .w = EPD_2IN9FF_WIDTH, .h = EPD_2IN9FF_HEIGHT, .clear = EPD_2IN9FF_Clear, .sleep =EPD_2IN9FF_Sleep, .display=EPD_2IN9FF_Display},
-        {.tp=MODEL_2in9_V2,.init=EPD_2IN9_V2_Init, .w = EPD_2IN9_V2_WIDTH, .h = EPD_2IN9_V2_HEIGHT, .clear = EPD_2IN9_V2_Clear, .sleep =EPD_2IN9_V2_Sleep, .display=EPD_2IN9_V2_Display},
-        {.tp=MODEL_3in7,.init=EPD_3IN7_1Gray_Init, .w = EPD_3IN7_WIDTH, .h = EPD_3IN7_HEIGHT, .clear = EPD_3IN7_1Gray_Clear, .sleep =EPD_3IN7_Sleep, .display=EPD_3IN7_1Gray_Display},
-        {.tp=MODEL_4in2,.init=EPD_4IN2_Init, .w = EPD_4IN2_WIDTH, .h = EPD_4IN2_HEIGHT, .clear = EPD_4IN2_Clear, .sleep =EPD_4IN2_Sleep, .display=EPD_4IN2_Display},
-        {.tp=MODEL_4in2bc,.init=EPD_4IN2BC_Init, .w = EPD_4IN2BC_WIDTH, .h = EPD_4IN2BC_HEIGHT, .clear = EPD_4IN2BC_Clear, .sleep =EPD_4IN2BC_Sleep, .display=EPD_4IN2BC_Display},
-        {.tp=MODEL_4in2b_V2,.init=EPD_4IN2B_V2_Init, .w = EPD_4IN2B_V2_WIDTH, .h = EPD_4IN2B_V2_HEIGHT, .clear = EPD_4IN2B_V2_Clear, .sleep =EPD_4IN2B_V2_Sleep, .display=EPD_4IN2B_V2_Display},
-        {.tp=MODEL_5in65f,.init=EPD_5IN65F_Init, .w = EPD_5IN65F_WIDTH, .h = EPD_5IN65F_HEIGHT, .clear = EPD_5IN65F_Clear, .sleep =EPD_5IN65F_Sleep, .display=EPD_5IN65F_Display},
-        {.tp=MODEL_5in83,.init=EPD_5IN83_Init, .w = EPD_5IN83_WIDTH, .h = EPD_5IN83_HEIGHT, .clear = EPD_5IN83_Clear, .sleep =EPD_5IN83_Sleep, .display=EPD_5IN83_Display},
-        {.tp=MODEL_5in83bc,.init=EPD_5IN83BC_Init, .w = EPD_5IN83BC_WIDTH, .h = EPD_5IN83BC_HEIGHT, .clear = EPD_5IN83BC_Clear, .sleep =EPD_5IN83BC_Sleep, .display=EPD_5IN83BC_Display},
-        {.tp=MODEL_5in83b_V2,.init=EPD_5IN83B_V2_Init, .w = EPD_5IN83B_V2_WIDTH, .h = EPD_5IN83B_V2_HEIGHT, .clear = EPD_5IN83B_V2_Clear, .sleep =EPD_5IN83B_V2_Sleep, .display=EPD_5IN83B_V2_Display},  
-        //{.tp=MODEL_5in83_V2,.init=EPD_5IN83_V2_Init, .w = EPD_5IN83_V2_WIDTH, .h = EPD_5IN83_V2_HEIGHT, .clear = EPD_5IN83_V2_Clear, .sleep =EPD_5IN83_V2_Sleep, .display=EPD_5IN83_V2_Display},
-        {.tp=MODEL_7in5,.init=EPD_7IN5_Init, .w = EPD_7IN5_WIDTH, .h = EPD_7IN5_HEIGHT, .clear = EPD_7IN5_Clear, .sleep =EPD_7IN5_Sleep, .display=EPD_7IN5_Display},
-        {.tp=MODEL_7in5bc,.init=EPD_7IN5BC_Init, .w = EPD_7IN5BC_WIDTH, .h = EPD_7IN5BC_HEIGHT, .clear = EPD_7IN5BC_Clear, .sleep =EPD_7IN5BC_Sleep, .display=EPD_7IN5BC_Display},
-        {.tp=MODEL_7in5b_HD,.init=EPD_7IN5B_HD_Init, .w = EPD_7IN5B_HD_WIDTH, .h = EPD_7IN5B_HD_HEIGHT, .clear = EPD_7IN5B_HD_Clear, .sleep =EPD_7IN5B_HD_Sleep, .display=EPD_7IN5B_HD_Display},
-        {.tp=MODEL_7in5b_V2,.init=EPD_7IN5B_V2_Init, .w = EPD_7IN5B_V2_WIDTH, .h = EPD_7IN5B_V2_HEIGHT, .clear = EPD_7IN5B_V2_Clear, .sleep =EPD_7IN5B_V2_Sleep, .display=EPD_7IN5B_V2_Display},
-        {.tp=MODEL_7in5_HD,.init=EPD_7IN5_HD_Init, .w = EPD_7IN5_HD_WIDTH, .h = EPD_7IN5_HD_HEIGHT, .clear = EPD_7IN5_HD_Clear, .sleep =EPD_7IN5_HD_Sleep, .display=EPD_7IN5_HD_Display},
-        //{.tp=MODEL_7in5_V2,.init=EPD_7IN5_V2_Init, .w = EPD_7IN5_V2_WIDTH, .h = EPD_7IN5_V2_HEIGHT, .clear = EPD_7IN5_V2_Clear, .sleep =EPD_7IN5_V2_Sleep, .display=EPD_7IN5_V2_Display},
-    {.tp = -1}
+        {.tp=MODEL_1in02d,      .colors=1, .init=EPD_1IN02_Init, .w = EPD_1IN02_WIDTH, .h = EPD_1IN02_HEIGHT, .clear = EPD_1IN02_Clear, .sleep =EPD_1IN02_Sleep, .display=EPD_1IN02_Display},
+        {.tp=MODEL_1in54,       .colors=1, .init=EPD_1IN54_Init, .w = EPD_1IN54_WIDTH, .h = EPD_1IN54_HEIGHT, .clear = EPD_1IN54_Clear, .sleep =EPD_1IN54_Sleep, .display=EPD_1IN54_Display},
+        {.tp=MODEL_1in54b,      .colors=1, .init=EPD_1IN54B_Init, .w = EPD_1IN54B_WIDTH, .h = EPD_1IN54B_HEIGHT, .clear = EPD_1IN54B_Clear, .sleep =EPD_1IN54B_Sleep, .display=EPD_1IN54B_Display},
+        {.tp=MODEL_1in54b_V2,   .colors=1, .init=EPD_1IN54B_V2_Init, .w = EPD_1IN54B_V2_WIDTH, .h = EPD_1IN54B_V2_HEIGHT, .clear = EPD_1IN54B_V2_Clear, .sleep =EPD_1IN54B_V2_Sleep, .display=EPD_1IN54B_V2_Display},
+        {.tp=MODEL_1in54c,      .colors=1, .init=EPD_1IN54C_Init, .w = EPD_1IN54C_WIDTH, .h = EPD_1IN54C_HEIGHT, .clear = EPD_1IN54C_Clear, .sleep =EPD_1IN54C_Sleep, .display=EPD_1IN54C_Display},
+        {.tp=MODEL_1in54f,      .colors=1, .init=EPD_1IN54FF_Init, .w = EPD_1IN54F_WIDTH, .h = EPD_1IN54F_HEIGHT, .clear = EPD_1IN54FF_Clear, .sleep =EPD_1IN54FF_Sleep, .display=EPD_1IN54FF_Display},
+        {.tp=MODEL_1in54_V2,    .colors=1, .init=EPD_1IN54_V2_Init, .w = EPD_1IN54_V2_WIDTH, .h = EPD_1IN54_V2_HEIGHT, .clear = EPD_1IN54_V2_Clear, .sleep =EPD_1IN54_V2_Sleep, .display=EPD_1IN54_V2_Display},       
+        {.tp=MODEL_1in54_V3,    .colors=1, .init=EPD_1IN54_V3_Init, .w = EPD_1IN54_V3_WIDTH, .h = EPD_1IN54_V3_HEIGHT, .clear = EPD_1IN54_V3_Clear, .sleep =EPD_1IN54_V3_Sleep, .display=EPD_1IN54_V3_Display},       
+        {.tp=MODEL_2in13,       .colors=1, .init=EPD_2IN13_Init, .w = EPD_2IN13_WIDTH, .h = EPD_2IN13_HEIGHT, .clear = EPD_2IN13_Clear, .sleep =EPD_2IN13_Sleep, .display=EPD_2IN13_Display},
+        {.tp=MODEL_2in13bc,     .colors=1, .init=EPD_2IN13BC_Init, .w = EPD_2IN13BC_WIDTH, .h = EPD_2IN13BC_HEIGHT, .clear = EPD_2IN13BC_Clear, .sleep =EPD_2IN13BC_Sleep, .display=EPD_2IN13BC_Display},
+        {.tp=MODEL_2in13b_V3,   .colors=1, .init=EPD_2IN13B_V3_Init, .w = EPD_2IN13B_V3_WIDTH, .h = EPD_2IN13B_V3_HEIGHT, .clear = EPD_2IN13B_V3_Clear, .sleep =EPD_2IN13B_V3_Sleep, .display=EPD_2IN13B_V3_Display},  
+        {.tp=MODEL_2in13d,      .colors=1, .init=EPD_2IN13D_Init, .w = EPD_2IN13D_WIDTH, .h = EPD_2IN13D_HEIGHT, .clear = EPD_2IN13D_Clear, .sleep =EPD_2IN13D_Sleep, .display=EPD_2IN13D_Display},
+        {.tp=MODEL_2in13_V2,    .colors=1, .init=EPD_2IN13_V2_Init, .w = EPD_2IN13_V2_WIDTH, .h = EPD_2IN13_V2_HEIGHT, .clear = EPD_2IN13_V2_Clear, .sleep =EPD_2IN13_V2_Sleep, .display=EPD_2IN13_V2_Display},
+        {.tp=MODEL_2in66,       .colors=1, .init=EPD_2IN66_Init, .w = EPD_2IN66_WIDTH, .h = EPD_2IN66_HEIGHT, .clear = EPD_2IN66_Clear, .sleep =EPD_2IN66_Sleep, .display=EPD_2IN66_Display},
+        {.tp=MODEL_2in66b,      .colors=1, .init=EPD_2IN66B_Init, .w = EPD_2IN66B_WIDTH, .h = EPD_2IN66B_HEIGHT, .clear = EPD_2IN66B_Clear, .sleep =EPD_2IN66B_Sleep, .display=EPD_2IN66B_Display},
+        {.tp=MODEL_2in7,        .colors=1, .init=EPD_2IN7_Init, .w = EPD_2IN7_WIDTH, .h = EPD_2IN7_HEIGHT, .clear = EPD_2IN7_Clear, .sleep =EPD_2IN7_Sleep, .display=EPD_2IN7_Display},
+        {.tp=MODEL_2in7b,       .colors=1, .init=EPD_2IN7B_Init, .w = EPD_2IN7B_WIDTH, .h = EPD_2IN7B_HEIGHT, .clear = EPD_2IN7B_Clear, .sleep =EPD_2IN7B_Sleep, .display=EPD_2IN7B_Display},
+        {.tp=MODEL_2in9,        .colors=1, .init=EPD_2IN9_Init, .w = EPD_2IN9_WIDTH, .h = EPD_2IN9_HEIGHT, .clear = EPD_2IN9_Clear, .sleep =EPD_2IN9_Sleep, .display=EPD_2IN9_Display},
+        {.tp=MODEL_2in9bc,      .colors=1, .init=EPD_2IN9BC_Init, .w = EPD_2IN9BC_WIDTH, .h = EPD_2IN9BC_HEIGHT, .clear = EPD_2IN9BC_Clear, .sleep =EPD_2IN9BC_Sleep, .display=EPD_2IN9BC_Display},
+        {.tp=MODEL_2in9b_V3,    .colors=1, .init=EPD_2IN9B_V3_Init, .w = EPD_2IN9B_V3_WIDTH, .h = EPD_2IN9B_V3_HEIGHT, .clear = EPD_2IN9B_V3_Clear, .sleep =EPD_2IN9B_V3_Sleep, .display=EPD_2IN9B_V3_Display},
+        {.tp=MODEL_2in9d,       .colors=1, .init=EPD_2IN9D_Init, .w = EPD_2IN9D_WIDTH, .h = EPD_2IN9D_HEIGHT, .clear = EPD_2IN9D_Clear, .sleep =EPD_2IN9D_Sleep, .display=EPD_2IN9D_Display},
+        {.tp=MODEL_2in9ff,      .colors=1, .init=EPD_2IN9FF_Init, .w = EPD_2IN9FF_WIDTH, .h = EPD_2IN9FF_HEIGHT, .clear = EPD_2IN9FF_Clear, .sleep =EPD_2IN9FF_Sleep, .display=EPD_2IN9FF_Display},
+        {.tp=MODEL_2in9_V2,     .colors=1, .init=EPD_2IN9_V2_Init, .w = EPD_2IN9_V2_WIDTH, .h = EPD_2IN9_V2_HEIGHT, .clear = EPD_2IN9_V2_Clear, .sleep =EPD_2IN9_V2_Sleep, .display=EPD_2IN9_V2_Display},
+        {.tp=MODEL_3in7,        .colors=1, .init=EPD_3IN7_1Gray_Init, .w = EPD_3IN7_WIDTH, .h = EPD_3IN7_HEIGHT, .clear = EPD_3IN7_1Gray_Clear, .sleep =EPD_3IN7_Sleep, .display=EPD_3IN7_1Gray_Display},
+        {.tp=MODEL_4in2,        .colors=1, .init=EPD_4IN2_Init, .w = EPD_4IN2_WIDTH, .h = EPD_4IN2_HEIGHT, .clear = EPD_4IN2_Clear, .sleep =EPD_4IN2_Sleep, .display=EPD_4IN2_Display},
+        {.tp=MODEL_4in2bc,      .colors=2, .init=EPD_4IN2BC_Init, .w = EPD_4IN2BC_WIDTH, .h = EPD_4IN2BC_HEIGHT, .clear = EPD_4IN2BC_Clear, .sleep =EPD_4IN2BC_Sleep, .display=EPD_4IN2BC_Display},
+        {.tp=MODEL_4in2b_V2,    .colors=1, .init=EPD_4IN2B_V2_Init, .w = EPD_4IN2B_V2_WIDTH, .h = EPD_4IN2B_V2_HEIGHT, .clear = EPD_4IN2B_V2_Clear, .sleep =EPD_4IN2B_V2_Sleep, .display=EPD_4IN2B_V2_Display},
+        {.tp=MODEL_5in65f,      .colors=1, .init=EPD_5IN65F_Init, .w = EPD_5IN65F_WIDTH, .h = EPD_5IN65F_HEIGHT, .clear = EPD_5IN65F_Clear, .sleep =EPD_5IN65F_Sleep, .display=EPD_5IN65F_Display},
+        {.tp=MODEL_5in83,       .colors=1, .init=EPD_5IN83_Init, .w = EPD_5IN83_WIDTH, .h = EPD_5IN83_HEIGHT, .clear = EPD_5IN83_Clear, .sleep =EPD_5IN83_Sleep, .display=EPD_5IN83_Display},
+        {.tp=MODEL_5in83bc,     .colors=1, .init=EPD_5IN83BC_Init, .w = EPD_5IN83BC_WIDTH, .h = EPD_5IN83BC_HEIGHT, .clear = EPD_5IN83BC_Clear, .sleep =EPD_5IN83BC_Sleep, .display=EPD_5IN83BC_Display},
+        {.tp=MODEL_5in83b_V2,   .colors=1, .init=EPD_5IN83B_V2_Init, .w = EPD_5IN83B_V2_WIDTH, .h = EPD_5IN83B_V2_HEIGHT, .clear = EPD_5IN83B_V2_Clear, .sleep =EPD_5IN83B_V2_Sleep, .display=EPD_5IN83B_V2_Display},  
+        //{.tp=MODEL_5in83_V2,  .colors=1, .init=EPD_5IN83_V2_Init, .w = EPD_5IN83_V2_WIDTH, .h = EPD_5IN83_V2_HEIGHT, .clear = EPD_5IN83_V2_Clear, .sleep =EPD_5IN83_V2_Sleep, .display=EPD_5IN83_V2_Display},
+        {.tp=MODEL_7in5,        .colors=1, .init=EPD_7IN5_Init, .w = EPD_7IN5_WIDTH, .h = EPD_7IN5_HEIGHT, .clear = EPD_7IN5_Clear, .sleep =EPD_7IN5_Sleep, .display=EPD_7IN5_Display},
+        {.tp=MODEL_7in5bc,      .colors=1, .init=EPD_7IN5BC_Init, .w = EPD_7IN5BC_WIDTH, .h = EPD_7IN5BC_HEIGHT, .clear = EPD_7IN5BC_Clear, .sleep =EPD_7IN5BC_Sleep, .display=EPD_7IN5BC_Display},
+        {.tp=MODEL_7in5b_HD,    .colors=2, .init=EPD_7IN5B_HD_Init, .w = EPD_7IN5B_HD_WIDTH, .h = EPD_7IN5B_HD_HEIGHT, .clear = EPD_7IN5B_HD_Clear, .sleep =EPD_7IN5B_HD_Sleep, .display=EPD_7IN5B_HD_Display},
+        {.tp=MODEL_7in5b_V2,    .colors=2, .init=EPD_7IN5B_V2_Init, .w = EPD_7IN5B_V2_WIDTH, .h = EPD_7IN5B_V2_HEIGHT, .clear = EPD_7IN5B_V2_Clear, .sleep =EPD_7IN5B_V2_Sleep, .display=EPD_7IN5B_V2_Display},
+        {.tp=MODEL_7in5_HD,     .colors=2, .init=EPD_7IN5_HD_Init, .w = EPD_7IN5_HD_WIDTH, .h = EPD_7IN5_HD_HEIGHT, .clear = EPD_7IN5_HD_Clear, .sleep =EPD_7IN5_HD_Sleep, .display=EPD_7IN5_HD_Display},
+        //{.tp=MODEL_7in5_V2, .colors=1, .init=EPD_7IN5_V2_Init, .w = EPD_7IN5_V2_WIDTH, .h = EPD_7IN5_V2_HEIGHT, .clear = EPD_7IN5_V2_Clear, .sleep =EPD_7IN5_V2_Sleep, .display=EPD_7IN5_V2_Display},
+        {.tp = 0xFF}
 };
 
 void EPD_Model(UBYTE model) {
@@ -68,7 +69,7 @@ void EPD_Model(UBYTE model) {
         return;
     const eink_reg_t* reg = eink_regs;
     int index = 0;
-    while (reg->tp >= 0) {
+    while (reg->tp != 0xFF) {
         if (reg->tp == model) {
             cur_model_index = index;
             break;
@@ -78,10 +79,11 @@ void EPD_Model(UBYTE model) {
     }
 }
 
-int EPD_Init(UBYTE mode, size_t *w, size_t *h) {
+int EPD_Init(UBYTE mode, size_t *w, size_t *h, size_t* colors) {
     eink_regs[cur_model_index].init(mode);
     *w = eink_regs[cur_model_index].w;
     *h = eink_regs[cur_model_index].h;
+    *colors = eink_regs[cur_model_index].colors;
     return 0;
 }
 void EPD_Clear(void) {
@@ -95,3 +97,23 @@ void EPD_Display(UBYTE *Image, UBYTE *Image2) {
 void EPD_Sleep(void) {
     eink_regs[cur_model_index].sleep();
 }
+
+void EPD_ReadBusy(void)
+{
+    uint16_t count = 1000;
+    Debug("e-Paper busy\r\n");
+	while(1)
+	{	 //=1 BUSY
+		if(DEV_Digital_Read(EPD_BUSY_PIN)==0) 
+			break;
+        if(!(count--))
+        {
+            Debug("error: e-Paper busy timeout!!!\r\n");
+            return;
+        }
+        else
+            DEV_Delay_ms(10);
+	}
+	DEV_Delay_ms(50);
+    Debug("e-Paper busy release\r\n");
+}

+ 2 - 1
components/epaper/epd.h

@@ -7,10 +7,11 @@
 #include "DEV_Config.h"
 
 void EPD_Model(UBYTE model);
-int EPD_Init(UBYTE Mode, size_t *w, size_t *h);
+int EPD_Init(UBYTE Mode, size_t *w, size_t *h, size_t* color_count);
 void EPD_Clear(void);
 void EPD_Display(UBYTE *Image, UBYTE *Image2);
 void EPD_Sleep(void);
+void EPD_ReadBusy(void);
 
 enum EPD_MODEL {
         MODEL_1in02d = 1,