Welcome to the Pycom forum Forum
    • \[\[global:header.categories\]\]
    • \[\[global:header.recent\]\]
    • \[\[global:header.tags\]\]
    • \[\[global:header.popular\]\]
    • Login

    Explore Pybytes | Official Documentation | Report a Firmware Bug/Issue | GitHub

    pyscan paper ink

    Scheduled Pinned Locked Moved Expansion Board
    23 Posts 2 Posters 130 Views 3 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • robert-hhR Offline
      robert-hh @gael cobert
      last edited by

      @gael-cobert Probing it with amultimeter it turns out, that the P15 and P19 at lower column, where you connectef the blue and lilac cable, are not connected to the socket for the xxPy module. However, the P15 amd P19 labeled pins at the upper socket, where you connected the green and yellow cable, are connected.
      Also: you have to connect mosi to din of the pyper ink, not miso. miso is actually not used at all, so you can select e.g. p13 for it.

      G 1 Reply Last reply Reply Quote 0
      • G Offline
        gael cobert @robert-hh
        last edited by gael cobert

        @robert-hh said in pyscan paper ink:

        you have to connect mosi to din of the pyper ink, not miso. miso is actually not used at all, so you can select e.g. p13 for it.

        ok thanks
        this this a photo of the corrected pin
        https://drive.google.com/file/d/121qPyq86FyFCAwZgKOXwRSW4PqKHniux/view?usp=drivesdk

        i connected RESET pin in P11 --> https://drive.google.com/file/d/126aoKHjdVRYbr9yN0W114HpItaYDK5zA/view?usp=drivesdk

        i don't know what is "mosi" and "miso"
        i have din ( blue cable) connected to P19
        so din must be connected to P13 or P19 ?

        robert-hhR 1 Reply Last reply Reply Quote 0
        • robert-hhR Offline
          robert-hh @gael cobert
          last edited by

          @gael-cobert It's easy to remember once you heard it:
          mosi = Master Out Slave In
          miso = Master In Slave Out

          The connection looks OK.

          G 2 Replies Last reply Reply Quote 0
          • G Offline
            gael cobert @robert-hh
            last edited by gael cobert

            @robert-hh

            ok this is the setup code

            rst = Pin('P11') --> ok ( white ) --> https://drive.google.com/file/d/126aoKHjdVRYbr9yN0W114HpItaYDK5zA/view?usp=drivesdk
            dc = Pin('P10') --> ok ( green )
            busy = Pin('P15') --> ok ( lilac )
            cs = Pin('???') --> KO ( orange ) ?? connected to GND --> must i type Pin('GND')
            clk = Pin('P9') --> ok ( yellow )
            mosi = Pin('???') --> ????? don't understand --> i have no cable ...

            spi = SPI(2, baudrate=20000000, polarity=0, phase=0, pins=(sck, mosi, None))
            
            robert-hhR 1 Reply Last reply Reply Quote 0
            • G Offline
              gael cobert @robert-hh
              last edited by gael cobert

              @robert-hh

              ok this is the setup code

              rst = Pin('P11') --> ok ( white )
              dc = Pin('P10') --> ok ( green )
              busy = Pin('P15') --> ok ( lilac )
              cs = Pin('???') --> KO ( orange ) ?? connected to GND --> must i type Pin('GND')
              clk = Pin('P9') --> ok ( yellow )
              mosi = DIN = Pin('P15') --> blue cable

              spi = SPI(2, baudrate=20000000, polarity=0, phase=0, pins=(sck, mosi, None))
              
              1 Reply Last reply Reply Quote 0
              • robert-hhR Offline
                robert-hh @gael cobert
                last edited by

                @gael-cobert
                since you have connected the cs pin of the device to GND, you can skip it in your code. I recommended that to save port pins. It requires howerver to change the code.
                mosi is the pin for DIN of the display, used to send data to the display. So you have that connected to P19.
                The SPI signal which you do not need is miso, because no data is read back from the display.

                G 2 Replies Last reply Reply Quote 0
                • G Offline
                  gael cobert @robert-hh
                  last edited by

                  ok thanks it seems ok so now i have this error :

                  Traceback (most recent call last):
                    File "main.py", line 76, in <module>
                    File "/flash/lib/epaper7in5.py", line 135, in display_frame
                  IndexError: bytearray index out of range
                  
                  """
                  	Example for 4.2 inch black & white Waveshare E-ink screen
                  	Run on ESP32
                  """
                  
                  import epaper7in5
                  from machine import Pin, SPI
                  
                  # SPIV on ESP32
                   
                  
                  rst = Pin('P11')
                  dc = Pin('P10')
                  busy = Pin('P15')
                  cs = Pin('P4')
                  clk = Pin('P9')
                  mosi = Pin('P15')
                  
                  
                  spi = SPI(0, mode=SPI.MASTER, baudrate=2000000, polarity=0, phase=0, pins=(clk, mosi, None))
                  
                  e = epaper7in5.EPD(spi, cs, dc, rst, busy)
                  e.init()
                  
                  w = 600
                  h = 384
                  x = 0
                  y = 0
                  
                  # --------------------
                  
                  # use a frame buffer
                  # 400 * 300 / 8 = 15000 - thats a lot of pixels
                  import framebuf
                  buf = bytearray(w * h // 8)
                  fb = framebuf.FrameBuffer(buf, w, h, framebuf.MONO_HLSB)
                  black = 0
                  white = 1
                  fb.fill(white)
                  
                  # --------------------
                  
                  # write hello world with black bg and white text
                  from image_dark import hello_world_dark
                  from image_light import hello_world_light
                  print('Image dark')
                  #bufImage = hello_world_dark
                  #fbImage = framebuf.FrameBuffer(bufImage, 128, 296, framebuf.MONO_HLSB)
                  #fb.blit(fbImage, 20, 2)
                  #bufImage = hello_world_light
                  #fbImage = framebuf.FrameBuffer(bufImage, 128, 296, framebuf.MONO_HLSB)
                  #fb.blit(fbImage, 168, 2)
                  #e.display_frame(buf)
                  
                  # --------------------
                  
                  # write hello world with white bg and black text
                  print('Image light')
                  #e.display_frame(hello_world_light)
                  
                  # --------------------
                  
                  
                  print('Frame buffer things')
                  fb.fill(white)
                  fb.text('Hello World',30,0,black)
                  #fb.pixel(30, 10, black)
                  #fb.hline(30, 30, 10, black)
                  #fb.vline(30, 50, 10, black)
                  #fb.line(30, 70, 40, 80, black)
                  #fb.rect(30, 90, 10, 10, black)
                  #fb.fill_rect(30, 110, 10, 10, black)
                  #for row in range(0,36):
                  #	fb.text(str(row),0,row*8,black)
                  #fb.text('Line 36',0,288,black)
                  e.display_frame(buf)
                  
                  # --------------------
                  
                  # wrap text inside a box
                  black = 0
                  white = 1
                  # clear
                  fb.fill(white)
                  # display as much as this as fits in the box
                  str = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam vel neque in elit tristique vulputate at et dui. Maecenas nec felis lectus. Pellentesque sit amet facilisis dui. Maecenas ac arcu euismod, tempor massa quis, ultricies est.'
                  
                  # this could be useful as a new method in FrameBuffer
                  def text_wrap(str,x,y,color,w,h,border=None):
                  	# optional box border
                  	if border is not None:
                  		fb.rect(x, y, w, h, border)
                  	cols = w // 8
                  	# for each row
                  	j = 0
                  	for i in range(0, len(str), cols):
                  		# draw as many chars fit on the line
                  		fb.text(str[i:i+cols], x, y + j, color)
                  		j += 8
                  		# dont overflow text outside the box
                  		if j >= h:
                  			break
                  
                  # clear
                  fb.fill(white)
                  
                  # draw text box 1
                  # box position and dimensions
                  print('Box 1')
                  bx = 8
                  by = 8
                  bw = 112 #  = 14 cols
                  bh = 112 #  = 14 rows (196 chars in total)
                  text_wrap(str,bx,by,black,bw,bh,black)
                  e.display_frame(buf)
                  
                  # draw text box 2
                  print('Box 2 & 3')
                  bx = 0
                  by = 128
                  bw = w # 128 = 16 cols
                  bh = 6 * 8 # 48 = 6 rows (96 chars in total)
                  text_wrap(str,bx,by,black,bw,bh,black)
                  
                  # draw text box 3
                  bx = 0
                  by = 184
                  bw = w//2 # 64 = 8 cols
                  bh = 8 * 8 # 64 = 8 rows (64 chars in total)
                  text_wrap(str,bx,by,black,bw,bh,None)
                  e.display_frame(buf)
                  
                  # --------------------
                  
                  
                  robert-hhR 2 Replies Last reply Reply Quote 0
                  • robert-hhR Offline
                    robert-hh @gael cobert
                    last edited by

                    @gael-cobert You have set MOSI to P15. That's not possible. and in fact you use P19

                    1 Reply Last reply Reply Quote 0
                    • robert-hhR Offline
                      robert-hh @gael cobert
                      last edited by

                      @gael-cobert In the epaper driver the dimension is set to 640x384, in your control code you use 600x384. These two setting must match.

                      G 2 Replies Last reply Reply Quote 0
                      • G Offline
                        gael cobert @robert-hh
                        last edited by gael cobert

                        @robert-hh
                        yes thanks
                        i checked the screen model
                        i have this one : 5.83inch-e-paper (waveshare website 640x480)
                        so
                        i changed the driver for : epaper5in83 (600x448)
                        but now i have this error

                        Traceback (most recent call last):
                        File "<stdin>", line 60, in <module>
                        File "/flash/lib/epaper5in83.py", line 136, in display_frame
                        IndexError: bytearray index out of range

                        """
                        	Example for 4.2 inch black & white Waveshare E-ink screen
                        	Run on ESP32
                        """
                        
                        import epaper5in83
                        from machine import Pin, SPI
                        
                        # SPIV on ESP32
                         
                        
                        rst = Pin('P11')
                        dc = Pin('P10')
                        busy = Pin('P15')
                        cs = Pin('P4')
                        clk = Pin('P9')
                        mosi = Pin('P19')
                        
                        
                        spi = SPI(0, mode=SPI.MASTER, baudrate=2000000, polarity=0, phase=0, pins=(clk, mosi, None))
                        
                        e = epaper5in83.EPD(spi, cs, dc, rst, busy)
                        e.init()
                        
                        w = 600
                        h = 448
                        x = 0
                        y = 0
                        
                        # --------------------
                        
                        # use a frame buffer
                        # 400 * 300 / 8 = 15000 - thats a lot of pixels
                        import framebuf
                        buf = bytearray(w * h // 8)
                        fb = framebuf.FrameBuffer(buf, w, h, framebuf.MONO_HLSB)
                        black = 0
                        white = 1
                        fb.fill(white)
                        
                        # --------------------
                        
                        # write hello world with black bg and white text
                        from image_dark import hello_world_dark
                        from image_light import hello_world_light
                        print('Image dark')
                        #bufImage = hello_world_dark
                        #fbImage = framebuf.FrameBuffer(bufImage, 128, 296, framebuf.MONO_HLSB)
                        #fb.blit(fbImage, 20, 2)
                        #bufImage = hello_world_light
                        #fbImage = framebuf.FrameBuffer(bufImage, 128, 296, framebuf.MONO_HLSB)
                        #fb.blit(fbImage, 168, 2)
                        #e.display_frame(buf)
                        
                        # --------------------
                        
                        # write hello world with white bg and black text
                        print('Image light')
                        e.display_frame(hello_world_light)
                        
                        # --------------------
                        
                        
                        print('Frame buffer things')
                        fb.fill(white)
                        fb.text('Hello World',30,0,black)
                        #fb.pixel(30, 10, black)
                        #fb.hline(30, 30, 10, black)
                        #fb.vline(30, 50, 10, black)
                        #fb.line(30, 70, 40, 80, black)
                        #fb.rect(30, 90, 10, 10, black)
                        #fb.fill_rect(30, 110, 10, 10, black)
                        #for row in range(0,36):
                        #	fb.text(str(row),0,row*8,black)
                        #fb.text('Line 36',0,288,black)
                        e.display_frame(buf)
                        
                        # --------------------
                        
                        # wrap text inside a box
                        black = 0
                        white = 1
                        # clear
                        fb.fill(white)
                        # display as much as this as fits in the box
                        str = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam vel neque in elit tristique vulputate at et dui. Maecenas nec felis lectus. Pellentesque sit amet facilisis dui. Maecenas ac arcu euismod, tempor massa quis, ultricies est.'
                        
                        # this could be useful as a new method in FrameBuffer
                        def text_wrap(str,x,y,color,w,h,border=None):
                        	# optional box border
                        	if border is not None:
                        		fb.rect(x, y, w, h, border)
                        	cols = w // 8
                        	# for each row
                        	j = 0
                        	for i in range(0, len(str), cols):
                        		# draw as many chars fit on the line
                        		fb.text(str[i:i+cols], x, y + j, color)
                        		j += 8
                        		# dont overflow text outside the box
                        		if j >= h:
                        			break
                        
                        # clear
                        fb.fill(white)
                        
                        # draw text box 1
                        # box position and dimensions
                        print('Box 1')
                        bx = 8
                        by = 8
                        bw = 112 #  = 14 cols
                        bh = 112 #  = 14 rows (196 chars in total)
                        text_wrap(str,bx,by,black,bw,bh,black)
                        e.display_frame(buf)
                        
                        # draw text box 2
                        print('Box 2 & 3')
                        bx = 0
                        by = 128
                        bw = w # 128 = 16 cols
                        bh = 6 * 8 # 48 = 6 rows (96 chars in total)
                        text_wrap(str,bx,by,black,bw,bh,black)
                        
                        # draw text box 3
                        bx = 0
                        by = 184
                        bw = w//2 # 64 = 8 cols
                        bh = 8 * 8 # 64 = 8 rows (64 chars in total)
                        text_wrap(str,bx,by,black,bw,bh,None)
                        e.display_frame(buf)
                        
                        # --------------------
                        
                        
                        1 Reply Last reply Reply Quote 0
                        • G Offline
                          gael cobert @robert-hh
                          last edited by gael cobert

                          @robert-hh
                          hello i have another 4.2 paper ink screen (WFT0420CZ15)
                          so i changed the driver and the resolution (400x300), no more error but the screen do not respond / change :p

                          """
                          	Example for 4.2 inch black & white Waveshare E-ink screen
                          	Run on ESP32
                          """
                          
                          import epaper4in2
                          from machine import Pin, SPI
                          
                          # SPIV on ESP32
                           
                          
                          rst = Pin('P11')
                          dc = Pin('P10')
                          busy = Pin('P15')
                          cs = Pin('P4')
                          clk = Pin('P9')
                          mosi = Pin('P19')
                          
                          
                          spi = SPI(0, mode=SPI.MASTER, baudrate=2000000, polarity=0, phase=0, pins=(clk, mosi, None))
                          
                          e = epaper4in2.EPD(spi, cs, dc, rst, busy)
                          e.init()
                          
                          w = 400
                          h = 300
                          x = 0
                          y = 0
                          
                          # --------------------
                          
                          # use a frame buffer
                          # 400 * 300 / 8 = 15000 - thats a lot of pixels
                          import framebuf
                          buf = bytearray(w * h // 8)
                          fb = framebuf.FrameBuffer(buf, w, h, framebuf.MONO_HLSB)
                          black = 0
                          white = 1
                          fb.fill(white)
                          
                          # --------------------
                          
                          # write hello world with black bg and white text
                          #from image_dark import hello_world_dark
                          #from image_light import hello_world_light
                          print('Image dark')
                          #bufImage = hello_world_dark
                          #fbImage = framebuf.FrameBuffer(bufImage, 128, 296, framebuf.MONO_HLSB)
                          #fb.blit(fbImage, 20, 2)
                          #bufImage = hello_world_light
                          #fbImage = framebuf.FrameBuffer(bufImage, 128, 296, framebuf.MONO_HLSB)
                          #fb.blit(fbImage, 168, 2)
                          #e.display_frame(buf)
                          
                          # --------------------
                          
                          # write hello world with white bg and black text
                          print('Image light')
                          #e.display_frame(hello_world_light)
                          
                          # --------------------
                          
                          
                          print('Frame buffer things')
                          fb.fill(white)
                          fb.text('Hello World',30,0,black)
                          #fb.pixel(30, 10, black)
                          #fb.hline(30, 30, 10, black)
                          #fb.vline(30, 50, 10, black)
                          #fb.line(30, 70, 40, 80, black)
                          #fb.rect(30, 90, 10, 10, black)
                          #fb.fill_rect(30, 110, 10, 10, black)
                          #for row in range(0,36):
                          #	fb.text(str(row),0,row*8,black)
                          #fb.text('Line 36',0,288,black)
                          e.display_frame(buf)
                          
                          # --------------------
                          
                          # wrap text inside a box
                          black = 0
                          white = 1
                          # clear
                          fb.fill(white)
                          # display as much as this as fits in the box
                          str = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam vel neque in elit tristique vulputate at et dui. Maecenas nec felis lectus. Pellentesque sit amet facilisis dui. Maecenas ac arcu euismod, tempor massa quis, ultricies est.'
                          
                          # this could be useful as a new method in FrameBuffer
                          def text_wrap(str,x,y,color,w,h,border=None):
                          	# optional box border
                          	if border is not None:
                          		fb.rect(x, y, w, h, border)
                          	cols = w // 8
                          	# for each row
                          	j = 0
                          	for i in range(0, len(str), cols):
                          		# draw as many chars fit on the line
                          		fb.text(str[i:i+cols], x, y + j, color)
                          		j += 8
                          		# dont overflow text outside the box
                          		if j >= h:
                          			break
                          
                          # clear
                          fb.fill(white)
                          
                          # draw text box 1
                          # box position and dimensions
                          print('Box 1')
                          bx = 8
                          by = 8
                          bw = 112 #  = 14 cols
                          bh = 112 #  = 14 rows (196 chars in total)
                          text_wrap(str,bx,by,black,bw,bh,black)
                          e.display_frame(buf)
                          
                          # draw text box 2
                          print('Box 2 & 3')
                          bx = 0
                          by = 128
                          bw = w # 128 = 16 cols
                          bh = 6 * 8 # 48 = 6 rows (96 chars in total)
                          text_wrap(str,bx,by,black,bw,bh,black)
                          
                          # draw text box 3
                          bx = 0
                          by = 184
                          bw = w//2 # 64 = 8 cols
                          bh = 8 * 8 # 64 = 8 rows (64 chars in total)
                          text_wrap(str,bx,by,black,bw,bh,None)
                          e.display_frame(buf)
                          
                          # --------------------
                          
                          robert-hhR 1 Reply Last reply Reply Quote 0
                          • G Offline
                            gael cobert @robert-hh
                            last edited by

                            @robert-hh
                            if i skip cs in the code,
                            how can i init : e = epaper4in2.EPD(spi,cs , dc, rst, busy)
                            because it needs "cs" ....

                            robert-hhR 1 Reply Last reply Reply Quote 0
                            • robert-hhR Offline
                              robert-hh @gael cobert
                              last edited by

                              @gael-cobert said in pyscan paper ink:

                              clk = Pin('P9')
                              mosi = Pin('P19')

                              No sign of life at all? no flickering? Check the wiring again.
                              I use the SPI constructor usually with the Pin names instead of Pin objects. That would then be:

                              clk = "P9"
                              mosi = "P19"

                              There are switches on the HAT. Did you set them accordingly. You are using the 4 wire SPI mode. And the display config switch must be at B.

                              G 1 Reply Last reply Reply Quote 0
                              • robert-hhR Offline
                                robert-hh @gael cobert
                                last edited by

                                @gael-cobert You assigned P4 to CS. So you can use that in the code, albeit cs is not connected to the display. The display has CS permanently active, since you wired it to GND. You can of course connect teh CS of the display to P4, or use P8, since you already soldered a connector to the bottom. But that seems not the problem here.

                                1 Reply Last reply Reply Quote 0
                                • G Offline
                                  gael cobert @robert-hh
                                  last edited by gael cobert

                                  @robert-hh

                                  no flickering at all, no sign of life :p
                                  last photo
                                  https://drive.google.com/file/d/12FfBYLkFZt49QnGn-oToWulc4fcd8lRR/view?usp=sharing

                                  is it important to plug the RST cable ?

                                  """
                                  	Example for 4.2 inch black & white Waveshare E-ink screen
                                  	Run on ESP32
                                  """
                                  
                                  import epaper4in2
                                  from machine import Pin, SPI
                                  
                                  # SPIV on ESP32
                                   
                                  
                                  rst = Pin('P11')
                                  dc = Pin('P10')
                                  busy = Pin('P15')
                                  cs = Pin('P4')
                                  clk = Pin('P9')
                                  mosi = Pin('P19')
                                  
                                  
                                  spi = SPI(0, mode=SPI.MASTER, baudrate=2000000, polarity=0, phase=0, pins=(clk, mosi, None))
                                  
                                  e = epaper4in2.EPD(spi, cs, dc, rst, busy)
                                  e.init()
                                  
                                  w = 400
                                  h = 300
                                  x = 0
                                  y = 0
                                  
                                  # --------------------
                                  
                                  # use a frame buffer
                                  # 400 * 300 / 8 = 15000 - thats a lot of pixels
                                  import framebuf
                                  buf = bytearray(w * h // 8)
                                  fb = framebuf.FrameBuffer(buf, w, h, framebuf.MONO_HLSB)
                                  black = 0
                                  white = 1
                                  fb.fill(white)
                                  
                                  print('print hello world')
                                  fb.fill(white)
                                  fb.text('Hello World',30,0,black)
                                  #fb.pixel(30, 10, black)
                                  #fb.hline(30, 30, 10, black)
                                  #fb.vline(30, 50, 10, black)
                                  #fb.line(30, 70, 40, 80, black)
                                  #fb.rect(30, 90, 10, 10, black)
                                  #fb.fill_rect(30, 110, 10, 10, black)
                                  #for row in range(0,36):
                                  #	fb.text(str(row),0,row*8,black)
                                  #fb.text('Line 36',0,288,black)
                                  e.display_frame(buf)
                                  
                                  
                                  # --------------------
                                  
                                  
                                  robert-hhR 1 Reply Last reply Reply Quote 0
                                  • robert-hhR Offline
                                    robert-hh @gael cobert
                                    last edited by

                                    @gael-cobert RST is required. Did you check that you connected the flat cable between HAT and display the right way around?
                                    Checking the board it seems that the Pinout paper is wrong. The PIN where the white cabel is connected to is actually P10. left to it is P4, right to it P2. The rows in the Pinout are swapped.

                                    1 Reply Last reply Reply Quote 0

                                    Hello! It looks like you're interested in this conversation, but you don't have an account yet.

                                    Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

                                    With your input, this post could be even better 💗

                                    Register Login
                                    • 1
                                    • 2
                                    • 2 / 2
                                    • First post
                                      Last post

                                    Pycom on Twitter

                                    Pycom