epd1in54.h 3.6 KB

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