I'm trying to optimize a part of an ili9341 driver and came across an ImportError when using @micropython.viper decorator.
the code i used is as follows:
Code: Select all
class Display(object):
self.spi = SPI(VSPI, 40000000, sck=Pin(18), mosi=Pin(23), miso=Pin(19))
@micropython.viper
def write_data(self, data):
self.spi.write(data)
@micropython.viper #if I remove this line the Import error goes away
def push_block(self, color: uint, length: uint):
chunks = uint(length // 512)
rest = uint(length % 512)
if chunks > 0:
data = ptr8(ustruct.pack(">H", color) * 512)
for _ in range(chunks):
self.write_data(data)
if rest > 0:
data = ptr8(ustruct.pack(">H", color) * rest)
self.write_data(data)
As you can see I tried adding hints for viper with uint and ptr8 however the error remains with and without those.
full error:
Traceback (most recent call last):
File "<stdin>", line 7, in <module>
ImportError: cannot import name Display
The ImportError only happens when I use the @micropython.viper decorator on push_block, any ideas why this happens ? and is it fixable ?
Note: I still want to use @micropython.viper decorator on push_block