示例arduino sketch打包为python包。

wheeler.blink的Python项目详细描述


#blink

这个项目演示了如何将arduino草图作为python包分发。

##使用arduino_helpersavr_helpers编程草图

虽然不是严格依赖于blink包,但是通过使用 [arduino_helpers][1]和[avr_helpers][2],我们可以轻松地刷新编译的 .hex包含在blink包中的固件文件。

例如:

>>> import blink
>>> board = 'diecimila'
>>> firmware = blink.get_firmwares()[board][0]
>>> firmware.name
path('blink.hex')
>>> from arduino_helpers.context import ArduinoContext, Board, Uploader
>>> # For Ubuntu systems, Arduino IDE is installed at `/usr/share/arduino`.
>>> context = ArduinoContext('/usr/share/arduino')
>>> uploader = Uploader(Board(context, board))
>>> from avr_helpers import AvrDude
>>> # Automatically select port, by iterating through available serial
>>> # ports until a connection can be established.
>>> avr_dude = AvrDude(uploader.protocol, uploader.board_context.mcu, uploader.speed)
>>> stdout, stderr = avr_dude.flash(firmware, ['-D'])
>>> print stderr

avrdude-x64: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.00s

avrdude-x64: Device signature = 0x1e9406 avrdude-x64: reading input file “blink.hex” avrdude-x64: writing flash (1056 bytes):

Writing | ################################################## | 100% 0.76s

avrdude-x64: 1056 bytes of flash written avrdude-x64: verifying flash memory against blink.hex: avrdude-x64: load data flash data from input file blink.hex: avrdude-x64: input file blink.hex contains 1056 bytes avrdude-x64: reading on-chip flash data:

Reading | ################################################## | 100% 0.67s

avrdude-x64: verifying … avrdude-x64: 1056 bytes of flash verified

avrdude-x64 done. Thank you.

[1]:https://github.com/wheeler-microfluidics/arduino_helpers [2]:https://github.com/wheeler-microfluidics/avr_helpers

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java我能在这个程序中更好地使用内存吗?   为什么我的Java while循环迭代了一半   java IntelliJ IDEA不在构建时复制资源   socket仅在Java TCP服务器输出上检查客户端断开连接   java游戏物理摩擦   java片段onClick调用方法   symja数学分析器中无法识别java Abs[x]   java在使用泛型时创建二进制搜索树类的实例?   java在外键约束表上的添加和删除   语法java表达式的含义,如果有条件   java创建内联对象并作为参数传递   是否有相当于Redis排序集(zset)的Java数据结构   java找不到适合的方法(无参数)   音频文件操作给定字节帧的音量Java   Eclipse4不以JavaWebStart启动   java如何使用org在JSON对象中获取嵌套的键元素。json?   java与Jackson的反序列化:“org.codehaus.Jackson.map.JsonMappingException:无法反序列化[projectname]的实例。”   字符串的Java正则表达式   spring集成上的java检测缺火指令