[Tinyos Core WG] non-TEP code

Joe Polastre joe at polastre.com
Tue Nov 28 08:51:27 PST 2006


On 11/28/06, Jonathan Hui <jhui at archrock.com> wrote:
>  From my point of view, the most generic button interface is something
> very similar to the GpioInterrrupt interface. There's enables, there's
> edge triggers, and possibly level triggers. I can see a developer caring
> about a single edge, both edges, and even a level triggered form (all of
> which can be emulated if need be). The basic Button interface you've
> proposed is a subset of this.

Actually, it includes what you're talking about with:

enable() and disable() -- self explanatory
pressed() -- this is the "falling" edge event
released() -- this is the "rising" edge event
get() -- this is to get the level position (i'm not sure how a level
trigger is relevant versus the first two)

if you only care about a single edge, then you only handle pressed(),
for example.

>  From that point of view, we've gone down this path before (e.g. static
> binding vs. not, how to deal with edge vs. level, platforms that provide
> both-edge mode vs. only single-edge mode, etc). We can either take
> decisions made in the past or re-open the issue. Either one is fine with
> me, but we should take advantage of their similarities. It's not
> immediately clear to me why the two interfaces should have significant
> differences in philosophy.

Agreed.  The primary difference with a button is that you don't
specify the edge to trigger on explicitly like you do an interrupt.
We could decide that this is the position that we want to take, but I
actually like having both edge events occur automagically under the
covers rather than explicitly having to ask for the rising edge
interrupt after the falling edge interrupt occurs (and likewise, the
debouncing happening for you automatically too).

> I know that you were going for a richer interface with ButtonAdvanced. I
> could see some of that functionality useful in more generic
> interrupt-driven settings, even those that are not human driven. But
> maybe I'm trying to generalize this too much.

I really like the functions in the advanced interface as they make my
life much easier.  This could be a separate library or called
something else (if you look at the implementation, it is built using
the generic Button interface so can easily be built above what is
proposed by you, Gil or I).

-Joe


More information about the Tinyos-2.0wg mailing list