mirror of
https://github.com/antirez/uc8151_micropython.git
synced 2026-04-29 21:49:36 +08:00
Refactor image transfer out of update().
This commit is contained in:
20
uc8151.py
20
uc8151.py
@@ -589,14 +589,26 @@ class UC8151:
|
||||
def update(self,blocking=False,fb=None):
|
||||
if fb == None: fb = self.raw_fb
|
||||
if blocking == False and self.is_busy(): return False
|
||||
self.write(CMD_PON) # Power on
|
||||
self.write(CMD_PTOU) # Partial mode off
|
||||
self.write(CMD_DTM2,fb) # Start data transfer
|
||||
self.write(CMD_DSP) # End of data
|
||||
self.send_image(fb)
|
||||
self.write(CMD_DRF) # Start refresh cycle.
|
||||
if blocking: self.wait_and_switch_off()
|
||||
return True
|
||||
|
||||
# Transfer bitmap to device. The chip has two framebuffers, one for
|
||||
# the old image and one for the new image. This way it can do the
|
||||
# difference when performing the update and apply the correct waveform
|
||||
# depending on WW, BB, WB, BW transition. When we refresh, the new
|
||||
# framebuffer is automatically copied to the old one, but we can control
|
||||
# both framebuffer when we wish to.
|
||||
def send_image(self,fb,old=False):
|
||||
self.write(CMD_PON) # Power on
|
||||
self.write(CMD_PTOU) # Partial mode off
|
||||
if old:
|
||||
self.write(CMD_DTM1,fb) # Transfer to previous image buffer.
|
||||
else:
|
||||
self.write(CMD_DTM2,fb) # Transfer to current image buffer.
|
||||
self.write(CMD_DSP) # End of data
|
||||
|
||||
# Helper function to render greyscale images.
|
||||
#
|
||||
# This function has to generate two one-bit images, using the two
|
||||
|
||||
Reference in New Issue
Block a user