pyscan paper ink



  • hello
    i want to use this paper ink hat with my pyscan
    https://www.waveshare.com/wiki/E-Paper_Driver_HAT
    is it possible to connect it to the pyscan ?
    https://docs.pycom.io/gitbook/assets/pyscan-pinout.pdf

    where must i connect the pin ?
    3.3V ->
    GND -->
    DIN -->
    CLK -->
    CS -->
    DC -->
    RST -->
    BUSY

    and do you know a micropython library for this HAT ?

    thanks



  • @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.



  • @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)
    
    
    # --------------------
    
    


  • @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.



  • @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.



  • @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-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-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)
    
    # --------------------
    
    


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



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



  • 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)
    
    # --------------------
    
    


  • @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.



  • @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))
    


  • @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))
    


  • @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.



  • @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 ?



  • @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.



  • @robert-hh said in pyscan paper ink:

    miso = "P19"

    ok thanks !
    this is a picture of the board / HAT and pin
    https://drive.google.com/file/d/11vN_3IOCtbFyNRU48OogThDfdZR2UpcA/view

    can you confirm miso = "P19"

    what is miso and mosi ? because i have DIN, CLK, CS, DC etc

    the new code :

    # SPIV on ESP32
    sck = "P18"
    miso = "P19"
    mosi = "P23"
    #dc = Pin(10)
    #cs = Pin(33)
    #rst = Pin(2)
    #busy = Pin(15)
    spi = SPI(2, baudrate=20000000, polarity=0, phase=0, pins=(sck, mosi, miso))
    
    

    and the error is now

    Traceback (most recent call last):
      File "<stdin>", line 18, in <module>
    OSError: resource not available
    


  • @gael-cobert In the Pycom world ĥave to write

    sck = "P18"
    miso = "P19"
    mosi = "P23"

    and then

    spi = SPI(2, baudrate=20000000, polarity=0, phase=0, pins=(sck, mosi, miso))

    You have to use either the Pxx numbers of the development board, or the Gxx numbers of the expansion board, but NEVER the GPIO numbers of the ESP32.

    See: https://docs.pycom.io/firmwareapi/pycom/machine/spi/ and
    https://docs.pycom.io/firmwareapi/pycom/machine/pin/#app



  • @robert-hh hello thanks

    when i start the program i have this error

    File "<stdin>", line 33, in <module>
    ValueError: invalid argument(s) value

    line 33 is : miso = Pin(19)

    SPIV on ESP32

    sck = Pin(18)
    miso = Pin(19)
    mosi = Pin(23)
    dc = Pin(32)
    cs = Pin(33)
    rst = Pin(19)
    busy = Pin(35)
    spi = SPI(2, baudrate=20000000, polarity=0, phase=0, sck=sck, miso=miso, mosi=mosi)


Log in to reply
 

Pycom on Twitter