当前SAKSHAT为我们提供的方法参考:http://wiki.nxez.com/saks:sdk:libraries:tactrow
这里就直接摘录了,以下是创百科的内容:
TactRow
轻触开关组类,配置一组轻触开关的触发事件并随时读取开关即时状态。 方法
初始化对象,设置引脚和触发电平(高电平或低电平触发)。pins 为 IO 引脚数组。
返回当前轻触开关的按下状态。true 或 false。index 为 LED 编号,从 0 开始。
返回当前轻触开关组的工作状态的数组。
返回当前轻触开关组的对象数组。
对于按键可以安装按键触发时的回调函数,回调函数复制给tact_event_handler方法
#输出按键状态
import time
from sakshat import SAKSHAT
from sakspins import SAKSPins as PINS
if __name__ == "__main__":
try:
#Declare the SAKS Board
SAKS = SAKSHAT()
while True:
#获取按键状态
blue_button = SAKS.tactrow.is_on(0)
yello_button = SAKS.tactrow.is_on(1)
if blue_button == False:
print("蓝色未按下")
else:
print("蓝色已按下")
if yello_button == False:
print("黄色未按下")
else:
print("黄色已按下")
time.sleep(1)
except KeyboardInterrupt:
print("任务被终止了")
#输出按键组状态
import time
from sakshat import SAKSHAT
from sakspins import SAKSPins as PINS
if __name__ == "__main__":
try:
#Declare the SAKS Board
SAKS = SAKSHAT()
while True:
#获取按键组状态
key_status = SAKS.tactrow.row_status
#打印安装状态
print("按键组状态为" + str(key_status))
time.sleep(1)
except KeyboardInterrupt:
print("任务被终止了")
#按键事件触发方式操作
import time
from sakshat import SAKSHAT
from sakspins import SAKSPins as PINS
#在检测到轻触开关触发时自动执行此函数
def key_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
'''
#判断是否是右边的轻触开关被触发,并且是在被按下
if pin == PINS.TACT_RIGHT and status == True:
print("黄色按键被按下")
#判断是否是右边的轻触开关被触发,并且是在被按下
if pin == PINS.TACT_RIGHT and status == False:
print("黄色按键被释放")
#判断是否是右边的轻触开关被触发,并且是在被按下
if pin == PINS.TACT_LEFT and status == True:
print("蓝色按键被按下")
#判断是否是右边的轻触开关被触发,并且是在被按下
if pin == PINS.TACT_LEFT and status == False:
print("蓝色按键被释放")
if __name__ == "__main__":
try:
#Declare the SAKS Board
SAKS = SAKSHAT()
#设定轻触开关回调函数
SAKS.tact_event_handler = key_event_handler
except KeyboardInterrupt:
print("任务被终止了")
课程 bilibili 视频地址:https://www.bilibili.com/video/av71878718/?p=20
伺服电机(servo motor )是指在伺服系统中控制机械元件运转的发动机,是一种补助马达间接变速装置。
本文档面向希望创建自己的应用程序的开发人员,这些应用程序将Blockly集成为代码编辑器。
“总统测验”是一个关于美国前总统的问答游戏。虽然测验的内容与总统有关,但你可以把它当作模板,来实现对任何题目的测验。
本章将创建一个与FrontlineSMS功能类似的广播中心,不过是运行在Android手机上。
由于Scratch软件界面显示和国内等级考试大纲用词不同,部分名词出现了两种称呼。例如指令模块(积木)、程序区(代码区),其实表达的是一个意思。
游戏是移动应用中最令人兴奋的部分,无论是玩游戏,还是做游戏。
Python图像处理库,该库支持多种文件格式,提供强大的图像处理功能。
UART 实现标准的 UART/USART 双工串行通信协议。在物理层,它由 2 条线组成:RX 和 TX。通信单位是一个字符(不要与字符串字符混淆),它可以是 8 位或 9 位宽。