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

    Waveshare 4.2b e-Ink, libraries not working?

    Scheduled Pinned Locked Moved WiPy 2&3
    eink
    7 Posts 2 Posters 547 Views 2 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.
    • P Offline
      Peter Ehses
      last edited by

      Hi,
      I'm trying to use the Red / Black Waveshare 4.2" e-Ink display with a WiPy. I tried the ayoy and mcauser libraries and got both running without errors after some changes (different SPI syntax, etc.).
      However, both libraries produce more or less random images. The mcauser one displays either random noise or solid colors, while the ayoy one colors half the screen black, the other half white, then fades both to 50% grey and adds red to the left half.

      Is there any proven working library for the 4.2b waveshare Display, or is there any obvious solution to my problems?

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

        @Peter-Ehses Look at the repositories of this guy: https://github.com/mcauser/micropython-waveshare-epaper
        He seems to have dedicated a lot of time to e-paper displays

        P 1 Reply Last reply Reply Quote 1
        • P Offline
          Peter Ehses @robert-hh
          last edited by

          @robert-hh as I wrote above, I have, and his library shows either random noise or solid colors.
          Thanks for the help, though.

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

            @Peter-Ehses You may raise an issue in his repository. I'm sure he will respond.

            P 1 Reply Last reply Reply Quote 1
            • P Offline
              Peter Ehses @robert-hh
              last edited by

              @robert-hh there is one for the same behavior on a different size, from 5 months ago. not solved, though. https://github.com/mcauser/micropython-waveshare-epaper/issues/5

              1 Reply Last reply Reply Quote 0
              • P Offline
                Peter Ehses
                last edited by

                For anyone having the same problem:

                For now these modifications to the ayoy library ( https://github.com/ayoy/micropython-waveshare-epd ) seem to be working for 4.2b displays:

                Display resolution is changed in these lines

                EPD_WIDTH       = 400
                EPD_HEIGHT      = 300
                

                but the init codes need to be changed, too, in order for it to actually use the whole screen and not break lines after 200px (those codes are taken from waveshare's RPi python driver):

                def init(self):
                        self.reset()
                        self.send_command(BOOSTER_SOFT_START)
                        self.send_data(0x17)
                        self.send_data(0x17)
                        self.send_data(0x17)
                        self.send_command(POWER_ON)
                
                        self.wait_until_idle()
                
                        self.send_command(PANEL_SETTING)
                        self.send_data(0x0F)
                        # self.send_command(POWER_SETTING)
                        # self.send_data(0x07)
                        # self.send_data(0x00)
                        # self.send_data(0x08)
                        # self.send_data(0x00)
                        # self.send_command(BOOSTER_SOFT_START)
                        # self.send_data(0x07)
                        # self.send_data(0x07)
                        # self.send_data(0x07)
                        # self.send_command(POWER_ON)
                        #
                        # self.wait_until_idle()
                        #
                        # self.send_command(PANEL_SETTING)
                        # self.send_data(0xCF)
                        # self.send_command(VCOM_AND_DATA_INTERVAL_SETTING)
                        # self.send_data(0x17)
                        # self.send_command(PLL_CONTROL)
                        # self.send_data(0x39)
                        # self.send_command(TCON_RESOLUTION)
                        # self.send_data(0xC8)
                        # self.send_data(0x00)
                        # self.send_data(0xC8)
                        # self.send_command(VCM_DC_SETTING_REGISTER)
                        # self.send_data(0x0E)
                        #
                        # self.set_lut_bw()
                        # self.set_lut_red()
                        return 0
                

                then, the display_frame function, which actually sends your frame data to the display driver needs to be changed (this is the method used in the waveshare python driver and mcauser's library):

                def display_frame(self, frame_buffer_black, frame_buffer_red=None):
                        if (frame_buffer_black != None):
                            self.send_command(DATA_START_TRANSMISSION_1)
                            self.delay_ms(2)
                            for i in range(0, self.width * self.height // 8):
                                self.send_data(frame_buffer_black[i])
                                # temp = 0x00
                                # for bit in range(0, 4):
                                #     if (frame_buffer_black[i] & (0x80 >> bit) != 0):
                                #         temp |= 0xC0 >> (bit * 2)
                                # self.send_data(temp)
                                # temp = 0x00
                                # for bit in range(4, 8):
                                #     if (frame_buffer_black[i] & (0x80 >> bit) != 0):
                                #         temp |= 0xC0 >> ((bit - 4) * 2)
                                # self.send_data(temp)
                            self.delay_ms(2)
                        if (frame_buffer_red != None):
                            self.send_command(DATA_START_TRANSMISSION_2)
                            self.delay_ms(2)
                            for i in range(0, self.width * self.height // 8):
                                self.send_data(frame_buffer_red[i])
                            self.delay_ms(2)
                
                        self.send_command(DISPLAY_REFRESH)
                        self.wait_until_idle()
                

                now, you should have yourself a kinda working e-paper library.
                It's slow but it might be by design. cheers

                robert-hhR 1 Reply Last reply Reply Quote 1
                • robert-hhR Offline
                  robert-hh @Peter Ehses
                  last edited by

                  @Peter-Ehses i had a wavershare 4.2 b/w display in the drawer which I never used. Now I grabbed that and tested it with mcauser's lib. It worked immediately. I used a ESP32, like WiPy3, with the micropython.org firmware.

                  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 / 1
                  • First post
                    Last post

                  Pycom on Twitter

                  Pycom