当前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
勾股定理,是一个基本的几何定理,指直角三角形的两条直角边的平方和等于斜边的平方。中国古代称直角三角形为勾股形,并且直角边中较小者为勾,另一长直角边为股,斜边为弦,所以称这个定理为勾股定理,也有人称商高定理。
Python有许多内置函数,共有66个。以下是这些内置函数的详细解释和示例代码
Processing是一款免费开源的互动编程软件,它是一种以数字艺术为背景的程序语言,主要面向计算机程序员和数字艺术家。
Small Basic 语言中也引入了 Turtle (龟标)对象,编程人员可以通过Small Basic 自带的很多命令调用这个对象。
计算机最擅长做的事情就是“重复”——像儿童一样不厌其烦地重复做一件事,而且重复的速度很快,可以在1毫秒内列出你的全部Facebook好友。