grove.grove_multi_switch
¶
- This is the code for
Examples
from grove.button import Button
import grove.grove_multi_switch.GroveMultiSwitch
import time
switch = GroveMultiSwitch()
# the default behavior is
# printing all happening event with names
# remove ''' pairs below to begin your experiment
'''
# define a customized event handle your self
def cust_on_event(index, event, tm):
# switch.btn(ButtonTypedI2c object) could be used to check every event.
print("event with code {}, time {}".format(event, tm))
switch.on_event = cust_on_event
'''
while True:
time.sleep(1)
Classes¶
GroveMultiSwitch
: Grove 5-Way-Switch/6-Po-DIP-Switch class
- class grove.grove_multi_switch.GroveMultiSwitch[source]¶
Grove 5-Way-Switch/6-Po-DIP-Switch class
all of them has a button array with I2C interface.
Inheritance
digraph inheritancef067a350d4 { bgcolor=transparent; rankdir=LR; size="8.0, 12.0"; "GroveMultiSwitch" [URL="#grove.grove_multi_switch.GroveMultiSwitch",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 5-Way-Switch/6-Po-DIP-Switch class"]; }- property on_event¶
- Argument
- callback – a callable function/object,
will be called when there is button event
- callback prototype:
callback(index, code, time)
- callback argument:
- Args:
index(int): button index, be in 0 to [button count - 1]
- code (int): bits combination of
Button.EV_LEVEL_CHANGED
Button.EV_SINGLE_CLICK
Button.EV_DOUBLE_CLICK
Button.EV_LONG_PRESS
time(time): event generation time
Returns: none
Examples
set
obj.on_event = callback
get
callobj = obj.on_event