34
Raspberry Pi 好好玩 - PiPhone 台灣樹莓派 <[email protected]> Sep 29, 2014/Raspberry Pi #7

用Raspberry Pi做手機 - PiPhone

Embed Size (px)

DESCRIPTION

用Raspberry Pi做手機。 硬體包括Raspberry Pi Model B,Adafruit PiTFT 2.8" Touchscreen,EFCom Pro GPRS/GSM Module,鋰電池等。 軟體使用AT command和GSM模組溝通,Tkinter處理畫面,Xstroke與tegaki為手寫輸入。

Citation preview

Page 1: 用Raspberry Pi做手機 - PiPhone

Raspberry Pi 好好玩- PiPhone

台灣樹莓派 <[email protected]>Sep 29, 2014/Raspberry Pi #7

Page 2: 用Raspberry Pi做手機 - PiPhone

2

● Element14 指定台灣地區 Raspberry Pi 獨家經銷商

about 台灣樹莓派

http://farnell.com/raspberrypi-consumer/approved-retailers.php?region=apac&MER=MER-LM-OB-RPICC-76315

Page 3: 用Raspberry Pi做手機 - PiPhone

● 專注於 Raspberry Pi 應用與推廣

● 舉辦 Raspberry Pi 社群聚會和工作坊

● Facebook : ● 搜尋 RaspberryPiTaiwan

about 台灣樹莓派

Page 4: 用Raspberry Pi做手機 - PiPhone

4

● COSCUP, MakerConf 講者

● 投影片 , http://www.slideshare.net/raspberrypi-tw/presentations

● 程式碼 , https://github.com/raspberrypi-tw

分享 x 社群

Page 5: 用Raspberry Pi做手機 - PiPhone

● David Hunt 用 Raspberry Pi , PiTFT 和 SIM900 GSM/GPRS 組合成一支手機

PiPhone 新聞

http://www.davidhunt.ie/piphone-a-raspberry-pi-based-smartphone/

Page 6: 用Raspberry Pi做手機 - PiPhone

● Raspberry Pi Model B● Adafruit PiTFT 2.8” Touchscreen● SIM900 GSM/GPRS module● 2000mAh LiPo battery● DC-DC boost converter ● Cables, connectors, switch, etc.● MIC and Speaker

所需硬體

Page 7: 用Raspberry Pi做手機 - PiPhone

所需硬體

Page 8: 用Raspberry Pi做手機 - PiPhone

完成圖

Page 9: 用Raspberry Pi做手機 - PiPhone

● EFCom Pro GPRS/GSM Module(AT commands)● IO List: GND , +5V , RX , TX , PWR , RST.● Quad-Band 850/ 900/ 1800/ 1900 MHz● Power Supply: +5V

GSM 通訊模組

http://goo.gl/7jCgpd

Page 10: 用Raspberry Pi做手機 - PiPhone

● Adafruit PiTFT 2.8” Touchscreen , 適合 Model B

顯示與觸控

https://www.adafruit.com/product/1601

Page 11: 用Raspberry Pi做手機 - PiPhone

● 3.7V 鋰聚合物 ( 記得配充電器 )● 升壓模組可將 3.7V 電壓升到 5V

● Input voltage: 3V - 35V● Output voltage: 4 - 35V● Output Current: 3A (MAX)

電源供應

http://www.elecfreaks.com/store/lm2596-dcdc-stepdown-module-bkdc010-p-292.html

Page 12: 用Raspberry Pi做手機 - PiPhone

● 收發電話 , 傳送簡訊 , GSM/GPRS 狀態

● AT command● 畫畫面 , 互動介面

● Tkinter● 文字輸入

● Xstroke, tegaki

所需軟體

Page 13: 用Raspberry Pi做手機 - PiPhone

● Hayes command set, for Hayes Smartmodem (1981)● Dialing, hanging up, and changing the parameters of

the connection● AT - "Attention"

AT Command

http://www.elecfreaks.com/wiki/index.php?title=EFCom_Pro_GPRS/GSM_Module

Page 14: 用Raspberry Pi做手機 - PiPhone

● Pi to Modem : 直接透過 UART(TX/RX)● PC to Modem : 或者用 FT232(FTDI) 轉接板

如何溝通

http://www.elecfreaks.com/wiki/index.php?title=EFCom_Pro_GPRS/GSM_Module

Page 15: 用Raspberry Pi做手機 - PiPhone

● putty, picocom, minicom● sudo picocom /dev/ttyAMA0 -b 115200 -l

終端機程式

Page 16: 用Raspberry Pi做手機 - PiPhone

● 基礎類命令● 參數類命令● 擴展類命令

AT Command 速成

http://elecfreaks.com/store/download/datasheet/rf/SIM900/SIM900_AT%20Command%20Manual_V1.03.pdf

Page 17: 用Raspberry Pi做手機 - PiPhone

● AT<X><n>

● 開啟命令回呼– ATE1

● 關閉命令回呼– ATE0

基礎類命令

Page 18: 用Raspberry Pi做手機 - PiPhone

● 範例: AT+CEER ( 錯誤報告 )● 測試命令 AT+<x>=?

– AT+CEER=?● 查詢命令 AT+<x>?

– AT+CEER?● 設定命令 AT+<x>=<y>

– AT+CEER=0● 執行命令 AT+<x>

– AT+CEER

擴展類命令

Page 19: 用Raspberry Pi做手機 - PiPhone

● 寄簡訊

● AT+CMGF=1● AT+CMGS=”0987654321”● Ctrl + Z

● 撥電話

● ATD0987654321;● 掛電話

● ATH● 接電話

● ATA

AT Command 範例

Page 20: 用Raspberry Pi做手機 - PiPhone

● AT+CSQ # 檢查目前 GSM 信號 (Max 31.99)● AT+CREG? # 查詢目前是否連上網路

● AT+COPS? # 查詢目前連上的 Operator● AT+CLIP=1 # 顯示來電號碼

● AT+GSN # 查詢 IMEI● AT+CMGF=1 # 選擇簡訊顯示為 readable

AT Command 範例

Page 21: 用Raspberry Pi做手機 - PiPhone

● Python binding to the Tk GUI toolkit● Raspberry Pi 內建 Tkinter 模組

● Layout, widget and event

TKinter

http://oreilly.com/catalog/pythonwin32/chapter/ch20.html

Page 22: 用Raspberry Pi做手機 - PiPhone

● Model-View-Controller 模式

● View = UI 畫面● Controller = 分派動作● Model = 實際 AT command, 更新 UI 畫面

MVC in Tkinter

http://en.wikipedia.org/wiki/Model%E2%80%93view%E2%80%93controller

UI 畫面

AT 命令

分派動作

Page 23: 用Raspberry Pi做手機 - PiPhone

● 硬體是獨占資源● 如何在電話來時 , 顯示畫面 & 來電號碼?

● 背景跑多執行緒監聽 Serial port● 來電時叫起 UI 並將號碼傳送過去

接電話問題

Page 24: 用Raspberry Pi做手機 - PiPhone

● 沒有鍵盤輸入 , 只能用觸控輸入

● 螢幕這麼小 (2.8”), 用虛擬鍵盤不適合

● 用手寫輸入

傳送簡訊問題

Page 25: 用Raspberry Pi做手機 - PiPhone

● Full-screen Gesture Recognition for X

Xstroke 手寫輸入

http://ozzmaker.com/2014/06/17/raspberry-pi-with-stroke-and-gesture-recognition/

Page 26: 用Raspberry Pi做手機 - PiPhone

● Open-Source Chinese and Japanese Handwriting Recognition

tegaki 手寫輸入

http://tegaki.org/

Page 27: 用Raspberry Pi做手機 - PiPhone

DEMO

Page 28: 用Raspberry Pi做手機 - PiPhone

打電話- 查詢網路狀態 / 註冊資料

Page 29: 用Raspberry Pi做手機 - PiPhone

打電話 - 帶起鍵盤 UI

Page 30: 用Raspberry Pi做手機 - PiPhone

打電話- 撥通後顯示相關資訊

Page 31: 用Raspberry Pi做手機 - PiPhone

接電話

Page 32: 用Raspberry Pi做手機 - PiPhone

接電話 - 任何時候都會帶起來電畫面

Page 33: 用Raspberry Pi做手機 - PiPhone

● http://www.davidhunt.ie/piphone-a-raspberry-pi-based-smartphone/

● https://github.com/climberhunt/PiPhone

參考資料

Page 34: 用Raspberry Pi做手機 - PiPhone

Raspberry Pi Rocks the World

Thanks