Timer channel callback() doesn't work

Questions and discussion about The WiPy 1.0 board and CC3200 boards.
Target audience: Users with a WiPy 1.0 or CC3200 board.
Post Reply
Saran
Posts: 17
Joined: Thu May 28, 2015 6:52 pm

Timer channel callback() doesn't work

Post by Saran » Thu Oct 15, 2015 10:01 am

I've been following the documentation, but callback method fails with

Code: Select all

>>> tim = Timer(1, mode=Timer.PERIODIC)
>>> def tick(timer): print(timer.counter())
... 
>>> tim.callback(tick)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: no such attribute
>>> 
Also tried it from main.py:

Code: Select all

from machine import Pin
from machine import Timer

tim = Timer(1, mode=Timer.PERIODIC)
tim_a = tim.channel(Timer.A, period=10000)
tim_a.time()

p_out = Pin('GP10', mode=Pin.OUT)

def tick():
    print(tim_a.time())
    p_out.toggle()

tim_a.callback(handler=tick)
Fails as well...

So, ideas?
Yet another discrepancy between the documentation and implementation or?!?

User avatar
platforma
Posts: 258
Joined: Thu May 28, 2015 5:08 pm
Location: Japan

Re: Timer channel callback() doesn't work

Post by platforma » Thu Oct 15, 2015 3:20 pm

this post was not useful
Last edited by platforma on Fri Oct 16, 2015 9:44 am, edited 1 time in total.

User avatar
danicampora
Posts: 342
Joined: Tue Sep 30, 2014 7:20 am
Contact:

Re: Timer channel callback() doesn't work

Post by danicampora » Thu Oct 15, 2015 3:35 pm

Hi,

.callbacks have been renamed to .irq() everywhere.

Saran
Posts: 17
Joined: Thu May 28, 2015 6:52 pm

Re: Timer channel callback() doesn't work

Post by Saran » Thu Oct 15, 2015 6:42 pm

danicampora wrote:Hi,

.callbacks have been renamed to .irq() everywhere.
Unbelievable. This must be a practical joke!

More than 2 months of shipping delay and "fine tuning" to find the API unusable -- because to be able to use any of it I have to look in the magic ball to tell me which are the correct method/module names! :evil:

If the makers of WiPy are so absorbed in their "success" to neglect half of their product (b/c what can HW be used for w/o a SW? Nothing), can't this at least be sorted out by the community effort?

I will do what I can (to contribute to doc updates), but I need a reference I can check the current docs against.

The docs at http://docs.micropython.org/en/latest/library/ are from micropython repo, which should be a source of correct information. But, from what I found there and what I also found when looking at tests is discoraging. Tests are still using the old method names (callback instead of irq):
https://github.com/micropython/micropyt ... allback.py

Either they are correct and there is a fork between micropython code and code on WiPy or the tests are just not updated. The later would be easily found out if they were run at all...

User avatar
danicampora
Posts: 342
Joined: Tue Sep 30, 2014 7:20 am
Contact:

Re: Timer channel callback() doesn't work

Post by danicampora » Thu Oct 15, 2015 8:36 pm

Hi Saran,

I understand your frustration. We are working on it, but reality is that we are a small team and we all have day jobs, families and a bunch other things to do, so that leaves limited time, and we are busy now with shipping, before we were busy with the API, which took time a lot of code rewrite. This might be a surprise, but a KS campaign doesn't make you rich. Go here:

http://forum.micropython.org/viewtopic.php?f=11&t=713


And click where it says "Provisional reference of the API", that is good enough to get you started.

Saran
Posts: 17
Joined: Thu May 28, 2015 6:52 pm

Re: Timer channel callback() doesn't work

Post by Saran » Thu Oct 15, 2015 9:52 pm

All that is understandable, but, if I was in your shoes, I would have rather left out 1 whole API (temporarily) than leaving main API interface doc ("machine") incorrectly referenced ("pyb"). For someone who knows what's what, that API doc update should have taken 15 minutes. So, in a few hours the whole API doc would have correctly reflected the API it represents.

Another thing that should not happen in a SW project (beside having outdated "customer" documentation) is having outdated tests (which just means tests are not run frequently enough, i.e. after each pull request/commit).

One final safety would be not to accept pull requests which refactor the API without them also having covered the corresponding docs and tests.
There's an abundance of automation tools out there and having an OS project in such scale as micropython and not having e.g. continuous integration is, well, you know...not cool.


Btw. I'm aware of the Provisional reference of the API, but unfortunately it is provisional (e.g. it doesn't mention Timer.channel(), which seems like an important interface to me or the channel.irq() which you have mentioned earlier). That's why I asked how can I help with that.

Post Reply