-Ho tsoa ho Foramo ea Baetsi ba DWIN
Khatiso ena bakeng sa hau ho sutumelletsa nyeoe e hapileng khau e bulehileng ea foramo ea nts'etsopele ea DWIN - skrini sa DWIN le mohala oa Android oa mekhoa e 'meli o laolang ho bapaloa ha mmino. Baenjiniere ka module ea Bluetooth ho fihlela tšebelisano e bohlale ea DWIN le tšebelisano ea data ea mohala oa Android, basebelisi ba ka khona ho laola mohala oa Android habonolo, USB Flash drive papaling ea lipina, ho khefutsa, ho fetola pina le litlhophiso tsa molumo, ho ba le skrine e bohlale le mohala oa Android tse peli- tsela e bonolo taolo.
1.C51 Moralo
(1) Boema-kepe ba serial ba T5L bo sebelisana le module ea Bluetooth ho fetola boemo ba ho bapala, ho beha molumo, le ho bala boemo ba Bluetooth, karolo ea khoutu ea referense e tjena:
int main(void)
{
INIT_CPU();
T2_Mocheso();
UART4_Init();
EA=1;
//UART4_SendStr(“hello”,sizeof(“hello”));
//WDT_ON();//Bulela Watchdog.
ha(1)
{
//WDT_RST();// Maoto a ntja
Mokhoa ();
}
}
UART4_Init e se nang letho
{
// Litlhophiso tsa sekhahla sa UART4 Baud:
//BODE2_DIV_H=CPU Mains frequency/(8*Baud rate) .
//206438400/8/115200=224=0xe0
//206438400/8/921600=28=0x1C
//206438400/8=25804800/230400=112=0×70
SCON2T=0×80;
SCON2R=0×80;
BODE2_DIV_H=0×00;//FCLK/(8*DIV)
BODE2_DIV_L=0xe0;// 921600 Baud sekhahla
//BODE2_DIV_H=0×00;
//FCLK/(8*DIV)
//BODE2_DIV_L=0×70;
//ES3T=1;
ES2R=1;
EA=1;
}
void TenMsHandle(void)
{
haeba(!TenmsFlag)
khutla;
TenmsFlag=0;
MohloliPress();//Jenereithara ya modumo
PlayCtrPress();// Phetoho ea boemo ba Playback
VolCtrSlider();//Ho fetoha ha molumo
VolLogSlider ();// Phetoho ea molumo
BalaBtState();//Bala boemo ba Bluetooth
}
void SourcePress(void)
{
charTouchKey[2]={0,0};
u8Sdata[2];
bala_dgusii_vp(0×3000,TouchKey,1);
haeba(TouchKey[1]==0)
khutla;
Boitsebiso[1]=0;
switjha(TouchKey[1])
{
case1://U disk
Boitsebiso[0]=1;
SendDataToBT(Ngola_Run_Mode,Sdata,1);
khefu;
case2:// Kenyo ya Kantle ya Mola
Boitsebiso[0]=2;
SendDataToBT(Ngola_Run_Mode,Sdata,1);
khefu;
case3://Bluetooth
Boitsebiso[0]=3;
SendDataToBT(Ngola_Run_Mode,Sdata,1);
khefu;
}
ngola_dgusii_vp(0×3003,TouchKey,1);
memset(TouchKey,0,sizeof(TouchKey));
ngola_dgusii_vp(0×3000,TouchKey,1);
ReadBtStatecount=0;
}
void PlayCtrPress(feela)
{
charTouchKey[2]={0,0};
u8Sdata[2];
bala_dgusii_vp(0×3001,TouchKey,1);
haeba(TouchKey[1]==0)
khutla;
Boitsebiso[1]=0;
switjha(TouchKey[1])
{
case1:// Pina e fetileng
Boitsebiso[0]=1;
SendDataToBT(Write_Next_Pre_PT,Sdata,1);
khefu;
case2:// Ho khefutsa ho bapala
Boitsebiso[0]=2;
SendDataToBT(Write_Next_Pre_PT,Sdata,1);
khefu;
case3:// Pina e latelang
Boitsebiso[0]=3;
SendDataToBT(Write_Next_Pre_PT,Sdata,1);
khefu;
}
memset(TouchKey,0,sizeof(TouchKey));
ngola_dgusii_vp(0×3001,TouchKey,1);
ReadBtStatecount=0;
}
(2) Sephutheloana sa software sa Android se ngotsoe ka QT, haholo-holo ho hlokomela khokahano ea Bluetooth le taolo ea puisano ka skrini se bohlale, karolo ea khoutu ea litšupiso e tjena:
ui->setupUi(this);
bluetooth_ble_Tool=Bluetooth_ble_Tool e ncha(“dwin_bt(BLE)”);
ui->label_localBT_Name->setText(bluetooth_ble_Tool->getLocalName());
hokela(bluetooth_ble_Tool,&Bluetooth_ble_Tool::BlueSearchConnectState,
ena,&BLE_PairPage::BlueSearchConnectState);
//btchat=BtChat e ncha();
//btchat->set_ble_Tool(bluetooth_ble_Tool);
//btchat->init_Page();
//btchat-> pata();
devicecommHandle=new DeviceComm();
devicecommHandle-> set_ble_Tool(bluetooth_ble_Tool);
devicecommHandle-> InitDevice ();
mwin=inwin e ncha();
tlase-> pata ();
hokela (mwin,&mainwin:layChangeMode,
devicecommHandle,&DeviceComm:layChangeMode);// Phetoho ya mokgwa wa ho ngola e fanoe
hokela (mwin,&mainwin:layCtrPreNextSt,
devicecommHandle,&DeviceComm:layCtrPreNextSt);// lit. ngola fatshe dikarolo tse ka hodimo le tse tlase tsa pina
hokela (mwin,&mainwin:layMusicVolChange,
devicecommHandle,&DeviceComm:layMusicVolChange);// Ngola phetoho ya modumo fatshe
hokela (sesebediswacommHandle,&DeviceComm::ReadPlayMode,
sena,[=](int mode){// Ho lokisa boemo ba hajoale
qDebug() qDebug()
mwin->B_AUX-> setChecked(false);
mwin->B_BT->setChecked(false);
haeba(mokhoa==1)
mwin->B_Upan-> setChecked(nnete);
ho seng joalo haeba(mokhoa==2)
mwin->B_AUX->setChecked(nnete);
ho seng joalo haeba(mokhoa==3)
mwin->B_BT->setChecked(nnete);
});
hokela(sesebediswacommHandle,&DeviceComm::ReadPlayMusicVol,
sena,[=](int vol){// Ho hlophisa Phatlalatso ea Bolumo
mwin->QS_MainVol->setValue(vol);
});
hokela(bluetooth_ble_Tool,&Bluetooth_ble_Tool::BLE_Link_phoso,
sena,[=](){
sena-> bontša();
tlase-> pata ();
devicecommHandle-> TimerStopReadDeviceST();
sena-> ui-> tsoelopeleBar-> setValue(0);
});
void BLE_PairPage::on_pushButton_clicked(){
bluetooth_ble_Tool-> SetOperUuidServer(QBluetoothUuid(serviceUuid));
//ui->label_localBT->hlakile();
//ui->label_localBT_Name->setText(bluetooth_ble_Tool->getLocalName());
bluetooth_ble_Tool->startFindConnectBle();
//bluetooth_ble_Tool->startStateprogressBar();
ui-> pushButton-> setEnabled(leshano);
ui-> pushButton-> setText(“Batla”);
hokela(bluetooth_ble_Tool,&Bluetooth_ble_Tool::BlueBLE_FindDevicefinished,
sena,[=](bool ho lokile){
ui-> pushButton-> setEnabled('nete);
ui-> pushButton-> setText(“Qala ho bona Bluetooth e hokahaneng”);
haeba(ho lokile== bohata) {
QMessageBox :: information(ena,tr("Search Status ")," Sesebediswa ha se khone ho batlisisa, ka kopo sheba hore na sesebelisoa se se se buletsoe, kapa selefounu e 'ngoe e se e hokahane le eona?");} }); }
lefeela BLE_PairPage::BlueSearchConnectState(Bluetooth_ble_Tool::startStateprogressBar_em Linkst, int progress){
ui->progressBar->setValue(tsoelopele);
haeba(Lihokelo>=Bluetooth_ble_Tool::Ble_OtherError){
QMessageBox :: lesedi (sena, tr(“potlako ya kgokelo “), bluetooth_ble_Tool->getErrorinfo());
ui->label_tips->setText(bluetooth_ble_Tool->getErrorinfo());}
ho seng joalo haeba(Lihokelo>=Bluetooth_ble_Tool::Ble_Deconnect_device){
QMessageBox :: leseli (ena, tr ("potlako ea khokahanyo ")," buggy ");
ui->label_tips->setText(“buggy”);}
ho seng joalo haeba(Linkst==Bluetooth_ble_Tool::Ble_Connect_characterOk){// QMessageBox::information(
sena,tr("e hokahane ka katleho "),bluetooth_ble_Tool->getErrorinfo());
ui-> label_tips-> setText("e hokahane ka katleho");
sena-> pata ();
mwin-> bontša();
devicecommHandle-> TimerStartReadDeviceST(100);
//btchat->show();
// hakolla(bluetooth_ble_Tool,&Bluetooth_ble_Tool::BlueSearchConnectState,
// sena,&BLE_PairPage::BlueSearchConnectState); }
tse ling{
ui-> label_tips-> setText(“Batla lihokelo”); }
Nako ea poso: May-23-2024