[Mã nguồn mở] Màn hình DWIN và Điện thoại Android Điều khiển liên kết hai chiều Phát lại nhạc

–Từ Diễn đàn nhà phát triển DWIN

Vấn đề này giúp bạn thúc đẩy trường hợp nguồn mở từng đoạt giải thưởng của diễn đàn nhà phát triển DWIN - Màn hình DWIN và điện thoại Android điều khiển liên kết hai chiều phát lại nhạc. Các kỹ sư thông qua mô-đun Bluetooth để đạt được màn hình thông minh DWIN và tương tác dữ liệu điện thoại Android, người dùng có thể dễ dàng điều khiển điện thoại Android, ổ flash USB trong khi phát bài hát, tạm dừng, thay đổi cài đặt bài hát và âm thanh, trải nghiệm màn hình thông minh và điện thoại Android hai- cách điều khiển thuận tiện.

Thiết kế 1.C51
(1) Cổng nối tiếp T5L tương tác với mô-đun Bluetooth để sửa đổi trạng thái phát lại, đặt âm lượng và đọc trạng thái Bluetooth, một phần của mã tham chiếu như sau:
int chính(void)
{
INIT_CPU();
T2_Heat();
UART4_Init();
EA=1;
//UART4_SendStr(“xin chào”, sizeof(“xin chào”));
//WDT_ON();//Bật Cơ quan giám sát.
trong khi(1)
{
//WDT_RST();//Chân chó
Quá trình();
}
}
khoảng trống UART4_Init(void)
{
// Cài đặt tốc độ truyền UART4:
//BODE2_DIV_H=Tần số nguồn điện của CPU/(8*Tốc độ truyền) .
//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 Tốc độ truyền
//BODE2_DIV_H=0×00;
//FCLK/(8*DIV)
//BODE2_DIV_L=0×70;
//ES3T=1;
ES2R=1;
EA=1;
}
void TenMsHandle(void)
{
if(! TenmsFlag)
trở lại;
TenmsFlag=0;
SourcePress();//Trình tạo giai điệu
PlayCtrPress();//Thay đổi trạng thái phát lại
VolCtrSlider();//Thay đổi âm lượng
VolLogSlider();//Thay đổi âm lượng
ReadBtState();//Đọc trạng thái Bluetooth
}
void SourcePress(void)
{
charTouchKey[2]={0,0};
u8Sdata[2];
read_dgusii_vp(0×3000,TouchKey,1);
if(TouchKey[1]==0)
trở lại;
Sdata[1]=0;
chuyển đổi(TouchKey[1])
{
case1://U đĩa
Sdata[0]=1;
SendDataToBT(Write_Run_Mode,Sdata,1);
phá vỡ;
case2:// Đầu vào LineIn bên ngoài
Sdata[0]=2;
SendDataToBT(Write_Run_Mode,Sdata,1);
phá vỡ;
trường hợp3://Bluetooth
Sdata[0]=3;
SendDataToBT(Write_Run_Mode,Sdata,1);
phá vỡ;
}
write_dgusii_vp(0×3003,TouchKey,1);
bộ nhớ(TouchKey,0,sizeof(TouchKey));
write_dgusii_vp(0×3000,TouchKey,1);
ReadBtStatecount=0;
}
vô hiệu PlayCtrPress(void)
{
charTouchKey[2]={0,0};
u8Sdata[2];
read_dgusii_vp(0×3001,TouchKey,1);
if(TouchKey[1]==0)
trở lại;
Sdata[1]=0;
chuyển đổi(TouchKey[1])
{
case1:// Bài hát trước đó
Sdata[0]=1;
SendDataToBT(Write_Next_Pre_PT,Sdata,1);
phá vỡ;
case2:// Tạm dừng phát lại
Sdata[0]=2;
SendDataToBT(Write_Next_Pre_PT,Sdata,1);
phá vỡ;
case3://Bài hát tiếp theo
Sdata[0]=3;
SendDataToBT(Write_Next_Pre_PT,Sdata,1);
phá vỡ;
}
bộ nhớ(TouchKey,0,sizeof(TouchKey));
write_dgusii_vp(0×3001,TouchKey,1);
ReadBtStatecount=0;
}

(2)Gói phần mềm Android được viết thông qua QT, chủ yếu thực hiện kết nối Bluetooth và điều khiển liên lạc bằng màn hình thông minh, một phần của mã tham chiếu như sau:
ui->setupUi(cái này);
bluetooth_ble_Tool=Bluetooth_ble_Tool mới(“dwin_bt(BLE)”);
ui->label_localBT_Name->setText(bluetooth_ble_Tool->getLocalName());
connect(bluetooth_ble_Tool,&Bluetooth_ble_Tool::BlueSearchConnectState,
cái này,&BLE_PairPage::BlueSearchConnectState);
//btchat=BtChat mới();
//btchat->set_ble_Tool(bluetooth_ble_Tool);
//btchat->init_Page();
//btchat->ẩn();
devicecommHandle=new DeviceComm();
devicecommHandle->set_ble_Tool(bluetooth_ble_Tool);
devicecommHandle->InitDevice();
mwin=new mainwin();
ít->ẩn();
connect(mwin,&mainwin:layChangeMode,
devicecommHandle,&DeviceComm:layChangeMode);// Đã ban hành thay đổi chế độ ghi
connect(mwin,&mainwin:layCtrPreNextSt,
devicecommHandle,&DeviceComm:layCtrPreNextSt);// lit. viết phần trên và phần dưới của bài hát
connect(mwin,&mainwin:layMusicVolChange,
devicecommHandle,&DeviceComm:layMusicVolChange);// Ghi giảm âm lượng
connect(devicecommHandle,&DeviceComm::ReadPlayMode,
this,[=](int mode){// Đặt chế độ hiện tại
qDebug() qDebug() B_Upan->setChecked(false);
mwin->B_AUX->setChecked(false);
mwin->B_BT->setChecked(false);
nếu(chế độ==1)
mwin->B_Upan->setChecked(true);
khác nếu (chế độ == 2)
mwin->B_AUX->setChecked(true);
khác nếu(chế độ==3)
mwin->B_BT->setChecked(true);
});
connect(devicecommHandle,&DeviceComm::ReadPlayMusicVol,
this,[=](int vol){// Cài đặt hiển thị âm lượng
mwin->QS_MainVol->setValue(vol);
});
kết nối(bluetooth_ble_Tool,&Bluetooth_ble_Tool::BLE_Link_error,
cái này,[=](){
cái này->hiển thị();
ít->ẩn();
devicecommHandle->TimerStopReadDeviceST();
cái này->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(“Đang tìm kiếm “);
connect(bluetooth_ble_Tool,&Bluetooth_ble_Tool::BlueBLE_FindDevice đã hoàn thành,
cái này,[=](bool được rồi){
ui->pushButton->setEnabled(true);
ui->pushButton->setText(“Bắt đầu phát hiện Bluetooth đã kết nối “);
nếu(ok==false) {
QMessageBox::information(this,tr(“Trạng thái tìm kiếm “),” Không thể tìm kiếm thiết bị, vui lòng kiểm tra xem thiết bị đã được bật hay chưa hoặc điện thoại di động khác đã được kết nối với thiết bị chưa?”);} }); }
void BLE_PairPage::BlueSearchConnectState(Bluetooth_ble_Tool::startStateprogressBar_em Linkst, int Progress){
ui->progressBar->setValue(tiến trình);
if(Linkst>=Bluetooth_ble_Tool::Ble_OtherError){
QMessageBox::information(this,tr(“nhắc nhở kết nối “),bluetooth_ble_Tool->getErrorinfo());
ui->label_tips->setText(bluetooth_ble_Tool->getErrorinfo());}
khác nếu(Linkst>=Bluetooth_ble_Tool::Ble_Deconnect_device){
QMessageBox::information(this,tr(“nhắc nhở kết nối “),” buggy “);
ui->label_tips->setText(“lỗi “);}
else if(Linkst==Bluetooth_ble_Tool::Ble_Connect_characterOk){// QMessageBox::information(
this,tr(“kết nối thành công “),bluetooth_ble_Tool->getErrorinfo());
ui->label_tips->setText(“kết nối thành công “);
cái này->ẩn();
mwin->show();
devicecommHandle->TimerStartReadDeviceST(100);
//btchat->show();
//ngắt kết nối(bluetooth_ble_Tool,&Bluetooth_ble_Tool::BlueSearchConnectState,
//this,&BLE_PairPage::BlueSearchConnectState); }
khác{
ui->label_tips->setText(“Tìm kiếm kết nối “); }


Thời gian đăng: 23-05-2024