[Tinyos Core WG] non-TEP code
Joe Polastre
joe at polastre.com
Mon Nov 27 16:36:28 PST 2006
Here is one proposal for a Button interface(s). The nesdoc includes
information about the units of time. Did you want to explicitly bind
TMilli to the interface? That seems a bit unnecessary.
Button is for generic button operations, while ButtonAdvanced allows
more functionality in the handling of button events.
If we can agree on the interface, I can commit the implementation...
/**
* Basic interface for handling button events.
*
* @author Joe Polastre, Moteiv Corporation <info at moteiv.com>
*/
interface Button {
/**
* Enable the button events.
*/
async command void enable();
/**
* Disable button events.
*/
async command void disable();
/**
* Notification that the button has been pressed.
*
* @param time the local time that the button was pressed in milliseconds.
* The current time may be queried through CounterMilliC.LocalTime.
*/
async event void pressed(uint16_t time);
/**
* Notification that the button has been released.
*
* @param time the local time that the button was released in milliseconds.
* The current time may be queried through CounterMilliC.LocalTime.
*/
async event void released(uint16_t time);
/**
* Get the current button value: FALSE=released, TRUE=pressed.
*/
async command bool getValue();
}
/**
* Advanced button handling interface for complex gestures.
*
* @author Joe Polastre, Moteiv Corporation <info at moteiv.com>
*/
interface ButtonAdvanced {
/**
* Enable advanced button processing.
*/
async command void enable();
/**
* Disable advanced button processing.
*/
async command void disable();
/**
* Request events when a long press occurs.
*
* @param time the number of milliseconds in duration for a button press
*/
async command void setLongPress(uint16_t time);
/**
* Get the time requested for a long button press.
*
* @return time the time required for a long press in milliseconds
*/
async command uint16_t getLongPress();
/**
* Notification that a long click occurred.
*
* @param time The duration of the long click in milliseconds
*/
async event void longClick(uint16_t time);
/**
* Notification that multiple clicks occurred.
*
* @param count Number of clicks in the multi click event
*/
async event void multiClick(uint8_t count);
/**
* Get the current butotn value: FALSE=released, TRUE=pressed.
*/
async command bool getValue();
}
On 11/27/06, Philip Levis <pal at cs.stanford.edu> wrote:
> On Nov 27, 2006, at 2:56 PM, Joe Polastre wrote:
>
> > The question arose "where is the user button interface in T2?". For
> > code that could be committed but has no TEP, what is the policy?
> > Similarly, do we need to work on a "button" TEP (sounds like
> > overkill)?
>
> Code doesn't require a TEP to be committed (often they go the other
> way around). It should generally follow TEPs when possible, though.
> In this case, the SIDs TEP (114) might be appropriate. The 1.x Button
> interface is a little dicey in that the time units of the stamps
> aren't clearly specified.
>
> Phil
>
More information about the Tinyos-2.0wg
mailing list