Waveshare 4.2b e-Ink, libraries not working?
-
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?
-
@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.
-
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-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
-
@Peter-Ehses You may raise an issue in his repository. I'm sure he will respond.
-
@robert-hh as I wrote above, I have, and his library shows either random noise or solid colors.
Thanks for the help, though.
-
@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