Upload
ichef
View
268
Download
1
Embed Size (px)
Citation preview
Swift Х Raspberry Pi
I am Mason ◉ A beginner in iOS◉ Intern at iCHEF
Swift meetup
“
感恩 seafood ,讚歎 seafood
Swift Swift
Raspberry Pi х
Swift
Requirements
◉Raspberry Pi 2 Model B◉8 GB microSD card◉USB wireless adapter
Operation System
◉Raspbian Jessie from raspberrypi.org
Getting Started
◉Copy the Raspbian image on microSD card
◉Resize the Raspbian image partition
◉Setup the Internet environment
sudo vi /etc/wpa_supplicant/wpa_supplicant.conf
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdevupdate_config=1network={ ssid=”Mission” psk=”00000000" proto=RSN key_mgmt=WPA-PSK pairwise=CCMP auth_alg=OPEN}
Prerequisites
Install clang-3.6 and libicu-dev via apt-get
wget http://repos.rcn-ee.com/debian/pool/main/r/rcn-ee-archive-keyring/rcn-ee-archive-keyring_2015.10.22~bpo90+20151022+1_all.deb
sudo dpkg -i rcn-ee-archive-keyring_2015.10.22~bpo90+20151022+1_all.deb
echo "deb [arch=armhf] http://repos.rcn-ee.com/debian/ jessie main" | sudo tee --append /etc/apt/sources.list
sudo apt-get update
Prerequisites
sudo apt-get install libicu-dev
sudo apt-get install clang-3.6
sudo update-alternatives --install /usr/bin/clang clang /usr/bin/clang-3.6 100
sudo update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-3.6 100
Install Swift 2.2◉ Add the @iachievedit repository key
wget -qO- http://dev.iachieved.it/iachievedit.gpg.key | sudo apt-key add -
◉ Add the repository to source.list
echo "deb [arch=armhf] http://iachievedit-repos.s3.amazonaws.com/ jessie main" | sudo tee --append /etc/apt/sources.list
◉ Install Swift 2.2
sudo apt-get updatesudo apt-get install swift-2.2
SwiftGPIO◉ Manually download SwiftGPIO.swift
wget https://raw.githubusercontent.com/uraimo/SwiftyGPIO/master/Sources/SwiftyGPIO.swift
SwiftGPIO◉ Create a main.swift file and make our Raspberry Pi lighten up a LED.
import Glibc
let gpios = SwiftyGPIO.getGPIOsForBoard(.RaspberryPi2)
gpios[.P26]!.direction = .OUT
while true { gpios[.P26]!.value = 1}
SwiftGPIO◉ Compile it
swiftc SwiftyGPIO.swift main.swift
◉ Run it
sudo ./main
Q & AYou can find this article at my medium blog.https://medium.com/@MissionKao