mcauser/micropython-waveshare-epaper

Partial Updates to Screen

Opened this issue · 0 comments

Partial updates seem to be available with the epaper screen, but I'm having some trouble implementing them.

https://github.com/elad661/rpi_epd2in7/blob/master/rpi_epd2in7/epd.py

Has them implemented on RPI using PIL, I've got something started with an ESP32 and framebuf.

I'm hoping you might have some insight, I don't really understand the behavior of the driver chip to know quite where I'm going wrong.

I adapted the current micropython write with the commands from the RasPi implementation above. The system executes, but doesn't seem to be writing anything at all to the screen.

    # draw the current frame memory
    def display_partial_frame_2(self, frame_buffer, box_x, box_y, box_h, box_w, fast=False):
        self._command(RESOLUTION_SETTING, ustruct.pack(">HH", EPD_WIDTH, EPD_HEIGHT))
        self._command(VCM_DC_SETTING, b'\x12')
        self._command(VCOM_AND_DATA_INTERVAL_SETTING)
        self._command(0x97) # VBDF 17|D7 VBDW 97  VBDB 57  VBDF F7  VBDW 77  VBDB 37  VBDR B7
        # TODO should ^ this be _data(0x97), not sure what it does
        box_x = _nearest_mult_of_8(box_x, False)
        box_w = _nearest_mult_of_8(box_w)

        if (frame_buffer != None):
            self._command(PARTIAL_DATA_START_TRANSMISSION_1)
            self._send_partial_frame_dimensions(box_x, box_y, box_h, box_w)
            for i in range(0, box_w * box_h // 8):
                self._data(bytearray([0xFF])) # bit set: white, bit reset: black
            machine.sleep(2)
            self._command(PARTIAL_DATA_START_TRANSMISSION_2)
            self._send_partial_frame_dimensions(box_x, box_y, box_h, box_w)
            for i in range(0, box_w * box_h // 8):
                self._data(bytearray([frame_buffer[i]]))
            machine.sleep(2)

        self.set_lut()
        self._command(PARTIAL_DISPLAY_REFRESH)
        self._send_partial_frame_dimensions(box_x, box_y, box_h, box_w)
        self._last_frame = frame_buffer
        machine.sleep(100)
        self.wait_until_idle()
        self._partial_refresh_count = 0  # reset the partial refreshes counter


    def _send_partial_frame_dimensions(self, x, y, l, w):
        self._data(bytearray([x >> 8]   ))
        self._data(bytearray([x & 0xf8] ))
        self._data(bytearray([y >> 8]   ))
        self._data(bytearray([y & 0xff] ))
        self._data(bytearray([w >> 8]   ))
        self._data(bytearray([w & 0xf8] ))
        self._data(bytearray([l >> 8]   ))
        self._data(bytearray([l & 0xff] ))

Also apologies I'm not generally used to making or using the github issue tracking system. Thanks for your help.