精品国产Av无码久久久蜜臀-免费看a级淫秽真实动作衫视频-人妻无码一区二区三区免费视频-奶好大 好长 好紧免费视频

logo

【開源獲獎案例】迪文屏與安卓手機(jī)雙向聯(lián)動控制音樂播放

——來自迪文開發(fā)者論壇


本期為大家推送迪文開發(fā)者論壇獲獎開源案例——??迪文屏與安卓手機(jī)雙向聯(lián)動控制音樂播放??。工程師通過藍(lán)牙模塊實現(xiàn)了迪文智能屏與安卓手機(jī)的數(shù)據(jù)交互,用戶可以輕松控制安卓手機(jī)、U盤中的歌曲播放、暫停、換曲及音效設(shè)置,體驗智能屏與安卓手機(jī)的雙向便捷操控。

 

演示視頻


完整開發(fā)資料含迪文屏DGUS工程資料與C51代碼,獲取方式:

1. 前往迪文開發(fā)者論壇獲?。?span style="font-family: 微軟雅黑, "Microsoft YaHei"; text-decoration: underline; line-height: 150%; color: rgb(51, 102, 153); background: rgb(255, 255, 255);">http://inforum.dwin.com.cn:20080/forum.php?mod=viewthread&tid=9992&extra=page%3D1

2. 微信公眾號中回復(fù)“音樂播放”獲取。

【UI開發(fā)示例】

 UI開發(fā)示例圖

 

 【C51工程設(shè)計】

 

T5L 串口與藍(lán)牙模塊進(jìn)行數(shù)據(jù)交互,修改播放狀態(tài)、設(shè)置音量、讀取藍(lán)牙狀態(tài),部分參考代碼如下:

int main(void)

{   

    INIT_CPU();

    T2_Init();

    UART4_Init();

    EA=1;

    //UART4_SendStr("hello",sizeof("hello"));

    //WDT_ON();//打開看門狗

    while(1)

    {   

    //WDT_RST();//喂狗

      Process();

    }

}

void UART4_Init(void)

{

    //UART4 波特率設(shè)置:

    //BODE2_DIV_H=CPU 主頻/(8*波特率) 。

    //206438400/8/115200=224=0xe0

    //206438400/8/921600=28=0x1C

    //206438400/8=25804800/230400=112=0x70

    SCON2T=0x80;

    SCON2R=0x80;

    BODE2_DIV_H=0x00;//FCLK/(8*DIV)

    BODE2_DIV_L=0xe0;//921600 波特率

    //BODE2_DIV_H=0x00;     

    //FCLK/(8*DIV)

    //BODE2_DIV_L=0x70;

    //ES3T=1;

    ES2R=1;

    EA=1;

}

void TenMsHandle(void)

{

    if(!TenmsFlag)

        return;

    TenmsFlag=0;

    SourcePress();//音源改變

    PlayCtrPress();//播放狀態(tài)改變

    VolCtrSlider();//音量改變

    VolLogSlider();//音量改變

    ReadBtState();//讀取藍(lán)牙狀態(tài)

}

void SourcePress(void)

{

    charTouchKey[2]={0,0};

  u8Sdata[2];

    read_dgusii_vp(0x3000,TouchKey,1);

    if(TouchKey[1]==0)

        return;

Sdata[1]=0;

    switch(TouchKey[1])

    {

        case1://U盤

            Sdata[0]=1;

            SendDataToBT(Write_Run_Mode,Sdata,1);

        break;

        case2://外部LineIn輸入

            Sdata[0]=2;

            SendDataToBT(Write_Run_Mode,Sdata,1);

        break;

        case3://藍(lán)牙

            Sdata[0]=3;

            SendDataToBT(Write_Run_Mode,Sdata,1);

        break;

    }

    write_dgusii_vp(0x3003,TouchKey,1);

    memset(TouchKey,0,sizeof(TouchKey));

    write_dgusii_vp(0x3000,TouchKey,1);

    ReadBtStatecount=0;

}

void PlayCtrPress(void)

{

    charTouchKey[2]={0,0};

  u8Sdata[2];

    read_dgusii_vp(0x3001,TouchKey,1);

    if(TouchKey[1]==0)

        return;

Sdata[1]=0;

    switch(TouchKey[1])

    {

        case1://上一曲

            Sdata[0]=1;

            SendDataToBT(Write_Next_Pre_PT,Sdata,1);

        break;

        case2://播放暫停

            Sdata[0]=2;

            SendDataToBT(Write_Next_Pre_PT,Sdata,1);

        break;

        case3://下一曲

            Sdata[0]=3;

            SendDataToBT(Write_Next_Pre_PT,Sdata,1);

        break;

    }

    memset(TouchKey,0,sizeof(TouchKey));

    write_dgusii_vp(0x3001,TouchKey,1);  

    ReadBtStatecount=0;

}

 

安卓軟件包通過QT編寫,主要實現(xiàn)與智能屏進(jìn)行藍(lán)牙連接、通信控制,部分參考代碼如下:

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,

      this,&BLE_PairPage::BlueSearchConnectState);

  //btchat=new BtChat();

  //btchat->set_ble_Tool(bluetooth_ble_Tool);

  //btchat->init_Page();

  //btchat->hide();

  devicecommHandle=new DeviceComm();

  devicecommHandle->set_ble_Tool(bluetooth_ble_Tool);

  devicecommHandle->InitDevice();

  mwin=new mainwin();

  mwin->hide();

  connect(mwin,&mainwin:layChangeMode,

      devicecommHandle,&DeviceComm:layChangeMode);//寫模式改變下發(fā)

  connect(mwin,&mainwin:layCtrPreNextSt,

      devicecommHandle,&DeviceComm:layCtrPreNextSt);//寫上下曲

  connect(mwin,&mainwin:layMusicVolChange,

      devicecommHandle,&DeviceComm:layMusicVolChange);//寫音量改變下發(fā)

  connect(devicecommHandle,&DeviceComm::ReadPlayMode,

      this,[=](int mode){//設(shè)置目前的模式

        qDebug()<<"mode:"<<mode;

        mwin->B_Upan->setChecked(false);

        mwin->B_AUX->setChecked(false);

        mwin->B_BT->setChecked(false);

        if(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);

      });

  connect(devicecommHandle,&DeviceComm::ReadPlayMusicVol,

      this,[=](int vol){//設(shè)置音量顯示

        mwin->QS_MainVol->setValue(vol);

      });

  connect(bluetooth_ble_Tool,&Bluetooth_ble_Tool::BLE_Link_error,

      this,[=](){

        this->show();

        mwin->hide();

        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,[=](bool ok){                

      ui->pushButton->setEnabled(true);                

      ui->pushButton->setText("開始檢測連接藍(lán)牙");                 

      if(ok==false) {                    

        QMessageBox::information(this,tr("搜索狀態(tài)"),"搜索不到設(shè)備,請查看設(shè)備是否已經(jīng)開機(jī),或者有其它手機(jī)已經(jīng)連接上?");} });}

void BLE_PairPage::BlueSearchConnectState(Bluetooth_ble_Tool::startStateprogressBar_em Linkst, int progress){    

  ui->progressBar->setValue(progress);     

  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();

    //disconnect(bluetooth_ble_Tool,&Bluetooth_ble_Tool::BlueSearchConnectState,

    //this,&BLE_PairPage::BlueSearchConnectState); }    

  else{

  ui->label_tips->setText("搜索連接中"); }

}