epd4in2.h 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. /**
  2. * @filename : epd4in2.h
  3. * @brief : Header file for Dual-color e-paper library epd4in2.cpp
  4. * @author : Yehui from Waveshare
  5. *
  6. * Copyright (C) Waveshare August 10 2017
  7. *
  8. * Permission is hereby granted, free of charge, to any person obtaining a copy
  9. * of this software and associated documnetation files (the "Software"), to deal
  10. * in the Software without restriction, including without limitation the rights
  11. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  12. * copies of the Software, and to permit persons to whom the Software is
  13. * furished to do so, subject to the following conditions:
  14. *
  15. * The above copyright notice and this permission notice shall be included in
  16. * all copies or substantial portions of the Software.
  17. *
  18. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  19. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  20. * FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  21. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  22. * LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  23. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  24. * THE SOFTWARE.
  25. */
  26. #ifndef EPD4IN2_H
  27. #define EPD4IN2_H
  28. #include "epdif.h"
  29. // Display resolution
  30. #define EPD_WIDTH 400
  31. #define EPD_HEIGHT 300
  32. // EPD4IN2 commands
  33. #define PANEL_SETTING 0x00
  34. #define POWER_SETTING 0x01
  35. #define POWER_OFF 0x02
  36. #define POWER_OFF_SEQUENCE_SETTING 0x03
  37. #define POWER_ON 0x04
  38. #define POWER_ON_MEASURE 0x05
  39. #define BOOSTER_SOFT_START 0x06
  40. #define DEEP_SLEEP 0x07
  41. #define DATA_START_TRANSMISSION_1 0x10
  42. #define DATA_STOP 0x11
  43. #define DISPLAY_REFRESH 0x12
  44. #define DATA_START_TRANSMISSION_2 0x13
  45. #define LUT_FOR_VCOM 0x20
  46. #define LUT_WHITE_TO_WHITE 0x21
  47. #define LUT_BLACK_TO_WHITE 0x22
  48. #define LUT_WHITE_TO_BLACK 0x23
  49. #define LUT_BLACK_TO_BLACK 0x24
  50. #define PLL_CONTROL 0x30
  51. #define TEMPERATURE_SENSOR_COMMAND 0x40
  52. #define TEMPERATURE_SENSOR_SELECTION 0x41
  53. #define TEMPERATURE_SENSOR_WRITE 0x42
  54. #define TEMPERATURE_SENSOR_READ 0x43
  55. #define VCOM_AND_DATA_INTERVAL_SETTING 0x50
  56. #define LOW_POWER_DETECTION 0x51
  57. #define TCON_SETTING 0x60
  58. #define RESOLUTION_SETTING 0x61
  59. #define GSST_SETTING 0x65
  60. #define GET_STATUS 0x71
  61. #define AUTO_MEASUREMENT_VCOM 0x80
  62. #define READ_VCOM_VALUE 0x81
  63. #define VCM_DC_SETTING 0x82
  64. #define PARTIAL_WINDOW 0x90
  65. #define PARTIAL_IN 0x91
  66. #define PARTIAL_OUT 0x92
  67. #define PROGRAM_MODE 0xA0
  68. #define ACTIVE_PROGRAMMING 0xA1
  69. #define READ_OTP 0xA2
  70. #define POWER_SAVING 0xE3
  71. extern const unsigned char lut_vcom0[];
  72. extern const unsigned char lut_ww[];
  73. extern const unsigned char lut_bw[];
  74. extern const unsigned char lut_bb[];
  75. extern const unsigned char lut_wb[];
  76. extern const unsigned char EPD_4IN2_4Gray_lut_vcom[];
  77. extern const unsigned char EPD_4IN2_4Gray_lut_ww[];
  78. extern const unsigned char EPD_4IN2_4Gray_lut_bw[];
  79. extern const unsigned char EPD_4IN2_4Gray_lut_wb[];
  80. extern const unsigned char EPD_4IN2_4Gray_lut_bb[];
  81. class Epd : EpdIf {
  82. public:
  83. unsigned int width;
  84. unsigned int height;
  85. Epd();
  86. ~Epd();
  87. int Init(void);
  88. int Init_4Gray(void);
  89. void SendCommand(unsigned char command);
  90. void SendData(unsigned char data);
  91. void WaitUntilIdle(void);
  92. void Reset(void);
  93. void SetPartialWindow(const unsigned char* frame_buffer, int x, int y, int w, int l);
  94. void SetPartialWindowBlack(const unsigned char* buffer_black, int x, int y, int w, int l);
  95. void SetPartialWindowRed(const unsigned char* buffer_red, int x, int y, int w, int l);
  96. void Set_4GrayDisplay(const char *Image, int x, int y, int w, int l);
  97. void SetLut(void);
  98. void set4Gray_lut(void);
  99. void DisplayFrame(const unsigned char* frame_buffer);
  100. void DisplayFrame(void);
  101. void ClearFrame(void);
  102. void Sleep(void);
  103. private:
  104. unsigned int reset_pin;
  105. unsigned int dc_pin;
  106. unsigned int cs_pin;
  107. unsigned int busy_pin;
  108. };
  109. #endif /* EPD4IN2_H */
  110. /* END OF FILE */