创客百科

姿势共享,有节操无门槛参与的创客百科,创客动力之源 \ (^_^) /

用户工具

站点工具


saks:sdk:libraries:tactrow

TactRow

轻触开关组类,配置一组轻触开关的触发事件并随时读取开关即时状态。

方法

__init__(self, pin, real_true = GPIO.HIGH)

初始化对象,设置引脚和触发电平(高电平或低电平触发)。pins 为 IO 引脚数组。

is_on(self, index)

返回当前轻触开关的按下状态。true 或 false。index 为 LED 编号,从 0 开始。

row_status(self)

返回当前轻触开关组的工作状态的数组。

items(self)

返回当前轻触开关组的对象数组。

调用方法:

self.tactrow = entities.TactRow([PINS.TACT_LEFT, PINS.TACT_RIGHT], GPIO.LOW)

tact_event_handler = None
def on_tact_event(self, pin, status):
    #print('on_tact_event')
    if self.tact_event_handler is not None:
        self.tact_event_handler(pin, status)
        
def tact_event_handler(pin, status):
    '''
    called while the status of tacts changed
    :param pin: pin number which stauts of tact is changed
    :param status: current status
    :return: void
    '''
    print('tact_event_handler')
    print("%d - %s" % (pin, status))
    
SAKS.tact_event_handler = tact_event_handler
本页面的其他翻译:
saks/sdk/libraries/tactrow.txt · 最后更改: 2017/01/23 14:40 由 Spoony