Example #1
0
 def reset(self):
     epdconfig.digital_write(self.reset_pin, 1)
     epdconfig.delay_ms(200)
     epdconfig.digital_write(self.reset_pin, 0)
     epdconfig.delay_ms(10)
     epdconfig.digital_write(self.reset_pin, 1)
     epdconfig.delay_ms(200)
Example #2
0
 def reset(self):
     epdconfig.digital_write(self.reset_pin, GPIO.HIGH)
     epdconfig.delay_ms(200)
     epdconfig.digital_write(self.reset_pin, GPIO.LOW)  # module reset
     epdconfig.delay_ms(200)
     epdconfig.digital_write(self.reset_pin, GPIO.HIGH)
     epdconfig.delay_ms(200)
Example #3
0
    def display_Partial(self, image):
        if (image == None):
            return

        epdconfig.digital_write(self.reset_pin, 0)
        epdconfig.delay_ms(2)
        epdconfig.digital_write(self.reset_pin, 1)
        epdconfig.delay_ms(2)

        self.SendLut()
        self.send_command(0x37)
        self.send_data(0x00)
        self.send_data(0x00)
        self.send_data(0x00)
        self.send_data(0x00)
        self.send_data(0x00)
        self.send_data(0x40)
        self.send_data(0x00)
        self.send_data(0x00)
        self.send_data(0x00)
        self.send_data(0x00)

        self.send_command(0x3C)
        # BorderWavefrom
        self.send_data(0x80)

        self.send_command(0x22)
        self.send_data(0xC0)
        self.send_command(0x20)
        self.ReadBusy()

        self.SetWindow(0, 0, self.width - 1, self.height - 1)
        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.TurnOnDisplay_Partial()
Example #4
0
 def reset(self):
     logger.debug("Reset module...")
     epdconfig.digital_write(self.reset_pin, GPIO.HIGH)
     epdconfig.delay_ms(50)
     epdconfig.digital_write(self.reset_pin, GPIO.LOW)  # module reset
     epdconfig.delay_ms(50)
     epdconfig.digital_write(self.reset_pin, GPIO.HIGH)
     epdconfig.delay_ms(50)
Example #5
0
    def DisplayPartial(self, image):
        if (Image == None):
            return
        self.SetPartReg()
        self.send_command(0x91)
        self.send_command(0x90)
        self.send_data(0)
        self.send_data(self.width - 1)

        self.send_data(0)
        self.send_data(0)
        self.send_data(self.height // 256)
        self.send_data(self.height % 256 - 1)
        self.send_data(0x28)
        self.send_command(0x10)
        for i in range(0, self.width * self.height // 8):
            self.send_data(image[i])
        epdconfig.delay_ms(10)
        self.send_command(0x13)
        for i in range(0, self.width * self.height // 8):
            self.send_data(~image[i])
        epdconfig.delay_ms(10)
        self.TurnOnDisplay()
    def init(self):
        if (epdconfig.module_init() != 0):
            return -1
        # EPD hardware init start
        self.reset()

        self.send_command(0x01)  #POWER SETTING
        self.send_data(0x07)
        self.send_data(0x07)  #VGH=20V,VGL=-20V
        self.send_data(0x3f)  #VDH=15V
        self.send_data(0x3f)  #VDL=-15V

        self.send_command(0x04)  #POWER ON
        epdconfig.delay_ms(100)
        self.ReadBusy()

        self.send_command(0X00)  #PANNEL SETTING
        self.send_data(0x1F)  #KW-3f   KWR-2F	BWROTP 0f	BWOTP 1f

        self.send_command(0x61)  #tres
        self.send_data(0x03)  #source 800
        self.send_data(0x20)
        self.send_data(0x01)  #gate 480
        self.send_data(0xE0)

        self.send_command(0X15)
        self.send_data(0x00)

        self.send_command(0X50)  #VCOM AND DATA INTERVAL SETTING
        self.send_data(0x10)
        self.send_data(0x07)

        self.send_command(0X60)  #TCON SETTING
        self.send_data(0x22)

        # EPD hardware init end
        return 0
    def init(self):
        if (epdconfig.module_init() != 0):
            return -1
            
        self.reset()
        
        self.send_command(0x01);			#POWER SETTING
        self.send_data(0x07);
        self.send_data(0x07);    #VGH=20V,VGL=-20V
        self.send_data(0x3f);		#VDH=15V
        self.send_data(0x3f);		#VDL=-15V

        self.send_command(0x04); #POWER ON
        epdconfig.delay_ms(100);
        self.ReadBusy();

        self.send_command(0X00);			#PANNEL SETTING
        self.send_data(0x0F);   #KW-3f   KWR-2F	BWROTP 0f	BWOTP 1f

        self.send_command(0x61);        	#tres
        self.send_data(0x03);		#source 800
        self.send_data(0x20);
        self.send_data(0x01);		#gate 480
        self.send_data(0xE0);

        self.send_command(0X15);
        self.send_data(0x00);

        self.send_command(0X50);			#VCOM AND DATA INTERVAL SETTING
        self.send_data(0x11);
        self.send_data(0x07);

        self.send_command(0X60);			#TCON SETTING
        self.send_data(0x22);
        
        return 0
Example #8
0
    
    font24 = ImageFont.truetype('/usr/share/fonts/truetype/freefont/FreeSans.ttf', 24)

    while 1:
       # t1=time.time()
        Himage = Image.new('1', (epd2in7.EPD_HEIGHT, epd2in7.EPD_WIDTH), 255)  # 255: clear the frame
        #t2=time.time()
        #print("1:"+str(t2-t1))

        draw = ImageDraw.Draw(Himage)
        #t3=time.time()
        #print("2:"+str(t3-t2))
        draw.text((10, 0), 'hello world', font = font24, fill = 0)
        draw.text((10,30),str(time.time()),font =font24 ,fill=0)
        #t4=time.time()
       # print("3:"+str(t4-t3))
        epd.display(epd.getbuffer(Himage))
        #t5=time.time()
       # print("4:"+str(t5-t4))
        epdconfig.delay_ms(100)
        print(str(time.time()))
        



except:
    print('traceback.format_exc():\n%s',traceback.format_exc())
    exit()

Example #9
0
 def wait_until_idle(self):
     print("e-Paper busy")
     while (epdconfig.digital_read(self.busy_pin) == 0):  # 0: idle, 1: busy
         self.send_command(0x71)
         epdconfig.delay_ms(100)
     print("e-Paper busy release")
Example #10
0
 def ReadBusy(self):
     print("e-Paper busy")
     while (epdconfig.digital_read(
             self.busy_pin) == 0):  #  0: idle, 1: busy
         epdconfig.delay_ms(200)
     print("e-Paper busy release")
Example #11
0
 def ReadBusy(self):
     while(epdconfig.digital_read(self.busy_pin) == 1):      #  0: idle, 1: busy
         epdconfig.delay_ms(200) 
Example #12
0
 def TurnOnDisplay(self):
     self.send_command(0x12)
     epdconfig.delay_ms(10)
     self.ReadBusy()
Example #13
0
 def wait_until_idle(self):
     self.logger.debug("e-Paper busy")
     while (epdconfig.digital_read(self.busy_pin) == 0):  # 0: busy, 1: idle
         epdconfig.delay_ms(100)
     self.logger.debug("e-Paper busy release")
Example #14
0
 def wait_until_idle(self):
     #print("e-Paper busy")
     while (epdconfig.digital_read(self.busy_pin) == 0):  # 0: busy, 1: idle
         epdconfig.delay_ms(100)
Example #15
0
 def wait_until_idle(self):
     i = 0
     while(epdconfig.digital_read(self.busy_pin) == 0):      # 0: idle, 1: busy
         print('wfi', i)
         i+=1
         epdconfig.delay_ms(100)    
Example #16
0
 def wait_until_idle(self):
     logger.debug("e-Paper busy")
     while (epdconfig.digital_read(self.busy_pin) == 0):  # 0: idle, 1: busy
         epdconfig.delay_ms(50)
     logger.debug("e-Paper busy release")
Example #17
0
 def ReadBusy(self):
     print("e-Paper busy")
     while (epdconfig.digital_read(self.busy_pin) == 1):
         epdconfig.delay_ms(100)
     print("e-Paper busy release")
 def wait_until_idle(self):
     print("busy")
     while(epdconfig.digital_read(self.busy_pin) == 1):      # 0: idle, 1: busy
         epdconfig.delay_ms(100)
     print("free busy")
Example #19
0
 def ReadBusy(self):
     logging.debug("e-Paper busy")
     while(epdconfig.digital_read(self.busy_pin) == 0): # 0: idle, 1: busy
         epdconfig.delay_ms(100)
     logging.debug("e-Paper busy release")
Example #20
0
    def sleep(self):
        self.send_command(0x10)  #deep sleep
        self.send_data(0x01)

        epdconfig.delay_ms(2000)
        epdconfig.module_exit()
Example #21
0
 def wait_until_idle(self):
     print "e-Paper busy"
     while (epdconfig.digital_read(self.busy_pin) == 0):  # 0: idle, 1: busy
         epdconfig.delay_ms(100)
     print "e-Paper busy release"
 def ReadBusy(self):
     logging.debug("e-Paper busy")
     busy = epdconfig.digital_read(self.busy_pin)
     while (busy == 1):
         busy = epdconfig.digital_read(self.busy_pin)
     epdconfig.delay_ms(200)
Example #23
0
 def wait_until_idle(self):        
     while(epdconfig.digital_read(self.busy_pin) == 0):      # 0: idle, 1: busy
         self.send_command(0x71)
     epdconfig.delay_ms(100)    
Example #24
0
 def sleep(self):
     self.send_command(0x10)  #enter deep sleep
     # self.send_data(0x01)
     epdconfig.delay_ms(100)
Example #25
0
 def TurnOnDisplay(self):
     self.send_command(0x12)
     epdconfig.delay_ms(10)
     self.wait_until_idle()
Example #26
0
    def display_4Gray(self, image):
        self.send_command(0x10)
        for i in range(0, 5808):  #5808*4  46464
            temp3 = 0
            for j in range(0, 2):
                temp1 = image[i * 2 + j]
                for k in range(0, 2):
                    temp2 = temp1 & 0xC0
                    if (temp2 == 0xC0):
                        temp3 |= 0x01  #white
                    elif (temp2 == 0x00):
                        temp3 |= 0x00  #black
                    elif (temp2 == 0x80):
                        temp3 |= 0x01  #gray1
                    else:  #0x40
                        temp3 |= 0x00  #gray2
                    temp3 <<= 1

                    temp1 <<= 2
                    temp2 = temp1 & 0xC0
                    if (temp2 == 0xC0):  #white
                        temp3 |= 0x01
                    elif (temp2 == 0x00):  #black
                        temp3 |= 0x00
                    elif (temp2 == 0x80):
                        temp3 |= 0x01  #gray1
                    else:  #0x40
                        temp3 |= 0x00  #gray2
                    if (j != 1 or k != 1):
                        temp3 <<= 1
                    temp1 <<= 2
            self.send_data(temp3)

        self.send_command(0x13)
        for i in range(0, 5808):  #5808*4  46464
            temp3 = 0
            for j in range(0, 2):
                temp1 = image[i * 2 + j]
                for k in range(0, 2):
                    temp2 = temp1 & 0xC0
                    if (temp2 == 0xC0):
                        temp3 |= 0x01  #white
                    elif (temp2 == 0x00):
                        temp3 |= 0x00  #black
                    elif (temp2 == 0x80):
                        temp3 |= 0x00  #gray1
                    else:  #0x40
                        temp3 |= 0x01  #gray2
                    temp3 <<= 1

                    temp1 <<= 2
                    temp2 = temp1 & 0xC0
                    if (temp2 == 0xC0):  #white
                        temp3 |= 0x01
                    elif (temp2 == 0x00):  #black
                        temp3 |= 0x00
                    elif (temp2 == 0x80):
                        temp3 |= 0x00  #gray1
                    else:  #0x40
                        temp3 |= 0x01  #gray2
                    if (j != 1 or k != 1):
                        temp3 <<= 1
                    temp1 <<= 2
            self.send_data(temp3)

        self.gray_SetLut()
        self.send_command(0x12)
        epdconfig.delay_ms(200)
        self.ReadBusy()
Example #27
0
 def wait_until_idle(self):
     while(epdconfig.digital_read(self.busy_pin) == 0):      # 0: idle, 1: busy
         epdconfig.delay_ms(100)    
Example #28
0
    def init(self, mode):
        if (epdconfig.module_init() != 0):
            return -1
        # EPD hardware init start
        self.reset()

        self.send_command(0x12)
        epdconfig.delay_ms(300)

        self.send_command(0x46)
        self.send_data(0xF7)
        self.ReadBusy()
        self.send_command(0x47)
        self.send_data(0xF7)
        self.ReadBusy()

        self.send_command(0x01)  # setting gaet number
        self.send_data([0xDF, 0x01, 0x00])

        self.send_command(0x03)  # set gate voltage
        self.send_data(0x00)

        self.send_command(0x04)  # set source voltage
        self.send_data([0x41, 0xA8, 0x32])

        self.send_command(0x11)  # set data entry sequence
        if self.rotation == 0:
            self.send_data(0x03)
        elif self.rotation == 180:
            self.send_data(0x00)
        elif self.rotation == 90:
            self.send_data(0x06)
        elif self.rotation == 270:
            self.send_data(0x05)
        else:
            raise ValueError(f"Incorrect rotation selected")

        self.send_command(0x3C)  # set border
        self.send_data(0x03)

        self.send_command(0x0C)  # set booster strength
        self.send_data([0xAE, 0xC7, 0xC3, 0xC0, 0xC0])

        self.send_command(0x18)  # set internal sensor on
        self.send_data(0x80)

        self.send_command(0x2C)  # set vcom value
        self.send_data(0x44)

        if (mode == 0):  #4Gray
            self.send_command(
                0x37
            )  # set display option, these setting turn on previous function
            self.send_data(
                [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00])
        elif (mode == 1):  #1Gray
            self.send_command(
                0x37
            )  # set display option, these setting turn on previous function
            # can switch 1 gray or 4 gray
            self.send_data(
                [0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0x4F, 0xFF, 0xFF, 0xFF, 0xFF])
        else:
            logger.debug("There is no such mode")

        self.set_window()

        self.send_command(0x22)  # Display Update Control 2
        self.send_data(0xCF)
        return 0