首先附上本文的两篇参考文档
一 Adafruit简介
为了更好的认识Adafruit,先看两篇摘自Adaruit官网和WiKi维基百科的两段话:
Adafruitwas
founded in 2005 by MIT engineer, Limor "Ladyada" Fried. Her goal was
to create the best place online for learning electronics and making the best
designed products for makers of all ages and skill levels. Adafruit has grown
to over 50 employees in the heart of NYC with a 15,000+ sq ft. factory.
Adafruit has expanded offerings to include tools, equipment and electronics
that Limor personally selects, tests and approves before going in to the
Adafruit store. Limor was the first female engineer on the
cover of WIRED magazine and was recently awardedEntrepreneur magazine\'s Entrepreneur of the year.
Ladyada is on the NYC Industrial Business Advisory Council. In 2014 Adafruit
was ranked #11 in the top 20 USA manufacturing companies and #1 in New York City by Inc. 5000 "fastest growing private companies". Adafruit is a 100% woman owned company. For all press
inquires,
大体是说,Adafruit创建于2015年,由MIT(麻省理工大学)的Limo Ladyada Fried组织,她的目标是创建一个网上上线的的学习电子技术平台,为不同年龄、不同技术水平的创建设计最好的电子产品。公司规模不断发展壮大,现在除了学习平台,还包括开发工具、仪器设备以及电子产品等,这些都是经过她本人选择、测试、批准的。因此,她也成为在WIRED杂志封面的首位女性工程师等。下面就是这位大名顶顶的Ladyada。
Adafruit Industries is
an open-source hardware company founded by Limor Fried in 2005.[1][2] The
company designs and manufactures a number of electronics products, sells a wide
variety of electronics components, tools, and accessories via its online
storefront, and produces a number of learning resources, including written
tutorials, introductory videos for children, and the longest running live video
electronics show on the internet.[3] All
AdaFruit products are manufactured in Manhattan,
New York City.[3] In
2013, the company took in $22 million in revenue, and had shipped over a
million products in 480,000 orders.[4]The
company\'s goal is to get more people involved in technology, science and
engineering. [5] Project
kits are designed to deliver practical outcomes not academic exercises and
encourage more women into the field.[6]
注意上面红色部分,也就是说,Adafruit上,有丰富的关于学习资源,具体可查看https://learn.adafruit.com,其实主要包括了三大开源硬件(Raspberry Pi ,Beaglebone Black,Arduino)的一些Maker的DIY,但这些DIY有详细的操作、开发说明,而且代码全部开源,如果想查看所有的关于Adafruit的源码,可到其github仓库查看https://github.com/adafruit,而在Adafruit中,部分关于BBB的DIY,如下图所示
二 Adafruit示例
1 搭建Python环境,安装Adafruit_BBIO库
/usr/bin/ntpdate -b -s -u pool.ntp.org
opkg update
opkg install task-native-sdk
opkg install python-pip python-setuptools
opkg install python-dev
opkg install python-imaging python-smbus
pip install Adafruit_BBIO
2 下载并安装SSD1306 python库
opkg install git
git clone https://github.com/adafruit/Adafruit_Python_SSD1306.git (http://adafru.it/dEH)
cd Adafruit_Python_SSD1306
sudo python setup.py install
3 启动spi
echo BB-SPI0-01 > /sys/devices/bone_capemgr.*/slots
4 电路连接
5 编写程序
# Initialize library.
disp.begin()
# Clear display.
disp.clear()
disp.display()
# Create blank image for drawing.
# Make sure to create image with mode \'1\' for 1-bit color.
width = disp.width
height = disp.height
image = Image.new(\'1\', (width, height))
# Get drawing object to draw on image.
draw = ImageDraw.Draw(image)
# Draw a black filled box to clear the image.
draw.rectangle((0,0,width,height), outline=0, fill=0)
# Draw some shapes.
# First define some constants to allow easy resizing of shapes.
padding = 2
shape_width = 20
top = padding
bottom = height-padding
# Move left to right keeping track of the current x position for drawing shapes.
x = padding
# Draw an ellipse.
draw.ellipse((x, top , x+shape_width, bottom), outline=255, fill=0)
x += shape_width+padding
# Draw a rectangle.
draw.rectangle((x, top, x+shape_width, bottom), outline=255, fill=0)
x += shape_width+padding
# Draw a triangle.
draw.polygon([(x, bottom), (x+shape_width/2, top), (x+shape_width, bottom)], outline=255, fill=0)
x += shape_width+padding
# Draw an X.
draw.line((x, bottom, x+shape_width, top), fill=255)
draw.line((x, top, x+shape_width, bottom), fill=255)
x += shape_width+padding
# Load default font.
font = ImageFont.load_default()
# Alternatively load a TTF font.
# Some other nice fonts to try: http://www.dafont.com/bitmap.php
#font = ImageFont.truetype(\'Minecraftia.ttf\', 8)
# Write two lines of text.
draw.text((x, top), \'Hello\', font=font, fill=255)
draw.text((x, top+20), \'World!\', font=font, fill=255)
# Display image.
disp.image(image)
disp.display()
6 运行
python spoiled.py
关注微信公众号【口袋物联】,微信号为koudaiwulian,更多物联网知识等着你
BeagleBone Green开发板试用帖汇总
|