这里会显示出您选择的修订版和当前版本之间的差别。
两侧同时换到之前的修订记录 前一修订版 | |||
note:qwedc:remote_control_saks [2017/04/14 18:45] 果果 |
note:qwedc:remote_control_saks [2017/04/14 19:11] 果果 改成代码格式 |
||
---|---|---|---|
行 10: | 行 10: | ||
- sudo git clone https://github.com/spoonysonny/SAKS-SDK.git | - sudo git clone https://github.com/spoonysonny/SAKS-SDK.git | ||
然后将SDK直接复制到文件夹下(注:clone命令会自动生成SAKS-SDK这个文件夹,而我们并不需要,可以用cp命令将它拷贝过来然后用rm -rf删除掉多余的文件夹。)克隆完毕以后,删除main.py,重新建立一个。在里面输入以下代码: | 然后将SDK直接复制到文件夹下(注:clone命令会自动生成SAKS-SDK这个文件夹,而我们并不需要,可以用cp命令将它拷贝过来然后用rm -rf删除掉多余的文件夹。)克隆完毕以后,删除main.py,重新建立一个。在里面输入以下代码: | ||
- | - #!/usr/bin/env python | + | <code> |
- | - # -*- coding: utf-8 -*- | + | #!/usr/bin/env python |
- | - from sakshat import SAKSHAT | + | # -*- coding: utf-8 -*- |
- | - import time | + | from sakshat import SAKSHAT |
- | - import commands | + | import time |
- | - import sys | + | import commands |
- | - #Declare the SAKS Board | + | import sys |
- | - SAKS = SAKSHAT() | + | #Declare the SAKS Board |
- | - args = sys.argv | + | SAKS = SAKSHAT() |
- | - action=args[1] | + | args = sys.argv |
- | - if __name__ == "__main__": | + | action=args[1] |
- | - if action=="beep": | + | if __name__ == "__main__": |
- | - SAKS.buzzer.beep(int(args[2])) | + | if action=="beep": |
- | - if action=="ledon": | + | SAKS.buzzer.beep(int(args[2])) |
- | - if args[2]=="all": | + | if action=="ledon": |
- | - SAKS.ledrow.on() | + | if args[2]=="all": |
- | - else: | + | SAKS.ledrow.on() |
- | - SAKS.ledrow.on_for_index(int(args[2])) | + | else: |
- | - if action=="ledoff": | + | SAKS.ledrow.on_for_index(int(args[2])) |
- | - SAKS.ledrow.off() | + | if action=="ledoff": |
- | - if action=="getledstatus": | + | SAKS.ledrow.off() |
- | - print(SAKS.ledrow.is_on(int(args[2]))) | + | if action=="getledstatus": |
- | - if action=="displaynum": | + | print(SAKS.ledrow.is_on(int(args[2]))) |
- | - SAKS.digital_display.show(args[2]) | + | if action=="displaynum": |
- | - if action=="displayoff": | + | SAKS.digital_display.show(args[2]) |
- | - SAKS.digital_display.off() | + | if action=="displayoff": |
- | (PS:由于百科不支持代码&缩进,所以放出来的代码需要大家自行手敲哦~如果想偷懒,请转向树莓派实验室主站哦~) | + | SAKS.digital_display.off() |
+ | </code> |