【文章內(nèi)容簡介】
TForm1FormCreate TObject Sender kg false c new Comm true Memo1 Text TrackBar1 Position 0 Timer1 Enabled false 設(shè)置串口和波特率并發(fā)送相應(yīng)的投影儀參數(shù) void __fastcall TForm1Button2Click TObject Sender unsigned long m char cp AnsiString 12 1 if kg CloseHandle hp 12 ComboBox30 Text hp CreateFile 12c_str GENERIC_READ GENERIC_WRITE0NULLOPEN_EXISTING00 kg true GetCommState hpdcb dcbBaudRate ComboBox29 Text ToInt SetCommState hpdcb c Resume PurgeComm Form1 hpPURGE_RXCLEAR AnsiString k if RadioButton1 Checked if ComboBox1 ItemIndex 0 k 25 else if ComboBox1 ItemIndex 1 k 26 else if RadioButton2 Checked if ComboBox3 ItemIndex 0 k 34 else if RadioButton3 Checked if ComboBox5 ItemIndex 0 k 67 else if RadioButton4 Checked if ComboBox7 ItemIndex 0 k 90 else if RadioButton5 Checked if ComboBox9 ItemIndex 0 k 12 else if RadioButton6 Checked if ComboBox11 ItemIndex 0 k 34 else if RadioButton7 Checked if ComboBox13 ItemIndex 0 k 45 else if RadioButton8 Checked if ComboBox15 ItemIndex 0 k 32 else if RadioButton9 Checked if ComboBox17 ItemIndex 0 k 56 else if RadioButton10 Checked if ComboBox19 ItemIndex 0 k 90 else if RadioButton11 Checked if ComboBox21 ItemIndex 0 k 78 else if RadioButton11 Checked if ComboBox23 ItemIndex 0 k 78 else if RadioButton11 Checked if ComboBox25 ItemIndex 0 k 78 else if RadioButton11 Checked if ComboBox27 ItemIndex 0 k 78 cp kc_str WriteFile hpcpStrLen cp mNULL void __fastcall TForm1Open1Click TObject Sender if OpenDialog1 Execute MediaPlayer1 FileName OpenDialog1 FileName MediaPlayer1 Open MediaPlayer1 Play MediaPlayer1 Previous TrackBar1 Min 0 TrackBar1 Position 0 TrackBar1 MediaPlayer1 Length Timer1 Enabled true 添加播放器并進行相應(yīng)的設(shè)置 void __fastcall TForm1Timer1Timer TObject Sender TrackBar1 Position MediaPlayer1 Position void __fastcall TForm1TrackBar1Change TObject Sender if TrackBar1 Position 0 TrackBar1 Position 1 TForm1Open1Click TObject Sender if Form1 Memo1 text 10 Form1 MediaPlayer1 FileName D 電動幕 avi Form1 MediaPlayer1 Open MediaPlayer1 Play MediaPlayer1 Previous TrackBar1 Min 0 TrackBar1 Position 0 TrackBar1 MediaPlayer1 Length Timer1 Enabled true Else if Form1 Memo1 text 11 Form1 MediaPlayer1 FileName D 預(yù)熱 avi Form1 MediaPlayer1 Open Else if Form1 Memo1 text 12 Form1 MediaPlayer1 FileName D 聲音 avi Form1 MediaPlayer1 Open void __fastcall TForm1Timer1Timer TObject Sender TrackBar1 Position MediaPlayer1 Position 播放器滾的條隨播放時間變化 void __fastcall TForm1TrackBar1Change TObject Sender if TrackBar1 Position 0 TrackBar1 Position 1 43 下位機設(shè)計 該設(shè)計主要以 AT89C52 單片機為主要 芯片的設(shè)計分為工作階段和學(xué)習(xí)階段用 AT89C52 單片機 P 3 口中的 P30 P 31 作 P 3 口的第二功能使用與串行接口相連接完成學(xué)習(xí)階段的任務(wù)工作階段采用部分 P 3 口的引腳作為信號切換端 P 1 口直接與外部存儲器 X25045 相連實現(xiàn)存儲器的擴展 P 0P 2 口與鍵 盤連接對鍵盤進行檢測用來執(zhí)行用戶的命令操作 程序流程圖如下 圖 14 工作階段流程圖如下 為了便于團隊成員共同開發(fā)將所有程序都進行了模塊劃分主要分為以下幾個模塊主函數(shù) mainc學(xué)習(xí)階段函數(shù) studyc工作階段函數(shù) workc存儲函數(shù) E2PROMc和聲音設(shè)置函數(shù) Voicec 主要程序如下 Mainc include include define uchar unsigned char define WREN 0x06 設(shè)置寫使能鎖存器 define WRDI 0x04 復(fù)位寫使能操作 define RDSR 0x05 讀狀態(tài)寄存器 define WRSR 0x01 寫狀態(tài)寄存器 define READ 0x03 讀 define WRITE 0x02 寫 sbit SCK P17 sbit CS P16 sbit CO P00 sbit SI P01 sbit ADD P35 sbit SUB P34 sbit CSZ P33 sbit CSY P32 extern void delay1 1 秒鐘延時子程序 用于兩件之間的間隔延時 extern void delay2 讀寫延時 extern void delay3 extern void delay4 extern void wren_cmd void 寫使能子程序 extern void wrsr_cmd void 復(fù)位時間位和數(shù)據(jù)保護位寫入狀態(tài)寄存器 extern void byte_write uchar aauchar dd 字節(jié)寫入 aa 為寫入的數(shù)據(jù) dd為寫入的地址 extern uchar byte_read uchar dd 字節(jié)讀出 dd 為讀出的地址返回讀出的數(shù)據(jù) extern void outbyte uchar aa extern uchar inputbyte extern void send uchar dz 向投影機發(fā)各指令代碼子程序 extern void baud void 波特率選擇子程序 extern void soundsmall