epd2in9.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. /**
  2. * @filename : epd2in9.h
  3. * @brief : Header file for e-paper library epd2in9.c
  4. * @author : Yehui from Waveshare
  5. *
  6. * Copyright (C) Waveshare September 12 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. #ifndef EPD2IN9_H
  29. #define EPD2IN9_H
  30. #ifndef uint8_t
  31. typedef unsigned char uint8_t;
  32. #endif
  33. #ifndef uint16_t
  34. typedef unsigned short uint16_t;
  35. #endif
  36. // Display resolution
  37. #define EPD_2IN9F_WIDTH 128
  38. #define EPD_2IN9F_HEIGHT 296
  39. // EPD2IN9 commands
  40. #define DRIVER_OUTPUT_CONTROL 0x01
  41. #define BOOSTER_SOFT_START_CONTROL 0x0C
  42. #define GATE_SCAN_START_POSITION 0x0F
  43. #define DEEP_SLEEP_MODE 0x10
  44. #define DATA_ENTRY_MODE_SETTING 0x11
  45. #define SW_RESET 0x12
  46. #define TEMPERATURE_SENSOR_CONTROL 0x1A
  47. #define MASTER_ACTIVATION 0x20
  48. #define DISPLAY_UPDATE_CONTROL_1 0x21
  49. #define DISPLAY_UPDATE_CONTROL_2 0x22
  50. #define WRITE_RAM 0x24
  51. #define WRITE_VCOM_REGISTER 0x2C
  52. #define WRITE_LUT_REGISTER 0x32
  53. #define SET_DUMMY_LINE_PERIOD 0x3A
  54. #define SET_GATE_TIME 0x3B
  55. #define BORDER_WAVEFORM_CONTROL 0x3C
  56. #define SET_RAM_X_ADDRESS_START_END_POSITION 0x44
  57. #define SET_RAM_Y_ADDRESS_START_END_POSITION 0x45
  58. #define SET_RAM_X_ADDRESS_COUNTER 0x4E
  59. #define SET_RAM_Y_ADDRESS_COUNTER 0x4F
  60. #define TERMINATE_FRAME_READ_WRITE 0xFF
  61. static const unsigned char lut_full_update[];
  62. // static const unsigned char lut_partial_update[];
  63. typedef struct EPD_2IN9F_t {
  64. int reset_pin;
  65. int dc_pin;
  66. int cs_pin;
  67. int busy_pin;
  68. int width;
  69. int height;
  70. const unsigned char* lut;
  71. } EPD;
  72. /* Hardware operating functions */
  73. /* public functions */
  74. int EPD_2IN9F_Init(EPD* epd, const unsigned char* lut);
  75. void EPD_2IN9F_SendCommand(EPD* epd, unsigned char command);
  76. void EPD_2IN9F_SendData(EPD* epd, unsigned char data);
  77. void EPD_2IN9F_WaitUntilIdle(EPD* epd);
  78. void EPD_2IN9F_Reset(EPD* epd);
  79. void EPD_2IN9F_SetFrameMemory(
  80. EPD* epd,
  81. const unsigned char* image_buffer,
  82. int x,
  83. int y,
  84. int image_width,
  85. int image_height
  86. );
  87. void EPD_2IN9F_ClearFrameMemory(EPD* epd, unsigned char color);
  88. void EPD_2IN9F_DisplayFrame(EPD* epd);
  89. void EPD_2IN9F_Sleep(EPD* epd);
  90. void EPD_2IN9F_DelayMs(EPD* epd, unsigned int delay_time);
  91. void EPD_2IN9F_DigitalWrite(EPD* epd, int pin, int value);
  92. int EPD_2IN9F_DigitalRead(EPD* epd, int pin);
  93. /* private functions */
  94. static void EPD_2IN9F_SetLut(EPD* epd, const unsigned char* lut);
  95. static void EPD_2IN9F_SetMemoryArea(EPD* epd, int x_start, int y_start, int x_end, int y_end);
  96. static void EPD_2IN9F_SetMemoryPointer(EPD* epd, int x, int y);
  97. #endif /* EPD2IN9_H */
  98. /* END OF FILE */