native and viper decorator problem

General discussions and questions abound development of code with MicroPython that is not hardware specific.
Target audience: MicroPython Users.
Post Reply
mpymike
Posts: 10
Joined: Mon May 26, 2014 5:48 am

native and viper decorator problem

Post by mpymike » Mon May 26, 2014 8:22 pm

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

Post Reply