Better handmade LUT.

This commit is contained in:
antirez
2024-03-15 18:34:22 +01:00
parent 5857a35724
commit 34c4969169

View File

@@ -274,18 +274,9 @@ class UC8151:
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00
])
WW = bytes([
0xa8, 0x02, 0x02, 0x03, 0x00, 0x02,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00
])
BW = bytes([
0x54, 0x01, 0x01, 0x02, 0x00, 0x01,
0xa8, 0x02, 0x02, 0x03, 0x00, 0x02,
0x99, 0x02, 0x02, 0x00, 0x00, 0x01,
0xaa, 0x02, 0x02, 0x03, 0x00, 0x02,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
@@ -293,8 +284,17 @@ class UC8151:
0x00, 0x00, 0x00, 0x00, 0x00, 0x00
])
WB = bytes([
0xa8, 0x01, 0x01, 0x02, 0x00, 0x01,
0x54, 0x02, 0x02, 0x03, 0x00, 0x02,
0x66, 0x02, 0x02, 0x00, 0x00, 0x01,
0x55, 0x02, 0x02, 0x03, 0x00, 0x02,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00
])
WW = bytes([
0xaa, 0x01, 0x01, 0x01, 0x01, 0x01,
0xaa, 0x02, 0x02, 0x03, 0x00, 0x02,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
@@ -302,8 +302,8 @@ class UC8151:
0x00, 0x00, 0x00, 0x00, 0x00, 0x00
])
BB = bytes([
0x54, 0x02, 0x02, 0x03, 0x00, 0x02,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x55, 0x01, 0x01, 0x01, 0x01, 0x01,
0x55, 0x02, 0x02, 0x03, 0x00, 0x02,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
@@ -375,7 +375,7 @@ class UC8151:
# However they are set to 0 in all the LUTs I saw, so they are generally
# not used and we don't use it either.
def set_waveform_lut(self):
if self.speed == 0:
if self.speed < 1:
# For the default speed, we don't set any LUT, but resort
# to the one inside the device. __init__() will take care
# to tell the chip to use internal LUTs by setting the right
@@ -388,6 +388,8 @@ class UC8151:
# In this driver we try to do things a bit differently and compute
# LUTs on the fly depending on the 'speed' requested by the user.
# Each successive speed value cuts the display update time in half.
# Floating point speeds are possible, so 2.5 will be between
# 2 and 3 from the POV of speed and quality.
#
# Moreover, we check if no_flickering was set to True. In this case
# we change the LUTs in two ways, with the goal to prevent the
@@ -530,11 +532,11 @@ if __name__ == "__main__":
import random
spi = SPI(0, baudrate=12000000, phase=0, polarity=0, sck=Pin(18), mosi=Pin(19), miso=Pin(16))
eink = UC8151(spi,cs=17,dc=20,rst=21,busy=26,speed=4,no_flickering=True)
eink = UC8151(spi,cs=17,dc=20,rst=21,busy=26,speed=4.3,no_flickering=True)
eink.fb.ellipse(10,10,10,10,1)
eink.fb.ellipse(50,50,10,10,1)
#eink.set_handmade_lut()
eink.set_handmade_lut()
random.seed(123)
for _ in range(10):