【Sous Louvri】 DWIN ekran ak telefòn Android de-fason Linkage Kontwòl Lektur Mizik

-Soti nan DWIN Developer Forum

Pwoblèm sa a pou ou pouse ka a sous ouvè-genyen prim nan fowòm pwomotè DWIN - ekran DWIN ak telefòn android de-fason lyen kontwòl mizik lèktur. Enjenyè atravè modil Bluetooth la pou reyalize ekran entèlijan DWIN ak entèraksyon done telefòn android, itilizatè yo ka fasilman kontwole telefòn android, kondwi flash USB nan jwe chante a, pran yon poz, chanje paramèt son ak chante, fè eksperyans ekran entèlijan ak telefòn android de-. fason pratik kontwòl.

1.C51 Design
(1) Pò seri T5L la reyaji ak modil Bluetooth la pou modifye estati lèktur, mete volim, epi li estati Bluetooth, yon pati nan kòd referans la se jan sa a:
int prensipal (anile)
{
INIT_CPU();
T2_Chalè();
UART4_Init();
EA=1;
//UART4_SendStr ("alo", sizeof ("alo");
//WDT_ON();//Limen Watchdog la.
pandan (1)
{
//WDT_RST();//Pye chen an
Pwosesis();
}
}
anile UART4_Init(anile)
{
// Anviwònman vitès baud UART4:
//BODE2_DIV_H=CPU Frekans prensipal/(8*Baud vitès) .
//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 vitès Baud
//BODE2_DIV_H=0×00;
//FCLK/(8*DIV)
//BODE2_DIV_L=0×70;
//ES3T=1;
ES2R=1;
EA=1;
}
anile TenMsHandle (anile)
{
si(!TenmsFlag)
retounen;
TenmsFlag=0;
SourcePress();//Tone dèlko
PlayCtrPress();//Lektur chanjman eta
VolCtrSlider ();// Chanjman volim
VolLogSlider ();// Chanjman volim
ReadBtState();//Li estati Bluetooth
}
anile SourcePress(anile)
{
charTouchKey[2]={0,0};
u8Sdata[2];
read_dgusii_vp(0×3000,TouchKey,1);
si(TouchKey[1]==0)
retounen;
Sdata[1]=0;
switch(TouchKey[1])
{
case1://U disk
Sdata[0]=1;
SendDataToBT(Write_Run_Mode,Sdata,1);
kraze;
case2:// External LineIn Antre
Sdata[0]=2;
SendDataToBT(Write_Run_Mode,Sdata,1);
kraze;
case3://Bluetooth
Sdata[0]=3;
SendDataToBT(Write_Run_Mode,Sdata,1);
kraze;
}
write_dgusii_vp(0×3003,TouchKey,1);
memset(TouchKey,0,sizeof(TouchKey));
write_dgusii_vp(0×3000,TouchKey,1);
ReadBtStatecount=0;
}
anile PlayCtrPress(anile)
{
charTouchKey[2]={0,0};
u8Sdata[2];
read_dgusii_vp(0×3001,TouchKey,1);
si(TouchKey[1]==0)
retounen;
Sdata[1]=0;
switch(TouchKey[1])
{
case1:// Chante anvan
Sdata[0]=1;
SendDataToBT(Write_Next_Pre_PT,Sdata,1);
kraze;
case2:// Lekti yon poz
Sdata[0]=2;
SendDataToBT(Write_Next_Pre_PT,Sdata,1);
kraze;
case3:// Next chante
Sdata[0]=3;
SendDataToBT(Write_Next_Pre_PT,Sdata,1);
kraze;
}
memset(TouchKey,0,sizeof(TouchKey));
write_dgusii_vp(0×3001,TouchKey,1);
ReadBtStatecount=0;
}

(2)Pake lojisyèl Android ekri nan QT, sitou reyalize koneksyon Bluetooth ak kontwòl kominikasyon ak ekran entelijan an, yon pati nan kòd referans la se jan sa a:
ui->setupUi(sa);
bluetooth_ble_Tool = nouvo Bluetooth_ble_Tool ("dwin_bt (BLE)");
ui->label_localBT_Name->setText(bluetooth_ble_Tool->getLocalName());
konekte(Bluetooth_ble_Tool,&Bluetooth_ble_Tool::BlueSearchConnectState,
sa a,&BLE_PairPage::BlueSearchConnectState);
//btchat=nouvo BtChat();
//btchat->set_ble_Tool(bluetooth_ble_Tool);
//btchat->init_Page();
//btchat-> kache();
devicecommHandle=nouvo DeviceComm();
devicecommHandle->set_ble_Tool(bluetooth_ble_Tool);
devicecommHandle->InitDevice();
mwin=nouvo mainwin();
mwens-> kache();
konekte(mwin,&mainwin:layChangeMode,
devicecommHandle,&DeviceComm:layChangeMode);// Chanjman nan mòd ekri
konekte(mwin,&mainwin:layCtrPreNextSt,
devicecommHandle,&DeviceComm:layCtrPreNextSt);// limen. ekri pati anwo ak anba yon chante
konekte(mwin,&mainwin:layMusicVolChange,
devicecommHandle,&DeviceComm:layMusicVolChange);// Ekri chanjman volim desann
konekte(devicecommHandle,&DeviceComm::ReadPlayMode,
sa a,[=](int mode){// Mete mòd aktyèl la
qDebug() qDebug() B_Upan->setChecked(fo);
mwin->B_AUX->setChecked(fo);
mwin->B_BT->setChecked(fo);
si(mòd==1)
mwin->B_Upan->setChecked(vre);
lòt moun si (mòd==2)
mwin->B_AUX->setChecked(vre);
lòt moun si (mòd==3)
mwin->B_BT->setChecked(vre);
});
konekte(devicecommHandle,&DeviceComm::ReadPlayMusicVol,
sa a,[=](int vol){// Mete ekspozisyon volim
mwin->QS_MainVol->setValue(vol);
});
konekte(Bluetooth_ble_Tool,&Bluetooth_ble_Tool::BLE_Link_error,
sa a,[=](){
sa a->montre();
mwens-> kache();
devicecommHandle->TimerStopReadDeviceST();
sa a->ui->progressBar->setValue(0);
});
void BLE_PairPage::on_pushButton_clicked(){
bluetooth_ble_Tool->SetOperUuidServer(QBluetoothUuid(serviceUuid));
//ui->label_localBT->clear();
//ui->label_localBT_Name->setText(bluetooth_ble_Tool->getLocalName());
bluetooth_ble_Tool->startFindConnectBle();
//bluetooth_ble_Tool->startStateprogressBar();
ui-> pushButton-> setEnabled (fo);
ui->pushButton->setText(“Rechèch”);
konekte(Bluetooth_ble_Tool,&Bluetooth_ble_Tool::BlueBLE_FindDevicefinished,
sa a,[=](bool ok){
ui-> pushButton-> setEnabled (vre);
ui->pushButton->setText ("Kòmanse detekte Bluetooth konekte ");
si(ok==fo) {
QMessageBox::information(this,tr(“Search Status”),” Aparèy la pa ka fouye, tanpri tcheke si aparèy la deja limen, oswa si yon lòt telefòn selilè deja konekte ak li?”);} }); }
void BLE_PairPage::BlueSearchConnectState(Bluetooth_ble_Tool::startStateprogressBar_em Linkst, int pwogrè){
ui->progressBar->setValue(pwogrè);
if(Linkst>=Bluetooth_ble_Tool::Ble_OtherError){
QMessageBox::information(sa,tr("koneksyon èd memwa"),bluetooth_ble_Tool->getErrorinfo());
ui->label_tips->setText(bluetooth_ble_Tool->getErrorinfo());}
else if(Linkst>=Bluetooth_ble_Tool::Ble_Deconnect_device){
QMessageBox::information(sa,tr("koneksyon èd memwa"),"buggy ");
ui->label_tips->setText(“buggy”);}
else if(Linkst==Bluetooth_ble_Tool::Ble_Connect_characterOk){// QMessageBox::information(
sa a,tr ("konekte avèk siksè "), bluetooth_ble_Tool->getErrorinfo ());
ui->label_tips->setText ("konekte avèk siksè ");
sa a-> kache();
mwin->montre();
devicecommHandle->TimerStartReadDeviceST(100);
//btchat->montre ();
//dekonekte(Bluetooth_ble_Tool,&Bluetooth_ble_Tool::BlueSearchConnectState,
//sa,&BLE_PairPage::BlueSearchConnectState); }
lòt bagay{
ui->label_tips->setText ("Rechèch koneksyon "); }


Lè poste: Me-23-2024