【Umthombo ovulekileyo】 Isikrini se-DWIN kunye neFowuni ye-Android yeendlela ezimbini zokuLawula ukuDlalwa koMculo

-Ukusuka kwiForam yoPhuhlisi ye-DWIN

Lo mbandela kuwe ukuba utyhale ityala eliphumelele ibhaso elivulekileyo leforum yomphuhlisi we-DWIN-isikrini se-DWIN kunye nefowuni ye-Android yeendlela ezimbini zolawulo lokudlala umculo. Iinjineli ngemodyuli yeBluetooth ukufezekisa isikrini esikrelekrele se-DWIN kunye nedatha yefowuni ye-Android, abasebenzisi banokulawula ngokulula ifowuni ye-Android, i-USB flash drive kumdlalo wengoma, nqumama, utshintshe ingoma kunye noseto lwesandi, amava esikrini esikrelekrele kunye nefowuni ye-Android ezimbini- indlela elula yokulawula.

1.C51 Uyilo
(1) I-T5L ye-serial port isebenzisana nemodyuli yeBluetooth ukuguqula isimo sokudlala, ukuseta umthamo, kwaye ufunde isimo seBluetooth, inxalenye yekhowudi yereferensi ngolu hlobo lulandelayo:
int main(ingekho)
{
INIT_CPU();
T2_Ubushushu();
UART4_Init();
I-EA=1;
//UART4_SendStr(“molo”,ubungakanani(“molo”));
//WDT_ON ();//Vula i-Watchdog.
ngelixa(1)
{
//WDT_RST();//Iinyawo zenja
Inkqubo ();
}
}
I-UART4_Init engenanto (ingenanto)
{
// UART4 ukusetwa kwenqanaba leBaud:
//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 Ireyithi yeBaud
//BODE2_DIV_H=0×00;
//FCLK/(8*DIV)
//BODE2_DIV_L=0×70;
//ES3T=1;
ES2R=1;
I-EA=1;
}
I-void TenMsHandle(ingekho)
{
ukuba(!TenmsFlag)
buya
I-TenmsFlag=0;
UmthomboCofa();//Ijenereyitha yethoni
I-PlayCtrPress ();//Utshintsho lwemeko yokudlala
VolCtrSlider();//Utshintsho lweVolume
IVolLogSlider ();//Utshintsho lweVolume
FundaBtState ();//Funda ubume beBluetooth
}
i-void SourcePress(ingenanto)
{
charTouchKey[2]={0,0};
u8Sdata[2];
read_dgusii_vp(0×3000,TouchKey,1);
ukuba(Iqhosha lokuchukumisa[1]==0)
buya
Idatha[1]=0;
tshintsha (Iqhosha lokuchukumisa[1])
{
umzekelo1://U idiski
Idatha[0]=1;
Thumela iDataToBT(Bhala_Imo_Yokuqhuba,Idatha,1);
ikhefu;
case2:// Igalelo lomgca wangaphandle
Idatha[0]=2;
Thumela iDataToBT(Bhala_Imo_Yokuqhuba,Idatha,1);
ikhefu;
ityala3://Bluetooth
Idatha[0]=3;
Thumela iDataToBT(Bhala_Imo_Yokuqhuba,Idatha,1);
ikhefu;
}
write_dgusii_vp(0×3003,TouchKey,1);
memset(TouchKey,0,ubungakanani(TouchKey));
bhala_dgusii_vp(0×3000,TouchKey,1);
ReadBtStatecount=0;
}
i-void PlayCtrPress (engenanto)
{
charTouchKey[2]={0,0};
u8Sdata[2];
read_dgusii_vp(0×3001,TouchKey,1);
ukuba(Iqhosha lokuchukumisa[1]==0)
buya
Idatha[1]=0;
tshintsha (Iqhosha lokuchukumisa[1])
{
case1:// Ingoma yangaphambili
Idatha[0]=1;
SendDataToBT(Bhala_Elandelayo_Pre_PT,Idatha,1);
ikhefu;
case2:// Dlala Misa
Idatha[0]=2;
SendDataToBT(Bhala_Elandelayo_Pre_PT,Idatha,1);
ikhefu;
case3:// Ingoma elandelayo
Idatha[0]=3;
SendDataToBT(Bhala_Elandelayo_Pre_PT,Idatha,1);
ikhefu;
}
memset(TouchKey,0,ubungakanani(TouchKey));
write_dgusii_vp(0×3001,TouchKey,1);
ReadBtStatecount=0;
}

(2) Iphakheji yesoftware ye-Android ibhalwe nge-QT, ikakhulu iqonda uqhagamshelo lweBluetooth kunye nolawulo lonxibelelwano ngescreen esihlakaniphile, inxalenye yekhowudi yereferensi ngolu hlobo lulandelayo:
ui-> setupUi(le);
bluetooth_ble_Tool=entsha Bluetooth_ble_Tool(“dwin_bt(BLE)”);
ui->ileyibhile_yelocalBT_Name->seta uMbhalo(bluetooth_ble_Tool->getLocalName());
qhagamshela(bluetooth_ble_Tool,&Bluetooth_ble_Tool::BlueSearchConnectState,
oku,&BLE_PairPage::BlueSearchConnectState);
//btchat=i-BtChat entsha ();
//btchat->set_ble_Tool(bluetooth_ble_Tool);
//btchat->init_Page();
//btchat-> fihla ();
devicecommHandle=new DeviceComm();
devicecommHandle->set_ble_Tool(bluetooth_ble_Tool);
devicecommHandle-> InitDevice ();
mwin=i-mainwin entsha ();
ngaphantsi-> fihla ();
qhagamshela (mwin,&mainwin:layChangeMode,
devicecommHandle,&DeviceComm:layChangeMode);// Utshintsho lwemo yokubhala lukhutshiwe
qhagamshela(mwin,&mainwin:layCtrPreNextSt,
devicecommHandle,&DeviceComm:layCtrPreNextSt);// lit. bhala amalungu aphezulu nasezantsi engoma
qhagamshela (mwin,&mainwin:layMusicVolChange,
devicecommHandle,&DeviceComm:layMusicVolChange);// Bhala utshintsho lwevolyum phantsi
qhagamshela (isixhobocommHandle,&IsixhoboComm ::Funda iModi yokuDlala,
le,[=](int mode){// Ukucwangcisa indlela yangoku
qDebug() qDebug() B_Upan-> setChecked(false);
mwin->B_AUX-> setChecked(false);
mwin->B_BT-> setChecked(false);
ukuba(imowudi==1)
mwin->B_Upan-> setChecked(yinyaniso);
ngenye indlela ukuba(imowudi==2)
mwin->B_AUX-> setChecked(yinyaniso);
ngenye indlela ukuba(imowudi==3)
mwin->B_BT-> setChecked(yinyani);
});
qhagamshela (isixhobocommHandle,&IsixhoboComm::Funda iPlayMusicVol,
le,[=](int vol){// Ukumisela uMboniso weVolyum
mwin->QS_MainVol->setValue(vol);
});
qhagamshela(bluetooth_ble_Tool,&Bluetooth_ble_Tool::BLE_Link_impazamo,
le,[=](){
le-> bonisa ();
ngaphantsi-> fihla ();
devicecommHandle->TimerStopReadDeviceST();
le-> ui->progressBar-> setValue(0);
});
i-void BLE_PairPage::on_pushButton_cofa(){
bluetooth_ble_Tool->SetOperUuidServer(QBluetoothUuid(serviceUuid));
//ui->ileyibhile_localBT->cima ();
//ui-> ilebula_localBT_Name->setaText(bluetooth_ble_Tool->getLocalName());
bluetooth_ble_Tool->startFindConnectBle();
//bluetooth_ble_Tool->startStateprogressBar ();
ui-> pushButton-> setEnebled (bubuxoki);
ui-> pushButton-> setText(“Ukukhangela”);
qhagamshela(bluetooth_ble_Tool,&Bluetooth_ble_Tool::BlueBLE_FindDevicefinished,
le,[=](bool kulungile){
ui-> pushButton-> setEnabled(yinyani);
ui-> pushButton-> setText ("Qala ukufumanisa iBluetooth eqhagamshelweyo");
ukuba(kulungile==bubuxoki) {
QMessageBox ::ulwazi(le,tr(“Isimo Sokufuna “),” Isixhobo asikwazi ukuphetshwa, nceda ujonge ukuba isixhobo sele sivuliwe na, okanye ukuba enye ifowuni sele iqhagamshelwe kuyo?”);} }); }
elingenanto BLE_PairPage::BlueSearchConnectState(Bluetooth_ble_Tool ::startStateprogressBar_em Linkst, int progress){
ui->progressBar->setValue(inkqubela phambili);
ukuba(Ikhonkco>=Bluetooth_ble_Tool::Ble_OtherError){
QMessageBox :: ulwazi (le, tr ("uqhagamshelwano olukhawulezayo "), bluetooth_ble_Tool->getErrorinfo ());
ui->label_tips-> setText(bluetooth_ble_Tool->getErrorinfo());}
ngenye indlela ukuba(Ikhonkco>=Bluetooth_ble_Tool::Ble_Deconnect_device){
QMessageBox :: ulwazi (le, tr("unxibelelwano olukhawulezileyo ")," buggy ");
ui->label_tips-> setText(“buggy”);}
ngenye indlela ukuba(Ikhonkco==Bluetooth_ble_Tool::Ble_Connect_characterOk){// QMessageBox::inkcukacha(
le,tr(“iqhagamshelwe ngempumelelo “),bluetooth_ble_Tool->getErrorinfo());
ui->label_tips-> setText("iqhagamshelwe ngempumelelo");
le-> fihla ();
mwin->bonisa ();
devicecommHandle->TimerStartReadDeviceST(100);
//btchat-> bonisa ();
// cima unxibelelwano(bluetooth_ble_Tool,&Bluetooth_ble_Tool::BlueSearchConnectState,
//le,&BLE_PairPage::BlueSearchConnectState); }
enye{
ui->label_tips-> setText(“Ukukhangela imidibaniso”); }


Ixesha lokuposa: May-23-2024