Page 1 of 1

native and viper decorator problem

Posted: Mon May 26, 2014 8:22 pm
by mpymike
Not sure if I'm using the decorators correctly, or if they are not supported yet.

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
and

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
>>>
-mike