Code: Select all
>>> @micropython.native
... def speed_native():
... print('doing speed_native')
... pin = pyb.Pin('X1', pyb.Pin.OUT_PP)
... for i in range(100000):
... pin.value(0)
... pin.value(1)
...
>>> speed_native()
doing speed_native
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: Can't convert 'function' object to str implicitly
Code: Select all
>>> @micropython.viper
... def speed_viper():
... print('doing speed_viper')
... pin = pyb.Pin('X1', pyb.Pin.OUT_PP)
... for i in range(100000):
... pin.value(0)
... pin.value(1)
...
>>>
>>> speed_viper()
.... hangs and locks up the upy board
But this 'native' works
Code: Select all
@micropython.native
def ptest_native():
millis = pyb.millis
endTime = millis() + 3000
count = 0
while millis() < endTime:
count += 1
return count
>>> ptest_native()
1225287
>>>