grove.grove_touch_sensor
¶
- This is the code for
Examples
from grove.grove_touch_sensor import GroveTouchSensor
import time
# connect to pin 5 (slot D5)
PIN = 5
touch = GroveTouchSensor(PIN)
def on_press(t):
print('Pressed')
def on_release(t):
print("Released.")
touch.on_press = on_press
touch.on_release = on_release
while True:
time.sleep(1)
Classes¶
GroveTouchSensor
: Grove Touch Sensor class
- class grove.grove_touch_sensor.GroveTouchSensor(pin)[source]¶
Grove Touch Sensor class
- Parameters:
pin (int) – the number of gpio/slot your grove device connected.
Inheritance
digraph inheritance3ca08ce460 { bgcolor=transparent; rankdir=LR; size="8.0, 12.0"; "GPIO" [URL="grove.gpio.gpio_rpi.html#grove.gpio.gpio_rpi.GPIO",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"]; "GroveTouchSensor" [URL="#grove.grove_touch_sensor.GroveTouchSensor",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 Touch Sensor class"]; "GPIO" -> "GroveTouchSensor" [arrowsize=0.5,style="setlinewidth(0.5)"]; }- 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