epd1in54.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. /**
  2. * @filename : epd1in54.h
  3. * @brief : Header file for e-paper library epd1in54.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 uint8_t
  29. typedef unsigned char uint8_t;
  30. #endif
  31. #ifndef uint16_t
  32. typedef unsigned short uint16_t;
  33. #endif
  34. // Display resolution
  35. #define EPD_1IN54F_WIDTH 200
  36. #define EPD_1IN54F_HEIGHT 200
  37. // EPD1IN54 commands
  38. #define DRIVER_OUTPUT_CONTROL 0x01
  39. #define BOOSTER_SOFT_START_CONTROL 0x0C
  40. #define GATE_SCAN_START_POSITION 0x0F
  41. #define DEEP_SLEEP_MODE 0x07 // 0x10
  42. #define DATA_ENTRY_MODE_SETTING 0x11
  43. #define SW_RESET 0x12
  44. #define TEMPERATURE_SENSOR_CONTROL 0x1A
  45. #define MASTER_ACTIVATION 0x20
  46. #define DISPLAY_UPDATE_CONTROL_1 0x21
  47. #define DISPLAY_UPDATE_CONTROL_2 0x22
  48. #define WRITE_RAM 0x24
  49. #define WRITE_VCOM_REGISTER 0x2C
  50. #define WRITE_LUT_REGISTER 0x32
  51. #define SET_DUMMY_LINE_PERIOD 0x3A
  52. #define SET_GATE_TIME 0x3B
  53. #define BORDER_WAVEFORM_CONTROL 0x3C
  54. #define SET_RAM_X_ADDRESS_START_END_POSITION 0x44
  55. #define SET_RAM_Y_ADDRESS_START_END_POSITION 0x45
  56. #define SET_RAM_X_ADDRESS_COUNTER 0x4E
  57. #define SET_RAM_Y_ADDRESS_COUNTER 0x4F
  58. #define TERMINATE_FRAME_READ_WRITE 0xFF
  59. static const unsigned char lut_full_update[];
  60. // static const unsigned char lut_partial_update[];
  61. typedef struct EPD_t {
  62. int reset_pin;
  63. int dc_pin;
  64. int cs_pin;
  65. int busy_pin;
  66. int width;
  67. int height;
  68. const unsigned char* lut;
  69. } EPD;
  70. /* Hardware operating functions */
  71. /* public functions */
  72. int EPD_1IN54F_Init(EPD* epd, const unsigned char* lut);
  73. void EPD_1IN54F_SendCommand(EPD* epd, unsigned char command);
  74. void EPD_1IN54F_SendData(EPD* epd, unsigned char data);
  75. void EPD_1IN54F_WaitUntilIdle(EPD* epd);
  76. void EPD_1IN54F_Reset(EPD* epd);
  77. void EPD_1IN54F_SetFrameMemory(
  78. EPD* epd,
  79. const unsigned char* image_buffer,
  80. int x,
  81. int y,
  82. int image_width,
  83. int image_height
  84. );
  85. void EPD_1IN54F_ClearFrameMemory(EPD* epd, unsigned char color);
  86. void EPD_1IN54F_DisplayFrame(EPD* epd);
  87. void EPD_1IN54F_Sleep(EPD* epd);
  88. void EPD_1IN54F_DelayMs(EPD* epd, unsigned int delay_time);
  89. void EPD_1IN54F_DigitalWrite(EPD* epd, int pin, int value);
  90. int EPD_1IN54F_DigitalRead(EPD* epd, int pin);
  91. /* private functions */
  92. static void EPD_1IN54F_SetLut(EPD* epd, const unsigned char* lut);
  93. static void EPD_1IN54F_SetMemoryArea(EPD* epd, int x_start, int y_start, int x_end, int y_end);
  94. static void EPD_1IN54F_SetMemoryPointer(EPD* epd, int x, int y);
  95. void jd79653a_lv_fb_flush(
  96. EPD* epd,
  97. const unsigned char *color_map,
  98. int x,
  99. int y,
  100. int image_width,
  101. int image_height
  102. );
  103. #endif /* EPD1IN54_H */
  104. /* END OF FILE */