Should it work with pre-allocated lists? Or are lists just not allowed period ?
Code: Select all
stuff = ['a','b','c']
class Keypad():
def __init__(self):
self.timer = Timer(5, freq=1)
self.stuff = ['x','y',z']
def timer_callback(self, timer):
## Can't use loop with micropython as memory is allocated => execption in timer interrupt !!
#for x in self.stuff:
for x in stuff:
print("DEBUG: x = ", x)
Code: Select all
def timer_callback(self, timer):
## this works
for i in range(len(stuff)):
x = stuff[i]
print("DEBUG: x = ", x)
## this works
for i in range(len(self.stuff)):
x = self.stuff[i]
print("DEBUG: x = ", x)
## this fails :(
for x in stuff:
print("DEBUG: x = ", x)
## this fails :(
for x in self.stuff:
print("DEBUG: x = ", x)