–Ka socota Madasha Horumarinta ee DWIN
Arrinkan adiga kugu saabsan si aad u riixdo kiiska isha furan ee ku guulaysta ee golaha horumariyaha DWIN - Shaashadda DWIN iyo talefoonka Android laba-geesoodka isku xirka dib-u-ciyaarista muusiga. Injineerada iyada oo loo marayo moduleka Bluetooth si ay u gaaraan shaashadda caqliga leh ee DWIN iyo isdhexgalka xogta taleefanka Android, isticmaalayaashu waxay si fudud u xakameyn karaan taleefanka Android, USB flash drive ee ciyaarta heesaha, hakinta, beddelka heesaha iyo goobaha codka, khibradda shaashadda caqliga leh iyo taleefanka Android laba- hab ku habboon xakamaynta.
1.C51 Naqshad
(1) Dekedda taxan ee T5L waxay la falgashaa moduleka Bluetooth-ka si loo beddelo heerka dib-u-ciyaarista, u dejiso mugga, oo loo akhriyo heerka Bluetooth-ka, qayb ka mid ah koodka tixraaca waa sida soo socota:
Int main(void)
{
INIT_CPU ();
T2_Heat ();
UART4_Init ();
EA=1;
// UART4_SendStr("hello",sizeof("hello"));
//WDT_ON();//Daar Ilaalada.
halka (1)
{
//WDT_RST();// Lugaha eyga
Habka();
}
}
maran UART4_Init (wax madhan)
{
// UART4 dejinta heerka Baud:
//BODE2_DIV_H=CPU Inta jeer ee Mais/(8*qiimaha Baud) .
//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 heerka Baud
//BODE2_DIV_H=0×00;
//FCLK/(8*DIV)
//BODE2_DIV_L=0×70;
//ES3T=1;
ES2R=1;
EA=1;
}
TenMsHandle (wax madhan)
{
haddi(!TenmsFlag)
soo noqosho;
TenmsFlag=0;
SourcePress();//Tone dhaliyaha
PlayCtrPress()
VolCtrSlider ();// Isbedelka codka
VolLogSlider ();// Isbedelka codka
ReadBtState();//Akhri heerka Bluetooth
}
madhan SourcePress(wax madhan)
{
charTouchKey[2]={0,0};
u8Sdata[2];
read_dgusii_vp(0×3000,TouchKey,1);
haddii (TouchKey[1]==0)
soo noqosho;
Xogta[1]=0;
bedel (TouchKey[1])
{
case1://U disk
Sdata[0]=1;
DirDataToBT(Qor_Run_Mode,Sdata,1);
jebin;
case2: // External LineIn Input
Sdata[0]=2;
DirDataToBT(Qor_Run_Mode,Sdata,1);
jebin;
case3://Bluetooth
Sdata[0]=3;
DirDataToBT(Qor_Run_Mode,Sdata,1);
jebin;
}
write_dgusii_vp(0×3003,TouchKey,1);
memset(TouchKey,0,sizeof(TouchKey));
write_dgusii_vp(0×3000,TouchKey,1);
ReadBtStatecount=0;
}
PlayCtrPress (wax madhan)
{
charTouchKey[2]={0,0};
u8Sdata[2];
read_dgusii_vp(0×3001,TouchKey,1);
haddii (TouchKey[1]==0)
soo noqosho;
Xogta[1]=0;
bedel (TouchKey[1])
{
case1:// heestii hore
Sdata[0]=1;
DirDataToBT(Qor_Next_Pre_PT,Sdata,1);
jebin;
case2: // dib u ciyaarista hakad
Sdata[0]=2;
DirDataToBT(Qor_Next_Pre_PT,Sdata,1);
jebin;
case3:// Heesta Xigta
Sdata[0]=3;
DirDataToBT(Qor_Next_Pre_PT,Sdata,1);
jebin;
}
memset(TouchKey,0,sizeof(TouchKey));
write_dgusii_vp(0×3001,TouchKey,1);
ReadBtStatecount=0;
}
(2) Xirmada softiweerka Android waxa lagu qoray QT, inta badan garashada xidhiidhka Bluetooth iyo xakamaynta isgaadhsiinta ee shaashadda smart, qayb ka mid ah koodhka tixraaca waa sida soo socota:
ui->setupUi (tan);
bluetooth_ble_Tool=Bluetooth_ble_Tool cusub("dwin_bt(BLE)");
ui->label_localBT_Name->setText(bluetooth_ble_Tool->getLocalName());
ku xidh(bluetooth_ble_Tool,&Blueooth_ble_Tool::BlueSearchConnectState,
kan,&BLE_PairPage::BlueSearchConnectState);
//btchat=BtChat cusub();
//btchat->set_ble_Tool(bluetooth_ble_Tool);
//btchat->init_Bogga();
//btchat->qari();
DevicecommHandle= DeviceComm cusub();
DevicecommHandle->set_ble_Tool(bluetooth_ble_Tool);
DevicecommHandle-> InitDevice ();
mwin=mainwin cusub();
wax yar->qarin();
isku xidh (mwin,&mainwin:layChangeMode,
DevicecommHandle,&DeviceComm:layChangeMode);// Qor qaabka isbeddelka ayaa soo baxay
isku xidh (mwin,&mainwin:layCtrPreNextSt,
DevicecommHandle,&DeviceComm:layCtrPreNextSt);// shiday. qor qaybaha sare iyo hoose ee heesta
isku xidh (mwin,&mainwin:layMusicVolChange,
DevicecommHandle,&DeviceComm:layMusicVolChange);// Hoos u qor isbedelka mugga
ku xidh (qalabkacommHandle,&DeviceComm ::ReadPlayMode,
kan,[=](int mode){// Dejinta qaabka hadda
qDebug() qDebug()
mwin-> B_AUX-> setChecked (been);
mwin-> B_BT-> setChecked (been);
haddii (qaabka==1)
mwin-> B_Upan-> setChecked (run);
haddii kale (mode==2)
mwin-> B_AUX-> setChecked (run);
haddii kale (mode==3)
mwin-> B_BT-> setChecked (run);
}
ku xidh (qalabkacommHandle,&DeviceComm::ReadPlayMusicVol,
kan,[=](int vol){// Dejinta Bandhigga Mugga
mwin-> QS_MainVol-> setValue (vol);
}
ku xidh (qalabka bluetooth_ble_Tool,&Bluetooth_ble_Tool ::BLE_Link_error,
kan,[=](){
this-> show ();
wax yar->qarin();
DevicecommHandle->TimerStopReadDeviceST();
this-> ui->progressBar-> setValue (0);
}
madhan BLE_PairPage::ku_pushButton_guji(){
bluetooth_ble_Tool->SetOperUuidServer(QBluetoothUuid(adeegUuid));
// ui-> sumadda_localBT-> cad ();
//ui->label_localBT_Name->setText(bluetooth_ble_Tool->helLocalName());
bluetooth_ble_Tool->startFindConnectBle();
// bluetooth_ble_Tool->startStateprogressBar();
ui->pushButton->setEnabled(been);
ui->pushButton->setText("Raadinta");
ku xidh (bluetooth_ble_Tool,&Bluetooth_ble_Tool::BlueBLE_FindDevifinished,
kan,[=](bool ok){
ui->pushButton->setEnabled (run);
ui->pushButton-> setText ("Bilow ogaanshaha Bluetooth ku xiran");
haddii (ok== been) {
QMessageBox:: macluumaadka (this,tr("Sarch Status"),"Qalabka lama baari karo, fadlan hubi in qalabku mar hore shidmay,ama haddii taleefoon kale oo gacanta ah uu horay ugu xirnaa?");}}); }
madhan BLE_PairPage::BlueSearchConnectState(Bluetooth_ble_Tool::startStateprogressBar_em Linkst,int horumarka){
ui->progressBar->setValue (horumar);
haddi
QMessageBox :: macluumaadka (tan,tr ("isku xidhka degdegga"), bluetooth_ble_Tool-> getErrorinfo ());
ui->label_tips->setText(bluetooth_ble_Tool->getErrorinfo());}
Haddii kale (Linkst>= Qalabka Bluetooth_ble:Ble_Deconnect_device){
QMessageBox :: macluumaadka (tan,tr ("xidhiidhka degdega ah ")," buggy ");
ui->label_tips->setText("buggy");}
Haddii kale (Linkst==Bluetooth_ble_Tool:: Ble_Connect_characterOk){// QMessageBox:: macluumaad(
this,tr ("si guul leh ayaa ku xiran "), bluetooth_ble_Tool->getErrorinfo());
ui->label_tips->setText("si guul leh ugu xidhan");
kan->qari();
mwin-> show ();
DevicecommHandle->TimerStartReadDeviceST(100);
//btchat-> show ();
//kala saar(qalabka bluetooth_ble_Tool,&Blueooth_ble_Tool ::BlueSearchConnectState,
//kan,&BLE_PairPage::BlueSearchConnectState); }
kale{
ui->label_tips->setText("Raadinta isku xirka"); }
Waqtiga boostada: Meey-23-2024