【Open Source】 DWIN Ihuenyo na gam akporo ekwentị abụọ njikwa njikwa egwu egwu

–Site na ọgbakọ Mmepụta DWIN

Esemokwu a maka gị ịkwanye ikpe mepere emepe na-emeri nke ọma nke onye nrụpụta DWIN - ihuenyo DWIN na ekwentị gam akporo ekwentị abụọ njikwa egwu egwu. Ndị injinia site na modul Bluetooth iji nweta ihuenyo ọgụgụ isi DWIN na mmekọrịta data ekwentị gam akporo, ndị ọrụ nwere ike ijikwa ekwentị gam akporo, USB flash drive na egwu egwu, kwụsịtụ, gbanwee egwu na ntọala ụda, ihuenyo nwere ọgụgụ isi na ekwentị gam akporo abụọ- ụzọ adaba akara.

1.C51 Imebe
(1) Ọdụ ụgbọ mmiri T5L na-emekọrịta ihe na modul Bluetooth iji gbanwee ọkwa ngụgharị, tọọ olu, wee gụọ ọkwa Bluetooth, akụkụ nke koodu ntụaka bụ nke a:
int isi (ihe efu)
{
INIT_CPU();
T2_Okpomọkụ ();
UART4_Init ();
EA=1;
// UART4_SendStr ("ndewo", sizeof ("ndewo"));
//WDT_ON();//Gbanye ihe nche.
mgbe (1)
{
//WDT_RST();//Ụkwụ nkịta
Usoro ();
}
}
UART4_Init (ihe efu)
{
// UART4 Baud ntọala ntọala:
//BODE2_DIV_H=CPU Main ugboro/(8*ọnụego 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 Ọnụego Baud
//BODE2_DIV_H=0×00;
//FCLK/(8*DIV)
//BODE2_DIV_L=0×70;
//ES3T=1;
ES2R=1;
EA=1;
}
Ihe efu TenMsHandle(ihe efu)
{
ọ bụrụ (!TenmsFlag)
laghachi;
TenmsFlag=0;
SourcePress();//Tone generator
PlayCtrPress();//Mgbanwe steeti mkpọghachi
VolCtrSlider();// Mgbanwe olu
VolLogSlider();// Mgbanwe olu
ReadBtState();//Gụọ ọkwa Bluetooth
}
ihe efu SourcePress(ihe efu)
{
charTouchKey[2]={0,0};
u8Sdata[2];
read_dgusii_vp(0×3000,TouchKey,1);
ọ bụrụ (TouchKey[1]==0)
laghachi;
Sdata[1]=0;
mgba ọkụ (Mkpọtụ aka[1])
{
case1: // U disk
Sdata[0]=1;
SendDataToBT(Write_Run_Mode,Sdata,1);
agbaji;
case2:// Mpụga LineInput
Sdata[0]=2;
SendDataToBT(Write_Run_Mode,Sdata,1);
agbaji;
case3://Bluetooth
Sdata[0]=3;
SendDataToBT(Write_Run_Mode,Sdata,1);
agbaji;
}
write_dgusii_vp(0×3003,TouchKey,1);
memset (TouchKey,0, nha (TouchKey));
write_dgusii_vp(0×3000,TouchKey,1);
ReadBtStatecount=0;
}
ihe efu PlayCtrPress(ihe efu)
{
charTouchKey[2]={0,0};
u8Sdata[2];
read_dgusii_vp(0×3001,TouchKey,1);
ọ bụrụ (TouchKey[1]==0)
laghachi;
Sdata[1]=0;
mgba ọkụ (Mkpọtụ aka[1])
{
case1:// egwu gara aga
Sdata[0]=1;
SendDataToBT(Write_Next_Pre_PT,Sdata,1);
agbaji;
case2:// playback kwụsịtụ
Sdata[0]=2;
SendDataToBT(Write_Next_Pre_PT,Sdata,1);
agbaji;
case3:// egwu ozo
Sdata[0]=3;
SendDataToBT(Write_Next_Pre_PT,Sdata,1);
agbaji;
}
memset (TouchKey,0, nha (TouchKey));
write_dgusii_vp(0×3001,TouchKey,1);
ReadBtStatecount=0;
}

(2) Edere ngwungwu ngwanrọ gam akporo site na QT, ọkachasị na-achọpụta njikọ Bluetooth na njikwa nkwukọrịta na smart ihuenyo, akụkụ nke koodu ntụaka bụ nke a:
ui->setupUi (nke a);
bluetooth_ble_Tool = Bluetooth_ble_Tool ọhụrụ ("dwin_bt(BLE)");
ui->label_localBT_Name->setText(bluetooth_ble_Tool->getLocalAha());
jikọọ(bluetooth_ble_Tool,&Bluetooth_ble_Tool ::BlueSearchConnectState,
nke a,&BLE_PairPage ::BlueSearchConnectState);
//btchat=BtChat ọhụrụ();
//btchat->set_ble_Tool(bluetooth_ble_Tool);
//btchat->init_Page();
//btchat->zoo();
DevicecommHandle= DeviceComm ọhụrụ();
DevicecommHandle->set_ble_Tool(bluetooth_ble_Tool);
DevicecommHandle-> InitDevice ();
mwin= new mainwin();
obere->zoo();
jikọọ (mwin, & mainwin:layChangeMode,
DevicecommHandle,&DeviceComm:layChangeMode);// Enyere mgbanwe n'ụdị dee
jikọọ (mwin,& mainwin:layCtrPreNextSt,
devicecommHandle,&DeviceComm:layCtrPreNextSt);// lit. dee akụkụ elu na ala nke egwu
jikọọ (mwin, & mainwin:layMusicVolChange,
DevicecommHandle,&DeviceComm:layMusicVolChange);// Dee mgbanwe olu ala
jikọọ (ngwaọrụcommHandle,&DeviceComm ::ReadPlayMode,
nke a,[=](int mode){// Ịtọlite ​​ọnọdụ dị ugbu a
qDebug() qDebug() B_Upan-> setChecked(ụgha);
mwin-> B_AUX-> setChecked (ụgha);
mwin-> B_BT-> setChecked (ụgha);
ọ bụrụ (ụdị = 1)
mwin-> B_Upan-> setChecked (ezi);
Ọ bụrụ na (ụdị = 2)
mwin-> B_AUX-> setChecked (ezi);
Ọ bụrụ na (ụdị = 3)
mwin-> B_BT-> setChecked (ezi);
}
jikọọ (ngwaọrụcommHandle,&DeviceComm ::ReadPlayMusicVol,
nke a,[=](int vol){// Ịtọ ntọala ngosi olu
mwin-> QS_MainVol-> setValue (vol);
}
jikọọ (bluetooth_ble_Tool,&Bluetooth_ble_Tool ::BLE_Link_error,
nke a,[=](){
ihe a-> ngosi();
obere->zoo();
DevicecommHandle-> TimerStopReadDeviceST ();
nke a-> ui->progressBar-> setValue (0);
}
efu BLE_PairPage ::na_pushButton_clicked(){
bluetooth_ble_Tool->SetOperUuidServer(QBluetoothUuid(serviceUuid));
// ui-> label_localBT-> doro anya ();
//ui->label_localBT_Name->setText(bluetooth_ble_Tool->getLocalAha());
bluetooth_ble_Tool->startFindConnectBle();
// bluetooth_ble_Tool->startStateprogressBar();
ui->pushButton->setEnabled(ụgha);
ui->pushButton->setText("Searching");
jikọọ (bluetooth_ble_Tool,&Bluetooth_ble_Tool ::BlueBLE_FindDevifinished,
nke a,[=](bọo mma){
ui->pushButton->setEnabled(ezi);
ui->pushButton->setText("Malite ịchọpụta Bluetooth ejikọrọ");
ọ bụrụ (ọ dị mma = ụgha) {
QMessageBox:: ozi (nke a,tr ("Ọnọdụ ọchụchọ"), enweghị ike ịchọ ngwaọrụ ahụ, biko lelee ma agbanyerela ngwaọrụ ahụ, ma ọ bụ ma ọ bụrụ na ejikọrọ ekwentị ọzọ na ya? ");}}); }
efu BLE_PairPage::BlueSearchConnectState(Bluetooth_ble_Tool::startStateprogressBar_em Linkst, ọganihu int){
ui->progressBar->setValue (ọganihu);
ma ọ bụrụ (Linkst>=Bluetooth_ble_Tool ::Ble_OtherError){
QMessageBox :: ozi (nke a, tr ("njikọ ozugbo"), bluetooth_ble_Tool-> getErrorinfo ());
ui->label_tips->setText(bluetooth_ble_Tool->getErrorinfo());}
ọzọ ma ọ bụrụ (Linkst>=Bluetooth_ble_Tool :: Ble_Deconnect_device){
QMessageBox :: ozi (nke a, tr ("njikọ ozugbo ")," buggy ");
ui->label_tips->setText("buggy");}
ọzọ ma ọ bụrụ na (Linkst==Bluetooth_ble_Tool:: Ble_Connect_characterOk){// QMessageBox:: ozi(
nke a,tr ("jikọrọ nke ọma"), bluetooth_ble_Tool->getErrorinfo());
ui->label_tips->setText("jikọrọ nke ọma");
nke a->zoo();
mwin-> ihe ngosi ();
DevicecommHandle->TimerStartReadDeviceST(100);
//btchat-> ngosi();
// gbanyụọ (bluetooth_ble_Tool,&Blueooth_ble_Tool :: BlueSearchConnectState,
// nke a,&BLE_PairPage :: BlueSearchConnectState); }
ọzọ{
ui->label_tips->setText("Ịchọ njikọ"); }


Oge nzipu: Mee-23-2024