From 914a09a5f3e095d875d178a16e3e6886c7abd639 Mon Sep 17 00:00:00 2001 From: antirez Date: Fri, 15 Mar 2024 16:03:45 +0100 Subject: [PATCH] Debugging function that shows a LUT. --- uc8151.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/uc8151.py b/uc8151.py index b3b9528..e8605ea 100644 --- a/uc8151.py +++ b/uc8151.py @@ -391,6 +391,9 @@ class UC8151: self.set_lut_row(BW,row,pat=0x80,dur=[period,0,0,0],rep=rep) self.set_lut_row(WB,row,pat=0x40,dur=[period,0,0,0],rep=rep) + self.show_lut(BW,"BW") + self.show_lut(WB,"WB") + self.write(CMD_LUT_VCOM,VCOM) self.write(CMD_LUT_BW,BW) self.write(CMD_LUT_WB,WB) @@ -401,6 +404,9 @@ class UC8151: BW[0] = 0x80 WB[0] = 0x40 + self.show_lut(BW,"WW") + self.show_lut(WB,"BB") + self.write(CMD_LUT_WW,BW) self.write(CMD_LUT_BB,WB) @@ -431,6 +437,15 @@ class UC8151: lut[off+4] = dur[3] lut[off+5] = rep + # Show a well-formatted LUT table. Useful for debugging. + def show_lut(self,lut,name): + print(name,":") + for i in range(7): + for j in range(6): + print(hex(lut[i*6+j]),end=' ') + print("") + print("---") + # Wait for the display to return back able to accept commands # (if it is updating the display it remains busy), and switch # it off once it is possible. @@ -462,7 +477,7 @@ 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=5,no_flickering=True) + eink = UC8151(spi,cs=17,dc=20,rst=21,busy=26,speed=4,no_flickering=True) eink.fb.ellipse(10,10,10,10,1) eink.fb.ellipse(50,50,10,10,1)