epd7in5_V2_old.py 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530
  1. # *****************************************************************************
  2. # * | File : epd7in5.py
  3. # * | Author : Waveshare team
  4. # * | Function : Electronic paper driver
  5. # * | Info :
  6. # *----------------
  7. # * | This version: V4.0
  8. # * | Date : 2019-06-20
  9. # # | Info : python demo
  10. # -----------------------------------------------------------------------------
  11. # Permission is hereby granted, free of charge, to any person obtaining a copy
  12. # of this software and associated documnetation files (the "Software"), to deal
  13. # in the Software without restriction, including without limitation the rights
  14. # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  15. # copies of the Software, and to permit persons to whom the Software is
  16. # furished to do so, subject to the following conditions:
  17. #
  18. # The above copyright notice and this permission notice shall be included in
  19. # all copies or substantial portions of the Software.
  20. #
  21. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  22. # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  23. # FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  24. # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  25. # LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  26. # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  27. # THE SOFTWARE.
  28. #
  29. import logging
  30. from . import epdconfig
  31. # Display resolution
  32. EPD_WIDTH = 800
  33. EPD_HEIGHT = 480
  34. logger = logging.getLogger(__name__)
  35. class EPD:
  36. def __init__(self):
  37. self.reset_pin = epdconfig.RST_PIN
  38. self.dc_pin = epdconfig.DC_PIN
  39. self.busy_pin = epdconfig.BUSY_PIN
  40. self.cs_pin = epdconfig.CS_PIN
  41. self.width = EPD_WIDTH
  42. self.height = EPD_HEIGHT
  43. Voltage_Frame_7IN5_V2 = [
  44. 0x6, 0x3F, 0x3F, 0x11, 0x24, 0x7, 0x17,
  45. ]
  46. LUT_VCOM_7IN5_V2 = [
  47. 0x0, 0xF, 0xF, 0x0, 0x0, 0x1,
  48. 0x0, 0xF, 0x1, 0xF, 0x1, 0x2,
  49. 0x0, 0xF, 0xF, 0x0, 0x0, 0x1,
  50. 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
  51. 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
  52. 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
  53. 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
  54. ]
  55. LUT_WW_7IN5_V2 = [
  56. 0x10, 0xF, 0xF, 0x0, 0x0, 0x1,
  57. 0x84, 0xF, 0x1, 0xF, 0x1, 0x2,
  58. 0x20, 0xF, 0xF, 0x0, 0x0, 0x1,
  59. 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
  60. 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
  61. 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
  62. 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
  63. ]
  64. LUT_BW_7IN5_V2 = [
  65. 0x10, 0xF, 0xF, 0x0, 0x0, 0x1,
  66. 0x84, 0xF, 0x1, 0xF, 0x1, 0x2,
  67. 0x20, 0xF, 0xF, 0x0, 0x0, 0x1,
  68. 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
  69. 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
  70. 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
  71. 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
  72. ]
  73. LUT_WB_7IN5_V2 = [
  74. 0x80, 0xF, 0xF, 0x0, 0x0, 0x1,
  75. 0x84, 0xF, 0x1, 0xF, 0x1, 0x2,
  76. 0x40, 0xF, 0xF, 0x0, 0x0, 0x1,
  77. 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
  78. 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
  79. 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
  80. 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
  81. ]
  82. LUT_BB_7IN5_V2 = [
  83. 0x80, 0xF, 0xF, 0x0, 0x0, 0x1,
  84. 0x84, 0xF, 0x1, 0xF, 0x1, 0x2,
  85. 0x40, 0xF, 0xF, 0x0, 0x0, 0x1,
  86. 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
  87. 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
  88. 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
  89. 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
  90. ]
  91. Lut_all_fresh=[0x67, 0xBF, 0x3F, 0x0D, 0x00, 0x1C,
  92. #VCOM
  93. 0x00, 0x32, 0x32, 0x00, 0x00, 0x01,
  94. 0x00, 0x0A, 0x0A, 0x00, 0x00, 0x00,
  95. 0x00, 0x28, 0x00, 0x00, 0x00, 0x00,
  96. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  97. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  98. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  99. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  100. #WW
  101. 0x60, 0x32, 0x32, 0x00, 0x00, 0x01,
  102. 0x60, 0x0A, 0x0A, 0x00, 0x00, 0x00,
  103. 0x80, 0x28, 0x00, 0x00, 0x00, 0x00,
  104. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  105. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  106. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  107. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  108. #BW
  109. 0x60, 0x32, 0x32, 0x00, 0x00, 0x01,
  110. 0x60, 0x0A, 0x0A, 0x00, 0x00, 0x00,
  111. 0x80, 0x28, 0x00, 0x00, 0x00, 0x00,
  112. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  113. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  114. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  115. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  116. #WB
  117. 0x90, 0x32, 0x32, 0x00, 0x00, 0x01,
  118. 0x60, 0x0A, 0x0A, 0x00, 0x00, 0x00,
  119. 0x40, 0x28, 0x00, 0x00, 0x00, 0x00,
  120. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  121. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  122. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  123. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  124. #BB
  125. 0x90, 0x32, 0x32, 0x00, 0x00, 0x01,
  126. 0x60, 0x0A, 0x0A, 0x00, 0x00, 0x00,
  127. 0x40, 0x28, 0x00, 0x00, 0x00, 0x00,
  128. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  129. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  130. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  131. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  132. #Reserved
  133. 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
  134. 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
  135. 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
  136. 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
  137. 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
  138. 0xFF,
  139. ]
  140. Lut_partial=[0x67, 0xBF, 0x3F, 0x0D, 0x00, 0x1C,
  141. #VCOM
  142. 0x00, 0x14, 0x02, 0x00, 0x00, 0x01,
  143. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  144. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  145. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  146. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  147. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  148. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  149. #WW
  150. 0x20, 0x14, 0x02, 0x00, 0x00, 0x01,
  151. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  152. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  153. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  154. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  155. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  156. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  157. #BW
  158. 0x80, 0x14, 0x02, 0x00, 0x00, 0x01,
  159. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  160. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  161. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  162. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  163. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  164. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  165. #WB
  166. 0x40, 0x14, 0x02, 0x00, 0x00, 0x01,
  167. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  168. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  169. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  170. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  171. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  172. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  173. #BB
  174. 0x00, 0x14, 0x02, 0x00, 0x00, 0x01,
  175. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  176. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  177. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  178. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  179. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  180. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  181. #Reserved
  182. 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
  183. 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
  184. 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
  185. 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
  186. 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
  187. 0xFF,
  188. ]
  189. # Hardware reset
  190. def reset(self):
  191. epdconfig.digital_write(self.reset_pin, 1)
  192. epdconfig.delay_ms(20)
  193. epdconfig.digital_write(self.reset_pin, 0)
  194. epdconfig.delay_ms(2)
  195. epdconfig.digital_write(self.reset_pin, 1)
  196. epdconfig.delay_ms(20)
  197. def send_command(self, command):
  198. epdconfig.digital_write(self.dc_pin, 0)
  199. epdconfig.digital_write(self.cs_pin, 0)
  200. epdconfig.spi_writebyte([command])
  201. epdconfig.digital_write(self.cs_pin, 1)
  202. def send_data(self, data):
  203. epdconfig.digital_write(self.dc_pin, 1)
  204. epdconfig.digital_write(self.cs_pin, 0)
  205. epdconfig.spi_writebyte([data])
  206. epdconfig.digital_write(self.cs_pin, 1)
  207. def send_data2(self, data):
  208. epdconfig.digital_write(self.dc_pin, 1)
  209. epdconfig.digital_write(self.cs_pin, 0)
  210. epdconfig.spi_writebyte2(data)
  211. epdconfig.digital_write(self.cs_pin, 1)
  212. def ReadBusy(self):
  213. logger.debug("e-Paper busy")
  214. self.send_command(0x71)
  215. busy = epdconfig.digital_read(self.busy_pin)
  216. while(busy == 0):
  217. self.send_command(0x71)
  218. busy = epdconfig.digital_read(self.busy_pin)
  219. epdconfig.delay_ms(20)
  220. logger.debug("e-Paper busy release")
  221. def SetLut(self, lut_vcom, lut_ww, lut_bw, lut_wb, lut_bb):
  222. self.send_command(0x20)
  223. for count in range(0, 42):
  224. self.send_data(lut_vcom[count])
  225. self.send_command(0x21)
  226. for count in range(0, 42):
  227. self.send_data(lut_ww[count])
  228. self.send_command(0x22)
  229. for count in range(0, 42):
  230. self.send_data(lut_bw[count])
  231. self.send_command(0x23)
  232. for count in range(0, 42):
  233. self.send_data(lut_wb[count])
  234. self.send_command(0x24)
  235. for count in range(0, 42):
  236. self.send_data(lut_bb[count])
  237. def init(self):
  238. if (epdconfig.module_init() != 0):
  239. return -1
  240. # EPD hardware init start
  241. self.reset()
  242. # self.send_command(0x06) # btst
  243. # self.send_data(0x17)
  244. # self.send_data(0x17)
  245. # self.send_data(0x28) # If an exception is displayed, try using 0x38
  246. # self.send_data(0x17)
  247. # self.send_command(0x01) #POWER SETTING
  248. # self.send_data(0x07)
  249. # self.send_data(0x07) #VGH=20V,VGL=-20V
  250. # self.send_data(0x3f) #VDH=15V
  251. # self.send_data(0x3f) #VDL=-15V
  252. self.send_command(0x01) # power setting
  253. self.send_data(0x17) # 1-0=11: internal power
  254. self.send_data(self.Voltage_Frame_7IN5_V2[6]) # VGH&VGL
  255. self.send_data(self.Voltage_Frame_7IN5_V2[1]) # VSH
  256. self.send_data(self.Voltage_Frame_7IN5_V2[2]) # VSL
  257. self.send_data(self.Voltage_Frame_7IN5_V2[3]) # VSHR
  258. self.send_command(0x82) # VCOM DC Setting
  259. self.send_data(self.Voltage_Frame_7IN5_V2[4]) # VCOM
  260. self.send_command(0x06) # Booster Setting
  261. self.send_data(0x27)
  262. self.send_data(0x27)
  263. self.send_data(0x2F)
  264. self.send_data(0x17)
  265. self.send_command(0x30) # OSC Setting
  266. self.send_data(self.Voltage_Frame_7IN5_V2[0]) # 3C=50Hz, 3A=100HZ
  267. self.send_command(0x04) # POWER ON
  268. epdconfig.delay_ms(100)
  269. self.ReadBusy()
  270. self.send_command(0X00) # PANNEL SETTING
  271. self.send_data(0x3F) # KW-3f KWR-2F BWROTP-0f BWOTP-1f
  272. self.send_command(0x61) # tres
  273. self.send_data(0x03) # source 800
  274. self.send_data(0x20)
  275. self.send_data(0x01) # gate 480
  276. self.send_data(0xE0)
  277. self.send_command(0X15)
  278. self.send_data(0x00)
  279. self.send_command(0X50) # VCOM AND DATA INTERVAL SETTING
  280. self.send_data(0x10)
  281. self.send_data(0x07)
  282. self.send_command(0X60) # TCON SETTING
  283. self.send_data(0x22)
  284. self.send_command(0x65) # Resolution setting
  285. self.send_data(0x00)
  286. self.send_data(0x00) # 800*480
  287. self.send_data(0x00)
  288. self.send_data(0x00)
  289. self.SetLut(self.LUT_VCOM_7IN5_V2, self.LUT_WW_7IN5_V2, self.LUT_BW_7IN5_V2, self.LUT_WB_7IN5_V2, self.LUT_BB_7IN5_V2)
  290. # EPD hardware init end
  291. return 0
  292. def Epaper_LUT_By_MCU(self,wavedata):
  293. VCEND=wavedata[0]&0x08
  294. BDEND=(wavedata[1]&0xC0)>>6
  295. EVS=VCEND|BDEND
  296. PLL=(wavedata[0]&0xF0)>>4
  297. XON=wavedata[2]&0xC0
  298. self.send_command(0x52) #EVS
  299. self.send_data(EVS)
  300. self.send_command(0x30) #PLL setting
  301. self.send_data(PLL)
  302. self.send_command(0x01) #Set VGH VGL VSH VSL VSHR
  303. self.send_data (0x17)
  304. self.send_data (wavedata[0]&0x07) #VGH/VGL Voltage Level selection
  305. self.send_data (wavedata[1]&0x3F) #VSH for black
  306. self.send_data (wavedata[2]&0x3F) #VSL for white
  307. self.send_data (wavedata[3]&0x3F) #VSHR for red
  308. self.send_command(0x2A) #LUTOPT
  309. self.send_data(XON)
  310. self.send_data(wavedata[4])
  311. self.send_command(0x82) #VCOM_DC setting
  312. self.send_data (wavedata[5]) #Vcom value
  313. self.send_command(0x20)
  314. self.send_data2(wavedata[6:48])
  315. self.send_command(0x21)
  316. self.send_data2(wavedata[48:90])
  317. self.send_command(0x22)
  318. self.send_data2(wavedata[90:132])
  319. self.send_command(0x23)
  320. self.send_data2(wavedata[132:174])
  321. self.send_command(0x24)
  322. self.send_data2(wavedata[174:216])
  323. def init2(self):
  324. if (epdconfig.module_init() != 0):
  325. return -1
  326. # EPD hardware init start
  327. self.reset()
  328. self.send_command(0x00) # Panel setting
  329. self.send_data(0x3F)
  330. self.send_command(0x06) # Booster Setting
  331. self.send_data(0x17)
  332. self.send_data(0x17)
  333. self.send_data(0x28)
  334. self.send_data(0x18)
  335. self.send_command(0x50) # VCOM and DATA interval setting
  336. self.send_data(0x22)
  337. self.send_data(0x07)
  338. self.send_command(0x60) # TCON setting
  339. self.send_data(0x22) # S-G G-S
  340. self.send_command(0x61) # Resolution setting
  341. self.send_data(0x03)#800*480
  342. self.send_data(0x20)
  343. self.send_data(0x01)
  344. self.send_data(0xE0)
  345. self.send_command(0x65) # Resolution setting
  346. self.send_data(0x00)
  347. self.send_data(0x00)
  348. self.send_data(0x00)
  349. self.send_data(0x00)
  350. self.send_command(0x04) #POWER ON
  351. epdconfig.delay_ms(100)
  352. self.ReadBusy()
  353. return 0
  354. def init_fast(self):
  355. self.init2()
  356. self.Epaper_LUT_By_MCU(self.Lut_all_fresh)
  357. return 0
  358. def init_part(self):
  359. self.init2()
  360. self.Epaper_LUT_By_MCU(self.Lut_partial)
  361. return 0
  362. def getbuffer(self, image):
  363. img = image
  364. imwidth, imheight = img.size
  365. if(imwidth == self.width and imheight == self.height):
  366. img = img.convert('1')
  367. elif(imwidth == self.height and imheight == self.width):
  368. # image has correct dimensions, but needs to be rotated
  369. img = img.rotate(90, expand=True).convert('1')
  370. else:
  371. logger.warning("Wrong image dimensions: must be " + str(self.width) + "x" + str(self.height))
  372. # return a blank buffer
  373. return [0x00] * (int(self.width/8) * self.height)
  374. buf = bytearray(img.tobytes('raw'))
  375. # The bytes need to be inverted, because in the PIL world 0=black and 1=white, but
  376. # in the e-paper world 0=white and 1=black.
  377. for i in range(len(buf)):
  378. buf[i] ^= 0xFF
  379. return buf
  380. def display(self, image):
  381. if(self.width % 8 == 0):
  382. Width = self.width // 8
  383. else:
  384. Width = self.width // 8 +1
  385. Height = self.height
  386. image1 = [0xFF] * int(self.width * self.height / 8)
  387. for j in range(Height):
  388. for i in range(Width):
  389. image1[i + j * Width] = ~image[i + j * Width]
  390. self.send_command(0x10)
  391. self.send_data2(image1)
  392. self.send_command(0x13)
  393. self.send_data2(image)
  394. self.send_command(0x12)
  395. epdconfig.delay_ms(100)
  396. self.ReadBusy()
  397. def Clear(self):
  398. self.send_command(0x10)
  399. self.send_data2([0xFF] * int(self.width * self.height / 8))
  400. self.send_command(0x13)
  401. self.send_data2([0x00] * int(self.width * self.height / 8))
  402. self.send_command(0x12)
  403. epdconfig.delay_ms(100)
  404. self.ReadBusy()
  405. def display_Partial(self, Image, Xstart, Ystart, Xend, Yend):
  406. if((Xstart % 8 + Xend % 8 == 8 & Xstart % 8 > Xend % 8) | Xstart % 8 + Xend % 8 == 0 | (Xend - Xstart)%8 == 0):
  407. Xstart = Xstart // 8 * 8
  408. Xend = Xend // 8 * 8
  409. else:
  410. Xstart = Xstart // 8 * 8
  411. if Xend % 8 == 0:
  412. Xend = Xend // 8 * 8
  413. else:
  414. Xend = Xend // 8 * 8 + 1
  415. Width = (Xend - Xstart) // 8
  416. Height = Yend - Ystart
  417. self.send_command(0x50)
  418. self.send_data(0xA9)
  419. self.send_data(0x07)
  420. self.send_command(0x91) #This command makes the display enter partial mode
  421. self.send_command(0x90) #resolution setting
  422. self.send_data (Xstart//256)
  423. self.send_data (Xstart%256) #x-start
  424. self.send_data ((Xend-1)//256)
  425. self.send_data ((Xend-1)%256) #x-end
  426. self.send_data (Ystart//256) #
  427. self.send_data (Ystart%256) #y-start
  428. self.send_data ((Yend-1)//256)
  429. self.send_data ((Yend-1)%256) #y-end
  430. self.send_data (0x01)
  431. image1 = [0xFF] * int(self.width * self.height / 8)
  432. for j in range(Height):
  433. for i in range(Width):
  434. image1[i + j * Width] = ~Image[i + j * Width]
  435. self.send_command(0x13) #Write Black and White image to RAM
  436. self.send_data2(image1)
  437. self.send_command(0x12)
  438. epdconfig.delay_ms(100)
  439. self.ReadBusy()
  440. def sleep(self):
  441. self.send_command(0x02) # POWER_OFF
  442. self.ReadBusy()
  443. self.send_command(0x07) # DEEP_SLEEP
  444. self.send_data(0XA5)
  445. epdconfig.delay_ms(2000)
  446. epdconfig.module_exit()
  447. ### END OF FILE ###