grove.grove_button
¶
- This is the code for
Examples
from grove.grove_button import GroveButton
import time
# connect to pin 5 (slot D5)
PIN = 5
button = GroveButton(PIN)
def on_press(t):
print('Button is pressed')
def on_release(t):
print("Button is released, pressed for {0} seconds".format(round(t,6)))
button.on_press = on_press
button.on_release = on_release
while True:
time.sleep(1)
Classes¶
GroveButton
: Grove Button class
- class grove.grove_button.GroveButton(pin)[source]¶
Grove Button class
- Parameters:
pin (int) – the number of gpio/slot your grove device connected.
Inheritance
digraph inheritancec760f12fbf { bgcolor=transparent; rankdir=LR; size="8.0, 12.0"; "GroveButton" [URL="#grove.grove_button.GroveButton",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="Grove Button class"]; }- property on_press¶
- Property access with
- callback – a callable function/object,
will be called when there is a button pressing.
- callback prototype:
callback() Returns: none
Examples
set
obj.on_press = callback
get
callobj = obj.on_press
- property on_release¶
- Property access with
- callback – a callable function/object,
will be called when there is a button releasing.
- callback prototype:
callback() Returns: none
Examples
set
obj.on_release = callback
get
callobj = obj.on_release