【Sumber Terbuka】 Layar DWIN lan Telpon Android Kontrol Linkage Kontrol Puter Musik

– Saka Forum Pangembang DWIN

Jeksa Agung bisa ngetokake iki kanggo sampeyan push kasus mbukak-menang penghargaan saka forum pangembang DWIN - layar DWIN lan telpon Android loro-arah linkage kontrol muter musik. Insinyur liwat modul Bluetooth kanggo entuk layar cerdas DWIN lan interaksi data telpon Android, pangguna bisa kanthi gampang ngontrol telpon Android, USB flash drive nalika muter lagu, ngaso, ngganti setelan lagu lan swara, ngalami layar cerdas lan telpon Android loro- cara kontrol trep.

1. C51 Desain
(1) Port serial T5L sesambungan karo modul Bluetooth kanggo ngowahi status puter maneh, nyetel volume, lan maca status Bluetooth, bagéan saka kode referensi minangka nderek:
int utama (void)
{
INIT_CPU();
T2_Kalor();
UART4_Init();
EA=1;
//UART4_SendStr("halo", sizeof("halo"));
//WDT_ON();//Aktifake Watchdog.
nalika (1)
{
//WDT_RST (); // Kaki asu
Proses ();
}
}
void UART4_Init(void)
{
// Setelan baud rate UART4:
//BODE2_DIV_H=Frekuensi Utama CPU/(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 Baud rate
//BODE2_DIV_H=0×00;
//FCLK/(8*DIV)
//BODE2_DIV_L=0×70;
//ES3T=1;
ES2R=1;
EA=1;
}
void TenMsHandle (void)
{
yen(!TenmsFlag)
bali;
TenmsFlag=0;
SourcePress();//Tone generator
PlayCtrPress (); // owah-owahan status Playback
VolCtrSlider();//Volume owah-owahan
VolLogSlider();//Volume owah-owahan
ReadBtState();//Waca status Bluetooth
}
void SourcePress (void)
{
charTouchKey[2]={0,0};
u8Sdata[2];
read_dgusii_vp(0×3000,TouchKey,1);
yen (TouchKey[1]==0)
bali;
Sdata[1]=0;
ngalih (TouchKey[1])
{
kasus1: // U disk
Sdata[0]=1;
SendDataToBT(Write_Run_Mode,Sdata,1);
putus;
case2: // External LineIn Input
Sdata[0]=2;
SendDataToBT(Write_Run_Mode,Sdata,1);
putus;
kasus3: // Bluetooth
Sdata[0]=3;
SendDataToBT(Write_Run_Mode,Sdata,1);
putus;
}
write_dgusii_vp(0×3003,TouchKey,1);
memset(TouchKey,0,sizeof(TouchKey));
write_dgusii_vp(0×3000,TouchKey,1);
ReadBtStatecount=0;
}
void PlayCtrPress(void)
{
charTouchKey[2]={0,0};
u8Sdata[2];
read_dgusii_vp(0×3001,TouchKey,1);
yen (TouchKey[1]==0)
bali;
Sdata[1]=0;
ngalih (TouchKey[1])
{
kasus1: // lagu sadurunge
Sdata[0]=1;
SendDataToBT(Write_Next_Pre_PT,Sdata,1);
putus;
kasus2: // Puter maneh Ngaso
Sdata[0]=2;
SendDataToBT(Write_Next_Pre_PT,Sdata,1);
putus;
kasus3: // Lagu sabanjure
Sdata[0]=3;
SendDataToBT(Write_Next_Pre_PT,Sdata,1);
putus;
}
memset(TouchKey,0,sizeof(TouchKey));
write_dgusii_vp(0×3001,TouchKey,1);
ReadBtStatecount=0;
}

(2)Paket piranti lunak Android ditulis liwat QT, utamane nyadari sambungan Bluetooth lan kontrol komunikasi karo layar cerdas, bagean saka kode referensi kaya ing ngisor iki:
ui->setupUi(iki);
bluetooth_ble_Tool=new Bluetooth_ble_Tool("dwin_bt(BLE)");
ui->label_localBT_Name->setText(bluetooth_ble_Tool->getLocalName());
connect(bluetooth_ble_Tool,&Bluetooth_ble_Tool::BlueSearchConnectState,
iki, & BLE_PairPage :: BlueSearchConnectState);
//btchat=new BtChat();
//btchat->set_ble_Tool(bluetooth_ble_Tool);
//btchat->init_Page();
//btchat->singidaken();
devicecommHandle=PerangkatComm anyar();
devicecommHandle->set_ble_Tool(bluetooth_ble_Tool);
devicecommHandle->InitDevice();
mwin=new mainwin();
kurang-> ndhelikake ();
nyambung(mwin,&mainwin:layChangeMode,
devicecommHandle,&DeviceComm:layChangeMode);// Tulis pangowahan mode ditanggepi
nyambung(mwin,&mainwin:layCtrPreNextSt,
devicecommHandle,&DeviceComm:layCtrPreNextSt);// lit. tulisen bagian ndhuwur lan ngisor tembang
nyambung(mwin,&mainwin:layMusicVolChange,
devicecommHandle,&DeviceComm:layMusicVolChange);// Tulis pangowahan volume mudhun
nyambung(devicecommHandle,&DeviceComm::ReadPlayMode,
iki,[=](mode int){// Nyetel mode saiki
qDebug() qDebug() B_Upan->setChecked(false);
mwin->B_AUX->setChecked(false);
mwin->B_BT->setChecked(palsu);
yen (mode == 1)
mwin->B_Upan->setChecked(true);
else if(mode==2)
mwin->B_AUX->setChecked(true);
else if(mode==3)
mwin->B_BT->setChecked(true);
});
nyambung(devicecommHandle,&DeviceComm::ReadPlayMusicVol,
iki,[=](int vol){// Nyetel Tampilan Volume
mwin->QS_MainVol->setValue(vol);
});
nyambung(bluetooth_ble_Tool,&Bluetooth_ble_Tool::BLE_Link_error,
iki, [=](){
iki -> nuduhake ();
kurang-> ndhelikake ();
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(false);
ui->PushButton->setText("Telusuri");
nyambung(bluetooth_ble_Tool,&Bluetooth_ble_Tool::BlueBLE_FindDevicefinished,
iki,[=](bool ok){
ui->PushButton->setEnabled(true);
ui->PushButton->setText("Mulai mendeteksi Bluetooth sing disambungake ");
yen (ok == salah) {
QMessageBox:: informasi(this,tr("Search Status"),"Piranti ora bisa digoleki, mangga dipriksa yen piranti wis diuripake, utawa yen ponsel liyane wis disambungake menyang?");}}); }
void BLE_PairPage::BlueSearchConnectState(Bluetooth_ble_Tool::startStateprogressBar_em Linkst, int progress){
ui->progressBar->setValue(progress);
if(Linkst>=Bluetooth_ble_Tool::Ble_OtherError){
QMessageBox :: informasi(this,tr("connection prompt"),bluetooth_ble_Tool->getErrorinfo());
ui->label_tips->setText(bluetooth_ble_Tool->getErrorinfo());}
else if(Linkst>=Bluetooth_ble_Tool::Ble_Deconnect_device){
QMessageBox::informasi(this,tr("sambungan prompt ")," buggy ");
ui->label_tips->setText("buggy");}
else if(Linkst==Bluetooth_ble_Tool::Ble_Connect_characterOk){// QMessageBox::information(
iki,tr("kasil nyambung"),bluetooth_ble_Tool->getErrorinfo());
ui->label_tips->setText("berhasil disambungkan");
iki -> ndhelikake ();
mwin->show();
devicecommHandle->TimerStartReadDeviceST(100);
//btchat->show();
//putus (bluetooth_ble_Tool,&Bluetooth_ble_Tool::BlueSearchConnectState,
//this,&BLE_PairPage ::BlueSearchConnectState); }
liyane{
ui->label_tips->setText("Telusuri koneksi "); }


Wektu kirim: Mei-23-2024