第四章 系統軟體討論
4.1. 軟(韌)體功能總覽
4.1.1. 軟韌體架構
身心障礙者用之電腦輔助輸入裝置 Main function
LCD display
(assembly) USB control
Keyboard & Mouse Touch mode Scan mode
Print one page
Timer ISR Column invert
Row invert
Fill buffer Check R/W
interrupt
page function table Touch ISR
USB protocol (chap 9) Single grid
invert
Table
USB descriptor
Send buffer USB enumeration
Print one Grid Print one byte
fonts
圖 4-1 軟(韌)體系統架構圖
如圖 4-1 所示,系統的軟體部分主要分作四個部分,分別是液晶畫面顯示、
USB 傳輸控制、鍵盤滑鼠功能選取、以及靜態資料如字型、每一頁的功能表和 USB 描述元等等。
32
4.1.2. 系統運作流程
計時器中斷服務常式
Timer Interrupt Service Routine
微動開關中斷服務常式
Micro Switch Interrupt Service Routine
開啟電源
Power ON
初始化液晶螢幕
Initialize LCD setting
& Clear Screen
致能觸控接收埠
Enable Serial port interrupt for touch panel singnal
初始化USB控制晶片
Initialize USB controller and enumerate
掃描模式 或 觸控模式
Scan or Touch Mode?
依觸控格座標查功能表
Using Touch Grid Coordinate to Look up function table
觸控模式
Touch Mode
將查詢結果以USB送出
Sending the function code to PC by USB
掃描模式
Scan Mode
掃描階層切換/將各階層 選擇結果記錄為格座標
Switch Scan State / Recording the result of selection as Grid Coordinate
觸控開關中斷服務常式
Touch Interrupt Service Routine
將觸碰值轉換為格座標
Converting the touch value to Grid Coordinate
有觸控未處理?
Any Unprocessed Touching ?
有 沒有 Yes
No
計時器累加/切換選取區
Switching the Selection area when every time the timer increase
依格座標查功能表
Using Grid Coordinate to Look up function table
將查詢結果以USB送出
Sending the function code to PC by USB
有選擇結果未處理?
Any Unprocessed result of selection ?
圖 4-2 系統運作主流程圖
在圖 4-2 中所示,主程式在開啟電源後,進行一連串的初始化動作,陸續將 液晶顯示功能、觸控接收功能等設定至定位,並完成 USB 列舉(Enumeration),使 得各週邊硬體皆可立即正常運作。
初始化完成後,會進入輪詢迴圈(Polling Loop) ,迴圈先確認目前的輸入模
33
式為「觸控模式」或「掃描模式」,若是觸控模式,則不斷的確認是否有未處理 的觸控發生,若有,則以觸控點所屬的格座標(Grid Coordinate),查表得到該頁面 此座標位置的對應功能,若為頁面切換鍵,則切換頁面,若為電腦功能鍵,則將 查詢結果以 USB 封包送出。
圖 4-3 主程式虛擬碼
圖 4-3 為本研究的主程式虛擬碼,在前面的初始化函式結束之後,便進入主 迴圈中,預設迴圈為觸控迴圈,不斷的檢查是否有觸控按鍵的功能需要以 USB 傳送,若成立,則查表並執行對應功能,掃描模式亦同。
34 頁面選擇狀態
Page Selection State
進入掃描模式
水平位置選擇狀態
Horizontal Position Selection State
垂直位置選擇狀態
Vertical Position Selection State
離開掃描模式
35
在每個狀態下,都有一個離開鍵,並且都配置在各狀態的第一選項,方便使 用者在第一時間決定是否繼續停留在此階層,而在不同階層,按下離開鍵所產生 的反應也略有不同,在第一層(頁面狀態)下選取離開鍵,會離開掃描模式,而在 第二、三層選取離開鍵,則會返回上一層選單。
36