epd2in13.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. /**
  2. * @filename : epd2in13.h
  3. * @brief : Header file for e-paper display library epd2in13.cpp
  4. * @author : Yehui from Waveshare
  5. *
  6. * Copyright (C) Waveshare September 9 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 EPD2IN13_H
  27. #define EPD2IN13_H
  28. #include "epdif.h"
  29. // Display resolution
  30. /* the resolution is 122x250 in fact */
  31. /* however, the logical resolution is 128x250 */
  32. #define EPD_WIDTH 128
  33. #define EPD_HEIGHT 250
  34. // EPD2IN13 commands
  35. #define DRIVER_OUTPUT_CONTROL 0x01
  36. #define BOOSTER_SOFT_START_CONTROL 0x0C
  37. #define GATE_SCAN_START_POSITION 0x0F
  38. #define DEEP_SLEEP_MODE 0x10
  39. #define DATA_ENTRY_MODE_SETTING 0x11
  40. #define SW_RESET 0x12
  41. #define TEMPERATURE_SENSOR_CONTROL 0x1A
  42. #define MASTER_ACTIVATION 0x20
  43. #define DISPLAY_UPDATE_CONTROL_1 0x21
  44. #define DISPLAY_UPDATE_CONTROL_2 0x22
  45. #define WRITE_RAM 0x24
  46. #define WRITE_VCOM_REGISTER 0x2C
  47. #define WRITE_LUT_REGISTER 0x32
  48. #define SET_DUMMY_LINE_PERIOD 0x3A
  49. #define SET_GATE_TIME 0x3B
  50. #define BORDER_WAVEFORM_CONTROL 0x3C
  51. #define SET_RAM_X_ADDRESS_START_END_POSITION 0x44
  52. #define SET_RAM_Y_ADDRESS_START_END_POSITION 0x45
  53. #define SET_RAM_X_ADDRESS_COUNTER 0x4E
  54. #define SET_RAM_Y_ADDRESS_COUNTER 0x4F
  55. #define TERMINATE_FRAME_READ_WRITE 0xFF
  56. extern const unsigned char lut_full_update[];
  57. extern const unsigned char lut_partial_update[];
  58. class Epd : EpdIf {
  59. public:
  60. unsigned long width;
  61. unsigned long height;
  62. Epd();
  63. ~Epd();
  64. int Init(const unsigned char* lut);
  65. void SendCommand(unsigned char command);
  66. void SendData(unsigned char data);
  67. void WaitUntilIdle(void);
  68. void Reset(void);
  69. void SetFrameMemory(
  70. const unsigned char* image_buffer,
  71. int x,
  72. int y,
  73. int image_width,
  74. int image_height
  75. );
  76. void SetFrameMemory(const unsigned char* image_buffer);
  77. void ClearFrameMemory(unsigned char color);
  78. void DisplayFrame(void);
  79. void Sleep(void);
  80. private:
  81. unsigned int reset_pin;
  82. unsigned int dc_pin;
  83. unsigned int cs_pin;
  84. unsigned int busy_pin;
  85. const unsigned char* lut;
  86. void SetLut(const unsigned char* lut);
  87. void SetMemoryArea(int x_start, int y_start, int x_end, int y_end);
  88. void SetMemoryPointer(int x, int y);
  89. };
  90. #endif /* EPD2IN13_H */
  91. /* END OF FILE */