Drivers for Waveshare 2.13inch E-Ink display

Discuss development of drivers for external hardware and components, such as LCD screens, sensors, motor drivers, etc.
Target audience: Users and developers of drivers.
robbyatbln
Posts: 3
Joined: Tue Mar 13, 2018 7:36 pm

Re: Drivers for Waveshare 2.13inch E-Ink display

Post by robbyatbln » Tue Mar 13, 2018 7:48 pm

[quote=mcauser post_id=26034 time=1520454982 user_id=732]
Have a look at epaper1in54.py.
Some of the drivers have more methods than others.
I only have a 2.9” b/w to test with.
[/quote]

hi did somebody has a working guide for the 1in54 on a wemos with micro-python and the spi 4 line ??
please help !

robby

OutoftheBOTS_
Posts: 847
Joined: Mon Nov 20, 2017 10:18 am

Re: Drivers for Waveshare 2.13inch E-Ink display

Post by OutoftheBOTS_ » Wed Apr 04, 2018 12:55 am

@mcauser

I have been looking over your hard work with the e-paper screens. I am just starting to have a play with them.

I have just received a little 2.13" 3 colour (Black/White/Red) screen (screen only not complete module) and am in the process of working out the needed supporting circuits. Traditionally with little TFT displays we have used 4 wire SPI mode but I am wondering if 3 wire SPI might be better for these little screens as it saves using up another GPIO pin. Considering the main reason for using 4 wire SPI is speed but these e-paper screens have updates rates of less than 1FPS it sort of seems pointless to use up another GPIO pin for DC.

As someone that has obviously played a fair bit with these e-paper screens what's your opinion on 3 wire vs 4 wire??

I am also thinking that I might hard wire the reset pin so it also doesn't use up a GPIO pin as well.

I am also trying to work out if I can work around the busy pin too???

User avatar
deshipu
Posts: 1388
Joined: Thu May 28, 2015 5:54 pm

Re: Drivers for Waveshare 2.13inch E-Ink display

Post by deshipu » Wed Apr 04, 2018 11:40 am

The 3-wire SPI is not really noticeably slower than the 4-wire — the toggling of the Data/Command pin can take as much time as sending of that extra bit. The reason why 4-wire SPI is often preferred is that 9-bit SPI is a bit tricky to do and most libraries don't handle it very well.

OutoftheBOTS_
Posts: 847
Joined: Mon Nov 20, 2017 10:18 am

Re: Drivers for Waveshare 2.13inch E-Ink display

Post by OutoftheBOTS_ » Wed Apr 04, 2018 2:39 pm

Thanks for your response.

I was thinking about just a simple software bit bang of the extra bit needed in the 3 wire SPI, much the same that would normally be done on the DC pin but now it will instead be on the MOSI pin.

The current wiring of many of the e-paper screens just takes sooooo many GPIO pins: Bus section, Busy, Reset, DC, CS, MOSI, MISO, SCK

I am hoping to maybe get it down to just needing the standard SPI pins : CS, MOSI, MISO, SCK

User avatar
deshipu
Posts: 1388
Joined: Thu May 28, 2015 5:54 pm

Re: Drivers for Waveshare 2.13inch E-Ink display

Post by deshipu » Thu Apr 05, 2018 8:05 am

You don't need MISO.

User avatar
devnull
Posts: 473
Joined: Sat Jan 07, 2017 1:52 am
Location: Singapore / Cornwall
Contact:

Re: Drivers for Waveshare 2.13inch E-Ink display

Post by devnull » Wed May 16, 2018 6:49 am

OK, just started testing the e-paper modules and started with the 1.54" black & white on the 'official' ESP32 latest 1.94 build.

I managed to get the display to work, but the font is so small and un-readable.

I just looked at the framebuffer docs and it states that the font size is fixed and can't be changed, which is a show-stopper.

How would it be possible to use external fonts, preferably the same as are used in the SH1106 oled modules ??

I see that Peter Hinch's larger display has the ability to use external fonts, it would be great if there's another driver for the 1.54" display that also allows ext fonts ??

User avatar
pythoncoder
Posts: 5956
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: Drivers for Waveshare 2.13inch E-Ink display

Post by pythoncoder » Wed May 16, 2018 7:08 am

I suggest you look at my font-to-py utility first. This enables you to convert any standard font file to Python sourcecode which may optionally be frozen as bytecode: doing this conserves a great deal of RAM. Fixed and variable pitch fonts are supported.

Then look at my SSD1306 module which includes the writer class. This allows text to be rendered to a framebuf using such fonts. Testing was done on an SSD1306 display but the framebuf class is device independent.

The writer class is fairly basic in that it doesn't do clever stuff with text metrics, but as the photo shows it enables large fonts to be rendered to a display which by default uses a tiny one.
Peter Hinch
Index to my micropython libraries.

OutoftheBOTS_
Posts: 847
Joined: Mon Nov 20, 2017 10:18 am

Re: Drivers for Waveshare 2.13inch E-Ink display

Post by OutoftheBOTS_ » Wed May 16, 2018 9:16 am

@pythoncoder thanks for sharing your code, I know you have posted links to it before but this time I sat down and took the time to look closely at your code. It was simple enough to understand how writer.py works.

It was the first time that I have seen memoryview() and will be incorporating it into all my larger bytearray buffers that I use for storing images.

User avatar
devnull
Posts: 473
Joined: Sat Jan 07, 2017 1:52 am
Location: Singapore / Cornwall
Contact:

Re: Drivers for Waveshare 2.13inch E-Ink display

Post by devnull » Wed May 16, 2018 9:23 am

Thanks Peter;

I already have fonts that I converted for the oled.

I tried quickly to use the writer class by passing the e-paper driver class to it, but that fails with "AttributeError: 'EPD' object has no attribute 'blit'" - what is this first attr supposed to be ?

Code: Select all

e = ep14.EPD(spi, CS, DC, RESET, BUSY)
e.init()

# clear display
e.clear_frame_memory(b'\xFF')
e.display_frame()

def go():
  import freesans20
  from writer import Writer
  wr = Writer(e, freesans20, verbose=False)
  Writer.set_clip(True, True)
  Writer.set_textpos(20, 20)
  wr.printstring('1234567890A\n1234567890A\n1234567890A')
  e.set_frame_memory(buf, x, y, w, h)
  e.display_frame()
This is the driver code (ep14.py): https://github.com/mcauser/micropython- ... er1in54.py

User avatar
devnull
Posts: 473
Joined: Sat Jan 07, 2017 1:52 am
Location: Singapore / Cornwall
Contact:

Re: Drivers for Waveshare 2.13inch E-Ink display

Post by devnull » Wed May 16, 2018 10:15 am

OK, made some progress, at least something is displayed, but it is white on black and indecipherable !

Code: Select all

class EPD(framebuf.FrameBuffer):
    def __init__(self, spi, cs, dc, rst, busy):
        self.spi = spi
        self.cs = cs
        self.dc = dc
        self.rst = rst
        self.busy = busy
        self.cs.init(self.cs.OUT, value=1)
        self.dc.init(self.dc.OUT, value=0)
        self.rst.init(self.rst.OUT, value=0)
        self.busy.init(self.busy.IN)
        self.width = EPD_WIDTH
        self.height = EPD_HEIGHT

        ## 180516
        self.buffer = bytearray(200 * 200 // 8)
        super().__init__(self.buffer, self.width, self.height, framebuf.MONO_VLSB)

Code: Select all


CS      = Pin(5,Pin.OUT)    ## OUT
CLK     = Pin(18,Pin.OUT)   ## OUT 
DIN     = Pin(23,Pin.OUT)   ## OUT
MISO    = Pin(19,Pin.IN)    ## IN N/A
BUSY    = Pin(17,Pin.IN)    ## IN
RESET   = Pin(16,Pin.OUT)   ## OUT
DC      = Pin (4,Pin.OUT)   ## OUT

spi = SPI(1, baudrate=2000000, sck=CLK, mosi=DIN, miso=MISO)
e = ep14.EPD(spi, CS, DC, RESET, BUSY)
e.init()

def go():
  import freesans20
  from writer import Writer
  wr = Writer(e, freesans20, verbose=False)
  Writer.set_clip(True, True)
  Writer.set_textpos(20, 20)
  wr.printstring('1234567890A\n1234567890A\n1234567890A')
  e.set_frame_memory(e.buffer, x, y, w, h)
  e.display_frame()
Last edited by devnull on Wed May 16, 2018 12:58 pm, edited 2 times in total.

Post Reply