古人智慧

Just Do it!
上士聞道,勤而行之;中士聞道,若存若亡;下士聞道,大笑之。不笑,不足以爲道。
~ 道德經 41

「實現夢想不是追逐成功,而是在於賦予生命意義,人生中的每個決定與聲音都有其重要含義。」"The key to realizing a dream is to focus not on success but on significance — and then even the small steps and little victories along your path will take on greater meaning."
電視名人-歐普拉·溫芙蕾(OPRAH WINFREY)

搜尋此網誌

Translation

2015年5月10日 星期日

[Banana Pro][WiringBP] How to control the GPIO by C/C++



上次用Python做GPIO控制,個人認為用於簡單電路測試或控制足夠。但是,未來有一些計劃會用到interrupt,用C/C++開發應該會是主要做法。


WiringBP是由LeMaker改寫Drogon開發的Wiring Pi:
root@bpro:/home/regis# git clone https://github.com/LeMaker/WiringBP -b bananapro
root@bpro:/home/regis# chmod +x ./build
root@bpro:/home/regis# sudo ./build

安裝好之後,查看GPIO的status:
root@bpro:/home/regis/WiringBP/examples# gpio readall 



[Banana Pro][RPi.GPIO_BP]用Python來寫GPIO控制程式


本次實驗是用Python來做GPIO控制,做法非常簡單易用。

先確定系統在更新狀態:
root@bpro:/home/regis# apt-get update
root@bpro:/home/regis# apt-get upgrade

再來安裝 git:
root@bpro:/home/regis# apt-get install git
root@bpro:/home/regis# apt-get install python-dev
root@bpro:/home/regis# apt-get install gcc g++ make git-core vim

裝Python的gpio控制模組:
### For Banana Pro
root@bpro:/home/regis# git clone https://github.com/LeMaker/RPi.GPIO_BP -b bananapro
root@bpro:/home/regis# cd RPi.GPIO_BP
root@bpro:/home/regis# python setup.py install
root@bpro:/home/regis# sudo python setup.py install

[Banana Pro][Wifi]解決Wifi不通 - 1'st step Wifi enable


當Banana Pro板子與HD組好後,就開始要試試他的功能。
我用HDMI接上電視,開機很順利的到login畫面,
但是,我沒usb keyboard,也不知Wifi是否有通,就算通也不知ip address。。。

這一關就卡住了。。。
後來,借了usb keyboard,總算可以login,但是發現Wifi是不運作的,真是糟啊!

[Banana Pro]解決Power Key無法關機










我在使用這系統時,發現按了Power button(左上角)時,系統並不會下指令讓Banana Pro關機。

上網搜尋一番,找到方法如下:














先安裝ACPI 模組:
regis@bpro:~$ sudo apt-get install acpid

[Banana Pro] - boot from SATA 120G HD ﹣﹣ 用HD開機

拿到板子後,做了很多實驗,也安裝不少軟件和設定,其中遇到很多問題,裝了一堆不知名的軟件模組,搞的Linux有點亂。

想了幾個解決方案,那就是用HD切幾個partition,其中2個來做實驗,只留一個乾淨來做使用。而SD卡就專職開機就好,避免開機失敗。

就開始吧~~~~

root@bpro / # fdisk /dev/sda
Command (m for help): p

Disk /dev/sda: 120.0 GB, 120034123776 bytes
255 heads, 63 sectors/track, 14593 cylinders, total 234441648 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk identifier: 0x00002b91

[Banana Pro]測試Linux的I2C tools [GY-273] [HMC5883]三軸電子羅盤 e-compass




用了Arduino之後,買了不少module都是I2C的interface。
本次實驗就用GY-273電子羅盤來試試Banana Pro的I2C的功能。
因為Bananian Linux是非常乾淨的OS,必須先安裝I2C tools

regis@bpro:~$ sudo apt-get install i2c-tools python-smbus 

安裝成功之後,會有這幾個features
i2cdetect – 用來列舉I2C bus和上面所有的裝置
i2cdump – 顯示裝置上所有register的值
i2cget – 讀取裝置上某個register的值
i2cset – 寫入裝置上某個register


2015年5月9日 星期六

BananaPro + HD holder by 3D printer


因為Banana Pro是用SD卡來啟動,
這幾天安裝gcc compiler和GPIO的部份時,
發現SD卡空間有限,
而且,
如果不小心可能開不了機。

Banana Pro有SATA的interface,
可以很容易接上SATA的HD,
剛好手邊有一顆2.5" 120GB,
就上吧!!!


《成果圖》