–Lati DWIN Apejọ Olùgbéejáde
Ọrọ yii fun ọ lati Titari ọran orisun-ìmọ ti o bori ti apejọ idagbasoke DWIN – iboju DWIN ati foonu Android ọna asopọ ọna asopọ meji ṣiṣiṣẹsẹhin orin. Awọn onimọ-ẹrọ nipasẹ module Bluetooth lati ṣaṣeyọri iboju oye DWIN ati ibaraenisepo data foonu Android, awọn olumulo le ni rọọrun ṣakoso foonu Android, kọnputa filasi USB ninu ere orin, da duro, yi orin ati awọn eto ohun pada, iboju ti oye ati foonu Android meji- ọna rọrun Iṣakoso.
1.C51 Oniru
(1) T5L ibudo ni tẹlentẹle pẹlu module Bluetooth lati yipada ipo ṣiṣiṣẹsẹhin, ṣeto iwọn didun, ati ka ipo Bluetooth, apakan ti koodu itọkasi jẹ bi atẹle:
int akọkọ(ofo)
{
INIT_CPU ();
T2_Heat ();
UART4_Init ();
EA=1;
// UART4_SendStr ("hello", iwọn ("hello"));
//WDT_ON();// Tan Oluṣọ.
nigba (1)
{
//WDT_RST();// Ẹsẹ aja
Ilana ();
}
}
ofo UART4_Init(ofo)
{
// Eto oṣuwọn Baud UART4:
//BODE2_DIV_H=CPU Mains igbohunsafẹfẹ/(8*oṣuwọn 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 Baud oṣuwọn
// BODE2_DIV_H = 0× 00;
//FCLK/(8*DIV)
//BODE2_DIV_L=0×70;
//ES3T=1;
ES2R=1;
EA=1;
}
ofo TenMsHandle(asan)
{
ti (!TenmsFlag)
pada;
TenmsFlag=0;
OrisunPress ();//Oluda ohun orin
PlayCtrPress ();// Iyipada ipo ṣiṣiṣẹsẹhin
VolCtrSlider ();// Iyipada iwọn didun
VolLogSlider ();// Iyipada didun
ReadBtState ();//Ka ipo Bluetooth
}
ofo SourcePress(ofo)
{
charTouchKey[2]={0,0};
u8Sdata[2];
read_dgusii_vp (0× 3000, TouchKey,1);
ti o ba jẹ (Kọtini ifọwọkan [1]==0)
pada;
Sdata[1]=0;
yipada (Kọtini ifọwọkan[1])
{
case1: // U disk
Sdata[0]=1;
FiranṣẹDataToBT (Write_Run_Mode, Sdata, 1);
fọ;
case2: // Ita LineIn Input
Sdata[0]=2;
FiranṣẹDataToBT (Write_Run_Mode, Sdata, 1);
fọ;
case3://Bluetooth
Sdata[0]=3;
FiranṣẹDataToBT (Write_Run_Mode, Sdata, 1);
fọ;
}
write_dgusii_vp (0× 3003, TouchKey,1);
memset (TouchKey,0, iwọn (TouchKey));
write_dgusii_vp (0× 3000, TouchKey,1);
ReadBtStatecount=0;
}
ofo PlayCtrPress(asan)
{
charTouchKey[2]={0,0};
u8Sdata[2];
read_dgusii_vp (0× 3001, TouchKey,1);
ti o ba jẹ (Kọtini ifọwọkan [1]==0)
pada;
Sdata[1]=0;
yipada (Kọtini ifọwọkan[1])
{
case1: // ti tẹlẹ orin
Sdata[0]=1;
SendDataToBT(Kọ_Next_Pre_PT,Sdata,1);
fọ;
case2: // Sisisẹsẹhin Sinmi
Sdata[0]=2;
SendDataToBT(Kọ_Next_Pre_PT,Sdata,1);
fọ;
case3: // Next song
Sdata[0]=3;
SendDataToBT(Kọ_Next_Pre_PT,Sdata,1);
fọ;
}
memset (TouchKey,0, iwọn (TouchKey));
write_dgusii_vp(0×3001,TouchKey,1);
ReadBtStatecount=0;
}
(2) Ohun elo sọfitiwia Android ti kọ nipasẹ QT, ni pataki mimọ asopọ Bluetooth ati iṣakoso ibaraẹnisọrọ pẹlu iboju smati, apakan ti koodu itọkasi jẹ bi atẹle:
ui->setupUi (eyi);
bluetooth_ble_Tool=Bluetooth_ble_Tool tuntun("dwin_bt(BLE)");
ui->label_localBT_Name->setText(bluetooth_ble_Tool->getLocalName());
so (bluetooth_ble_Tool,&Bluetooth_ble_Tool :: BlueSearchConnectState,
yi, & BLE_PairPage :: BlueSearchConnectState);
//btchat=tuntun BtChat();
//btchat->set_ble_Tool (bluetooth_ble_Tool);
//btchat->init_Page ();
//btchat-> tọju ();
devicecommHandle= DeviceComm tuntun();
DevicecommHandle->set_ble_Tool (bluetooth_ble_Tool);
DevicecommHandle-> InitDevice ();
mwin = titun mainwin ();
less-> tọju ();
so (mwin, & mainwin: layChangeMode,
DevicecommHandle,&DeviceComm:layChangeMode);// Kọ iyipada ipo ti a gbejade
so (mwin, & mainwin:layCtrPreNextSt,
DevicecommHandle,&DeviceComm:layCtrPreNextSt);// tan. kọ awọn apa oke ati isalẹ ti orin kan
so (mwin, & mainwin:layMusicVolChange,
DevicecommHandle,&DeviceComm:layMusicVolChange);// Kọ iyipada iwọn didun si isalẹ
so (devicecommHandle,&DeviceComm :: ReadPlayMode,
yii,[=](ipo int){// Ṣiṣeto ipo lọwọlọwọ
qDebug() qDebug()
mwin-> B_AUX-> setChecked (èké);
mwin-> B_BT-> setChecked (èké);
ti o ba jẹ (ipo==1)
mwin-> B_Upan-> setChecked (otitọ);
miiran ti o ba jẹ (ipo==2)
mwin-> B_AUX-> setChecked (otitọ);
miiran ti o ba jẹ (ipo==3)
mwin-> B_BT-> setChecked (otitọ);
});
so (devicecommHandle,&DeviceComm :: ReadPlayMusicVol,
eyi,[=](int vol){// Ṣiṣeto Ifihan Iwọn didun naa
mwin-> QS_MainVol-> setValue (vol);
});
so (bluetooth_ble_Tool,&Bluetooth_ble_Tool :: BLE_Link_error,
yii,[=](){
eyi-> show ();
less-> tọju ();
DevicecommHandle-> TimerStopReadDeviceST ();
yi-> ui->progressBar-> setValue (0);
});
ofo BLE_PairPage:: lori_pushButton_clicked(){
bluetooth_ble_Tool-> SetOperUuidServer (QBluetoothUuid (serviceUuid));
// ui-> label_localBT-> ko ();
// ui->label_localBT_Name->setText (bluetooth_ble_Tool->getLocalName ());
bluetooth_ble_Tool-> startFindConnectBle ();
// bluetooth_ble_Tool->startStateprogressBar ();
ui-> pushButton->setEnabled (eke);
ui->pushButton->setText ("Ṣawari");
so (bluetooth_ble_Tool,&Bluetooth_ble_Tool :: BlueBLE_FindDevicefinished,
eyi,[=](bool ok){
ui-> pushButton->setEnabled (otitọ);
ui->pushButton->setText("Bẹrẹ wiwa Bluetooth ti a ti sopọ");
ti (ok== iro) {
QMessageBox :: alaye (eyi,tr ("Ipo Wa"),"Ẹrọ naa ko le wa, jọwọ ṣayẹwo boya ẹrọ naa ti wa ni titan, tabi ti foonu miiran ba ti sopọ mọ?");}}); }
ofo BLE_PairPage::BlueSearchConnectState(Bluetooth_ble_Tool::startStateprogressBar_em Linkst, int itesiwaju){
ui->progressBar-> setValue (ilọsiwaju);
if(Linkst>=Bluetooth_ble_Tool::Ble_OtherError){
QMessageBox :: alaye (yi, tr ("Asopọmọra tọ"), bluetooth_ble_Tool-> getErrorinfo ());
ui->label_tips->setText(bluetooth_ble_Tool->getErrorinfo());}
miiran ti (Linkst>=Bluetooth_ble_Tool::Ble_Deconnect_device){
QMessageBox :: alaye (yi, tr ("asopọ tọ "),"buggy ");
ui->label_tips->setText("buggy");}
miran ti o ba ti (Linkst==Bluetooth_ble_Tool :: Ble_Connect_characterOk) {// QMessageBox :: alaye (
yi,tr ("aṣeyọri ti sopọ"), bluetooth_ble_Tool->getErrorinfo ());
ui->label_tips->setText ("ti sopọ mọ aṣeyọri");
eyi-> tọju ();
mwin-> show ();
DevicecommHandle-> TimeStartReadDeviceST (100);
//btchat-> show ();
// ge asopọ (bluetooth_ble_Tool,&Bluetooth_ble_Tool :: BlueSearchConnectState,
// eyi, & BLE_PairPage :: BlueSearchConnectState); }
omiran{
ui->label_tips->setText("Wiwa awọn asopọ"); }
Akoko ifiweranṣẹ: Oṣu Karun-23-2024