-Kutoka Jukwaa la Wasanidi Programu wa DWIN
Suala hili kwako kusukuma kesi ya chanzo huria iliyoshinda tuzo ya jukwaa la wasanidi wa DWIN - skrini ya DWIN na simu ya Android ya njia mbili kudhibiti uchezaji wa muziki. Wahandisi kupitia moduli ya Bluetooth ili kufikia skrini ya akili ya DWIN na mwingiliano wa data ya simu ya Android, watumiaji wanaweza kudhibiti simu ya Android kwa urahisi, kiendeshi cha USB flash kwenye uchezaji wa wimbo, kusitisha, kubadilisha mipangilio ya wimbo na sauti, kutumia skrini yenye akili na simu ya Android mbili- njia rahisi ya udhibiti.
1.C51 Muundo
(1) Mlango wa ufuatiliaji wa T5L huingiliana na moduli ya Bluetooth ili kurekebisha hali ya kucheza tena, kuweka sauti na kusoma hali ya Bluetooth, sehemu ya msimbo wa rejeleo ni kama ifuatavyo:
int kuu (utupu)
{
INIT_CPU();
T2_Joto();
UART4_Init();
EA=1;
//UART4_SendStr(“hello”,sizeof(“hello”));
//WDT_ON();//Washa Mlinzi.
wakati(1)
{
//WDT_RST();// Miguu ya mbwa
Mchakato ();
}
}
batili UART4_Init(batili)
{
// Mpangilio wa kiwango cha UART4 Baud:
//BODE2_DIV_H=Marudio ya Mains ya CPU/(8*Kiwango cha 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 Kiwango cha Baud
//BODE2_DIV_H=0×00;
//FCLK/(8*DIV)
//BODE2_DIV_L=0×70;
//ES3T=1;
ES2R=1;
EA=1;
}
utupu TenMsHandle(batili)
{
if(!TenmsFlag)
kurudi;
TenmsFlag=0;
ChanzoPress();//Jenereta ya toni
PlayCtrPress();//Mabadiliko ya hali ya Playback
VolCtrSlider();// Mabadiliko ya kiasi
VolLogSlider();// Mabadiliko ya kiasi
ReadBtState();//Soma hali ya Bluetooth
}
utupu SourcePress(utupu)
{
charTouchKey[2]={0,0};
u8Sdata[2];
read_dgusii_vp(0×3000,TouchKey,1);
ikiwa(TouchKey[1]==0)
kurudi;
Data[1]=0;
swichi(TouchKey[1])
{
kesi1://U disk
Data[0]=1;
SendDataToBT(Write_Run_Mode,Sdata,1);
mapumziko;
case2:// Ingizo la Mstari wa Nje
Data[0]=2;
SendDataToBT(Write_Run_Mode,Sdata,1);
mapumziko;
kesi3://Bluetooth
Data[0]=3;
SendDataToBT(Write_Run_Mode,Sdata,1);
mapumziko;
}
andika_dgusii_vp(0×3003,TouchKey,1);
memset(TouchKey,0,sizeof(TouchKey));
andika_dgusii_vp(0×3000,TouchKey,1);
ReadBtStatecount=0;
}
PlayCtrPress batili(batili)
{
charTouchKey[2]={0,0};
u8Sdata[2];
read_dgusii_vp(0×3001,TouchKey,1);
ikiwa(TouchKey[1]==0)
kurudi;
Data[1]=0;
swichi(TouchKey[1])
{
kesi1:// Wimbo uliopita
Data[0]=1;
SendDataToBT(Write_Next_Pre_PT,Sdata,1);
mapumziko;
kesi2:// Sitisha Uchezaji
Data[0]=2;
SendDataToBT(Write_Next_Pre_PT,Sdata,1);
mapumziko;
kesi3:// Wimbo unaofuata
Data[0]=3;
SendDataToBT(Write_Next_Pre_PT,Sdata,1);
mapumziko;
}
memset(TouchKey,0,sizeof(TouchKey));
andika_dgusii_vp(0×3001,TouchKey,1);
ReadBtStatecount=0;
}
(2) Kifurushi cha programu ya Android kimeandikwa kupitia QT, hasa kwa kutambua muunganisho wa Bluetooth na udhibiti wa mawasiliano kwa skrini mahiri, sehemu ya msimbo wa marejeleo ni kama ifuatavyo:
ui->setupUi(hii);
bluetooth_ble_Tool=new Bluetooth_ble_Tool(“dwin_bt(BLE)”);
ui->label_localBT_Name->setText(bluetooth_ble_Tool->getLocalName());
unganisha(bluetooth_ble_Tool,&Bluetooth_ble_Tool::BlueSearchConnectState,
hii,&BLE_PairPage::BlueSearchConnectState);
//btchat=new BtChat();
//btchat->set_ble_Tool(bluetooth_ble_Tool);
//btchat->init_Page();
//btchat->ficha();
devicecommHandle=new DeviceComm();
devicecommHandle->set_ble_Tool(bluetooth_ble_Tool);
devicecommHandle->InitDevice();
mwin=mashindano mapya();
chini-> ficha ();
unganisha(mwin,&mainwin:layChangeMode,
devicecommHandle,&DeviceComm:layChangeMode);// Mabadiliko ya hali ya kuandika yametolewa
connect(mwin,&mainwin:layCtrPreNextSt,
devicecommHandle,&DeviceComm:layCtrPreNextSt);// lit. andika sehemu za juu na za chini za wimbo
unganisha(mwin,&mainwin:layMusicVolChange,
devicecommHandle,&DeviceComm:layMusicVolChange);// Andika mabadiliko ya sauti
unganisha(kifaacommHandle,&DeviceComm::SomaPlayMode,
hii,[=](int mode){// Kuweka hali ya sasa
qDebug() qDebug()
mwin->B_AUX->setChecked(false);
mwin->B_BT->setChecked(false);
ikiwa(modi==1)
mwin->B_Upan->setChecked(true);
vinginevyo ikiwa(modi==2)
mwin->B_AUX->setChecked(true);
vinginevyo ikiwa(modi==3)
mwin->B_BT->setChecked(kweli);
});
unganisha(kifaacommHandle,&DeviceComm::ReadPlayMusicVol,
hii,[=](int vol){// Kuweka Onyesho la Kiasi
mwin->QS_MainVol->setValue(vol);
});
unganisha(bluetooth_ble_Tool,&Bluetooth_ble_Tool::BLE_Link_kosa,
hii,[=](){
hii->onyesha();
chini-> ficha ();
devicecommHandle->TimerStopReadDeviceST();
this->ui->progressBar->setValue(0);
});
utupu BLE_PairPage::on_pushButton_clicked(){
bluetooth_ble_Tool->SetOperUuidServer(QBluetoothUuid(serviceUuid));
//ui->lebo_ya_localBT->wazi();
//ui->lebo_localBT_Name->setText(bluetooth_ble_Tool->getLocalName());
bluetooth_ble_Tool->startFindConnectBle();
//bluetooth_ble_Tool->startStateprogressBar();
ui->pushButton->setEnabled(false);
ui->pushButton->setText(“Inatafuta”);
unganisha(bluetooth_ble_Tool,&Bluetooth_ble_Tool::BlueBLE_FindDevice imekamilika,
hii,[=](bool sawa){
ui->pushButton->setEnabled(kweli);
ui-> pushButton-> setText(“Anza kugundua Bluetooth iliyounganishwa”);
ikiwa(sawa==uongo) {
QMessageBox::maelezo(hii,tr(“Hali ya Utafutaji “),” Kifaa hakiwezi kutafutwa, tafadhali angalia ikiwa kifaa tayari kimewashwa, au kama simu nyingine ya mkononi tayari imeunganishwa kwayo?”);} }); }
BLE_PairPage tupu::BlueSearchConnectState(Bluetooth_ble_Tool::startStateprogressBar_em Linkst, int progress){
ui->progressBar->setValue(progress);
if(Kiungo>=Bluetooth_ble_Tool::Ble_OtherError){
QMessageBox::maelezo(hii,tr("uhakika wa muunganisho "),bluetooth_ble_Tool->getErrorinfo());
ui->label_tips->setText(bluetooth_ble_Tool->getErrorinfo());}
vinginevyo if(Kiungo>=Bluetooth_ble_Tool::Ble_Deconnect_device){
QMessageBox::maelezo(hii,tr("uhakika wa muunganisho ")," buggy ");
ui->label_tips->setText(“buggy”);}
vinginevyo if(Linkst==Bluetooth_ble_Tool::Ble_Connect_characterOk){// QMessageBox::maelezo(
this,tr("imeunganishwa kwa mafanikio "),bluetooth_ble_Tool->getErrorinfo());
ui->label_tips->setText("imeunganishwa kwa mafanikio");
hii->ficha();
mwin->onyesha();
devicecommHandle->TimerStartReadDeviceST(100);
//btchat->onyesha();
//ondoa(bluetooth_ble_Tool,&Bluetooth_ble_Tool::BlueSearchConnectState,
//hii,&BLE_PairPage::BlueSearchConnectState); }
mwingine{
ui->label_tips->setText(“Kutafuta miunganisho”); }
Muda wa kutuma: Mei-23-2024