Quellcode durchsuchen

del:去掉部分驱动统一使用epaper

Dozingfiretruck vor 3 Jahren
Ursprung
Commit
90a2631c36

+ 0 - 702
components/eink/epd1in54.c

@@ -1,702 +0,0 @@
-/**
- *  @filename   :   epd1in54b.c
- *  @brief      :   Implements for e-paper library
- *  @author     :   Yehui from Waveshare
- *
- *  Copyright (C) Waveshare     September 12 2017
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documnetation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to  whom the Software is
- * furished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-#include  <stdlib.h>
-#include "epd1in54.h"
-#include "epdif.h"
-
-#define LUAT_LOG_TAG "luat.epaper"
-#include "luat_log.h"
-
-//#define CONFIG_LV_DISPLAY_ORIENTATION_PORTRAIT_INVERTED 0
-#define CONFIG_LV_DISPLAY_ORIENTATION_PORTRAIT 0
-#define EPD_1IN54F_WIDTH           200
-#define EPD_1IN54F_HEIGHT          200
-#define EPD_1IN54F_ROW_LEN         (EPD_1IN54F_HEIGHT / 8u)
-#define EPD_1IN54F_PARTIAL_CNT     5;
-
-static uint8_t partial_counter = 0;
-static const uint8_t lut_vcom_dc1[] = {
-    0x01, 0x04, 0x04, 0x03, 0x01, 0x01, 0x01,
-    0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00,
-    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-};
-
-
-static const uint8_t lut_ww1[] = {
-    0x01, 0x04, 0x04, 0x03, 0x01, 0x01, 0x01,
-    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-};
-
-
-static const uint8_t lut_bw1[] = {
-    0x01, 0x84, 0x84, 0x83, 0x01, 0x01, 0x01,
-    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-};
-
-
-static const uint8_t lut_wb1[] = {
-    0x01, 0x44, 0x44, 0x43, 0x01, 0x01, 0x01,
-    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-};
-
-
-static const uint8_t lut_bb1[] = {
-    0x01, 0x04, 0x04, 0x03, 0x01, 0x01, 0x01,
-    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-};
-
-
-
-static void EPD_1IN54F_load_partial_lut(EPD* epd)
-{
-    EPD_1IN54F_SendCommand(epd,0x20); // LUT VCOM register
-    for (int i = 0; i < 56; i++)
-      EPD_1IN54F_SendData(epd, lut_vcom_dc1[i]);
-  //  EPD_1IN54F_SendData((uint8_t *)lut_vcom_dc1, sizeof(lut_vcom_dc1));
-
-    EPD_1IN54F_SendCommand(epd,0x21); // LUT White-to-White
-    for (int i = 0; i < 56; i++)
-      EPD_1IN54F_SendData(epd, lut_ww1[i]);
-  //  EPD_1IN54F_SendData((uint8_t *)lut_ww1, sizeof(lut_ww1));
-
-    EPD_1IN54F_SendCommand(epd,0x22); // LUT Black-to-White
-    //EPD_1IN54F_SendData((uint8_t *)lut_bw1, sizeof(lut_bw1));
-    for (int i = 0; i < 56; i++)
-      EPD_1IN54F_SendData(epd, lut_bw1[i]);
-
-    EPD_1IN54F_SendCommand(epd,0x23); // LUT White-to-Black
-    //EPD_1IN54F_SendData((uint8_t *)lut_wb1,sizeof(lut_wb1));
-    for (int i = 0; i < 56; i++)
-      EPD_1IN54F_SendData(epd, lut_wb1[i]);
-
-    EPD_1IN54F_SendCommand(epd,0x24); // LUT Black-to-Black
-    //EPD_1IN54F_SendData((uint8_t *)lut_bb1, sizeof(lut_bb1));
-    for (int i = 0; i < 56; i++)
-      EPD_1IN54F_SendData(epd, lut_bb1[i]);
-}
-static void EPD_1IN54F_partial_in(EPD* epd)
-{
-//    ESP_LOGD(TAG, "Partial in!");
-
-    // Panel setting: accept LUT from registers instead of OTP
-#if defined (CONFIG_LV_DISPLAY_ORIENTATION_PORTRAIT_INVERTED)
-    uint8_t pst_use_reg_lut[] = { 0xf3, 0x0e };
-#elif defined(CONFIG_LV_DISPLAY_ORIENTATION_PORTRAIT)
-    uint8_t pst_use_reg_lut[] = { 0xff, 0x0e };
-#else
-#//error "Unsupported orientation - only portrait modes are supported for now"
-#endif
-    EPD_1IN54F_SendCommand(epd,0x00);
-   // EPD_1IN54F_SendData(pst_use_reg_lut, sizeof(pst_use_reg_lut));
-    for (int i = 0; i < 2; i++)
-      EPD_1IN54F_SendData(epd, pst_use_reg_lut[i]);
-
-    // WORKAROUND: need to ignore OLD framebuffer or otherwise partial refresh won't work
-    uint8_t vcom = 0xb7;
-    EPD_1IN54F_SendCommand(epd,0x50);
-    EPD_1IN54F_SendData(epd, vcom);
-
-    // Dump LUT in
-    EPD_1IN54F_load_partial_lut(epd);
-
-    // Go partial!
-    EPD_1IN54F_SendCommand(epd,0x91);
-}
-
-static void EPD_1IN54F_partial_out(EPD* epd)
-{
-//    ESP_LOGD(TAG, "Partial out!");
-
-    // Panel setting: use LUT from OTP
-#if defined (CONFIG_LV_DISPLAY_ORIENTATION_PORTRAIT_INVERTED)
-    uint8_t pst_use_otp_lut[] = { 0xd3, 0x0e };
-#elif defined(CONFIG_LV_DISPLAY_ORIENTATION_PORTRAIT)
-    uint8_t pst_use_otp_lut[] = { 0xdf, 0x0e };
-#else
-//#error "Unsupported orientation - only portrait modes are supported for now"
-#endif
-    EPD_1IN54F_SendCommand(epd,0x00);
-    //EPD_1IN54F_SendData(pst_use_otp_lut, sizeof(pst_use_otp_lut));
-    for (int i = 0; i < 2; i++)
-      EPD_1IN54F_SendData(epd, pst_use_otp_lut[i]);
-
-    // WORKAROUND: re-enable OLD framebuffer to get a better full refresh
-    uint8_t vcom = 0x97;
-    EPD_1IN54F_SendCommand(epd,0x50);
-    EPD_1IN54F_SendData(epd, vcom);
-
-    // Out from partial!
-    EPD_1IN54F_SendCommand(epd,0x92);
-}
-
-int EPD_1IN54F_Init(EPD* epd, const unsigned char* lut) {
-  epd->reset_pin = EPD_RST_PIN;
-  epd->dc_pin = EPD_DC_PIN;
-  epd->cs_pin = EPD_CS_PIN;
-  epd->busy_pin = EPD_BUSY_PIN;
-  epd->width = EPD_1IN54F_WIDTH;
-  epd->height = EPD_1IN54F_HEIGHT;
-  /* this calls the peripheral hardware interface, see epdif */
-  if (EpdInitCallback() != 0) {
-    return -1;
-  }
-  /* EPD hardware init start */
-  EPD_1IN54F_Reset(epd);
-  /*
-  EPD_1IN54F_SendCommand(epd, DRIVER_OUTPUT_CONTROL);
-  EPD_1IN54F_SendData(epd, (EPD_1IN54F_HEIGHT - 1) & 0xFF);
-  EPD_1IN54F_SendData(epd, ((EPD_1IN54F_HEIGHT - 1) >> 8) & 0xFF);
-  EPD_1IN54F_SendData(epd, 0x00);                     // GD = 0; SM = 0; TB = 0;
-  EPD_1IN54F_SendCommand(epd, BOOSTER_SOFT_START_CONTROL);
-  EPD_1IN54F_SendData(epd, 0xD7);
-  EPD_1IN54F_SendData(epd, 0xD6);
-  EPD_1IN54F_SendData(epd, 0x9D);
-  EPD_1IN54F_SendCommand(epd, WRITE_VCOM_REGISTER);
-  EPD_1IN54F_SendData(epd, 0xA8);                     // VCOM 7C
-  EPD_1IN54F_SendCommand(epd, SET_DUMMY_LINE_PERIOD);
-  EPD_1IN54F_SendData(epd, 0x1A);                     // 4 dummy lines per gate
-  EPD_1IN54F_SendCommand(epd, SET_GATE_TIME);
-  EPD_1IN54F_SendData(epd, 0x08);                     // 2us per line
-  EPD_1IN54F_SendCommand(epd, DATA_ENTRY_MODE_SETTING);
-  EPD_1IN54F_SendData(epd, 0x03);                     // X increment; Y increment
-  EPD_1IN54F_SetLut(epd, epd->lut);
-  */
-///*
-  EPD_1IN54F_SendCommand(epd,0x00); // panel setting
-  EPD_1IN54F_SendData (epd,0xdf);
-  EPD_1IN54F_SendData (epd,0x0e);
-
-  EPD_1IN54F_SendCommand(epd,0x01); // power setting
-  EPD_1IN54F_SendData(epd,0x03);
-  EPD_1IN54F_SendData(epd,0x06); // 16V
-  EPD_1IN54F_SendData(epd,0x2A);//
-  EPD_1IN54F_SendData(epd,0x2A);//
-
-  EPD_1IN54F_SendCommand(epd,0x4D); // FITIinternal code
-  EPD_1IN54F_SendData (epd,0x55);
-
-  EPD_1IN54F_SendCommand(epd,0xaa);
-  EPD_1IN54F_SendData (epd,0x0f);
-
-  EPD_1IN54F_SendCommand(epd,0xE9);
-  EPD_1IN54F_SendData (epd,0x02);
-
-  EPD_1IN54F_SendCommand(epd,0xb6);
-  EPD_1IN54F_SendData (epd,0x11);
-
-  EPD_1IN54F_SendCommand(epd,0xF3);
-  EPD_1IN54F_SendData (epd,0x0a);
-
-  EPD_1IN54F_SendCommand(epd,0x06); // boost soft start
-  EPD_1IN54F_SendData (epd,0xc7);
-  EPD_1IN54F_SendData (epd,0x0c);
-  EPD_1IN54F_SendData (epd,0x0c);
-
-  EPD_1IN54F_SendCommand(epd,0x61); // resolution setting
-  EPD_1IN54F_SendData (epd,0xc8); // 200
-  EPD_1IN54F_SendData (epd,0x00);
-  EPD_1IN54F_SendData (epd,0xc8); // 200
-
-  EPD_1IN54F_SendCommand(epd,0x60); // Tcon setting
-  EPD_1IN54F_SendData (epd,0x00);
-
-  EPD_1IN54F_SendCommand(epd,0x82); // VCOM DC setting
-  EPD_1IN54F_SendData (epd,0x12);
-
-  EPD_1IN54F_SendCommand(epd,0x30); // PLL control
-  EPD_1IN54F_SendData (epd,0x3C);   // default 50Hz
-
-  EPD_1IN54F_SendCommand(epd,0X50); // VCOM and data interval
-  EPD_1IN54F_SendData(epd,0x97);//
-
-  EPD_1IN54F_SendCommand(epd,0XE3); // power saving register
-  EPD_1IN54F_SendData(epd,0x00); // default
-
-  EPD_1IN54F_SendCommand(epd,0X04);
-//*/
-
-/*  esp32 lib
-  EPD_1IN54F_SendCommand(epd,0x00); // panel setting
-  EPD_1IN54F_SendData (epd,0xdf);
-  EPD_1IN54F_SendData (epd,0x0e);
-
-  EPD_1IN54F_SendCommand(epd,0x4d); // panel setting
-  EPD_1IN54F_SendData (epd,0x55);
-
-  EPD_1IN54F_SendCommand(epd,0xaa); // panel setting
-  EPD_1IN54F_SendData (epd,0x0f);
-
-  EPD_1IN54F_SendCommand(epd,0xe9); // panel setting
-  EPD_1IN54F_SendData (epd,0x02);
-
-  EPD_1IN54F_SendCommand(epd,0xb6); // panel setting
-  EPD_1IN54F_SendData (epd,0x11);
-
-  EPD_1IN54F_SendCommand(epd,0xf3); // panel setting
-  EPD_1IN54F_SendData (epd,0x0a);
-
-  EPD_1IN54F_SendCommand(epd,0x61); // resolution setting
-  EPD_1IN54F_SendData (epd,0xc8); // 200
-  EPD_1IN54F_SendData (epd,0x00);
-  EPD_1IN54F_SendData (epd,0xc8); // 200
-
-  EPD_1IN54F_SendCommand(epd,0x60); // panel setting
-  EPD_1IN54F_SendData (epd,0x00);
-
-  EPD_1IN54F_SendCommand(epd,0x50); // panel setting
-  EPD_1IN54F_SendData (epd,0x97);
-
-  EPD_1IN54F_SendCommand(epd,0xe3); // panel setting
-  EPD_1IN54F_SendData (epd,0x00);
-*/
-  EPD_1IN54F_DelayMs(epd, 100);
-  EPD_1IN54F_WaitUntilIdle(epd);
-
-  /* EPD hardware init end */
-  return 0;
-}
-
-/**
- *  @brief: this calls the corresponding function from epdif.h
- *          usually there is no need to change this function
- */
-void EPD_1IN54F_DigitalWrite(EPD* epd, int pin, int value) {
-  EpdDigitalWriteCallback(pin, value);
-}
-
-/**
- *  @brief: this calls the corresponding function from epdif.h
- *          usually there is no need to change this function
- */
-int EPD_1IN54F_DigitalRead(EPD* epd, int pin) {
-  return EpdDigitalReadCallback(pin);
-}
-
-/**
- *  @brief: this calls the corresponding function from epdif.h
- *          usually there is no need to change this function
- */
-void EPD_1IN54F_DelayMs(EPD* epd, unsigned int delaytime) {  // 1ms
-  EpdDelayMsCallback(delaytime);
-}
-
-/**
- *  @brief: basic function for sending commands
- */
-void EPD_1IN54F_SendCommand(EPD* epd, unsigned char command) {
-  EPD_1IN54F_DigitalWrite(epd, epd->dc_pin, LOW);
-  EpdSpiTransferCallback(command);
-}
-
-/**
- *  @brief: basic function for sending data
- */
-void EPD_1IN54F_SendData(EPD* epd, unsigned char data) {
-  EPD_1IN54F_DigitalWrite(epd, epd->dc_pin, HIGH);
-  EpdSpiTransferCallback(data);
-}
-
-/**
- *  @brief: Wait until the busy_pin goes LOW
- */
-void EPD_1IN54F_WaitUntilIdle(EPD* epd) {
-  EPD_Busy_WaitUntil(0,0);
-  // while(EPD_1IN54F_DigitalRead(epd, epd->busy_pin) == HIGH) {      //0: busy, 1: idle
-  //   EPD_1IN54F_DelayMs(epd, 100);
-  // }      
-}
-
-/**
- *  @brief: module reset.
- *          often used to awaken the module in deep sleep,
- *          see EPD::Sleep();
- */
-void EPD_1IN54F_Reset(EPD* epd) {
-  EPD_1IN54F_DigitalWrite(epd, epd->reset_pin, LOW);                //module reset    
-  EPD_1IN54F_DelayMs(epd, 200);
-  EPD_1IN54F_DigitalWrite(epd, epd->reset_pin, HIGH);
-  EPD_1IN54F_DelayMs(epd, 200);    
-}
-
-/**
- *  @brief: module Power on.
- */
-void EPD_1IN54F_power_on(EPD* epd) {
-  EPD_1IN54F_SendCommand(epd, 0x50);  
-  EPD_1IN54F_SendData(epd,0x97); 
-
-  EPD_1IN54F_SendCommand(epd, 0x04);     
-}
-
-/**
- *  @brief: module Power off.
- */
-void EPD_1IN54F_power_off(EPD* epd) {
-  EPD_1IN54F_SendCommand(epd, 0x50);  
-  EPD_1IN54F_SendData(epd,0xf7);  
-
-  EPD_1IN54F_SendCommand(epd, 0x02);
-}
-
-/**
- *  @brief: put an image buffer to the frame memory.
- *          this won't update the display.
- */
-
-
-void EPD_1IN54F_SetFrameMemory(
-  EPD* epd,
-  const unsigned char* image_buffer,
-  int x,
-  int y,
-  int image_width,
-  int image_height
-) {
-  int x_end;
-  int y_end;
-
-  if (
-    image_buffer == NULL ||
-    x < 0 || image_width < 0 ||
-    y < 0 || image_height < 0
-  ) {
-    return;
-  }
-  /* x point must be the multiple of 8 or the last 3 bits will be ignored */
-  x &= 0xF8;
-  image_width &= 0xF8;
-  if (x + image_width >= epd->width) {
-    x_end = epd->width - 1;
-  } else {
-    x_end = x + image_width - 1;
-  }
-  if (y + image_height >= epd->height) {
-    y_end = epd->height - 1;
-  } else {
-    y_end = y + image_height - 1;
-  }
-
-  // 局刷还不行
-  EPD_1IN54F_SetMemoryArea(epd, x, y, x_end, y_end);
-  //EPD_1IN54F_SetMemoryPointer(epd, x, y);
-  //EPD_1IN54F_SendCommand(epd, WRITE_RAM);
-  EPD_1IN54F_SendCommand(epd, 0x10);
-  /* send the image data */
-  for (int j = 0; j < y_end - y + 1; j++) {
-    for (int i = 0; i < (x_end - x + 1) / 8; i++) {
-      EPD_1IN54F_SendData(epd, image_buffer[i + j * (image_width / 8)]);
-    }
-  }
-
-    EPD_1IN54F_SendCommand(epd, 0x13);
-  /* send the image data */
-  for (int j = 0; j < y_end - y + 1; j++) {
-    for (int i = 0; i < (x_end - x + 1) / 8; i++) {
-      EPD_1IN54F_SendData(epd, image_buffer[i + j * (image_width / 8)]);
-    }
-  }
-}
-
-/**
-*  @brief: clear the frame memory with the specified color.
-*          this won't update the display.
-*/
-void EPD_1IN54F_ClearFrameMemory(EPD* epd, unsigned char color) {
-  EPD_1IN54F_SetMemoryArea(epd, 0, 0, epd->width - 1, epd->height - 1);
-  EPD_1IN54F_SetMemoryPointer(epd, 0, 0);
-  EPD_1IN54F_SendCommand(epd, WRITE_RAM);
-  /* send the color data */
-  for (int i = 0; i < epd->width / 8 * epd->height; i++) {
-    EPD_1IN54F_SendData(epd, color);
-  }
-}
-
-/**
-*  @brief: update the display
-*          there are 2 memory areas embedded in the e-paper display
-*          but once this function is called,
-*          the the next action of SetFrameMemory or ClearFrame will 
-*          set the other memory area.
-*/
-void EPD_1IN54F_DisplayFrame(EPD* epd) {
-  // EPD_1IN54F_SendCommand(epd, DISPLAY_UPDATE_CONTROL_2);
-  // EPD_1IN54F_SendData(epd, 0xC4);
-  // EPD_1IN54F_SendCommand(epd, MASTER_ACTIVATION);
-  // EPD_1IN54F_SendCommand(epd, TERMINATE_FRAME_READ_WRITE);
-
-
-  EPD_1IN54F_SendCommand(epd, 0x12);
-  EPD_1IN54F_WaitUntilIdle(epd);
-}
-
-/**
- *  @brief: After this command is transmitted, the chip would enter the 
- *          deep-sleep mode to save power. 
- *          The deep sleep mode would return to standby by hardware reset. 
- *          You can use EPD_1IN54F_Init() to awaken
- */
-void EPD_1IN54F_Sleep(EPD* epd) {
-  EPD_1IN54F_SendCommand(epd, DEEP_SLEEP_MODE);
-  EPD_1IN54F_WaitUntilIdle(epd);
-}
-
-/**
- *  @brief: set the look-up tables
- */
-static void EPD_1IN54F_SetLut(EPD* epd, const unsigned char* lut) {
-  epd->lut = lut;
-  EPD_1IN54F_SendCommand(epd, WRITE_LUT_REGISTER);
-  /* the length of look-up table is 30 bytes */
-  for (int i = 0; i < 30; i++) {
-    EPD_1IN54F_SendData(epd, epd->lut[i]);
-  } 
-}
-
-
-
-
-/**
- *  @brief: private function to specify the memory area for data R/W
- */
-static void EPD_1IN54F_SetMemoryArea(EPD* epd, int x_start, int y_start, int x_end, int y_end) {
-  // EPD_1IN54F_SendCommand(epd, SET_RAM_X_ADDRESS_START_END_POSITION);
-  // /* x point must be the multiple of 8 or the last 3 bits will be ignored */
-  // EPD_1IN54F_SendData(epd, (x_start >> 3) & 0xFF);
-  // EPD_1IN54F_SendData(epd, (x_end >> 3) & 0xFF);
-  // EPD_1IN54F_SendCommand(epd, SET_RAM_Y_ADDRESS_START_END_POSITION);
-  // EPD_1IN54F_SendData(epd, y_start & 0xFF);
-  // EPD_1IN54F_SendData(epd, (y_start >> 8) & 0xFF);
-  // EPD_1IN54F_SendData(epd, y_end & 0xFF);
-  // EPD_1IN54F_SendData(epd, (y_end >> 8) & 0xFF);
-
-  uint16_t xe = (x_start + x_end - 1) | 0x0007; // byte boundary inclusive (last byte)
-  uint16_t ye = y_start + y_end - 1;
-  x_start &= 0xFFF8; // byte boundary
-  EPD_1IN54F_SendCommand(epd,0x90); // partial window
-  //_writeData(x / 256);
-  EPD_1IN54F_SendData(epd,x_start % 256);
-  //_writeData(xe / 256);
-  EPD_1IN54F_SendData(epd,xe % 256);
-  EPD_1IN54F_SendData(epd,y_start / 256);
-  EPD_1IN54F_SendData(epd,y_start % 256);
-  EPD_1IN54F_SendData(epd,ye / 256);
-  EPD_1IN54F_SendData(epd,ye % 256);
-  EPD_1IN54F_SendData(epd,0x01); // don't see any difference
-  //_writeData(0x00); // don't see any difference
-}
-
-/**
- *  @brief: private function to specify the start point for data R/W
- */
-static void EPD_1IN54F_SetMemoryPointer(EPD* epd, int x, int y) {
-  EPD_1IN54F_SendCommand(epd, SET_RAM_X_ADDRESS_COUNTER);
-  /* x point must be the multiple of 8 or the last 3 bits will be ignored */
-  EPD_1IN54F_SendData(epd, (x >> 3) & 0xFF);
-  EPD_1IN54F_SendCommand(epd, SET_RAM_Y_ADDRESS_COUNTER);
-  EPD_1IN54F_SendData(epd, y & 0xFF);
-  EPD_1IN54F_SendData(epd, (y >> 8) & 0xFF);
-  EPD_1IN54F_WaitUntilIdle(epd);
-}
-
-
-
-static 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
-};
-
-// static 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
-// };
-
-static void EPD_1IN54F_update_partial(EPD* epd,uint8_t x1, uint8_t y1, uint8_t x2, uint8_t y2, uint8_t *data)
-{
-  EPD_1IN54F_power_on(epd);
-  EPD_1IN54F_partial_in(epd);
-
-  // Set partial window
-  uint8_t ptl_setting[8] = { x1, x2, 0, y1, 0, y2, 0x01 };
-  //uint8_t ptl_setting[8] = { x1, x1+x2, 0, y1, 0, y1+y2, 0x01 };
-  //EPD_1IN54F_SendCommand(epd,0X90); // power saving register
-  EPD_1IN54F_SendCommand(epd,0x90);
-  for (int i = 0; i < 7; i++)
-    EPD_1IN54F_SendData(epd, ptl_setting[i]);
-
-  //uint8_t *data_ptr = (uint8_t *)data;
-
-  EPD_1IN54F_SendCommand(epd,0x13);
-  for (size_t h_idx = 0; h_idx < y2; h_idx++) {
-    //EPD_1IN54F_SendData(data_ptr, EPD_1IN54F_ROW_LEN);
-    for (int i = 0; i < x2/8; i++)
-      EPD_1IN54F_SendData(epd, data[i]);
-    data += x2/8;
- //   len -= EPD_1IN54F_ROW_LEN;
-  }
-
-
-
-//  ESP_LOGD(TAG, "Partial wait start");
-
-  EPD_1IN54F_SendCommand(epd,0x12);
-  EPD_1IN54F_WaitUntilIdle(epd);
-
-//  ESP_LOGD(TAG, "Partial updated");
-  EPD_1IN54F_partial_out(epd);
-  EPD_1IN54F_power_off(epd);
-
-}
-
-void EPD_1IN54F_fb_full_update(EPD* epd,uint8_t *data, size_t len)
-{
-  EPD_1IN54F_power_on(epd);
-//    ESP_LOGD(TAG, "Performing full update, len: %u", len);
-
-  uint8_t *data_ptr = data;
-
-    // Fill OLD data (maybe not necessary)
-  uint8_t old_data[EPD_1IN54F_ROW_LEN] = { 0 };
-  EPD_1IN54F_SendCommand(epd,0x10);
-  for (size_t idx = 0; idx < EPD_1IN54F_HEIGHT; idx++) {
-      //jd79653a_spi_send_data(old_data, EPD_1IN54F_ROW_LEN);
-    for (int i = 0; i < EPD_1IN54F_ROW_LEN; i++)
-      EPD_1IN54F_SendData(epd, old_data[i]);
-  }
-
-  // Fill NEW data
-  EPD_1IN54F_SendCommand(epd,0x13);
-  for (size_t h_idx = 0; h_idx < EPD_1IN54F_HEIGHT; h_idx++) {
-        //jd79653a_spi_send_data(data_ptr, EPD_1IN54F_ROW_LEN);
-    for (int i = 0; i < EPD_1IN54F_ROW_LEN; i++)
-      EPD_1IN54F_SendData(epd, data_ptr[i]);
-    data_ptr += EPD_1IN54F_ROW_LEN;
-      //len -= EPD_1IN54F_ROW_LEN;
-  }
-    //ESP_LOGD(TAG, "Rest len: %u", len);
-  EPD_1IN54F_SendCommand(epd,0x12); // Issue refresh command
-  EPD_1IN54F_DelayMs(epd, 100);
-  EPD_1IN54F_WaitUntilIdle(epd);
-
-  EPD_1IN54F_power_off(epd);
-}
-//void jd79653a_lv_fb_flush(lv_disp_drv_t *drv, const lv_area_t *area, lv_color_t *color_map)
-void jd79653a_lv_fb_flush(
-  EPD* epd,
-  const unsigned char *color_map,
-  int x,
-  int y,
-  int image_width,
-  int image_height
-){
-//    size_t len = ((area->x2 - area->x1 + 1) * (area->y2 - area->y1 + 1)) / 8;
-
-   // ESP_LOGD(TAG, "x1: 0x%x, x2: 0x%x, y1: 0x%x, y2: 0x%x", area->x1, area->x2, area->y1, area->y2);
- //   ESP_LOGD(TAG, "Writing LVGL fb with len: %u, partial counter: %u", len, partial_counter);
-
-    uint8_t *buf = (uint8_t *) color_map;
-
-    if (partial_counter == 0) {
-    //    ESP_LOGD(TAG, "Refreshing in FULL");
-        EPD_1IN54F_fb_full_update(epd, buf, ((EPD_1IN54F_HEIGHT * EPD_1IN54F_WIDTH) / 8));
-        partial_counter = EPD_1IN54F_PARTIAL_CNT; // Reset partial counter here
-    } else {
-        EPD_1IN54F_update_partial(epd, x, y, x+image_width-1, y+image_height-1, buf);
-        partial_counter -= 1;   // ...or otherwise, decrease 1
-    }
-
- //   lv_disp_flush_ready(drv);
-}
-
-#define UBYTE uint8_t
-UBYTE EPD_1IN54FF_Init(void);
-void EPD_1IN54FF_Clear(void);
-void EPD_1IN54FF_Display(UBYTE *Image);
-void EPD_1IN54FF_Sleep(void);
-
-#define BUSY_Pin          (18)
-#define RST_Pin           (7)
-#define DC_Pin            (9)
-#define SPI_CS_Pin        (16)
-
-static EPD _epd;
-UBYTE EPD_1IN54FF_Init(void) {
-  _epd.busy_pin = EPD_BUSY_PIN;
-  _epd.reset_pin = EPD_RST_PIN;
-  _epd.dc_pin = EPD_DC_PIN;
-  _epd.cs_pin = EPD_CS_PIN;
-  _epd.width = EPD_1IN54F_WIDTH;
-  _epd.height = EPD_1IN54F_HEIGHT;
-  LLOGD("EPD_1IN54F_Init");
-  EPD_1IN54F_Init(&_epd, lut_full_update);
-  return 0;
-}
-void EPD_1IN54FF_Clear(void) {
-  ;
-}
-void EPD_1IN54FF_Display(UBYTE *Image) {
-  EPD_1IN54F_SetFrameMemory(&_epd, Image, 0, 0, EPD_1IN54F_WIDTH, EPD_1IN54F_HEIGHT);
-  EPD_1IN54F_DisplayFrame(&_epd);
-}
-void EPD_1IN54FF_Sleep(void) {
-  EPD_1IN54F_Sleep(&_epd);
-}
-
-/* END OF FILE */
-
-

+ 0 - 115
components/eink/epd1in54.h

@@ -1,115 +0,0 @@
-/**
- *  @filename   :   epd1in54.h
- *  @brief      :   Header file for e-paper library epd1in54.c
- *  @author     :   Yehui from Waveshare
- *  
- *  Copyright (C) Waveshare     September 12 2017
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documnetation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to  whom the Software is
- * furished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-#ifndef EPD1IN54_H
-#define EPD1IN54_H
-
-#ifndef uint8_t
-typedef unsigned char      uint8_t;
-#endif 
-#ifndef uint16_t
-typedef unsigned short     uint16_t;
-#endif 
-
-// Display resolution
-#define EPD_1IN54F_WIDTH       200
-#define EPD_1IN54F_HEIGHT      200
-
-// EPD1IN54 commands
-#define DRIVER_OUTPUT_CONTROL                       0x01
-#define BOOSTER_SOFT_START_CONTROL                  0x0C
-#define GATE_SCAN_START_POSITION                    0x0F
-#define DEEP_SLEEP_MODE                             0x07 // 0x10
-#define DATA_ENTRY_MODE_SETTING                     0x11
-#define SW_RESET                                    0x12
-#define TEMPERATURE_SENSOR_CONTROL                  0x1A
-#define MASTER_ACTIVATION                           0x20
-#define DISPLAY_UPDATE_CONTROL_1                    0x21
-#define DISPLAY_UPDATE_CONTROL_2                    0x22
-#define WRITE_RAM                                   0x24
-#define WRITE_VCOM_REGISTER                         0x2C
-#define WRITE_LUT_REGISTER                          0x32
-#define SET_DUMMY_LINE_PERIOD                       0x3A
-#define SET_GATE_TIME                               0x3B
-#define BORDER_WAVEFORM_CONTROL                     0x3C
-#define SET_RAM_X_ADDRESS_START_END_POSITION        0x44
-#define SET_RAM_Y_ADDRESS_START_END_POSITION        0x45
-#define SET_RAM_X_ADDRESS_COUNTER                   0x4E
-#define SET_RAM_Y_ADDRESS_COUNTER                   0x4F
-#define TERMINATE_FRAME_READ_WRITE                  0xFF
-
-static const unsigned char lut_full_update[];
-// static const unsigned char lut_partial_update[];
-
-typedef struct EPD_t {
-  int reset_pin;
-  int dc_pin;
-  int cs_pin;
-  int busy_pin;
-  int width;
-  int height;
-  const unsigned char* lut;
-} EPD;
-
-/* Hardware operating functions */
-/* public functions */
-int  EPD_1IN54F_Init(EPD* epd, const unsigned char* lut);
-void EPD_1IN54F_SendCommand(EPD* epd, unsigned char command);
-void EPD_1IN54F_SendData(EPD* epd, unsigned char data);
-void EPD_1IN54F_WaitUntilIdle(EPD* epd);
-void EPD_1IN54F_Reset(EPD* epd);
-void EPD_1IN54F_SetFrameMemory(
-  EPD* epd,
-  const unsigned char* image_buffer,
-  int x,
-  int y,
-  int image_width,
-  int image_height
-);
-void EPD_1IN54F_ClearFrameMemory(EPD* epd, unsigned char color);
-void EPD_1IN54F_DisplayFrame(EPD* epd);
-void EPD_1IN54F_Sleep(EPD* epd);
-void EPD_1IN54F_DelayMs(EPD* epd, unsigned int delay_time);
-void EPD_1IN54F_DigitalWrite(EPD* epd, int pin, int value);
-int  EPD_1IN54F_DigitalRead(EPD* epd, int pin);
-
-/* private functions */
-static void EPD_1IN54F_SetLut(EPD* epd, const unsigned char* lut);
-static void EPD_1IN54F_SetMemoryArea(EPD* epd, int x_start, int y_start, int x_end, int y_end);
-static void EPD_1IN54F_SetMemoryPointer(EPD* epd, int x, int y);
-
-
-void jd79653a_lv_fb_flush(
-  EPD* epd,
-  const unsigned char *color_map,
-  int x,
-  int y,
-  int image_width,
-  int image_height
-);
-#endif /* EPD1IN54_H */
-
-/* END OF FILE */

+ 0 - 314
components/eink/epd2in9.c

@@ -1,314 +0,0 @@
-/**
- *  @filename   :   epd2in9.c
- *  @brief      :   Implements for e-paper library
- *  @author     :   Yehui from Waveshare
- *
- *  Copyright (C) Waveshare     September 12 2017
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documnetation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to  whom the Software is
- * furished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-#include <stdlib.h>
-// #include "epd1in54.h"
-#include "epd2in9.h"
-#include "epdif.h"
-
-int EPD_2IN9F_Init(EPD* epd, const unsigned char* lut) {
-  epd->reset_pin = EPD_RST_PIN;
-  epd->dc_pin = EPD_DC_PIN;
-  epd->cs_pin = EPD_CS_PIN;
-  epd->busy_pin = EPD_BUSY_PIN;
-  epd->width = EPD_2IN9F_WIDTH;
-  epd->height = EPD_2IN9F_HEIGHT;
-  /* this calls the peripheral hardware interface, see epdif */
-  if (EpdInitCallback() != 0) {
-    return -1;
-  }
-  epd->lut = lut;
-  /* EPD hardware init start */
-
-  EPD_2IN9F_Reset(epd);
- 
-  EPD_2IN9F_SendCommand(epd, DRIVER_OUTPUT_CONTROL);
-  EPD_2IN9F_SendData(epd, (EPD_2IN9F_HEIGHT - 1) & 0xFF);
-  EPD_2IN9F_SendData(epd, ((EPD_2IN9F_HEIGHT - 1) >> 8) & 0xFF);
-  EPD_2IN9F_SendData(epd, 0x00);                     // GD = 0; SM = 0; TB = 0;
-  EPD_2IN9F_SendCommand(epd, BOOSTER_SOFT_START_CONTROL);
-  EPD_2IN9F_SendData(epd, 0xD7);
-  EPD_2IN9F_SendData(epd, 0xD6);
-  EPD_2IN9F_SendData(epd, 0x9D);
-  EPD_2IN9F_SendCommand(epd, WRITE_VCOM_REGISTER);
-  EPD_2IN9F_SendData(epd, 0x9A);                     // VCOM 7C
-  //  EPD_2IN9F_SendData(epd, 0xA8);                     // VCOM 7C
-  EPD_2IN9F_SendCommand(epd, SET_DUMMY_LINE_PERIOD);
-  EPD_2IN9F_SendData(epd, 0x1A);                     // 4 dummy lines per gate
-  EPD_2IN9F_SendCommand(epd, SET_GATE_TIME);
-  EPD_2IN9F_SendData(epd, 0x08);                     // 2us per line
-  EPD_2IN9F_SendCommand(epd, DATA_ENTRY_MODE_SETTING);
-  EPD_2IN9F_SendData(epd, 0x03);                     // X increment; Y increment
-
-  // EPD_2IN9F_DelayMs(epd, 10);
-  // EPD_2IN9F_WaitUntilIdle(epd);
-
-  EPD_2IN9F_SetLut(epd, epd->lut);
-  /* EPD hardware init end */
-  return 0;
-}
-
-/**
- *  @brief: this calls the corresponding function from epdif.h
- *          usually there is no need to change this function
- */
-void EPD_2IN9F_DigitalWrite(EPD* epd, int pin, int value) {
-  EpdDigitalWriteCallback(pin, value);
-}
-
-/**
- *  @brief: this calls the corresponding function from epdif.h
- *          usually there is no need to change this function
- */
-int EPD_2IN9F_DigitalRead(EPD* epd, int pin) {
-  return EpdDigitalReadCallback(pin);
-}
-
-/**
- *  @brief: this calls the corresponding function from epdif.h
- *          usually there is no need to change this function
- */
-void EPD_2IN9F_DelayMs(EPD* epd, unsigned int delaytime) {  // 1ms
-  EpdDelayMsCallback(delaytime);
-}
-
-/**
- *  @brief: basic function for sending commands
- */
-void EPD_2IN9F_SendCommand(EPD* epd, unsigned char command) {
-  EPD_2IN9F_DigitalWrite(epd, epd->dc_pin, LOW);
-  EpdSpiTransferCallback(command);
-}
-
-/**
- *  @brief: basic function for sending data
- */
-void EPD_2IN9F_SendData(EPD* epd, unsigned char data) {
-  EPD_2IN9F_DigitalWrite(epd, epd->dc_pin, HIGH);
-  EpdSpiTransferCallback(data);
-}
-
-/**
- *  @brief: Wait until the busy_pin goes LOW
- */
-void EPD_2IN9F_WaitUntilIdle(EPD* epd) {
-  EPD_Busy_WaitUntil(0,0);
-  // while(EPD_2IN9F_DigitalRead(epd, epd->busy_pin) == HIGH) {      //0: busy, 1: idle
-  //   EPD_2IN9F_DelayMs(epd, 100);
-  // }      
-}
-
-/**
- *  @brief: module reset.
- *          often used to awaken the module in deep sleep,
- *          see EPD::Sleep();
- */
-void EPD_2IN9F_Reset(EPD* epd) {
-  EPD_2IN9F_DigitalWrite(epd, epd->reset_pin, LOW);                //module reset    
-  EPD_2IN9F_DelayMs(epd, 30);
-  EPD_2IN9F_DigitalWrite(epd, epd->reset_pin, HIGH);
-  EPD_2IN9F_DelayMs(epd, 30);    
-}
-
-/**
- *  @brief: put an image buffer to the frame memory.
- *          this won't update the display.
- */
-void EPD_2IN9F_SetFrameMemory(
-  EPD* epd,
-  const unsigned char* image_buffer,
-  int x,
-  int y,
-  int image_width,
-  int image_height
-) {
-  int x_end;
-  int y_end;
-
-  if (
-    image_buffer == NULL ||
-    x < 0 || image_width < 0 ||
-    y < 0 || image_height < 0
-  ) {
-    return;
-  }
-  /* x point must be the multiple of 8 or the last 3 bits will be ignored */
-  x &= 0xF8;
-  image_width &= 0xF8;
-  if (x + image_width >= epd->width) {
-    x_end = epd->width - 1;
-  } else {
-    x_end = x + image_width - 1;
-  }
-  if (y + image_height >= epd->height) {
-    y_end = epd->height - 1;
-  } else {
-    y_end = y + image_height - 1;
-  }
-  EPD_2IN9F_SetMemoryArea(epd, x, y, x_end, y_end);
-  EPD_2IN9F_SetMemoryPointer(epd, x, y);
-  EPD_2IN9F_SendCommand(epd, WRITE_RAM);
-  /* send the image data */
-  for (int j = 0; j < y_end - y + 1; j++) {
-    for (int i = 0; i < (x_end - x + 1) / 8; i++) {
-      EPD_2IN9F_SendData(epd, image_buffer[i + j * (image_width / 8)]);
-    }
-  }
-}
-
-/**
-*  @brief: clear the frame memory with the specified color.
-*          this won't update the display.
-*/
-void EPD_2IN9F_ClearFrameMemory(EPD* epd, unsigned char color) {
-  EPD_2IN9F_SetMemoryArea(epd, 0, 0, epd->width - 1, epd->height - 1);
-  EPD_2IN9F_SetMemoryPointer(epd, 0, 0);
-  EPD_2IN9F_SendCommand(epd, WRITE_RAM);
-  /* send the color data */
-  for (int i = 0; i < epd->width / 8 * epd->height; i++) {
-    EPD_2IN9F_SendData(epd, color);
-  }
-}
-
-/**
-*  @brief: update the display
-*          there are 2 memory areas embedded in the e-paper display
-*          but once this function is called,
-*          the the next action of SetFrameMemory or ClearFrame will 
-*          set the other memory area.
-*/
-void EPD_2IN9F_DisplayFrame(EPD* epd) {
-  EPD_2IN9F_SendCommand(epd, DISPLAY_UPDATE_CONTROL_2);
-  EPD_2IN9F_SendData(epd, 0xC4);
-  EPD_2IN9F_SendCommand(epd, MASTER_ACTIVATION);
-  EPD_2IN9F_SendCommand(epd, TERMINATE_FRAME_READ_WRITE);
-  EPD_2IN9F_WaitUntilIdle(epd);
-}
-
-/**
- *  @brief: After this command is transmitted, the chip would enter the 
- *          deep-sleep mode to save power. 
- *          The deep sleep mode would return to standby by hardware reset. 
- *          You can use EPD_2IN9F_Init() to awaken
- */
-void EPD_2IN9F_Sleep(EPD* epd) {
-  EPD_2IN9F_SendCommand(epd, DEEP_SLEEP_MODE);
-  EPD_2IN9F_WaitUntilIdle(epd);
-}
-
-/**
- *  @brief: set the look-up tables
- */
-static void EPD_2IN9F_SetLut(EPD* epd, const unsigned char* lut) {
-  epd->lut = lut;
-  EPD_2IN9F_SendCommand(epd, WRITE_LUT_REGISTER);
-  /* the length of look-up table is 30 bytes */
-  for (int i = 0; i < 30; i++) {
-    EPD_2IN9F_SendData(epd, epd->lut[i]);
-  } 
-}
-
-/**
- *  @brief: private function to specify the memory area for data R/W
- */
-static void EPD_2IN9F_SetMemoryArea(EPD* epd, int x_start, int y_start, int x_end, int y_end) {
-  EPD_2IN9F_SendCommand(epd, SET_RAM_X_ADDRESS_START_END_POSITION);
-  /* x point must be the multiple of 8 or the last 3 bits will be ignored */
-  EPD_2IN9F_SendData(epd, (x_start >> 3) & 0xFF);
-  EPD_2IN9F_SendData(epd, (x_end >> 3) & 0xFF);
-  EPD_2IN9F_SendCommand(epd, SET_RAM_Y_ADDRESS_START_END_POSITION);
-  EPD_2IN9F_SendData(epd, y_start & 0xFF);
-  EPD_2IN9F_SendData(epd, (y_start >> 8) & 0xFF);
-  EPD_2IN9F_SendData(epd, y_end & 0xFF);
-  EPD_2IN9F_SendData(epd, (y_end >> 8) & 0xFF);
-}
-
-/**
- *  @brief: private function to specify the start point for data R/W
- */
-static void EPD_2IN9F_SetMemoryPointer(EPD* epd, int x, int y) {
-  EPD_2IN9F_SendCommand(epd, SET_RAM_X_ADDRESS_COUNTER);
-  /* x point must be the multiple of 8 or the last 3 bits will be ignored */
-  EPD_2IN9F_SendData(epd, (x >> 3) & 0xFF);
-  EPD_2IN9F_SendCommand(epd, SET_RAM_Y_ADDRESS_COUNTER);
-  EPD_2IN9F_SendData(epd, y & 0xFF);
-  EPD_2IN9F_SendData(epd, (y >> 8) & 0xFF);
-  EPD_2IN9F_WaitUntilIdle(epd);
-}
-
-static 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
-};
-
-// static 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
-// };
-
-/* END OF FILE */
-
-//-----------------------------
-#define UBYTE uint8_t
-UBYTE EPD_2IN9FF_Init(void);
-void EPD_2IN9FF_Clear(void);
-void EPD_2IN9FF_Display(UBYTE *Image);
-void EPD_2IN9FF_Sleep(void);
-
-#define BUSY_Pin          (18)
-#define RST_Pin           (7)
-#define DC_Pin            (9)
-#define SPI_CS_Pin        (16)
-
-static EPD _epd;
-UBYTE EPD_2IN9FF_Init(void) {
-  _epd.busy_pin = BUSY_Pin;
-  _epd.reset_pin = RST_PIN;
-  _epd.dc_pin = DC_PIN;
-  _epd.cs_pin = SPI_CS_Pin;
-  _epd.width = EPD_2IN9F_WIDTH;
-  _epd.height = EPD_2IN9F_HEIGHT;
-
-  EPD_2IN9F_Init(&_epd, lut_full_update);
-  return 0;
-}
-void EPD_2IN9FF_Clear(void) {
-  ;
-}
-void EPD_2IN9FF_Display(UBYTE *Image) {
-  EPD_2IN9F_SetFrameMemory(&_epd, Image, 0, 0, EPD_2IN9F_WIDTH, EPD_2IN9F_HEIGHT);
-  EPD_2IN9F_DisplayFrame(&_epd);
-}
-void EPD_2IN9FF_Sleep(void) {
-  EPD_2IN9F_Sleep(&_epd);
-}
-

+ 0 - 108
components/eink/epd2in9.h

@@ -1,108 +0,0 @@
-/**
- *  @filename   :   epd2in9.h
- *  @brief      :   Header file for e-paper library epd2in9.c
- *  @author     :   Yehui from Waveshare
- *  
- *  Copyright (C) Waveshare     September 12 2017
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documnetation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to  whom the Software is
- * furished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-// #ifndef EPD1IN54_H
-// #define EPD1IN54_H
-#ifndef EPD2IN9_H
-#define EPD2IN9_H
-
-#ifndef uint8_t
-typedef unsigned char      uint8_t;
-#endif 
-#ifndef uint16_t
-typedef unsigned short     uint16_t;
-#endif 
-
-// Display resolution
-#define EPD_2IN9F_WIDTH       128
-#define EPD_2IN9F_HEIGHT      296
-
-// EPD2IN9 commands
-#define DRIVER_OUTPUT_CONTROL                       0x01
-#define BOOSTER_SOFT_START_CONTROL                  0x0C
-#define GATE_SCAN_START_POSITION                    0x0F
-#define DEEP_SLEEP_MODE                             0x10
-#define DATA_ENTRY_MODE_SETTING                     0x11
-#define SW_RESET                                    0x12
-#define TEMPERATURE_SENSOR_CONTROL                  0x1A
-#define MASTER_ACTIVATION                           0x20
-#define DISPLAY_UPDATE_CONTROL_1                    0x21
-#define DISPLAY_UPDATE_CONTROL_2                    0x22
-#define WRITE_RAM                                   0x24
-#define WRITE_VCOM_REGISTER                         0x2C
-#define WRITE_LUT_REGISTER                          0x32
-#define SET_DUMMY_LINE_PERIOD                       0x3A
-#define SET_GATE_TIME                               0x3B
-#define BORDER_WAVEFORM_CONTROL                     0x3C
-#define SET_RAM_X_ADDRESS_START_END_POSITION        0x44
-#define SET_RAM_Y_ADDRESS_START_END_POSITION        0x45
-#define SET_RAM_X_ADDRESS_COUNTER                   0x4E
-#define SET_RAM_Y_ADDRESS_COUNTER                   0x4F
-#define TERMINATE_FRAME_READ_WRITE                  0xFF
-
-static const unsigned char lut_full_update[];
-// static const unsigned char lut_partial_update[];
-
-typedef struct EPD_2IN9F_t {
-  int reset_pin;
-  int dc_pin;
-  int cs_pin;
-  int busy_pin;
-  int width;
-  int height;
-  const unsigned char* lut;
-} EPD;
-
-/* Hardware operating functions */
-/* public functions */
-int  EPD_2IN9F_Init(EPD* epd, const unsigned char* lut);
-void EPD_2IN9F_SendCommand(EPD* epd, unsigned char command);
-void EPD_2IN9F_SendData(EPD* epd, unsigned char data);
-void EPD_2IN9F_WaitUntilIdle(EPD* epd);
-void EPD_2IN9F_Reset(EPD* epd);
-void EPD_2IN9F_SetFrameMemory(
-  EPD* epd,
-  const unsigned char* image_buffer,
-  int x,
-  int y,
-  int image_width,
-  int image_height
-);
-void EPD_2IN9F_ClearFrameMemory(EPD* epd, unsigned char color);
-void EPD_2IN9F_DisplayFrame(EPD* epd);
-void EPD_2IN9F_Sleep(EPD* epd);
-void EPD_2IN9F_DelayMs(EPD* epd, unsigned int delay_time);
-void EPD_2IN9F_DigitalWrite(EPD* epd, int pin, int value);
-int  EPD_2IN9F_DigitalRead(EPD* epd, int pin);
-
-/* private functions */
-static void EPD_2IN9F_SetLut(EPD* epd, const unsigned char* lut);
-static void EPD_2IN9F_SetMemoryArea(EPD* epd, int x_start, int y_start, int x_end, int y_end);
-static void EPD_2IN9F_SetMemoryPointer(EPD* epd, int x, int y);
-
-#endif /* EPD2IN9_H */
-
-/* END OF FILE */

+ 0 - 121
components/eink/epdif.c

@@ -1,121 +0,0 @@
-/**
- *  @filename   :   epdif.c
- *  @brief      :   Implements EPD interface functions
- *                  Users have to implement all the functions in epdif.cpp
- *  @author     :   Yehui from Waveshare
- *
- *  Copyright (C) Waveshare     July 7 2017
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documnetation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to  whom the Software is
- * furished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-#include "epdif.h"
-#include "luat_gpio.h"
-#include "luat_spi.h"
-
-//#include "main.h"
-
-// #define SPI_CS_GPIO_Port  0
-// #define RST_GPIO_Port     0
-// #define DC_GPIO_Port      0
-// #define BUSY_GPIO_Port    0
-
-
-// #define BUSY_Pin          (18)
-// #define RST_Pin           (7)
-// #define DC_Pin            (9)
-// #define SPI_CS_Pin        (16)
-
-// #define SPI_ID            (0)
-
-//extern SPI_HandleTypeDef hspi1;
-
-// EPD_Pin epd_cs_pin = {
-//   SPI_CS_GPIO_Port
-// };
-
-// EPD_Pin epd_rst_pin = {
-//   RST_GPIO_Port
-// };
-
-// EPD_Pin epd_dc_pin = {
-//   DC_GPIO_Port
-// };
-
-// EPD_Pin epd_busy_pin = {
-//   BUSY_GPIO_Port
-// };
-
-EPD_Pin pins[4];
-
-void EpdDigitalWriteCallback(int pin_num, int value) {
-  if (value == HIGH) {
-  //  HAL_GPIO_WritePin((GPIO_TypeDef*)pins[pin_num].port, pins[pin_num].pin, GPIO_PIN_SET);
-    luat_gpio_set(pins[pin_num].port, Luat_GPIO_HIGH);
-  } else {
-  //  HAL_GPIO_WritePin((GPIO_TypeDef*)pins[pin_num].port, pins[pin_num].pin, GPIO_PIN_RESET);
-    luat_gpio_set(pins[pin_num].port, Luat_GPIO_LOW);
-  }
-
-
-  
-}
-
-int EpdDigitalReadCallback(int pin_num) {
-  // if (HAL_GPIO_ReadPin(pins[pin_num].port, pins[pin_num].pin) == GPIO_PIN_SET) {
-  //   return HIGH;
-  // } else {
-  //   return LOW;
-  // }
-
-  if (luat_gpio_get(pins[pin_num].port) == Luat_GPIO_HIGH) {
-    return HIGH;
-  } else {
-    return LOW;
-  }
-}
-
-void EpdDelayMsCallback(unsigned int delaytime) {
- // HAL_Delay(delaytime);
-    while(delaytime--)
-    {
-        luat_timer_us_delay(1000);
-    }
-}
-
-void EpdSpiTransferCallback(unsigned char data) {
-  // HAL_GPIO_WritePin((GPIO_TypeDef*)pins[CS_PIN].port, pins[CS_PIN].pin, GPIO_PIN_RESET);
-  // HAL_SPI_Transmit(&hspi1, &data, 1, 1000);
-  // HAL_GPIO_WritePin((GPIO_TypeDef*)pins[CS_PIN].port, pins[CS_PIN].pin, GPIO_PIN_SET);
-
-  luat_gpio_set(pins[CS_PIN].port, Luat_GPIO_LOW);
-  luat_spi_send(EPD_SPI_ID, (char *)&data, 1);
-  luat_gpio_set(pins[CS_PIN].port, Luat_GPIO_HIGH);
-
-}
-
-int EpdInitCallback(void) {
-  pins[CS_PIN].port = EPD_CS_PIN;
-  pins[RST_PIN].port = EPD_RST_PIN;
-  pins[DC_PIN].port = EPD_DC_PIN;
-  pins[BUSY_PIN].port = EPD_BUSY_PIN;
-  
-  return 0;
-}
-

+ 0 - 82
components/eink/epdif.h

@@ -1,82 +0,0 @@
-/**
- *  @filename   :   epdif.h
- *  @brief      :   Header file of epdif.c providing EPD interface functions
- *                  Users have to implement all the functions in epdif.cpp
- *  @author     :   Yehui from Waveshare
- *
- *  Copyright (C) Waveshare     July 7 2017
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documnetation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to  whom the Software is
- * furished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-#ifndef EPDIF_H
-#define EPDIF_H
-
-
-// Pin definition
-#define CS_PIN           0
-#define RST_PIN          1
-#define DC_PIN           2
-#define BUSY_PIN         3
-
-#ifndef uint8_t
-typedef unsigned char      uint8_t;
-#endif 
-#ifndef uint16_t
-typedef unsigned short     uint16_t;
-#endif 
-
-typedef struct eink_conf {
-    uint8_t spi_id;
-    uint8_t busy_pin;
-    uint8_t res_pin;
-    uint8_t dc_pin;
-    uint8_t cs_pin;
-    uint8_t full_mode;
-    uint8_t port;
-    void* userdata;
-}eink_conf_t;
-
-extern eink_conf_t econf;
-
-/**
- * e-Paper GPIO
-**/
-#define EPD_RST_PIN     (econf.res_pin)
-#define EPD_DC_PIN      (econf.dc_pin)
-#define EPD_CS_PIN      (econf.cs_pin)
-#define EPD_BUSY_PIN    (econf.busy_pin)
-#define EPD_SPI_ID      (econf.spi_id)
-
-// Pin level definition
-#define LOW             0
-#define HIGH            1
-
-typedef struct {
-//  GPIO_TypeDef* port;
-  uint8_t port;
-} EPD_Pin;
-
-int  EpdInitCallback(void);
-void EpdDigitalWriteCallback(int pin, int value);
-int  EpdDigitalReadCallback(int pin);
-void EpdDelayMsCallback(unsigned int delaytime);
-void EpdSpiTransferCallback(unsigned char data);
-
-#endif /* EPDIF_H */

+ 0 - 4
components/eink/luat_lib_eink.c

@@ -1266,8 +1266,6 @@ static const rotable_Reg_t reg_eink[] =
     { "MODEL_1in54_V3",       ROREG_INT(MODEL_1in54_V3)},
     //@const MODEL_1in54c number 1.54寸c
     { "MODEL_1in54c",         ROREG_INT(MODEL_1in54c)},
-    //@const MODEL_1in54f number 1.54寸f
-    { "MODEL_1in54f",         ROREG_INT(MODEL_1in54f)},
     //@const MODEL_2in13 number 2.13寸
     { "MODEL_2in13",          ROREG_INT(MODEL_2in13)},
     //@const MODEL_2in13bc number 2.13寸bc
@@ -1296,8 +1294,6 @@ static const rotable_Reg_t reg_eink[] =
     { "MODEL_2in9b_V3",       ROREG_INT(MODEL_2in9b_V3)},
     //@const MODEL_2in9d number 2.9寸d
     { "MODEL_2in9d",          ROREG_INT(MODEL_2in9d)},
-    //@const MODEL_2in9f number 2.9寸f
-    { "MODEL_2in9f",          ROREG_INT(MODEL_2in9ff)},
     //@const MODEL_3in7 number 3.7寸
     { "MODEL_3in7",           ROREG_INT(MODEL_3in7)},
     //@const MODEL_4in2 number 4.2寸

+ 73 - 0
components/epaper/DEV_Config.c

@@ -30,6 +30,7 @@
 #
 ******************************************************************************/
 #include "DEV_Config.h"
+#include "luat_rtos.h"
 
 void DEV_SPI_WriteByte(UBYTE value)
 {
@@ -48,3 +49,75 @@ int DEV_Digital_Write(int pin, int level){
     return luat_gpio_set(pin, level);
 }
 
+static int32_t l_eink_callback(lua_State *L, void* ptr){
+    rtos_msg_t* msg = (rtos_msg_t*)lua_topointer(L, -1);
+    luat_release_rtos_timer(econf.readbusy_timer);
+    luat_cbcwait(L, econf.idp, 1);
+    return 0;
+}
+
+static LUAT_RT_RET_TYPE readbusy_timer_cb(LUAT_RT_CB_PARAM){
+    rtos_msg_t msg = {
+		.handler = l_eink_callback,
+	};
+    if (econf.timer_count++ > 300){//30s
+        luat_cbcwait_noarg(econf.idp);
+        luat_stop_rtos_timer(econf.readbusy_timer);
+        luat_msgbus_put(&msg, 0);
+        return;
+    }
+    eink_async_t* async_cmd = (eink_async_t *)param;
+    if (async_cmd->level){
+        if(DEV_Digital_Read(EPD_BUSY_PIN)) {
+            if (async_cmd->send_cmd){
+                DEV_Digital_Write(EPD_DC_PIN, 0);
+                DEV_Digital_Write(EPD_CS_PIN, 0);
+                DEV_SPI_WriteByte(0x71);
+                DEV_Digital_Write(EPD_CS_PIN, 1);
+            }
+            luat_cbcwait_noarg(econf.idp);
+            luat_stop_rtos_timer(econf.readbusy_timer);
+            luat_msgbus_put(&msg, 0);
+        }
+    }else{
+        if(DEV_Digital_Read(EPD_BUSY_PIN)==0) {
+            luat_cbcwait_noarg(econf.idp);
+            luat_stop_rtos_timer(econf.readbusy_timer);
+            luat_msgbus_put(&msg, 0);
+        }
+    }
+}
+
+void EPD_Busy_WaitUntil(uint8_t level,uint8_t send_cmd){
+    uint16_t count = 200;//20s
+    econf.async_cmd.level = level;
+    econf.async_cmd.send_cmd = send_cmd;
+    if (econf.async){
+        econf.readbusy_timer = luat_create_rtos_timer(readbusy_timer_cb, &econf.async_cmd, NULL);
+        luat_start_rtos_timer(econf.readbusy_timer, 100, 1);
+    }else{
+        while(1){
+            if (level){
+                if (send_cmd){
+                    DEV_Digital_Write(EPD_DC_PIN, 0);
+                    DEV_Digital_Write(EPD_CS_PIN, 0);
+                    DEV_SPI_WriteByte(0x71);
+                    DEV_Digital_Write(EPD_CS_PIN, 1);
+                }
+                if(DEV_Digital_Read(EPD_BUSY_PIN)) 
+                    break;
+            }else{
+                if(DEV_Digital_Read(EPD_BUSY_PIN)==0) 
+                    break;
+            }
+            if(!(count--)){
+                Debug("error: e-Paper busy timeout!!!\r\n");
+                return;
+            }
+            else
+                DEV_Delay_ms(100);
+        }
+        DEV_Delay_ms(100);
+    }
+}
+

+ 4 - 0
components/epaper/DEV_Config.h

@@ -54,6 +54,9 @@
 #include "luat_timer.h"
 
 #include "u8g2.h"
+
+#include "Debug.h"
+
 /**
  * data
 **/
@@ -117,5 +120,6 @@ int DEV_Digital_Write(int pin, int level);
 #define DEV_Delay_ms(__xms) luat_timer_mdelay(__xms);
 
 void DEV_SPI_WriteByte(UBYTE value);
+void EPD_Busy_WaitUntil(uint8_t level,uint8_t send_cmd);
 
 #endif

+ 2 - 73
components/epaper/epd.c

@@ -28,7 +28,7 @@ static const eink_reg_t eink_regs[] = {
         {.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_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},
@@ -44,7 +44,7 @@ static const eink_reg_t eink_regs[] = {
         {.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_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},
@@ -98,74 +98,3 @@ void EPD_Sleep(void) {
     eink_regs[cur_model_index].sleep();
 }
 
-static int32_t l_eink_callback(lua_State *L, void* ptr){
-    rtos_msg_t* msg = (rtos_msg_t*)lua_topointer(L, -1);
-    luat_release_rtos_timer(econf.readbusy_timer);
-    luat_cbcwait(L, econf.idp, 1);
-    return 0;
-}
-
-static LUAT_RT_RET_TYPE readbusy_timer_cb(LUAT_RT_CB_PARAM){
-    rtos_msg_t msg = {
-		.handler = l_eink_callback,
-	};
-    if (econf.timer_count++ > 300){//30s
-        luat_cbcwait_noarg(econf.idp);
-        luat_stop_rtos_timer(econf.readbusy_timer);
-        luat_msgbus_put(&msg, 0);
-        return;
-    }
-    eink_async_t* async_cmd = (eink_async_t *)param;
-    if (async_cmd->level){
-        if(DEV_Digital_Read(EPD_BUSY_PIN)) {
-            if (async_cmd->send_cmd){
-                DEV_Digital_Write(EPD_DC_PIN, 0);
-                DEV_Digital_Write(EPD_CS_PIN, 0);
-                DEV_SPI_WriteByte(0x71);
-                DEV_Digital_Write(EPD_CS_PIN, 1);
-            }
-            luat_cbcwait_noarg(econf.idp);
-            luat_stop_rtos_timer(econf.readbusy_timer);
-            luat_msgbus_put(&msg, 0);
-        }
-    }else{
-        if(DEV_Digital_Read(EPD_BUSY_PIN)==0) {
-            luat_cbcwait_noarg(econf.idp);
-            luat_stop_rtos_timer(econf.readbusy_timer);
-            luat_msgbus_put(&msg, 0);
-        }
-    }
-}
-
-void EPD_Busy_WaitUntil(uint8_t level,uint8_t send_cmd){
-    uint16_t count = 200;//20s
-    econf.async_cmd.level = level;
-    econf.async_cmd.send_cmd = send_cmd;
-    if (econf.async){
-        econf.readbusy_timer = luat_create_rtos_timer(readbusy_timer_cb, &econf.async_cmd, NULL);
-        luat_start_rtos_timer(econf.readbusy_timer, 100, 1);
-    }else{
-        while(1){
-            if (level){
-                if (send_cmd){
-                    DEV_Digital_Write(EPD_DC_PIN, 0);
-                    DEV_Digital_Write(EPD_CS_PIN, 0);
-                    DEV_SPI_WriteByte(0x71);
-                    DEV_Digital_Write(EPD_CS_PIN, 1);
-                }
-                if(DEV_Digital_Read(EPD_BUSY_PIN)) 
-                    break;
-            }else{
-                if(DEV_Digital_Read(EPD_BUSY_PIN)==0) 
-                    break;
-            }
-            if(!(count--)){
-                Debug("error: e-Paper busy timeout!!!\r\n");
-                return;
-            }
-            else
-                DEV_Delay_ms(100);
-        }
-        DEV_Delay_ms(100);
-    }
-}

+ 2 - 4
components/epaper/epd.h

@@ -3,7 +3,6 @@
 #define EPD_EPD
 
 #include "stdio.h"
-#include "Debug.h"
 #include "DEV_Config.h"
 
 void EPD_Model(UBYTE model);
@@ -11,7 +10,6 @@ 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_Busy_WaitUntil(uint8_t level,uint8_t send_cmd);
 
 enum EPD_MODEL {
         MODEL_1in02d = 1,
@@ -19,7 +17,7 @@ enum EPD_MODEL {
         MODEL_1in54b,
         MODEL_1in54b_V2,
         MODEL_1in54c,
-        MODEL_1in54f,
+        // MODEL_1in54f,
         MODEL_1in54_V2,
         MODEL_1in54_V3,
         MODEL_2in13,
@@ -35,7 +33,7 @@ enum EPD_MODEL {
         MODEL_2in9bc,
         MODEL_2in9b_V3,
         MODEL_2in9d,
-        MODEL_2in9ff,
+        // MODEL_2in9ff,
         MODEL_2in9_V2,
         MODEL_3in7,
         MODEL_4in2,