-Ji Foruma Pêşdebir a DWIN
Ev mijar ji bo we ye ku hûn doza çavkaniya vekirî ya xelatgirtî ya foruma pêşdebiran a DWIN - ekrana DWIN û têlefona Android-ê ya girêdana du-alî veguheztina muzîkê kontrol bikin. Endezyarên bi modula Bluetooth-ê ve ji bo ku bigihîjin danûstendina daneya têlefonê ya aqilmend DWIN û têlefonê Android-ê, bikarhêner dikarin bi hêsanî têlefonê Android-ê, ajokera flash USB-yê di lîstika stranê de kontrol bikin, rawestînin, mîhengên stran û deng biguhezînin, dîmendera hişmend û têlefona Android-ê du-du biceribînin. awayê kontrolkirina hêsan.
1.C51 Design
(1) Porta serial T5L bi modula Bluetooth-ê re têkildar e da ku statûya lîstikê biguhezîne, dengdanê saz bike û statûya Bluetooth-ê bixwîne, beşek koda referansê wiha ye:
int sereke (vala)
{
INIT_CPU();
T2_Heat();
UART4_Init();
EA=1;
//UART4_SendStr("silav",sizeof("silav"));
//WDT_ON();// Çavdêriyê veke.
dema (1)
{
//WDT_RST();//Lingên kûçikê
Doz();
}
}
betal UART4_Destpêk(betal)
{
// Sazkirina rêjeya UART4 Baud:
//BODE2_DIV_H= Frekansa sereke ya CPU/(8* Rêjeya 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 Rêjeya Baud
//BODE2_DIV_H=0×00;
//FCLK/(8*DIV)
//BODE2_DIV_L=0×70;
//ES3T=1;
ES2R=1;
EA=1;
}
void TenMsHandle(vala)
{
eger(!TenmsFlag)
vegerr;
TenmsFlag=0;
SourcePress ();// Afirînerê tone
PlayCtrPress();//Guhertina rewşa lêdanê
VolCtrSlider();// Guhertina deng
VolLogSlider();// Guhertina cildê
ReadBtState ();// Rewşa Bluetooth-ê bixwînin
}
void ÇavkanîPress(betal)
{
charTouchKey[2]={0,0};
u8Sdata[2];
read_dgusii_vp(0×3000,TouchKey,1);
eger(TouchKey[1]==0)
vegerr;
Sdata[1]=0;
guhêrbar (TouchKey[1])
{
case1: // U dîskê
Sdata[0]=1;
SendDataToBT(Write_Run_Mode,Sdata,1);
rawesta;
case2: // Têketina LineIn Derveyî
Sdata[0]=2;
SendDataToBT(Write_Run_Mode,Sdata,1);
rawesta;
doza3: // Bluetooth
Sdata[0]=3;
SendDataToBT(Write_Run_Mode,Sdata,1);
rawesta;
}
write_dgusii_vp(0×3003,TouchKey,1);
memset(TouchKey,0,sizeof(TouchKey));
write_dgusii_vp(0×3000,TouchKey,1);
ReadBtStatecount=0;
}
betal PlayCtrPress(betal)
{
charTouchKey[2]={0,0};
u8Sdata[2];
read_dgusii_vp(0×3001,TouchKey,1);
eger(TouchKey[1]==0)
vegerr;
Sdata[1]=0;
guhêrbar (TouchKey[1])
{
case1:// Strana berê
Sdata[0]=1;
SendDataToBT(Write_Next_Pre_PT,Sdata,1);
rawesta;
case2:// Pause Playback
Sdata[0]=2;
SendDataToBT(Write_Next_Pre_PT,Sdata,1);
rawesta;
case3:// Stranek din
Sdata[0]=3;
SendDataToBT(Write_Next_Pre_PT,Sdata,1);
rawesta;
}
memset(TouchKey,0,sizeof(TouchKey));
write_dgusii_vp(0×3001,TouchKey,1);
ReadBtStatecount=0;
}
(2) Pakêta nermalava Android-ê bi navgîniya QT-ê ve hatî nivîsandin, bi giranî têgihîştina girêdana Bluetooth û kontrolkirina ragihandinê bi ekrana hişmend re, beşek koda referansê wiha ye:
ui->setupUi(this);
bluetooth_ble_Tool=Amûra Bluetooth_ble_nû("dwin_bt(BLE)");
ui->label_localBT_Name->setText(bluetooth_ble_Tool->getLocalName());
connect(Bluetooth_ble_Tool,&Bluetooth_ble_Tool::BlueSearchConnectState,
ev,&BLE_PairPage::BlueSearchConnectState);
//btchat=BtChat nû();
//btchat->set_ble_Tool(bluetooth_ble_Tool);
//btchat->init_Page();
//btchat->veşêre();
devicecommHandle=new DeviceComm();
devicecommHandle->set_ble_Tool(bluetooth_ble_Tool);
devicecommHandle->InitDevice();
mwin=new mainwin();
kêmtir-> veşêre();
girêdan(mwin,&mainwin:layChangeMode,
devicecommHandle,&DeviceComm:layChangeMode);// Guherîna moda nivîsandinê derket
girêdan(mwin,&mainwin:layCtrPreNextSt,
devicecommHandle,&DeviceComm:layCtrPreNextSt);// ronahî. beşên jorîn û jêr ên stranekê binivîsin
girêdan(mwin,&mainwin:layMusicVolChange,
devicecommHandle,&DeviceComm:layMusicVolChange);// Guhertina dengan binivîsîne
connect(devicecommHandle,&DeviceComm::ReadPlayMode,
ev,[=](moda int){// Sazkirina moda heyî
qDebug() qDebug()
mwin->B_AUX->setChecked(derew);
mwin->B_BT->setChecked(false);
heke (mod==1)
mwin->B_Upan->setChecked(true);
din eger (mod==2)
mwin->B_AUX->setChecked(true);
din eger (mod==3)
mwin->B_BT->setChecked(true);
});
connect(devicecommHandle,&DeviceComm::ReadPlayMusicVol,
ev,[=](int vol){// Sazkirina Nîşandana Volume
mwin->QS_MainVol->setValue(vol);
});
girêdan(bluetooth_ble_Tool,&Bluetooth_ble_Tool::BLE_Link_error,
ev,[=](){
this-> show();
kêmtir-> veşêre();
devicecommHandle->TimerStopReadDeviceST();
this->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(derew);
ui->pushButton->setText("Lêgerîn");
connect(Bluetooth_ble_Tool,&Bluetooth_ble_Tool::BlueBLE_FindDevicefinished,
ev,[=](bool ok){
ui->pushButton->setEnabled(true);
ui->pushButton->setText("Destpêkkirina Bluetooth-ya girêdayî");
eger(ok==derew) {
QMessageBox::information(this,tr("Rewşa Lêgerînê"),"Alav nayê gerîn, ji kerema xwe kontrol bikin ka cîhaz jixwe vekiriye, an têlefonek din a desta jixwe pê ve girêdayî ye?");} }); }
void BLE_PairPage::BlueSearchConnectState(Bluetooth_ble_Tool::startStateprogressBar_em Girêdan, pêşveçûn){
ui->progressBar->setValue(pêşveçûn);
if(Linkst>=Bluetooth_ble_Tool::Ble_OtherError){
QMessageBox:: agahî (ev, tr("lêgerîna girêdanê"), bluetooth_ble_Tool->getErrorinfo());
ui-> label_tips->setText(bluetooth_ble_Tool->getErrorinfo());}
else if(Linkst>=Bluetooth_ble_Tool::Ble_Deconnect_device){
QMessageBox:: agahdarî (ev, tr ("lêgerîna pêwendiyê ")," buggy ");
ui-> label_tips-> setText("buggy");}
else if(Linkst==Bluetooth_ble_Tool::Ble_Connect_characterOk){// QMessageBox::information(
this,tr("bi serkeftin hat girêdan"),bluetooth_ble_Tool->getErrorinfo());
ui->label_tips->setText("bi serketî hat girêdan");
this->hide();
mwin-> show();
devicecommHandle->TimerStartReadDeviceST(100);
//btchat-> nîşan bide();
//disconnect(bluetooth_ble_Tool,&Bluetooth_ble_Tool::BlueSearchConnectState,
//ev,&BLE_PairPage::BlueSearchConnectState); }
wekîdi{
ui->label_tips->setText("Li peywendiyan digere"); }
Dema şandinê: Gulan-23-2024