grove.button.button
¶
Classes¶
Button
: Button Base Class
- class grove.button.button.Button(pin=0)[source]¶
Button Base Class
provide event callback ability to derived class
- Parameters:
pin (int) – optional, for GPIO type button, it’s the GPIO pin number.
Inheritance
digraph inheritance9a3741d07e { bgcolor=transparent; rankdir=LR; size="8.0, 12.0"; "Button" [URL="#grove.button.button.Button",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="Button Base Class"]; }- get_on_event()[source]¶
Get the event receiving object and callback member function
- Returns:
- a pair consist of event receiving object
and callback member function
- Return type:
(obj, event_callback)
- is_pressed(index=0)[source]¶
Get the button status if it’s being pressed ?
- Parameters:
index (int) – optional, the index number of which button to be checked. must be specified only if it’s a multiple button device.
- Returns:
- True if the button is being pressed.
False if not.
- Return type:
(bool)
- on_event(obj, callback)[source]¶
Set the event receiving object and it’callback member function
- Parameters:
obj (object) – the object to receiving event
callback (callable) –
a member function of obj, will be called when there is button event
- callback prototype:
callback(obj, evt_dict)
- callback argument:
- Args:
obj(object) : the object that is obj argument of
on_event
- evt_dict(dict): the event dictionary include items:
index
code
pressed
time
Returns: none