这里会显示出您选择的修订版和当前版本之间的差别。
| 后一修订版 | 前一修订版 | ||
|
saks:sdk:libraries:tactrow [2017/01/23 14:30] Spoony 创建 |
saks:sdk:libraries:tactrow [2017/01/23 14:40] (当前版本) Spoony |
||
|---|---|---|---|
| 行 1: | 行 1: | ||
| ====== TactRow ====== | ====== TactRow ====== | ||
| - | 轻触开关组类,读取单个轻触开关的状态。 | + | 轻触开关组类,配置一组轻触开关的触发事件并随时读取开关即时状态。 |
| ===== 方法 ===== | ===== 方法 ===== | ||
| 行 14: | 行 14: | ||
| ==== items(self) ==== | ==== items(self) ==== | ||
| 返回当前轻触开关组的对象数组。 | 返回当前轻触开关组的对象数组。 | ||
| + | |||
| + | 调用方法: | ||
| + | <code> | ||
| + | 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 | ||
| + | </code> | ||