diff --git a/RaspberryPi_JetsonNano/python/examples/epd_1in64g_test.py b/RaspberryPi_JetsonNano/python/examples/epd_1in64g_test.py index 9334760..6508616 100644 --- a/RaspberryPi_JetsonNano/python/examples/epd_1in64g_test.py +++ b/RaspberryPi_JetsonNano/python/examples/epd_1in64g_test.py @@ -30,29 +30,29 @@ try: font18 = ImageFont.truetype(os.path.join(picdir, 'Font.ttc'), 18) font30 = ImageFont.truetype(os.path.join(picdir, 'Font.ttc'), 40) - - # Drawing on the image - logging.info("1.Drawing on the image...") - Himage = Image.new('RGB', (epd.width, epd.height), 0xffffff) - draw = ImageDraw.Draw(Himage) - draw.text((5, 0), 'hello world', font = font18, fill = epd.RED) - draw.text((5, 20), '1.64inch e-Paper', font = font18, fill = epd.YELLOW) - draw.text((5, 40), u'微雪电子', font = font30, fill = epd.BLACK) + # # The Sunrise X3 PI is a bit problematic to use + # # Drawing on the image + # logging.info("1.Drawing on the image...") + # Himage = Image.new('RGB', (epd.width, epd.height), 0xffffff) + # draw = ImageDraw.Draw(Himage) + # draw.text((5, 0), 'hello world', font = font18, fill = epd.RED) + # draw.text((5, 20), '1.64inch e-Paper', font = font18, fill = epd.YELLOW) + # draw.text((5, 40), u'微雪电子', font = font30, fill = epd.BLACK) - draw.line((5, 90, 45, 160), fill = epd.RED) - draw.line((45, 90, 5, 160), fill = epd.YELLOW) - draw.rectangle((5, 90, 45, 160), outline = epd.BLACK) - draw.rectangle((55, 90, 95, 160), fill = epd.BLACK) - draw.arc((115, 90, 150, 125), 0, 360, fill = epd.BLACK) - draw.chord((115, 130, 150, 165), 0, 360, fill = epd.BLACK) - epd.display(epd.getbuffer(Himage)) - time.sleep(3) + # draw.line((5, 90, 45, 160), fill = epd.RED) + # draw.line((45, 90, 5, 160), fill = epd.YELLOW) + # draw.rectangle((5, 90, 45, 160), outline = epd.BLACK) + # draw.rectangle((55, 90, 95, 160), fill = epd.BLACK) + # draw.arc((115, 90, 150, 125), 0, 360, fill = epd.BLACK) + # draw.chord((115, 130, 150, 165), 0, 360, fill = epd.BLACK) + # epd.display(epd.getbuffer(Himage)) + # time.sleep(3) - # read bmp file - logging.info("3.read bmp file") - Himage = Image.open(os.path.join(picdir, '1.64inch-1.bmp')) - epd.display(epd.getbuffer(Himage)) - time.sleep(3) + # # read bmp file + # logging.info("3.read bmp file") + # Himage = Image.open(os.path.join(picdir, '1.64inch-1.bmp')) + # epd.display(epd.getbuffer(Himage)) + # time.sleep(3) logging.info("3.read bmp file") Himage = Image.open(os.path.join(picdir, '1.64inch-2.bmp')) diff --git a/RaspberryPi_JetsonNano/python/examples/epd_2in13d_test.py b/RaspberryPi_JetsonNano/python/examples/epd_2in13d_test.py index 04526c9..62c3ca4 100644 --- a/RaspberryPi_JetsonNano/python/examples/epd_2in13d_test.py +++ b/RaspberryPi_JetsonNano/python/examples/epd_2in13d_test.py @@ -22,7 +22,7 @@ try: epd = epd2in13d.EPD() logging.info("init and Clear") epd.init() - epd.Clear(0xFF) + epd.Clear() font15 = ImageFont.truetype(os.path.join(picdir, 'Font.ttc'), 15) font24 = ImageFont.truetype(os.path.join(picdir, 'Font.ttc'), 24) @@ -60,7 +60,7 @@ try: # partial update logging.info("5.show time...") # epd.init() - # epd.Clear(0xFF) + # epd.Clear() # time_image = Image.new('1', (epd.width, epd.height), 255) # time_draw = ImageDraw.Draw(time_image) # num = 0 @@ -76,7 +76,7 @@ try: logging.info("Clear...") epd.init() - epd.Clear(0xFF) + epd.Clear() logging.info("Goto Sleep...") epd.sleep() diff --git a/RaspberryPi_JetsonNano/python/examples/epd_2in9d_test.py b/RaspberryPi_JetsonNano/python/examples/epd_2in9d_test.py index 6e0d017..8a0c92c 100644 --- a/RaspberryPi_JetsonNano/python/examples/epd_2in9d_test.py +++ b/RaspberryPi_JetsonNano/python/examples/epd_2in9d_test.py @@ -21,7 +21,7 @@ try: epd = epd2in9d.EPD() logging.info("init and Clear") epd.init() - epd.Clear(0xFF) + epd.Clear() font24 = ImageFont.truetype(os.path.join(picdir, 'Font.ttc'), 24) font18 = ImageFont.truetype(os.path.join(picdir, 'Font.ttc'), 18) @@ -77,7 +77,7 @@ try: # # partial update logging.info("5.show time...") epd.init() - epd.Clear(0xFF) + epd.Clear() time_image = Image.new('1', (epd.width, epd.height), 255) time_draw = ImageDraw.Draw(time_image) @@ -94,7 +94,7 @@ try: epd.init() logging.info("Clear...") - epd.Clear(0xFF) + epd.Clear() time.sleep(2) logging.info("Goto Sleep...") epd.sleep() diff --git a/RaspberryPi_JetsonNano/python/examples/epd_3in52_test.py b/RaspberryPi_JetsonNano/python/examples/epd_3in52_test.py index a238411..22c8185 100644 --- a/RaspberryPi_JetsonNano/python/examples/epd_3in52_test.py +++ b/RaspberryPi_JetsonNano/python/examples/epd_3in52_test.py @@ -16,7 +16,7 @@ import traceback logging.basicConfig(level=logging.DEBUG) try: - logging.info("epd2in9 Demo") + logging.info("epd3in52 Demo") epd = epd3in52.EPD() logging.info("init and Clear") diff --git a/RaspberryPi_JetsonNano/python/examples/epd_7in3g_test.py b/RaspberryPi_JetsonNano/python/examples/epd_7in3g_test.py index 2b8f4f6..637f73f 100644 --- a/RaspberryPi_JetsonNano/python/examples/epd_7in3g_test.py +++ b/RaspberryPi_JetsonNano/python/examples/epd_7in3g_test.py @@ -16,7 +16,7 @@ import traceback logging.basicConfig(level=logging.DEBUG) try: - logging.info("epd1in64g Demo") + logging.info("epd7in3g Demo") BLACK = 0x00 WHITE = 0x55 diff --git a/RaspberryPi_JetsonNano/python/lib/waveshare_epd/epd1in54_V2.py b/RaspberryPi_JetsonNano/python/lib/waveshare_epd/epd1in54_V2.py index b489d9a..32d8f65 100644 --- a/RaspberryPi_JetsonNano/python/lib/waveshare_epd/epd1in54_V2.py +++ b/RaspberryPi_JetsonNano/python/lib/waveshare_epd/epd1in54_V2.py @@ -4,8 +4,8 @@ # * | Function : Electronic paper driver # * | Info : # *---------------- -# * | This version: V1 -# * | Date : 2019-06-20 +# * | This version: V1.1 +# * | Date : 2022-08-10 # # | Info : python demo # ----------------------------------------------------------------------------- # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -111,6 +111,13 @@ class EPD: epdconfig.digital_write(self.cs_pin, 0) epdconfig.spi_writebyte([data]) epdconfig.digital_write(self.cs_pin, 1) + + # send a lot of data + def send_data2(self, data): + epdconfig.digital_write(self.dc_pin, 1) + epdconfig.digital_write(self.cs_pin, 0) + epdconfig.spi_writebyte2(data) + epdconfig.digital_write(self.cs_pin, 1) def ReadBusy(self): logger.debug("e-Paper busy") @@ -132,8 +139,7 @@ class EPD: def lut(self, lut): self.send_command(0x32) # WRITE_LUT_REGISTER - for i in range(0, len(lut)): - self.send_data(lut[i]) + self.send_data2(lut) def set_lut(self, lut): self.lut(lut) @@ -153,15 +159,15 @@ class EPD: self.send_data(lut[158]) def SetWindows(self, Xstart, Ystart, Xend, Yend): - self.send_command(0x44); # SET_RAM_X_ADDRESS_START_END_POSITION - self.send_data((Xstart>>3) & 0xFF); - self.send_data((Xend>>3) & 0xFF); + self.send_command(0x44) # SET_RAM_X_ADDRESS_START_END_POSITION + self.send_data((Xstart>>3) & 0xFF) + self.send_data((Xend>>3) & 0xFF) - self.send_command(0x45); # SET_RAM_Y_ADDRESS_START_END_POSITION - self.send_data(Ystart & 0xFF); - self.send_data((Ystart >> 8) & 0xFF); - self.send_data(Yend & 0xFF); - self.send_data((Yend >> 8) & 0xFF); + self.send_command(0x45) # SET_RAM_Y_ADDRESS_START_END_POSITION + self.send_data(Ystart & 0xFF) + self.send_data((Ystart >> 8) & 0xFF) + self.send_data(Yend & 0xFF) + self.send_data((Yend >> 8) & 0xFF) def SetCursor(self, Xstart, Ystart): @@ -239,10 +245,13 @@ class EPD: self.set_lut(self.WF_Full_1IN54) # Set lut def Clear(self, color): + if self.width%8 == 0: + linewidth = int(self.width/8) + else: + linewidth = int(self.width/8) + 1 + self.send_command(0x24) - for j in range(0, self.height): - for i in range(0, int(self.width / 8)): - self.send_data(color) + self.send_data2([color] * self.height * linewidth) self.TurnOnDisplay() @@ -273,9 +282,7 @@ class EPD: return self.send_command(0x24) - for j in range(0, self.height): - for i in range(0, int(self.width / 8)): - self.send_data(image[i + j * int(self.width / 8)]) + self.send_data2(image) self.TurnOnDisplay() def displayPartBaseImage(self, image): @@ -283,14 +290,10 @@ class EPD: return self.send_command(0x24) - for j in range(0, self.height): - for i in range(0, int(self.width / 8)): - self.send_data(image[i + j * int(self.width / 8)]) + self.send_data2(image) self.send_command(0x26) - for j in range(0, self.height): - for i in range(0, int(self.width / 8)): - self.send_data(image[i + j * int(self.width / 8)]) + self.send_data2(image) self.TurnOnDisplay() @@ -299,9 +302,7 @@ class EPD: return self.send_command(0x24) - for j in range(0, self.height): - for i in range(0, int(self.width / 8)): - self.send_data(image[i + j * int(self.width / 8)]) + self.send_data2(image) self.TurnOnDisplayPart() diff --git a/RaspberryPi_JetsonNano/python/lib/waveshare_epd/epd1in54b_V2.py b/RaspberryPi_JetsonNano/python/lib/waveshare_epd/epd1in54b_V2.py index 1a9a52b..1575749 100644 --- a/RaspberryPi_JetsonNano/python/lib/waveshare_epd/epd1in54b_V2.py +++ b/RaspberryPi_JetsonNano/python/lib/waveshare_epd/epd1in54b_V2.py @@ -4,8 +4,8 @@ # * | Function : Electronic paper driver # * | Info : # *---------------- -# * | This version: V4.0 -# * | Date : 2019-06-20 +# * | This version: V4.1 +# * | Date : 2022-08-10 # # | Info : python demo # ----------------------------------------------------------------------------- # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -66,6 +66,13 @@ class EPD: epdconfig.digital_write(self.cs_pin, 0) epdconfig.spi_writebyte([data]) epdconfig.digital_write(self.cs_pin, 1) + + # send a lot of data + def send_data2(self, data): + epdconfig.digital_write(self.dc_pin, 1) + epdconfig.digital_write(self.cs_pin, 0) + epdconfig.spi_writebyte2(data) + epdconfig.digital_write(self.cs_pin, 1) def ReadBusy(self): logger.debug("e-Paper busy") @@ -134,17 +141,25 @@ class EPD: return buf def display(self, blackimage, redimage): + + if self.width%8 == 0: + linewidth = int(self.width/8) + else: + linewidth = int(self.width/8) + 1 + + buf = [0x00] * self.height * linewidth + # send black data if (blackimage != None): self.send_command(0x24) # DATA_START_TRANSMISSION_1 - for i in range(0, int(self.width * self.height / 8)): - self.send_data(blackimage[i]) + self.send_data2(blackimage) # send red data if (redimage != None): self.send_command(0x26) # DATA_START_TRANSMISSION_2 for i in range(0, int(self.width * self.height / 8)): - self.send_data(~redimage[i]) + buf[i] = ~redimage[i] + self.send_data2(buf) self.send_command(0x22) # DISPLAY_REFRESH self.send_data(0xF7) @@ -152,13 +167,16 @@ class EPD: self.ReadBusy() def Clear(self): + if self.width%8 == 0: + linewidth = int(self.width/8) + else: + linewidth = int(self.width/8) + 1 + self.send_command(0x24) # DATA_START_TRANSMISSION_1 - for i in range(0, int(self.width * self.height / 8)): - self.send_data(0xFF) + self.send_data2([0xff] * int(self.height * linewidth)) self.send_command(0x26) # DATA_START_TRANSMISSION_2 - for i in range(0, int(self.width * self.height / 8)): - self.send_data(0x00) + self.send_data2([0x00] * int(self.height * linewidth)) self.send_command(0x22) # DISPLAY_REFRESH self.send_data(0xF7) diff --git a/RaspberryPi_JetsonNano/python/lib/waveshare_epd/epd2in13_V2.py b/RaspberryPi_JetsonNano/python/lib/waveshare_epd/epd2in13_V2.py index 1900654..888f6ae 100644 --- a/RaspberryPi_JetsonNano/python/lib/waveshare_epd/epd2in13_V2.py +++ b/RaspberryPi_JetsonNano/python/lib/waveshare_epd/epd2in13_V2.py @@ -104,6 +104,13 @@ class EPD: epdconfig.digital_write(self.cs_pin, 0) epdconfig.spi_writebyte([data]) epdconfig.digital_write(self.cs_pin, 1) + + # send a lot of data + def send_data2(self, data): + epdconfig.digital_write(self.dc_pin, 1) + epdconfig.digital_write(self.cs_pin, 0) + epdconfig.spi_writebyte2(data) + epdconfig.digital_write(self.cs_pin, 1) def ReadBusy(self): while(epdconfig.digital_read(self.busy_pin) == 1): # 0: idle, 1: busy @@ -242,15 +249,8 @@ class EPD: def display(self, image): - if self.width%8 == 0: - linewidth = int(self.width/8) - else: - linewidth = int(self.width/8) + 1 - self.send_command(0x24) - for j in range(0, self.height): - for i in range(0, linewidth): - self.send_data(image[i + j * linewidth]) + self.send_data2(image) self.TurnOnDisplay() def displayPartial(self, image): @@ -259,34 +259,25 @@ class EPD: else: linewidth = int(self.width/8) + 1 - self.send_command(0x24) + buf = [0x00] * self.height * linewidth for j in range(0, self.height): for i in range(0, linewidth): - self.send_data(image[i + j * linewidth]) + buf[i + j * linewidth] = ~image[i + j * linewidth] + + self.send_command(0x24) + self.send_data2(image) self.send_command(0x26) - for j in range(0, self.height): - for i in range(0, linewidth): - self.send_data(~image[i + j * linewidth]) + self.send_data2(buf) self.TurnOnDisplayPart() def displayPartBaseImage(self, image): - if self.width%8 == 0: - linewidth = int(self.width/8) - else: - linewidth = int(self.width/8) + 1 - self.send_command(0x24) - for j in range(0, self.height): - for i in range(0, linewidth): - self.send_data(image[i + j * linewidth]) - + self.send_data2(image) self.send_command(0x26) - for j in range(0, self.height): - for i in range(0, linewidth): - self.send_data(image[i + j * linewidth]) + self.send_data2(image) self.TurnOnDisplay() def Clear(self, color): @@ -296,10 +287,13 @@ class EPD: linewidth = int(self.width/8) + 1 # logger.debug(linewidth) - self.send_command(0x24) + buf = [0x00] * self.height * linewidth for j in range(0, self.height): for i in range(0, linewidth): - self.send_data(color) + buf[i + j * linewidth] = color + + self.send_command(0x24) + self.send_data2(buf) # self.send_command(0x26) # for j in range(0, self.height): diff --git a/RaspberryPi_JetsonNano/python/lib/waveshare_epd/epd2in13_V3.py b/RaspberryPi_JetsonNano/python/lib/waveshare_epd/epd2in13_V3.py index 8ef814d..7b56bb8 100644 --- a/RaspberryPi_JetsonNano/python/lib/waveshare_epd/epd2in13_V3.py +++ b/RaspberryPi_JetsonNano/python/lib/waveshare_epd/epd2in13_V3.py @@ -4,8 +4,8 @@ # * | Function : Electronic paper driver # * | Info : # *---------------- -# * | This version: V1.1 -# * | Date : 2021-10-30 +# * | This version: V1.2 +# * | Date : 2022-08-9 # # | Info : python demo # ----------------------------------------------------------------------------- # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -123,6 +123,13 @@ class EPD: epdconfig.digital_write(self.cs_pin, 0) epdconfig.spi_writebyte([data]) epdconfig.digital_write(self.cs_pin, 1) + + # send a lot of data + def send_data2(self, data): + epdconfig.digital_write(self.dc_pin, 1) + epdconfig.digital_write(self.cs_pin, 0) + epdconfig.spi_writebyte2(data) + epdconfig.digital_write(self.cs_pin, 1) ''' function :Wait until the busy_pin goes LOW @@ -336,9 +343,10 @@ class EPD: self.SetCursor(0, 0) self.send_command(0x24) # WRITE_RAM - for j in range(0, self.height): - for i in range(0, linewidth): - self.send_data(image[i + j * linewidth]) + # for j in range(0, self.height): + # for i in range(0, linewidth): + # self.send_data(image[i + j * linewidth]) + self.send_data2(image) self.TurnOnDisplayPart() ''' @@ -353,14 +361,10 @@ class EPD: linewidth = int(self.width/8) + 1 self.send_command(0x24) - for j in range(0, self.height): - for i in range(0, linewidth): - self.send_data(image[i + j * linewidth]) + self.send_data2(image) self.send_command(0x26) - for j in range(0, self.height): - for i in range(0, linewidth): - self.send_data(image[i + j * linewidth]) + self.send_data2(image) self.TurnOnDisplay() ''' @@ -375,10 +379,7 @@ class EPD: # logger.debug(linewidth) self.send_command(0x24) - for j in range(0, self.height): - for i in range(0, linewidth): - self.send_data(color) - + self.send_data2([color] * int(self.height * linewidth)) self.TurnOnDisplay() ''' diff --git a/RaspberryPi_JetsonNano/python/lib/waveshare_epd/epd2in13d.py b/RaspberryPi_JetsonNano/python/lib/waveshare_epd/epd2in13d.py index 2430261..bcdd1e9 100644 --- a/RaspberryPi_JetsonNano/python/lib/waveshare_epd/epd2in13d.py +++ b/RaspberryPi_JetsonNano/python/lib/waveshare_epd/epd2in13d.py @@ -4,8 +4,8 @@ # * | Function : Electronic paper driver # * | Info : # *---------------- -# * | This version: V4.0 -# * | Date : 2019-06-20 +# * | This version: V4.1 +# * | Date : 2022-08-10 # # | Info : python demo # ----------------------------------------------------------------------------- # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -171,6 +171,13 @@ class EPD: epdconfig.spi_writebyte([data]) epdconfig.digital_write(self.cs_pin, 1) + # send a lot of data + def send_data2(self, data): + epdconfig.digital_write(self.dc_pin, 1) + epdconfig.digital_write(self.cs_pin, 0) + epdconfig.spi_writebyte2(data) + epdconfig.digital_write(self.cs_pin, 1) + def ReadBusy(self): logger.debug("e-Paper busy") while(epdconfig.digital_read(self.busy_pin) == 0): # 0: idle, 1: busy @@ -227,20 +234,15 @@ class EPD: self.send_data(0x97) self.send_command(0x20) # vcom - for count in range(0, 44): - self.send_data(self.lut_vcomDC[count]) + self.send_data2(self.lut_vcomDC) self.send_command(0x21) # ww -- - for count in range(0, 42): - self.send_data(self.lut_ww[count]) + self.send_data2(self.lut_ww) self.send_command(0x22) # bw r - for count in range(0, 42): - self.send_data(self.lut_bw[count]) + self.send_data2(self.lut_bw) self.send_command(0x23) # wb w - for count in range(0, 42): - self.send_data(self.lut_wb[count]) + self.send_data2(self.lut_wb) self.send_command(0x24) # bb b - for count in range(0, 42): - self.send_data(self.lut_bb[count]) + self.send_data2(self.lut_bb) def SetPartReg(self): self.send_command(0x82) @@ -249,20 +251,15 @@ class EPD: self.send_data(0x47) self.send_command(0x20) # vcom - for count in range(0, 44): - self.send_data(self.lut_vcom1[count]) + self.send_data2(self.lut_vcom1) self.send_command(0x21) # ww -- - for count in range(0, 42): - self.send_data(self.lut_ww1[count]) + self.send_data2(self.lut_ww1) self.send_command(0x22) # bw r - for count in range(0, 42): - self.send_data(self.lut_bw1[count]) + self.send_data2(self.lut_bw1) self.send_command(0x23) # wb w - for count in range(0, 42): - self.send_data(self.lut_wb1[count]) + self.send_data2(self.lut_wb1) self.send_command(0x24) # bb b - for count in range(0, 42): - self.send_data(self.lut_bb1[count]) + self.send_data2(self.lut_bb1) def getbuffer(self, image): # logger.debug("bufsiz = ",int(self.width/8) * self.height) @@ -292,14 +289,17 @@ class EPD: if (Image == None): return + if self.width%8 == 0: + linewidth = int(self.width/8) + else: + linewidth = int(self.width/8) + 1 + self.send_command(0x10) - for i in range(0, int(self.width * self.height / 8)): - self.send_data(0x00) + self.send_data2([0x00] * self.height * linewidth) epdconfig.delay_ms(10) self.send_command(0x13) - for i in range(0, int(self.width * self.height / 8)): - self.send_data(image[i]) + self.send_data2(image) epdconfig.delay_ms(10) self.SetFullReg() @@ -319,29 +319,40 @@ class EPD: self.send_data(int(self.height / 256)) self.send_data(self.height % 256 - 1) self.send_data(0x28) - + + if self.width%8 == 0: + linewidth = int(self.width/8) + else: + linewidth = int(self.width/8) + 1 + + buf = [0x00] * self.height * linewidth + + for i in range(self.height * linewidth): + buf[i] = ~image[i] + self.send_command(0x10) - for i in range(0, int(self.width * self.height / 8)): - self.send_data(image[i]) + self.send_data2(image) epdconfig.delay_ms(10) self.send_command(0x13) - for i in range(0, int(self.width * self.height / 8)): - self.send_data(~image[i]) + self.send_data2(buf) epdconfig.delay_ms(10) self.SetPartReg() self.TurnOnDisplay() - def Clear(self, color): + def Clear(self): + if self.width%8 == 0: + linewidth = int(self.width/8) + else: + linewidth = int(self.width/8) + 1 + self.send_command(0x10) - for i in range(0, int(self.width * self.height / 8)): - self.send_data(0x00) + self.send_data2([0x00] * self.height * linewidth) epdconfig.delay_ms(10) self.send_command(0x13) - for i in range(0, int(self.width * self.height / 8)): - self.send_data(0xFF) + self.send_data2([0xFF] * self.height * linewidth) epdconfig.delay_ms(10) self.SetFullReg() diff --git a/RaspberryPi_JetsonNano/python/lib/waveshare_epd/epd2in66.py b/RaspberryPi_JetsonNano/python/lib/waveshare_epd/epd2in66.py index d8b4384..cee45dd 100644 --- a/RaspberryPi_JetsonNano/python/lib/waveshare_epd/epd2in66.py +++ b/RaspberryPi_JetsonNano/python/lib/waveshare_epd/epd2in66.py @@ -4,8 +4,8 @@ # * | Function : Electronic paper driver # * | Info : # *---------------- -# * | This version: V1.0 -# * | Date : 2020-07-22 +# * | This version: V1.1 +# * | Date : 2022-08-9 # # | Info : python demo # ----------------------------------------------------------------------------- # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -70,7 +70,7 @@ class EPD: epdconfig.digital_write(self.reset_pin, 1) epdconfig.delay_ms(200) epdconfig.digital_write(self.reset_pin, 0) - epdconfig.delay_ms(5) + epdconfig.delay_ms(2) epdconfig.digital_write(self.reset_pin, 1) epdconfig.delay_ms(200) @@ -88,6 +88,13 @@ class EPD: epdconfig.spi_writebyte([data]) epdconfig.digital_write(self.cs_pin, 1) + # send a lot of data + def send_data2(self, data): + epdconfig.digital_write(self.dc_pin, 1) + epdconfig.digital_write(self.cs_pin, 0) + epdconfig.spi_writebyte2(data) + epdconfig.digital_write(self.cs_pin, 1) + def ReadBusy(self): logger.debug("e-Paper busy") @@ -152,9 +159,9 @@ class EPD: def load_lut(self, lut): self.send_command(0x32) - for i in range(0, 153): - self.send_data(lut[i]) - + # for i in range(0, 153): + # self.send_data(lut[i]) + self.send_data2(lut) def turnon_display(self): self.send_command(0x20) @@ -196,10 +203,7 @@ class EPD: self.send_data(0x01) self.send_command(0x24) - for j in range(0, self.height): - for i in range(0, int(self.width / 8)): - self.send_data(image[i + j * int(self.width / 8)]) - + self.send_data2(image) self.turnon_display() @@ -210,15 +214,18 @@ class EPD: self.send_data(0x27) self.send_data(0x01) + if self.width%8 == 0: + linewidth = int(self.width/8) + else: + linewidth = int(self.width/8) + 1 + + buf = [0xff] * int(self.height * linewidth) + self.send_command(0x24) - for j in range(0, self.height): - for i in range(0, int(self.width / 8)): - self.send_data(0xff) + self.send_data2(buf) self.send_command(0x26) - for j in range(0, self.height): - for i in range(0, int(self.width / 8)): - self.send_data(0xff) + self.send_data2(buf) self.turnon_display() diff --git a/RaspberryPi_JetsonNano/python/lib/waveshare_epd/epd2in66b.py b/RaspberryPi_JetsonNano/python/lib/waveshare_epd/epd2in66b.py index a52e6f8..870d866 100644 --- a/RaspberryPi_JetsonNano/python/lib/waveshare_epd/epd2in66b.py +++ b/RaspberryPi_JetsonNano/python/lib/waveshare_epd/epd2in66b.py @@ -4,8 +4,8 @@ # * | Function : Electronic paper driver # * | Info : # *---------------- -# * | This version: V1.0 -# * | Date : 2020-12-01 +# * | This version: V1.1 +# * | Date : 2022-08-9 # # | Info : python demo # ----------------------------------------------------------------------------- # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -68,6 +68,13 @@ class EPD: epdconfig.spi_writebyte([data]) epdconfig.digital_write(self.cs_pin, 1) + # send a lot of data + def send_data2(self, data): + epdconfig.digital_write(self.dc_pin, 1) + epdconfig.digital_write(self.cs_pin, 0) + epdconfig.spi_writebyte2(data) + epdconfig.digital_write(self.cs_pin, 1) + def ReadBusy(self): logger.debug("e-Paper busy") @@ -149,30 +156,30 @@ class EPD: def display(self, Blackimage, Redimage): if (Blackimage == None or Redimage == None): - return + return + Redimage_1 = [0x00] * len(Redimage) + for i in range(len(Redimage)) : + Redimage_1[i] = ~Redimage[i] self.send_command(0x24) - for j in range(0, self.height): - for i in range(0, int(self.width / 8)): - self.send_data(Blackimage[i + j * int(self.width / 8)]) + self.send_data2(Blackimage) self.send_command(0x26) - for j in range(0, self.height): - for i in range(0, int(self.width / 8)): - self.send_data(~Redimage[i + j * int(self.width / 8)]) + self.send_data2(Redimage_1) self.turnon_display() def Clear(self): + if self.width%8 == 0: + linewidth = int(self.width/8) + else: + linewidth = int(self.width/8) + 1 + self.send_command(0x24) - for j in range(0, self.height): - for i in range(0, int(self.width / 8)): - self.send_data(0xff) + self.send_data2([0xff] * int(self.height * linewidth)) self.send_command(0x26) - for j in range(0, self.height): - for i in range(0, int(self.width / 8)): - self.send_data(0x00) + self.send_data2([0x00] * int(self.height * linewidth)) self.turnon_display() diff --git a/RaspberryPi_JetsonNano/python/lib/waveshare_epd/epd2in7b_V2.py b/RaspberryPi_JetsonNano/python/lib/waveshare_epd/epd2in7b_V2.py index 3c1b25e..1538023 100644 --- a/RaspberryPi_JetsonNano/python/lib/waveshare_epd/epd2in7b_V2.py +++ b/RaspberryPi_JetsonNano/python/lib/waveshare_epd/epd2in7b_V2.py @@ -4,8 +4,8 @@ # * | Function : Electronic paper driver # * | Info : # *---------------- -# * | This version: V1.0 -# * | Date : 2020-10-22 +# * | This version: V1.1 +# * | Date : 2022-08-10 # # | Info : python demo # ----------------------------------------------------------------------------- # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -68,6 +68,13 @@ class EPD: epdconfig.digital_write(self.cs_pin, 0) epdconfig.spi_writebyte([data]) epdconfig.digital_write(self.cs_pin, 1) + + # send a lot of data + def send_data2(self, data): + epdconfig.digital_write(self.dc_pin, 1) + epdconfig.digital_write(self.cs_pin, 0) + epdconfig.spi_writebyte2(data) + epdconfig.digital_write(self.cs_pin, 1) # Read Busy def ReadBusy(self): @@ -148,25 +155,25 @@ class EPD: Width = self.width / 8 Height = self.height - self.send_command(0x24) + buf = [0x00] * int(Width * Height) for i in range(0, int(Width * Height)): - self.send_data(imageblack[i]) + buf[i] = ~imagered[i] + + self.send_command(0x24) + self.send_data2(imageblack) self.send_command(0x26) - for i in range(0, int(Width * Height)): - self.send_data(~imagered[i]) + self.send_data2(buf) self.TurnOnDisplay() # Clear the screen def Clear(self): self.send_command(0x24) - for i in range(0, int(self.width * self.height / 8)): - self.send_data(0xff) + self.send_data2([0xff] * int(self.width * self.height / 8)) self.send_command(0x26) - for i in range(0, int(self.width * self.height / 8)): - self.send_data(0x00) + self.send_data2([0x00] * int(self.width * self.height / 8)) self.TurnOnDisplay() diff --git a/RaspberryPi_JetsonNano/python/lib/waveshare_epd/epd2in9_V2.py b/RaspberryPi_JetsonNano/python/lib/waveshare_epd/epd2in9_V2.py index 76d630e..1f79460 100644 --- a/RaspberryPi_JetsonNano/python/lib/waveshare_epd/epd2in9_V2.py +++ b/RaspberryPi_JetsonNano/python/lib/waveshare_epd/epd2in9_V2.py @@ -4,8 +4,8 @@ # * | Function : Electronic paper driver # * | Info : # *---------------- -# * | This version: V1.0 -# * | Date : 2020-10-20 +# * | This version: V1.1 +# * | Date : 2022-08-9 # # | Info : python demo # ----------------------------------------------------------------------------- # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -109,6 +109,13 @@ class EPD: epdconfig.digital_write(self.cs_pin, 0) epdconfig.spi_writebyte([data]) epdconfig.digital_write(self.cs_pin, 1) + + # send a lot of data + def send_data2(self, data): + epdconfig.digital_write(self.dc_pin, 1) + epdconfig.digital_write(self.cs_pin, 0) + epdconfig.spi_writebyte2(data) + epdconfig.digital_write(self.cs_pin, 1) def ReadBusy(self): logger.debug("e-Paper busy") @@ -226,9 +233,7 @@ class EPD: if (image == None): return self.send_command(0x24) # WRITE_RAM - for j in range(0, self.height): - for i in range(0, int(self.width / 8)): - self.send_data(image[i + j * int(self.width / 8)]) + self.send_data2(image) self.TurnOnDisplay() def display_Base(self, image): @@ -236,14 +241,10 @@ class EPD: return self.send_command(0x24) # WRITE_RAM - for j in range(0, self.height): - for i in range(0, int(self.width / 8)): - self.send_data(image[i + j * int(self.width / 8)]) + self.send_data2(image) self.send_command(0x26) # WRITE_RAM - for j in range(0, self.height): - for i in range(0, int(self.width / 8)): - self.send_data(image[i + j * int(self.width / 8)]) + self.send_data2(image) self.TurnOnDisplay() @@ -281,16 +282,17 @@ class EPD: self.SetCursor(0, 0) self.send_command(0x24) # WRITE_RAM - for j in range(0, self.height): - for i in range(0, int(self.width / 8)): - self.send_data(image[i + j * int(self.width / 8)]) + self.send_data2(image) self.TurnOnDisplay_Partial() def Clear(self, color): + if self.width%8 == 0: + linewidth = int(self.width/8) + else: + linewidth = int(self.width/8) + 1 + self.send_command(0x24) # WRITE_RAM - for j in range(0, self.height): - for i in range(0, int(self.width / 8)): - self.send_data(color) + self.send_data2([color] * int(self.height * linewidth)) self.TurnOnDisplay() def sleep(self): diff --git a/RaspberryPi_JetsonNano/python/lib/waveshare_epd/epd2in9b_V3.py b/RaspberryPi_JetsonNano/python/lib/waveshare_epd/epd2in9b_V3.py index 7749155..2a1cc09 100644 --- a/RaspberryPi_JetsonNano/python/lib/waveshare_epd/epd2in9b_V3.py +++ b/RaspberryPi_JetsonNano/python/lib/waveshare_epd/epd2in9b_V3.py @@ -4,8 +4,8 @@ # * | Function : Electronic paper driver # * | Info : # *---------------- -# * | This version: V1.1 -# * | Date : 2020-12-03 +# * | This version: V1.2 +# * | Date : 2022-08-10 # # | Info : python demo # ----------------------------------------------------------------------------- # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -66,6 +66,13 @@ class EPD: epdconfig.digital_write(self.cs_pin, 0) epdconfig.spi_writebyte([data]) epdconfig.digital_write(self.cs_pin, 1) + + # send a lot of data + def send_data2(self, data): + epdconfig.digital_write(self.dc_pin, 1) + epdconfig.digital_write(self.cs_pin, 0) + epdconfig.spi_writebyte2(data) + epdconfig.digital_write(self.cs_pin, 1) def ReadBusy(self): logger.debug("e-Paper busy") @@ -126,12 +133,10 @@ class EPD: def display(self, blackimage, ryimage): # ryimage: red or yellow image if (blackimage != None): self.send_command(0X10) - for i in range(0, int(self.width * self.height / 8)): - self.send_data(blackimage[i]) + self.send_data2(blackimage) if (ryimage != None): self.send_command(0X13) - for i in range(0, int(self.width * self.height / 8)): - self.send_data(ryimage[i]) + self.send_data2(ryimage) self.send_command(0x12) epdconfig.delay_ms(200) @@ -139,11 +144,9 @@ class EPD: def Clear(self): self.send_command(0X10) - for i in range(0, int(self.width * self.height / 8)): - self.send_data(0xff) + self.send_data2([0xff] * int(self.width * self.height / 8)) self.send_command(0X13) - for i in range(0, int(self.width * self.height / 8)): - self.send_data(0xff) + self.send_data2([0xff] * int(self.width * self.height / 8)) self.send_command(0x12) epdconfig.delay_ms(200) diff --git a/RaspberryPi_JetsonNano/python/lib/waveshare_epd/epd2in9d.py b/RaspberryPi_JetsonNano/python/lib/waveshare_epd/epd2in9d.py index b48d7d8..28d3757 100644 --- a/RaspberryPi_JetsonNano/python/lib/waveshare_epd/epd2in9d.py +++ b/RaspberryPi_JetsonNano/python/lib/waveshare_epd/epd2in9d.py @@ -7,8 +7,8 @@ # * | Function : Electronic paper driver # * | Info : # *---------------- -# * | This version: V2.0 -# * | Date : 2019-06-20 +# * | This version: V2.1 +# * | Date : 2022-08-10 # # | Info : python demo # ----------------------------------------------------------------------------- # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -30,6 +30,7 @@ # THE SOFTWARE. # +from distutils.command.build_scripts import build_scripts import logging from . import epdconfig from PIL import Image @@ -129,6 +130,13 @@ class EPD: epdconfig.digital_write(self.cs_pin, 0) epdconfig.spi_writebyte([data]) epdconfig.digital_write(self.cs_pin, 1) + + # send a lot of data + def send_data2(self, data): + epdconfig.digital_write(self.dc_pin, 1) + epdconfig.digital_write(self.cs_pin, 0) + epdconfig.spi_writebyte2(data) + epdconfig.digital_write(self.cs_pin, 1) def ReadBusy(self): logger.debug("e-Paper busy") @@ -199,20 +207,15 @@ class EPD: self.send_data(0x97) self.send_command(0x20) # vcom - for count in range(0, 44): - self.send_data(self.lut_vcom1[count]) + self.send_data2(self.lut_vcom1) self.send_command(0x21) # ww -- - for count in range(0, 42): - self.send_data(self.lut_ww1[count]) + self.send_data2(self.lut_ww1) self.send_command(0x22) # bw r - for count in range(0, 42): - self.send_data(self.lut_bw1[count]) + self.send_data2(self.lut_bw1) self.send_command(0x23) # wb w - for count in range(0, 42): - self.send_data(self.lut_wb1[count]) + self.send_data2(self.lut_wb1) self.send_command(0x24) # bb b - for count in range(0, 42): - self.send_data(self.lut_bb1[count]) + self.send_data2(self.lut_bb1) def getbuffer(self, image): # logger.debug("bufsiz = ",int(self.width/8) * self.height) @@ -240,13 +243,11 @@ class EPD: def display(self, image): self.send_command(0x10) - for i in range(0, int(self.width * self.height / 8)): - self.send_data(0x00) + self.send_data2([0x00] * int(self.width * self.height / 8)) epdconfig.delay_ms(10) self.send_command(0x13) - for i in range(0, int(self.width * self.height / 8)): - self.send_data(image[i]) + self.send_data2(image) epdconfig.delay_ms(10) self.TurnOnDisplay() @@ -263,28 +264,28 @@ class EPD: self.send_data(int(self.height / 256)) self.send_data(self.height % 256 - 1) self.send_data(0x28) - - self.send_command(0x10) + + + buf = [0x00] * int(self.width * self.height / 8) for i in range(0, int(self.width * self.height / 8)): - self.send_data(image[i]) + buf[i] = ~image[i] + self.send_command(0x10) + self.send_data2(image) epdconfig.delay_ms(10) self.send_command(0x13) - for i in range(0, int(self.width * self.height / 8)): - self.send_data(~image[i]) + self.send_data2(buf) epdconfig.delay_ms(10) self.TurnOnDisplay() - def Clear(self, color): + def Clear(self): self.send_command(0x10) - for i in range(0, int(self.width * self.height / 8)): - self.send_data(0x00) + self.send_data2([0x00] * int(self.width * self.height / 8)) epdconfig.delay_ms(10) self.send_command(0x13) - for i in range(0, int(self.width * self.height / 8)): - self.send_data(0xFF) + self.send_data2([0xFF] * int(self.width * self.height / 8)) epdconfig.delay_ms(10) self.TurnOnDisplay() diff --git a/RaspberryPi_JetsonNano/python/lib/waveshare_epd/epd3in0g.py b/RaspberryPi_JetsonNano/python/lib/waveshare_epd/epd3in0g.py index 1e9f0dd..8df8c6d 100644 --- a/RaspberryPi_JetsonNano/python/lib/waveshare_epd/epd3in0g.py +++ b/RaspberryPi_JetsonNano/python/lib/waveshare_epd/epd3in0g.py @@ -165,7 +165,7 @@ class EPD: else: logger.warning("Invalid image dimensions: %d x %d, expected %d x %d" % (imwidth, imheight, self.width, self.height)) - # Convert the soruce image to the 7 colors, dithering if needed + # Convert the soruce image to the 4 colors, dithering if needed image_4color = image_temp.convert("RGB").quantize(palette=pal_image) buf_4color = bytearray(image_4color.tobytes('raw')) diff --git a/RaspberryPi_JetsonNano/python/lib/waveshare_epd/epd3in52.py b/RaspberryPi_JetsonNano/python/lib/waveshare_epd/epd3in52.py index 0d0257b..2e8688d 100644 --- a/RaspberryPi_JetsonNano/python/lib/waveshare_epd/epd3in52.py +++ b/RaspberryPi_JetsonNano/python/lib/waveshare_epd/epd3in52.py @@ -199,7 +199,7 @@ class EPD: epdconfig.digital_write(self.reset_pin, 1) epdconfig.delay_ms(200) epdconfig.digital_write(self.reset_pin, 0) - epdconfig.delay_ms(5) + epdconfig.delay_ms(2) epdconfig.digital_write(self.reset_pin, 1) epdconfig.delay_ms(200) @@ -214,6 +214,13 @@ class EPD: epdconfig.digital_write(self.cs_pin, 0) epdconfig.spi_writebyte([data]) epdconfig.digital_write(self.cs_pin, 1) + + # send a lot of data + def send_data2(self, data): + epdconfig.digital_write(self.dc_pin, 1) + epdconfig.digital_write(self.cs_pin, 0) + epdconfig.spi_writebyte2(data) + epdconfig.digital_write(self.cs_pin, 1) def ReadBusy(self): logger.debug("e-Paper busy") @@ -223,24 +230,19 @@ class EPD: def lut(self) : self.send_command(0x20) # vcom - for count in range(0 ,42): - self.send_data(self.lut_vcom[count]) + self.send_data2(self.lut_vcom[:42]) self.send_command(0x21) # ww -- - for count in range(0 ,42): - self.send_data(self.lut_ww[count]) + self.send_data2(self.lut_ww[:42]) self.send_command(0x22) # bw r - for count in range(0 ,42): - self.send_data(self.lut_bw[count]) + self.send_data2(self.lut_bw[:42]) self.send_command(0x23) # wb w - for count in range(0 ,42): - self.send_data(self.lut_bb[count]) + self.send_data2(self.lut_bb[:42]) self.send_command(0x24) # bb b - for count in range(0 ,42): - self.send_data(self.lut_wb[count]) + self.send_data2(self.lut_wb[:42]) def refresh(self): self.send_command(0x17) @@ -251,70 +253,56 @@ class EPD: # LUT download def lut_GC(self): self.send_command(0x20); # vcom - for count in range(0 ,56): - self.send_data(self.lut_R20_GC[count]) + self.send_data2(self.lut_R20_GC[:56]) self.send_command(0x21); # red not use - for count in range(0 ,42): - self.send_data(self.lut_R21_GC[count]) + self.send_data2(self.lut_R21_GC[:42]) self.send_command(0x24); # bb b - for count in range(0 ,42): - self.send_data(self.lut_R24_GC[count]) + self.send_data2(self.lut_R24_GC[:42]) if(self.Flag == 0) : self.send_command(0x22); # bw r - for count in range(0 ,56): - self.send_data(self.lut_R22_GC[count]) + self.send_data2(self.lut_R22_GC[:56]) self.send_command(0x23); # wb w - for count in range(0 ,42): - self.send_data(self.lut_R23_GC[count]) + self.send_data2(self.lut_R23_GC[:42]) self.Flag = 1 else : self.send_command(0x22); # bw r - for count in range(0 ,56): - self.send_data(self.lut_R23_GC[count]) + self.send_data2(self.lut_R23_GC[:56]) self.send_command(0x23); # wb w - for count in range(0 ,42): - self.send_data(self.lut_R22_GC[count]) + self.send_data2(self.lut_R22_GC[:42]) self.Flag = 0 # LUT download def lut_DU(self): self.send_command(0x20); # vcom - for count in range(0 ,56): - self.send_data(self.lut_R20_DU[count]) + self.send_data2(self.lut_R20_DU[:56]) self.send_command(0x21); # red not use - for count in range(0 ,42): - self.send_data(self.lut_R21_DU[count]) + self.send_data2(self.lut_R21_DU[:42]) self.send_command(0x24); # bb b - for count in range(0 ,42): - self.send_data(self.lut_R24_DU[count]) + self.send_data2(self.lut_R24_DU[:42]) if(self.Flag == 0) : self.send_command(0x22); # bw r - for count in range(0 ,56): - self.send_data(self.lut_R22_DU[count]) + self.send_data2(self.lut_R22_DU[:56]) self.send_command(0x23); # wb w - for count in range(0 ,42): - self.send_data(self.lut_R23_DU[count]) + self.send_data2(self.lut_R23_DU[:42]) self.Flag = 1 else : self.send_command(0x22); # bw r - for count in range(0 ,56): - self.send_data(self.lut_R23_DU[count]) + self.send_data2(self.lut_R23_DU[:56]) self.send_command(0x23); # wb w - for count in range(0 ,42): - self.send_data(self.lut_R22_DU[count]) + self.send_data2(self.lut_R22_DU[:42]) self.Flag = 0 @@ -391,15 +379,14 @@ class EPD: if (image == None): return self.send_command(0x13); # Transfer new data - for i in range(0, self.width * self.height / 8) : - self.send_data(image[i]) + self.send_data2(image) def display_NUM(self, NUM): # pcnt = 0 self.send_command(0x13); #Transfer new data for column in range(0, self.height): - for row in range(0, self.width/8): + for row in range(0, self.width//8): if NUM == self.WHITE: self.send_data(0xFF) @@ -458,8 +445,7 @@ class EPD: def Clear(self): self.send_command(0x13); # Transfer new data - for i in range(0, self.width * self.height / 8) : - self.send_data(0xFF) + self.send_data2([0xFF] * int(self.width * self.height / 8)) self.lut_GC() self.refresh() diff --git a/RaspberryPi_JetsonNano/python/lib/waveshare_epd/epd3in7.py b/RaspberryPi_JetsonNano/python/lib/waveshare_epd/epd3in7.py index fe4dd26..b36632b 100644 --- a/RaspberryPi_JetsonNano/python/lib/waveshare_epd/epd3in7.py +++ b/RaspberryPi_JetsonNano/python/lib/waveshare_epd/epd3in7.py @@ -4,8 +4,8 @@ # * | Function : Electronic paper driver # * | Info : # *---------------- -# * | This version: V1.0 -# * | Date : 2020-07-16 +# * | This version: V1.1 +# * | Date : 2022-08-10 # # | Info : python demo # ----------------------------------------------------------------------------- # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -133,6 +133,13 @@ class EPD: epdconfig.spi_writebyte([data]) epdconfig.digital_write(self.cs_pin, 1) + # send a lot of data + def send_data2(self, data): + epdconfig.digital_write(self.dc_pin, 1) + epdconfig.digital_write(self.cs_pin, 0) + epdconfig.spi_writebyte2(data) + epdconfig.digital_write(self.cs_pin, 1) + def ReadBusy(self): logger.debug("e-Paper busy") @@ -235,8 +242,7 @@ class EPD: def load_lut(self, lut): self.send_command(0x32) - for i in range(0, 105): - self.send_data(lut[i]) + self.send_data2(lut) def getbuffer(self, image): @@ -312,6 +318,13 @@ class EPD: self.send_data(0x00) self.send_data(0x00) + if self.width%8 == 0: + linewidth = int(self.width/8) + else: + linewidth = int(self.width/8) + 1 + + buf = [0x00] * self.height * linewidth + self.send_command(0x24) for i in range(0, (int)(self.height*(self.width/8))): temp3=0 @@ -341,7 +354,8 @@ class EPD: if(j!=1 or k!=1): temp3 <<= 1 temp1 <<= 2 - self.send_data(temp3) + buf[i] = temp3 + self.send_data2(buf) self.send_command(0x4E) self.send_data(0x00) @@ -379,7 +393,8 @@ class EPD: if(j!=1 or k!=1): temp3 <<= 1 temp1 <<= 2 - self.send_data(temp3) + buf[i] = temp3 + self.send_data2(buf) self.load_lut(self.lut_4Gray_GC) self.send_command(0x22) @@ -400,9 +415,7 @@ class EPD: self.send_data(0x00) self.send_command(0x24) - for j in range(0, self.height): - for i in range(0, int(self.width / 8)): - self.send_data(image[i + j * int(self.width / 8)]) + self.send_data2(image) self.load_lut(self.lut_1Gray_A2) self.send_command(0x20) @@ -417,16 +430,18 @@ class EPD: self.send_data(0x00) self.send_data(0x00) + if self.width%8 == 0: + linewidth = int(self.width/8) + else: + linewidth = int(self.width/8) + 1 + self.send_command(0x24) - for j in range(0, self.height): - for i in range(0, int(self.width / 8)): - self.send_data(0xff) + self.send_data2([0xff] * int(self.height * linewidth)) if(mode == 0): #4Gray self.send_command(0x26) - for j in range(0, self.height): - for i in range(0, int(self.width / 8)): - self.send_data(0xff) + self.send_data2([0xff] * int(self.height * linewidth)) + self.load_lut(self.lut_4Gray_GC) self.send_command(0x22) self.send_data(0xC7) diff --git a/RaspberryPi_JetsonNano/python/lib/waveshare_epd/epd4in01f.py b/RaspberryPi_JetsonNano/python/lib/waveshare_epd/epd4in01f.py index ae423fb..fd20241 100644 --- a/RaspberryPi_JetsonNano/python/lib/waveshare_epd/epd4in01f.py +++ b/RaspberryPi_JetsonNano/python/lib/waveshare_epd/epd4in01f.py @@ -6,8 +6,8 @@ # * | Function : Electronic paper driver # * | Info : # *---------------- -# * | This version: V1.0 -# * | Date : 2020-11-06 +# * | This version: V1.1 +# * | Date : 2022-08-10 # # | Info : python demo # ----------------------------------------------------------------------------- # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -75,6 +75,13 @@ class EPD: epdconfig.digital_write(self.cs_pin, 0) epdconfig.spi_writebyte([data]) epdconfig.digital_write(self.cs_pin, 1) + + # send a lot of data + def send_data2(self, data): + epdconfig.digital_write(self.dc_pin, 1) + epdconfig.digital_write(self.cs_pin, 0) + epdconfig.spi_writebyte2(data) + epdconfig.digital_write(self.cs_pin, 1) def ReadBusyHigh(self): logger.debug("e-Paper busy") @@ -95,33 +102,33 @@ class EPD: self.reset() self.ReadBusyHigh() - self.send_command(0x00); - self.send_data(0x2f); - self.send_data(0x00); - self.send_command(0x01); - self.send_data(0x37); - self.send_data(0x00); - self.send_data(0x05); - self.send_data(0x05); - self.send_command(0x03); - self.send_data(0x00); - self.send_command(0x06); - self.send_data(0xC7); - self.send_data(0xC7); - self.send_data(0x1D); - self.send_command(0x41); - self.send_data(0x00); - self.send_command(0x50); - self.send_data(0x37); - self.send_command(0x60); - self.send_data(0x22); - self.send_command(0x61); - self.send_data(0x02); - self.send_data(0x80); - self.send_data(0x01); - self.send_data(0x90); - self.send_command(0xE3); - self.send_data(0xAA); + self.send_command(0x00) + self.send_data(0x2f) + self.send_data(0x00) + self.send_command(0x01) + self.send_data(0x37) + self.send_data(0x00) + self.send_data(0x05) + self.send_data(0x05) + self.send_command(0x03) + self.send_data(0x00) + self.send_command(0x06) + self.send_data(0xC7) + self.send_data(0xC7) + self.send_data(0x1D) + self.send_command(0x41) + self.send_data(0x00) + self.send_command(0x50) + self.send_data(0x37) + self.send_command(0x60) + self.send_data(0x22) + self.send_command(0x61) + self.send_data(0x02) + self.send_data(0x80) + self.send_data(0x01) + self.send_data(0x90) + self.send_command(0xE3) + self.send_data(0xAA) # EPD hardware init end return 0 @@ -189,9 +196,7 @@ class EPD: self.send_data(0x01) self.send_data(0x90) self.send_command(0x10) - for i in range(0, int(EPD_HEIGHT)): - for j in range(0, int(EPD_WIDTH/2)): - self.send_data((image[j+(int(EPD_WIDTH/2)*i)])) + self.send_data2(image) self.send_command(0x04)#0x04 self.ReadBusyHigh() self.send_command(0x12)#0x12 @@ -207,9 +212,7 @@ class EPD: self.send_data(0x01) self.send_data(0x90) self.send_command(0x10) - for i in range(0, int(EPD_HEIGHT)): - for j in range(0, int(EPD_WIDTH/2)): - self.send_data(0x11) + self.send_data2([0x11] * int(EPD_HEIGHT) * int(EPD_WIDTH/2)) #BLACK 0x00 /// 0000 #WHITE 0x11 /// 0001 #GREEN 0x22 /// 0010 diff --git a/RaspberryPi_JetsonNano/python/lib/waveshare_epd/epd4in2.py b/RaspberryPi_JetsonNano/python/lib/waveshare_epd/epd4in2.py index 08ce91f..8562639 100644 --- a/RaspberryPi_JetsonNano/python/lib/waveshare_epd/epd4in2.py +++ b/RaspberryPi_JetsonNano/python/lib/waveshare_epd/epd4in2.py @@ -4,8 +4,8 @@ # * | Function : Electronic paper driver # * | Info : # *---------------- -# * | This version: V4.0 -# * | Date : 2019-06-20 +# * | This version: V4.1 +# * | Date : 2022-08-9 # # | Info : python demo # ----------------------------------------------------------------------------- # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -241,6 +241,13 @@ class EPD: epdconfig.digital_write(self.cs_pin, 0) epdconfig.spi_writebyte([data]) epdconfig.digital_write(self.cs_pin, 1) + + # send a lot of data + def send_data2(self, data): + epdconfig.digital_write(self.dc_pin, 1) + epdconfig.digital_write(self.cs_pin, 0) + epdconfig.spi_writebyte2(data) + epdconfig.digital_write(self.cs_pin, 1) def ReadBusy(self): self.send_command(0x71) @@ -250,73 +257,57 @@ class EPD: def set_lut(self): self.send_command(0x20) # vcom - for count in range(0, 36): - self.send_data(self.lut_vcom0[count]) + self.send_data2(self.lut_vcom0) self.send_command(0x21) # ww -- - for count in range(0, 36): - self.send_data(self.lut_ww[count]) + self.send_data2(self.lut_ww) self.send_command(0x22) # bw r - for count in range(0, 36): - self.send_data(self.lut_bw[count]) + self.send_data2(self.lut_bw) self.send_command(0x23) # wb w - for count in range(0, 36): - self.send_data(self.lut_bb[count]) + self.send_data2(self.lut_bb) self.send_command(0x24) # bb b - for count in range(0, 36): - self.send_data(self.lut_wb[count]) + self.send_data2(self.lut_wb) def Partial_SetLut(self): - self.send_command(0x20); - for count in range(0, 44): - self.send_data(self.EPD_4IN2_Partial_lut_vcom1[count]) + self.send_command(0x20) + self.send_data2(self.EPD_4IN2_Partial_lut_vcom1) - self.send_command(0x21); - for count in range(0, 42): - self.send_data(self.EPD_4IN2_Partial_lut_ww1[count]) + self.send_command(0x21) + self.send_data2(self.EPD_4IN2_Partial_lut_ww1) - self.send_command(0x22); - for count in range(0, 42): - self.send_data(self.EPD_4IN2_Partial_lut_bw1[count]) + self.send_command(0x22) + self.send_data2(self.EPD_4IN2_Partial_lut_bw1) - self.send_command(0x23); - for count in range(0, 42): - self.send_data(self.EPD_4IN2_Partial_lut_wb1[count]) + self.send_command(0x23) + self.send_data2(self.EPD_4IN2_Partial_lut_wb1) - self.send_command(0x24); - for count in range(0, 42): - self.send_data(self.EPD_4IN2_Partial_lut_bb1[count]) + self.send_command(0x24) + self.send_data2(self.EPD_4IN2_Partial_lut_bb1) def Gray_SetLut(self): self.send_command(0x20) #vcom - for count in range(0, 42): - self.send_data(self.EPD_4IN2_4Gray_lut_vcom[count]) + self.send_data2(self.EPD_4IN2_4Gray_lut_vcom) self.send_command(0x21) #red not use - for count in range(0, 42): - self.send_data(self.EPD_4IN2_4Gray_lut_ww[count]) + self.send_data2(self.EPD_4IN2_4Gray_lut_ww) self.send_command(0x22) #bw r - for count in range(0, 42): - self.send_data(self.EPD_4IN2_4Gray_lut_bw[count]) + self.send_data2(self.EPD_4IN2_4Gray_lut_bw) self.send_command(0x23) #wb w - for count in range(0, 42): - self.send_data(self.EPD_4IN2_4Gray_lut_wb[count]) + self.send_data2(self.EPD_4IN2_4Gray_lut_wb) self.send_command(0x24) #bb b - for count in range(0, 42): - self.send_data(self.EPD_4IN2_4Gray_lut_bb[count]) + self.send_data2(self.EPD_4IN2_4Gray_lut_bb) self.send_command(0x25) #vcom - for count in range(0, 42): - self.send_data(self.EPD_4IN2_4Gray_lut_ww[count]) + self.send_data2(self.EPD_4IN2_4Gray_lut_ww) def init(self): @@ -504,15 +495,18 @@ class EPD: return buf def display(self, image): + if self.width%8 == 0: + linewidth = int(self.width/8) + else: + linewidth = int(self.width/8) + 1 + self.send_command(0x92); - self.set_lut(); + self.set_lut() self.send_command(0x10) - for i in range(0, int(self.width * self.height / 8)): - self.send_data(0xFF) + self.send_data2([0xFF] * int(self.width * linewidth)) self.send_command(0x13) - for i in range(0, int(self.width * self.height / 8)): - self.send_data(image[i]) + self.send_data2(image) self.send_command(0x12) self.ReadBusy() @@ -520,54 +514,72 @@ class EPD: def EPD_4IN2_PartialDisplay(self, X_start, Y_start, X_end, Y_end, Image): # EPD_WIDTH = 400 # EPD_HEIGHT = 300 + if(EPD_WIDTH % 8 != 0): - Width = int(EPD_WIDTH / 8) + 1; + Width = int(EPD_WIDTH / 8) + 1 else: - Width = int(EPD_WIDTH / 8); - Height = EPD_HEIGHT; + Width = int(EPD_WIDTH / 8) + Height = EPD_HEIGHT if(X_start % 8 != 0): - X_start = int(X_start/8)*8+8 + X_start = int(X_start/8) + 1 + else: + X_start = int(X_start/8) if(X_end % 8 != 0): - X_end = int(X_end/8)*8+8 + X_end = int(X_end/8) + 1 + else: + X_end = int(X_end/8) - - self.send_command(0x91); #This command makes the display enter partial mode - self.send_command(0x90); #resolution setting - self.send_data (int(X_start/256)); - self.send_data (int(X_start%256)); #x-start - - self.send_data (int(X_end /256)); - self.send_data (int(X_end %256)-1); #x-end + buf = [0x00] * (Y_end - Y_start) * (X_end - X_start) - self.send_data (int(Y_start/256)); - self.send_data (int(Y_start%256)); #y-start + + self.send_command(0x91) #This command makes the display enter partial mode + self.send_command(0x90) #resolution setting + self.send_data (int(X_start*8/256)) + self.send_data (int(X_start*8%256)) #x-start + + self.send_data (int(X_end*8 /256)) + self.send_data (int(X_end*8 %256)-1) #x-end + + self.send_data (int(Y_start/256)) + self.send_data (int(Y_start%256)) #y-start - self.send_data (int(Y_end/256)); - self.send_data (int(Y_end%256)-1); #y-end - self.send_data (0x28); + self.send_data (int(Y_end/256)) + self.send_data (int(Y_end%256)-1) #y-end + self.send_data (0x28) + self.send_command(0x10); #writes Old data to SRAM for programming - for j in range(0, int(Y_end - Y_start)): - for i in range(0, int(X_end/8) - int(X_start/8)): - self.send_data(self.DATA[(Y_start + j)*Width + int(X_start/8) + i]); + for j in range(0, Y_end - Y_start): + for i in range(0, X_end - X_start): + buf[j * (X_end - X_start) + i] = self.DATA[(Y_start + j)*Width + X_start + i] + self.send_data2(buf) self.send_command(0x13); #writes New data to SRAM. - for j in range(0, int(Y_end - Y_start)): - for i in range(0, int(X_end/8) - int(X_start/8)): - self.send_data(~Image[(Y_start + j)*Width + int(X_start/8) + i]); - self.DATA[(Y_start + j)*Width + int(X_start/8) + i] = ~Image[(Y_start + j)*Width + int(X_start/8) + i] + for j in range(0, Y_end - Y_start): + for i in range(0, X_end - X_start): + buf[j * (X_end - X_start) + i] = ~Image[(Y_start + j)*Width + X_start + i] + self.DATA[(Y_start + j)*Width + X_start + i] = ~Image[(Y_start + j)*Width + X_start/8 + i] + self.send_data2(buf) - self.send_command(0x12); #DISPLAY REFRESH + self.send_command(0x12) #DISPLAY REFRESH epdconfig.delay_ms(200) #The delay here is necessary, 200uS at least!!! self.ReadBusy() def display_4Gray(self, image): self.send_command(0x92); - self.set_lut(); + self.set_lut() self.send_command(0x10) + + if self.width%8 == 0: + linewidth = int(self.width/8) + else: + linewidth = int(self.width/8) + 1 + + buf = [0x00] * self.height * linewidth + for i in range(0, int(EPD_WIDTH * EPD_HEIGHT / 8)): # EPD_WIDTH * EPD_HEIGHT / 4 temp3=0 for j in range(0, 2): @@ -597,7 +609,8 @@ class EPD: if(j!=1 or k!=1): temp3 <<= 1 temp1 <<= 2 - self.send_data(temp3) + buf[i] = temp3 + self.send_data2(buf) self.send_command(0x13) @@ -626,11 +639,12 @@ class EPD: elif(temp2 == 0x80): temp3 |= 0x00 #gray1 else: #0x40 - temp3 |= 0x01 #gray2 + temp3 |= 0x01 #gray2 if(j!=1 or k!=1): temp3 <<= 1 temp1 <<= 2 - self.send_data(temp3) + buf[i] = temp3 + self.send_data2(buf) self.Gray_SetLut() self.send_command(0x12) @@ -639,13 +653,16 @@ class EPD: # pass def Clear(self): + if self.width%8 == 0: + linewidth = int(self.width/8) + else: + linewidth = int(self.width/8) + 1 + self.send_command(0x10) - for i in range(0, int(self.width * self.height / 8)): - self.send_data(0xFF) + self.send_data2([0xff] * int(self.height * linewidth)) self.send_command(0x13) - for i in range(0, int(self.width * self.height / 8)): - self.send_data(0xFF) + self.send_data2([0xff] * int(self.height * linewidth)) self.send_command(0x12) self.ReadBusy() diff --git a/RaspberryPi_JetsonNano/python/lib/waveshare_epd/epd4in2b_V2.py b/RaspberryPi_JetsonNano/python/lib/waveshare_epd/epd4in2b_V2.py index db080a5..701ac32 100644 --- a/RaspberryPi_JetsonNano/python/lib/waveshare_epd/epd4in2b_V2.py +++ b/RaspberryPi_JetsonNano/python/lib/waveshare_epd/epd4in2b_V2.py @@ -4,8 +4,8 @@ # * | Function : Electronic paper driver # * | Info : # *---------------- -# * | This version: V4.0 -# * | Date : 2019-06-20 +# * | This version: V4.1 +# * | Date : 2022-08-10 # # | Info : python demo # ----------------------------------------------------------------------------- # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -65,12 +65,19 @@ class EPD: epdconfig.digital_write(self.cs_pin, 0) epdconfig.spi_writebyte([data]) epdconfig.digital_write(self.cs_pin, 1) + + # send a lot of data + def send_data2(self, data): + epdconfig.digital_write(self.dc_pin, 1) + epdconfig.digital_write(self.cs_pin, 0) + epdconfig.spi_writebyte2(data) + epdconfig.digital_write(self.cs_pin, 1) def ReadBusy(self): logger.debug("e-Paper busy") - self.send_command(0x71); + self.send_command(0x71) while(epdconfig.digital_read(self.busy_pin) == 0): # 0: idle, 1: busy - self.send_command(0x71); + self.send_command(0x71) epdconfig.delay_ms(20) logger.debug("e-Paper busy release") @@ -114,38 +121,39 @@ class EPD: def display(self, imageblack, imagered): self.send_command(0x10) - for i in range(0, int(self.width * self.height / 8)): - self.send_data(imageblack[i]) + self.send_data2(imageblack) self.send_command(0x13) - for i in range(0, int(self.width * self.height / 8)): - self.send_data(imagered[i]) + self.send_data2(imagered) self.send_command(0x12) epdconfig.delay_ms(20) self.ReadBusy() def Clear(self): + if self.width%8 == 0: + linewidth = int(self.width/8) + else: + linewidth = int(self.width/8) + 1 + self.send_command(0x10) - for i in range(0, int(self.width * self.height / 8)): - self.send_data(0xFF) + self.send_data2([0xff] * int(self.height * linewidth)) self.send_command(0x13) - for i in range(0, int(self.width * self.height / 8)): - self.send_data(0xFF) + self.send_data2([0xff] * int(self.height * linewidth)) self.send_command(0x12) epdconfig.delay_ms(20) self.ReadBusy() def sleep(self): - self.send_command(0X50); - self.send_data(0xf7); #border floating + self.send_command(0X50) + self.send_data(0xf7) #border floating - self.send_command(0X02); #power off - self.ReadBusy(); #waiting for the electronic paper IC to release the idle signal - self.send_command(0X07); #deep sleep - self.send_data(0xA5); + self.send_command(0X02) #power off + self.ReadBusy() #waiting for the electronic paper IC to release the idle signal + self.send_command(0X07) #deep sleep + self.send_data(0xA5) epdconfig.delay_ms(2000) epdconfig.module_exit() diff --git a/RaspberryPi_JetsonNano/python/lib/waveshare_epd/epd5in65f.py b/RaspberryPi_JetsonNano/python/lib/waveshare_epd/epd5in65f.py index fc71d79..711b4a3 100644 --- a/RaspberryPi_JetsonNano/python/lib/waveshare_epd/epd5in65f.py +++ b/RaspberryPi_JetsonNano/python/lib/waveshare_epd/epd5in65f.py @@ -80,7 +80,8 @@ class EPD: epdconfig.spi_writebyte([data]) epdconfig.digital_write(self.cs_pin, 1) - def send_data_bulk(self, data): + # send a lot of data + def send_data2(self, data): epdconfig.digital_write(self.dc_pin, 1) epdconfig.digital_write(self.cs_pin, 0) epdconfig.spi_writebyte2(data) @@ -177,7 +178,7 @@ class EPD: self.send_data(0xC0) self.send_command(0x10) - self.send_data_bulk(image) + self.send_data2(image) self.send_command(0x04) #0x04 self.ReadBusyHigh() self.send_command(0x12) #0x12 @@ -196,7 +197,7 @@ class EPD: # Set all pixels to white buf = [0x11] * int(self.width * self.height / 2) - self.send_data_bulk(buf) + self.send_data2(buf) self.send_command(0x04) #0x04 self.ReadBusyHigh() diff --git a/RaspberryPi_JetsonNano/python/lib/waveshare_epd/epd5in83_V2.py b/RaspberryPi_JetsonNano/python/lib/waveshare_epd/epd5in83_V2.py index 680fcc7..b8e8281 100644 --- a/RaspberryPi_JetsonNano/python/lib/waveshare_epd/epd5in83_V2.py +++ b/RaspberryPi_JetsonNano/python/lib/waveshare_epd/epd5in83_V2.py @@ -4,8 +4,8 @@ # * | Function : Electronic paper driver # * | Info : # *---------------- -# * | This version: V1.0 -# * | Date : 2020-12-09 +# * | This version: V1.1 +# * | Date : 2022-08-10 # # | Info : python demo # ----------------------------------------------------------------------------- # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -65,6 +65,13 @@ class EPD: epdconfig.digital_write(self.cs_pin, 0) epdconfig.spi_writebyte([data]) epdconfig.digital_write(self.cs_pin, 1) + + # send a lot of data + def send_data2(self, data): + epdconfig.digital_write(self.dc_pin, 1) + epdconfig.digital_write(self.cs_pin, 0) + epdconfig.spi_writebyte2(data) + epdconfig.digital_write(self.cs_pin, 1) def ReadBusy(self): logger.debug("e-Paper busy") @@ -140,21 +147,20 @@ class EPD: return buf def display(self, image): + buf = [0x00] * int(self.width * self.height / 8) + for i in range(0, int(self.width * self.height / 8)): + buf[i] = ~image[i] self.send_command(0x10) - for i in range(0, int(self.width * self.height / 8)): - self.send_data(0x00) + self.send_data2([0x00] * int(self.width * self.height / 8)) self.send_command(0x13) - for i in range(0, int(self.width * self.height / 8)): - self.send_data(~image[i]) + self.send_data2(buf) self.TurnOnDisplay() def Clear(self): self.send_command(0x10) - for i in range(0, int(self.width * self.height / 8)): - self.send_data(0x00) + self.send_data2([0x00] * int(self.width * self.height / 8)) self.send_command(0x13) - for i in range(0, int(self.width * self.height / 8)): - self.send_data(0x00) + self.send_data2([0x00] * int(self.width * self.height / 8)) self.TurnOnDisplay() def sleep(self): diff --git a/RaspberryPi_JetsonNano/python/lib/waveshare_epd/epd5in83b_V2.py b/RaspberryPi_JetsonNano/python/lib/waveshare_epd/epd5in83b_V2.py index 67fa7f7..3f424d0 100644 --- a/RaspberryPi_JetsonNano/python/lib/waveshare_epd/epd5in83b_V2.py +++ b/RaspberryPi_JetsonNano/python/lib/waveshare_epd/epd5in83b_V2.py @@ -4,8 +4,8 @@ # * | Function : Electronic paper driver # * | Info : # *---------------- -# * | This version: V1.0 -# * | Date : 2020-07-04 +# * | This version: V1.1 +# * | Date : 2022-08-10 # # | Info : python demo # ----------------------------------------------------------------------------- # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -66,6 +66,13 @@ class EPD: epdconfig.digital_write(self.cs_pin, 0) epdconfig.spi_writebyte([data]) epdconfig.digital_write(self.cs_pin, 1) + + # send a lot of data + def send_data2(self, data): + epdconfig.digital_write(self.dc_pin, 1) + epdconfig.digital_write(self.cs_pin, 0) + epdconfig.spi_writebyte2(data) + epdconfig.digital_write(self.cs_pin, 1) def ReadBusy(self): logger.debug("e-Paper busy") @@ -137,14 +144,16 @@ class EPD: return buf def display(self, imageblack, imagered): + buf = [0x00] * int(self.width * self.height / 8) + for i in range(0, int(self.width * self.height / 8)): + buf[i] = ~imagered[i] + if (imageblack != None): self.send_command(0X10) - for i in range(0, int(self.width * self.height / 8)): - self.send_data(imageblack[i]) + self.send_data2(imageblack) if (imagered != None): self.send_command(0X13) - for i in range(0, int(self.width * self.height / 8)): - self.send_data(~imagered[i]) + self.send_data2(buf) self.send_command(0x12) epdconfig.delay_ms(200) @@ -152,11 +161,9 @@ class EPD: def Clear(self): self.send_command(0X10) - for i in range(0, int(self.width * self.height / 8)): - self.send_data(0xff) + self.send_data2([0xFF] * int(self.width * self.height / 8)) self.send_command(0X13) - for i in range(0, int(self.width * self.height / 8)): - self.send_data(0x00) + self.send_data2([0x00] * int(self.width * self.height / 8)) self.send_command(0x12) epdconfig.delay_ms(200) diff --git a/RaspberryPi_JetsonNano/python/lib/waveshare_epd/epdconfig.py b/RaspberryPi_JetsonNano/python/lib/waveshare_epd/epdconfig.py index f4feff0..3d22c85 100644 --- a/RaspberryPi_JetsonNano/python/lib/waveshare_epd/epdconfig.py +++ b/RaspberryPi_JetsonNano/python/lib/waveshare_epd/epdconfig.py @@ -4,8 +4,8 @@ # * | Function : Hardware underlying interface # * | Info : # *---------------- -# * | This version: V1.0 -# * | Date : 2019-06-21 +# * | This version: V1.1 +# * | Date : 2022-08-10 # * | Info : # ****************************************************************************** # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -29,6 +29,7 @@ import os import logging +from ossaudiodev import SOUND_MIXER_SPEAKER import sys import time @@ -127,6 +128,10 @@ class JetsonNano: def spi_writebyte(self, data): self.SPI.SYSFS_software_spi_transfer(data[0]) + def spi_writebyte2(self, data): + for i in range(len(data)): + self.SPI.SYSFS_software_spi_transfer(data[i]) + def module_init(self): self.GPIO.setmode(self.GPIO.BCM) self.GPIO.setwarnings(False) @@ -147,9 +152,71 @@ class JetsonNano: self.GPIO.cleanup([self.RST_PIN, self.DC_PIN, self.CS_PIN, self.BUSY_PIN]) +class SunriseX3: + # Pin definition + RST_PIN = 17 + DC_PIN = 25 + CS_PIN = 8 + BUSY_PIN = 24 + Flag = 0 + + def __init__(self): + import spidev + import Hobot.GPIO + + self.GPIO = Hobot.GPIO + self.SPI = spidev.SpiDev() + + def digital_write(self, pin, value): + self.GPIO.output(pin, value) + + def digital_read(self, pin): + return self.GPIO.input(pin) + + def delay_ms(self, delaytime): + time.sleep(delaytime / 1000.0) + + def spi_writebyte(self, data): + self.SPI.writebytes(data) + + def spi_writebyte2(self, data): + # for i in range(len(data)): + # self.SPI.writebytes([data[i]]) + self.SPI.xfer3(data) + + def module_init(self): + if self.Flag == 0 : + self.Flag = 1 + self.GPIO.setmode(self.GPIO.BCM) + self.GPIO.setwarnings(False) + self.GPIO.setup(self.RST_PIN, self.GPIO.OUT) + self.GPIO.setup(self.DC_PIN, self.GPIO.OUT) + self.GPIO.setup(self.CS_PIN, self.GPIO.OUT) + self.GPIO.setup(self.BUSY_PIN, self.GPIO.IN) + + # SPI device, bus = 0, device = 0 + self.SPI.open(2, 0) + self.SPI.max_speed_hz = 4000000 + self.SPI.mode = 0b00 + return 0 + else : + return 0 + + def module_exit(self): + logger.debug("spi end") + self.SPI.close() + + logger.debug("close 5V, Module enters 0 power consumption ...") + self.Flag = 0 + self.GPIO.output(self.RST_PIN, 0) + self.GPIO.output(self.DC_PIN, 0) + + self.GPIO.cleanup([self.RST_PIN, self.DC_PIN, self.CS_PIN, self.BUSY_PIN]) if os.path.exists('/sys/bus/platform/drivers/gpiomem-bcm2835'): implementation = RaspberryPi() +elif os.path.exists('/sys/bus/platform/drivers/gpio-x3'): + implementation = SunriseX3() else: implementation = JetsonNano() diff --git a/RaspberryPi_JetsonNano/python/readme_sunrise_CN.txt b/RaspberryPi_JetsonNano/python/readme_sunrise_CN.txt new file mode 100644 index 0000000..1797035 --- /dev/null +++ b/RaspberryPi_JetsonNano/python/readme_sunrise_CN.txt @@ -0,0 +1,47 @@ +/***************************************************************************** +* | File : Readme_CN.txt +* | Author : Waveshare team +* | Function : Help with use +* | Info : +*---------------- +* | This version: V1.0 +* | Date : 2022-08-11 +* | Info : 在这里提供一个中文版本的使用文档,以便你的快速使用 +******************************************************************************/ +这个文件是帮助您使用本例程。 +由于我们的墨水屏越来越多,不便于我们的维护,因此把所有的墨水屏程序做成一个工程。 +在这里简略的描述本工程的使用: + +1.基本信息: +本例程是基于Ubuntu 20.04 Server_20220718系统镜像而开发的 +本例程是基于sunrise x3 pi进行开发的,例程均在sunrise x3 pi上进行了验证; +本例程使用e-paper Driver HAT模块进行了验证,你可以在工程的examples\中查看对应的测试例程; + +2.管脚连接: +管脚连接你可以在\lib\epdconfig.py中查看,这里也再重述一次: +EPD => sunrise x3 pi (BCM) +VCC -> 3.3 +GND -> GND +DIN -> 10(SPI0_MOSI) +CLK -> 11(SPI0_SCK) +CS -> 8(SPI0_CS0) +DC -> 25 +RST -> 17 +BUSY -> 24 + +3.安装库: +系统已经内置库,无需安装 + +4.基本使用: +由于本工程是一个综合工程,对于使用而言,你可能需要阅读以下内容: +你可以在examples\目录中查看测试程序 +请注意你购买的是哪一款的墨水屏。 +栗子1: + 如果你购买的5.83inch e-paper,那么你应该执行命令: + sudo python epd_5in83_test.py +栗子2: + 如果你购买的2.9inch e-paper (B),由于2.9寸的B型和C型是公用的驱动代码, + 那么你应该执行命令: + sudo python epd_2in9bc_test.py + +注意:对于epd_1in54_V2_test.py和epd_2in13_V2_test.py请注意你的屏幕背面是否贴有V2标识。 diff --git a/RaspberryPi_JetsonNano/python/readme_sunrise_EN.txt b/RaspberryPi_JetsonNano/python/readme_sunrise_EN.txt new file mode 100644 index 0000000..c69d814 --- /dev/null +++ b/RaspberryPi_JetsonNano/python/readme_sunrise_EN.txt @@ -0,0 +1,47 @@ +/***************************************************************************** +* | File : Readme_CN.txt +* | Author : Waveshare team +* | Function : Help with use +* | Info : +*---------------- +* | This version: V1.0 +* | Date : 2022-08-11 +* | Info : Here is an English version of the documentation for your quick use. +******************************************************************************/ +This file is to help you use this Demo. +Since our ink screens are getting more and more, it is not convenient for our maintenance, so all the ink screen programs are made into one project. +A brief description of the use of this project is here: + +1. Basic information: +This routine is developed based on the Ubuntu 20.04 Server_20220718 system image +This routine is developed based on Sunrise X3 PI, routines are verified on Sunrise X3 PI; +This routine is verified using the e-paper Driver HAT module. You can check the corresponding test routine in the examples\ of the project. + +2. Pin connection: +Pin connections can be viewed in \lib\epdconfig.py and will be repeated here: +EPD => sunrise x3 pi (BCM) +VCC -> 3.3 +GND -> GND +DIN -> 10(SPI0_MOSI) +CLK -> 11(SPI0_SCK) +CS -> 8(SPI0_CS0) +DC -> 25 +RST -> 17 +BUSY -> 24 + +3.Installation library +The system has built-in libraries, so you do not need to install them + +4. Basic use: +Since this project is a comprehensive project, you may need to read the following for use: +You can view the test program in the examples\ directory. +Please note which ink screen you purchased. +Chestnut 1: +     If you purchased 5.83inch e-paper, then you should execute the command: +     Sudo python epd_5in83_test.py +Chestnut 2: +     If you buy a 2.9inch e-paper (B), since the 2.9-inch Type B and Type C are common driver codes, +     Then you should execute the command: +     Sudo python epd_2in9bc_test.py +     +Note: For epd_1in54_V2_test.py and epd_2in13_V2_test.py, please note that the V2 logo is attached to the back of your screen. diff --git a/RaspberryPi_JetsonNano/python/setup.py b/RaspberryPi_JetsonNano/python/setup.py index a48f5a4..37d998e 100644 --- a/RaspberryPi_JetsonNano/python/setup.py +++ b/RaspberryPi_JetsonNano/python/setup.py @@ -5,6 +5,8 @@ dependencies = ['Pillow'] if os.path.exists('/sys/bus/platform/drivers/gpiomem-bcm2835'): dependencies += ['RPi.GPIO', 'spidev'] +elif os.path.exists('/sys/bus/platform/drivers/gpio-x3'): + dependencies += ['Hobot.GPIO', 'spidev'] else: dependencies += ['Jetson.GPIO']