【オープンソース】DWIN画面とAndroidフォンの双方向連携制御音楽再生

–DWIN 開発者フォーラムより

この問題は、DWIN 開発者フォーラムの受賞歴のあるオープンソース ケース、つまり DWIN 画面と Android 携帯電話の双方向連携制御音楽再生をプッシュするためのものです。 Bluetooth モジュールを介して DWIN インテリジェント画面と Android 携帯電話データの相互作用を実現することで、ユーザーは Android 携帯電話、USB フラッシュ ドライブの曲の再生、一時停止、曲とサウンドの設定の変更を簡単に制御でき、インテリジェント画面と Android 携帯電話の 2 つの操作を体験できます。とても便利なコントロール。

1.C51のデザイン
(1) T5L シリアル ポートは Bluetooth モジュールと通信して、再生ステータスを変更し、音量を設定し、Bluetooth ステータスを読み取ります。参照コードの一部は次のとおりです。
int main(void)
{
INIT_CPU();
T2_Heat();
UART4_Init();
EA=1;
//UART4_SendStr(“hello”,sizeof(“hello”));
//WDT_ON();//ウォッチドッグをオンにします。
その間(1)
{
//WDT_RST();//犬の足を踏む
プロセス();
}
}
void UART4_Init(void)
{
// UART4 ボーレート設定:
//BODE2_DIV_H=CPU 電源周波数/(8*ボーレート) 。
//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 ボーレート
//BODE2_DIV_H=0×00;
//FCLK/(8*DIV)
//BODE2_DIV_L=0×70;
//ES3T=1;
ES2R=1;
EA=1;
}
void TenMsHandle(void)
{
if(!TenmsFlag)
戻る;
TenmsFlag=0;
SourcePress();//トーンジェネレーター
PlayCtrPress();//再生状態の変更
VolCtrSlider();//音量変更
VolLogSlider();//音量変更
ReadBtState();//Bluetooth ステータスを読み取ります
}
void ソースプレス(void)
{
charTouchKey[2]={0,0};
u8Sdata[2];
read_dgusii_vp(0×3000,タッチキー,1);
if(タッチキー[1]==0)
戻る;
Sdata[1]=0;
スイッチ(タッチキー[1])
{
case1://Uディスク
Sdata[0]=1;
SendDataToBT(Write_Run_Mode,Sdata,1);
壊す;
case2:// 外部 LineIn 入力
Sdata[0]=2;
SendDataToBT(Write_Run_Mode,Sdata,1);
壊す;
case3://Bluetooth
Sdata[0]=3;
SendDataToBT(Write_Run_Mode,Sdata,1);
壊す;
}
write_dgusii_vp(0×3003,タッチキー,1);
memset(TouchKey,0,sizeof(TouchKey));
write_dgusii_vp(0×3000,タッチキー,1);
ReadBtStatecount=0;
}
void PlayCtrPress(void)
{
charTouchKey[2]={0,0};
u8Sdata[2];
read_dgusii_vp(0×3001,タッチキー,1);
if(タッチキー[1]==0)
戻る;
Sdata[1]=0;
スイッチ(タッチキー[1])
{
case1:// 前の曲
Sdata[0]=1;
SendDataToBT(Write_Next_Pre_PT,Sdata,1);
壊す;
case2:// 再生一時停止
Sdata[0]=2;
SendDataToBT(Write_Next_Pre_PT,Sdata,1);
壊す;
case3:// 次の曲
Sdata[0]=3;
SendDataToBT(Write_Next_Pre_PT,Sdata,1);
壊す;
}
memset(TouchKey,0,sizeof(TouchKey));
write_dgusii_vp(0×3001,タッチキー,1);
ReadBtStatecount=0;
}

(2)Android ソフトウェア パッケージは QT を通じて記述され、主に Bluetooth 接続とスマート スクリーンとの通信制御を実現します。参照コードの一部は次のとおりです。
ui->setupUi(this);
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,
これ、&BLE_PairPage::BlueSearchConnectState);
//btchat=新しいBtChat();
//btchat->set_ble_Tool(bluetooth_ble_Tool);
//btchat->init_Page();
//btchat->hide();
devicecommHandle=新しい DeviceComm();
devicecommHandle->set_ble_Tool(bluetooth_ble_Tool);
devicecommHandle->InitDevice();
mwin=新しいmainwin();
少ない->非表示();
connect(mwin,&mainwin:layChangeMode,
devicecommHandle,&DeviceComm:layChangeMode);// 書き込みモードの変更が発行されました
connect(mwin,&mainwin:layCtrPreNextSt,
devicecommHandle,&DeviceComm:layCtrPreNextSt);// 点灯。 曲の上部と下部を書き留める
connect(mwin,&mainwin:layMusicVolChange,
devicecommHandle,&DeviceComm:layMusicVolChange);// 音量変更を書き留めます
connect(devicecommHandle,&DeviceComm::ReadPlayMode,
this,[=](int mode){// 現在のモードの設定
qDebug() qDebug() B_Upan->setChecked(false);
mwin->B_AUX->setChecked(false);
mwin->B_BT->setChecked(false);
if(モード==1)
mwin->B_Upan->setChecked(true);
else if(mode==2)
mwin->B_AUX->setChecked(true);
else if(mode==3)
mwin->B_BT->setChecked(true);
});
connect(devicecommHandle,&DeviceComm::ReadPlayMusicVol,
this,[=](int vol){// 音量表示の設定
mwin->QS_MainVol->setValue(vol);
});
connect(bluetooth_ble_Tool,&Bluetooth_ble_Tool::BLE_Link_error,
これ、[=](){
this->show();
少ない->非表示();
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(“検索中”);
connect(bluetooth_ble_Tool,&Bluetooth_ble_Tool::BlueBLE_FindDevicefinished,
this,[=](ブールOK){
ui->pushButton->setEnabled(true);
ui->pushButton->setText(“接続された Bluetooth の検出を開始します”);
if(ok==false) {
QMessageBox::information(this,tr(“検索ステータス “),” デバイスを検索できません。デバイスの電源がすでに入っているかどうか、または別の携帯電話がすでに接続されているかどうかを確認してください。”);} }); }
void BLE_PairPage::BlueSearchConnectState(Bluetooth_ble_Tool::startStateprogressBar_em Linkst, int progress){
ui->progressBar->setValue(進行状況);
if(Linkst>=Bluetooth_ble_Tool::Ble_OtherError){
QMessageBox::information(this,tr(“接続プロンプト”),bluetooth_ble_Tool->getErrorinfo());
ui->label_tips->setText(bluetooth_ble_Tool->getErrorinfo());}
else if(Linkst>=Bluetooth_ble_Tool::Ble_Deconnect_device){
QMessageBox::information(this,tr(“接続プロンプト”),“バグ”);
ui->label_tips->setText(“バグ”);}
else if(Linkst==Bluetooth_ble_Tool::Ble_Connect_characterOk){// QMessageBox::information(
this,tr(“正常に接続されました”),bluetooth_ble_Tool->getErrorinfo());
ui->label_tips->setText(“正常に接続されました”);
this->hide();
mwin->show();
devicecommHandle->TimerStartReadDeviceST(100);
//btchat->show();
//切断(bluetooth_ble_Tool,&Bluetooth_ble_Tool::BlueSearchConnectState,
//this,&BLE_PairPage::BlueSearchConnectState); }
それ以外{
ui->label_tips->setText(“接続の検索”); }


投稿日時: 2024 年 5 月 23 日