????????基于ARM+Linux的車載系統(tǒng)演示效果
基于ARM+Linux的車載系統(tǒng)
前言:
????????本項(xiàng)目計(jì)劃主要應(yīng)用于家用,辦公等領(lǐng)域轎車中實(shí)施的基于物聯(lián)網(wǎng)云平臺(tái)的車載系統(tǒng)項(xiàng)目,既能夠?yàn)檐囍髟谛旭傔^(guò)程中提供舒適的體驗(yàn),又能提供一定的安全保障。???
目錄:
????????基于ARM+Linux的車載系統(tǒng)演示效果
前言:
目錄:
一、系統(tǒng)方案
1.1 項(xiàng)目背景
1.2 項(xiàng)目特性
1.2.1 安全性
1.2.2 實(shí)用性
1.2.3?美觀性
1.2.1?實(shí)用性
1.3?落地應(yīng)用范例
二、功能與特色
2.1?項(xiàng)目功能
2.1.1?基本功能
2.1.2創(chuàng)新功能
2.2?項(xiàng)目特色
三、實(shí)現(xiàn)原理
3.1?核心框架
3.2?模塊原理
3.2.1?陀螺儀模塊
3.2.2?溫度傳感器模塊
3.3?功能開(kāi)發(fā)
3.3.1 UI界面開(kāi)發(fā)
3.3.2?上位機(jī)APP開(kāi)發(fā)
3.3.3?定位功能實(shí)現(xiàn)
3.3.4?底層驅(qū)動(dòng)實(shí)現(xiàn)
3.4?QT部分源碼
3.5?電路原理圖:?
3.5.1 短信模塊
3.5.2 紅外傳感器
3.6 APP頁(yè)面?
四、項(xiàng)目框圖
4.1?具體框圖
4.1.1?硬件框圖
4.1.2?軟件流程圖
4.2?開(kāi)發(fā)目標(biāo)
3.2.1 APP開(kāi)發(fā)目標(biāo)
3.2.2 UI界面開(kāi)發(fā)目標(biāo)
3.2.3 安全保障實(shí)現(xiàn)
五、系統(tǒng)測(cè)試方案及結(jié)果
5.1?系統(tǒng)測(cè)試方案
5.2?測(cè)試結(jié)果
5.2.1 主界面測(cè)試
5.2.2 汽車傾倒測(cè)試
5.2.3 溫度過(guò)高測(cè)試
5.2.4 APP測(cè)試
5.2.5 音樂(lè)播放器測(cè)試
?六、實(shí)物演示
6.1?圖片展示
6.2 實(shí)物展示?
?資源鏈接:畢設(shè)&競(jìng)賽&項(xiàng)目&實(shí)訓(xùn)-基于ARM+Linux的車載系統(tǒng)(完整工程代碼用戶開(kāi)發(fā)手冊(cè))資源-CSDN文庫(kù)
資料詳情:
資源總文件夾:
電路圖:?
數(shù)據(jù):
應(yīng)用程序:?
源程序?
用戶手冊(cè):
?文章來(lái)源地址http://www.zghlxwxcb.cn/news/detail-843521.html
一、系統(tǒng)方案
1.1 項(xiàng)目背景
????????本項(xiàng)目在實(shí)現(xiàn)了基本的功能包括實(shí)時(shí)時(shí)鐘,天氣預(yù)報(bào),車內(nèi)溫濕度獲取,照片顯示,音樂(lè)播放器等功能還增加了汽車傾倒短信報(bào)警,APP數(shù)據(jù)互傳,溫度過(guò)高報(bào)警等功能,其中控制方面通過(guò)APP,觸摸屏兩種方式對(duì)車載系統(tǒng)的控制與數(shù)據(jù)顯示,且能夠?qū)?dāng)前車內(nèi)的環(huán)境與信息顯示在觸摸屏與APP上,并搭配溫度傳感器,陀螺儀等模塊實(shí)現(xiàn)基本的智能化數(shù)據(jù)收集,搭配上GPS模塊與短信模塊,實(shí)現(xiàn)汽車傾倒時(shí)將準(zhǔn)確經(jīng)緯度信息發(fā)送至指定的用戶手機(jī)上。部署在華為云服務(wù)器上實(shí)現(xiàn)遠(yuǎn)程數(shù)據(jù)通信與控制,使人們能夠無(wú)距離限制地查看當(dāng)前汽車所處的準(zhǔn)確經(jīng)緯度信息與當(dāng)前車內(nèi)的環(huán)境,通過(guò)網(wǎng)絡(luò)模塊,獲取當(dāng)前的網(wǎng)絡(luò)時(shí)間與未來(lái)五天的天氣情況,能夠方便車主更好地預(yù)防位置的天氣變化,提高了生活和事業(yè)上的效率,并且在車載系統(tǒng)中提供了音樂(lè)播放器功能,不僅實(shí)現(xiàn)了市面上存在的音樂(lè)播放器的所有功能,還提高了UI界面的美觀性。通過(guò)上述功能的全方位服務(wù),不僅實(shí)現(xiàn)了汽車在行駛過(guò)程中舒適的體驗(yàn),更提高了車主的安全保障,真正讓車主放心,家人安心的智能車載系統(tǒng)。
1.2 項(xiàng)目特性
1.2.1 安全性
????????該系統(tǒng)不僅能保證車主在形式過(guò)程中安全地駕駛,并且因?yàn)榧由狭硕绦拍K與GPS模塊,通過(guò)姿態(tài)傳感器檢測(cè)當(dāng)前汽車行駛的狀態(tài),當(dāng)檢測(cè)到汽車傾倒時(shí),就可以立即通過(guò)短信模塊,將當(dāng)前的GPS信息,即經(jīng)緯度信息發(fā)送給指定的用戶,能夠讓對(duì)方立即接收到車禍的信息,并且能夠及時(shí)地進(jìn)行報(bào)警與打電話急救,這極大地保證了用戶的安全性,并且加上網(wǎng)絡(luò)模塊,在車載系統(tǒng)中添加APP互傳功能,當(dāng)用戶登錄APP時(shí),就可以隨時(shí)查看當(dāng)前汽車所處的位置與車內(nèi)信息,如果用戶發(fā)現(xiàn)異常時(shí),就可以即使做出處理
1.2.2 實(shí)用性
????????通過(guò)網(wǎng)絡(luò)模塊的幫助,用戶能夠?qū)崟r(shí)查看車內(nèi)信息以及汽車的形式狀態(tài),無(wú)論是汽車在行駛過(guò)程中還是停下,或是進(jìn)入隧道,用戶都可以通過(guò)手機(jī)APP,實(shí)時(shí)地查看汽車。
1.2.3?美觀性
????????通過(guò)QT實(shí)現(xiàn)的UI界面,在完成基本的汽車車載系統(tǒng)的功能下還盡可能的美化界面,QT作為嵌入式上位機(jī)設(shè)計(jì)軟件,是市面上最常見(jiàn)的UI界面設(shè)計(jì)軟件,能夠滿足大部分的界面的設(shè)計(jì),并且,也能夠保證所有的功能正常運(yùn)行。
1.2.1?實(shí)用性
????????該車載系統(tǒng)不僅能夠完成危險(xiǎn)報(bào)警與APP數(shù)據(jù)互傳控制,在極盡美觀的基礎(chǔ)上,還完成了車載系統(tǒng)該有的功能,包括音樂(lè)播放器,圖片顯示,天氣預(yù)報(bào)獲取,車內(nèi)溫濕度查看等多種功能。
1.3?落地應(yīng)用范例
????????在如今許多家庭都已經(jīng)買車的基礎(chǔ)上,車載系統(tǒng)作為汽車必備的功能,無(wú)論是上百萬(wàn)元的高檔車還是幾萬(wàn)的家用型轎車,都存在著車載系統(tǒng),因此該項(xiàng)目是被市場(chǎng)普遍認(rèn)可的,市場(chǎng)接受能力極高。
????????在臺(tái)灣車載資通訊產(chǎn)業(yè)2012年的產(chǎn)值約為4,026億新臺(tái)幣。透過(guò)經(jīng)濟(jì)部之推動(dòng)協(xié)助,臺(tái)灣產(chǎn)業(yè)于2015年時(shí)達(dá)成突破6,000億元年產(chǎn)值的目標(biāo)。進(jìn)而整合ITS/Telematics創(chuàng)新技術(shù)應(yīng)用,提供全面“智慧化交通運(yùn)輸服務(wù)”,進(jìn)行整體交通網(wǎng)絡(luò)與跨運(yùn)具之計(jì)劃,建立智慧車載系統(tǒng),達(dá)成流暢交通路網(wǎng)服務(wù)與無(wú)縫隙智慧旅運(yùn)生活 [1]? 。此外,臺(tái)灣產(chǎn)業(yè)界近年來(lái)亦積極投入車聯(lián)網(wǎng)智慧車載產(chǎn)品之研發(fā),如科技大廠華碩(ASUS)、宏碁(ACER)與新創(chuàng)公司諦諾科技(ADENOVO)...等均爭(zhēng)相投入這塊新藍(lán)海。
????????在國(guó)際中由全球移動(dòng)通信系統(tǒng)協(xié)會(huì)(GSMA)近期發(fā)布的報(bào)告指出,從2012年原先的130億歐元(5千億臺(tái)幣),預(yù)估到2018年全球車載資通訊系統(tǒng)的市場(chǎng)規(guī)模將達(dá)到約390億歐元(新臺(tái)幣1.5兆元),顯示智慧聯(lián)網(wǎng)結(jié)合車載資通訊系統(tǒng)之商機(jī)正逐年翻倍成長(zhǎng)。
二、功能與特色
2.1?項(xiàng)目功能
2.1.1?基本功能
(1)音樂(lè)播放器:車載系統(tǒng)中的音樂(lè)播放器是最常見(jiàn)的功能,因此該項(xiàng)目中,音樂(lè)播放器也作為主要的項(xiàng)目開(kāi)發(fā)進(jìn)行,不僅擺脫了傳統(tǒng)音樂(lè)播放器中丑陋的UI界面與操作難,更提升了音質(zhì)與藍(lán)牙音樂(lè)播放
(2)實(shí)時(shí)時(shí)鐘:車載系統(tǒng)中,通過(guò)網(wǎng)絡(luò)模塊,獲取當(dāng)前的北京時(shí)間,方便車主實(shí)時(shí)查看時(shí)間,安排生活或辦公的計(jì)劃,并且,可以設(shè)置提醒功能,當(dāng)某個(gè)時(shí)間需要做某事時(shí),可以設(shè)定提醒功能,方便日常生活和工作的安排
(3)照片顯示:在車載系統(tǒng)中,可以存放車主的照片,并且選擇自己喜歡的照片作為車載系統(tǒng)的主頁(yè)
2.1.2創(chuàng)新功能
(1)汽車傾倒短信報(bào)警:通過(guò)姿態(tài)檢測(cè)模塊,實(shí)時(shí)檢測(cè)汽車的姿態(tài),當(dāng)檢測(cè)到汽車發(fā)生傾倒時(shí),及時(shí)地通過(guò)短信模塊,將當(dāng)前的GPS信息通過(guò)短信方式發(fā)送至指定的用戶手機(jī),使得車主能第一時(shí)間得到治療,極大地保證了車主的安全。
(2)車內(nèi)溫濕度:車內(nèi)溫濕度信息的顯示,不僅方便車主查看,及時(shí)地調(diào)整,還方便用戶通過(guò)手機(jī)APP查看該信息,并且當(dāng)檢測(cè)到車內(nèi)有人而溫度又過(guò)高的情況下會(huì)觸發(fā)短信報(bào)警以及蜂鳴器報(bào)警向路人請(qǐng)求援助,避免當(dāng)有人在車內(nèi)時(shí),車門緊鎖而導(dǎo)致溫度過(guò)高發(fā)生的慘狀
(3)上位機(jī)APP開(kāi)發(fā):手機(jī)APP的實(shí)現(xiàn),使得車主的家人能夠足不出戶就可以觀察到車主當(dāng)前所處汽車的狀態(tài),并且當(dāng)車主發(fā)生危險(xiǎn)時(shí),及時(shí)地進(jìn)行報(bào)警,并且當(dāng)用戶在汽車內(nèi)時(shí),也可以通過(guò)APP實(shí)現(xiàn)切歌,更換相冊(cè)等功能。
(4)天氣預(yù)報(bào)顯示:在車載系統(tǒng)中,提供了未來(lái)五天的天氣情況顯示,并且支持三個(gè)城市間的切換,當(dāng)方便車主及時(shí)地根據(jù)未來(lái)幾天的天氣情況安排出行。
?
2.2?項(xiàng)目特色
????????在完成市面上的車載系統(tǒng)基本的音樂(lè)播放器,實(shí)時(shí)時(shí)鐘,天氣預(yù)報(bào)等功能的實(shí)現(xiàn)的基礎(chǔ)上,額外增加了溫度過(guò)高報(bào)警,手機(jī)APP上位機(jī)實(shí)現(xiàn),汽車傾倒報(bào)警,車載系統(tǒng)主界面DIY設(shè)計(jì)等功能,保護(hù)了車主的人身安全,并且增加了車載系統(tǒng)的美觀度
三、實(shí)現(xiàn)原理
3.1?核心框架
????????該項(xiàng)目硬件方面是選擇了I.MX6ULL,操作系統(tǒng)使用Linux,并且在此基礎(chǔ)上,增加了QT作為UI界面開(kāi)發(fā)工具,I.MX6ULL作為ARM公司生產(chǎn)的A7系列芯片,能夠滿足該項(xiàng)目的開(kāi)發(fā)需求,并且Linux作為項(xiàng)目的車載系統(tǒng),因?yàn)槠浞€(wěn)定,開(kāi)源,兼容各種硬件的優(yōu)點(diǎn),是主流的嵌入式操作系統(tǒng),而QT作為嵌入式開(kāi)發(fā)上位機(jī)的應(yīng)用程序,有大量的插件與開(kāi)源庫(kù)提供,為項(xiàng)目成功開(kāi)發(fā)提供了穩(wěn)定的報(bào)賬
3.2?模塊原理
3.2.1?陀螺儀模塊
????????陀螺儀模塊所選擇的是MPU6050,因?yàn)槠浔阋?,功能穩(wěn)定,使用I2C通信的特性,所以方便在項(xiàng)目開(kāi)發(fā)中使用
3.2.2?溫度傳感器模塊
????????溫濕度檢測(cè)通過(guò)DHT11實(shí)現(xiàn),該模塊使用單總線通信,能夠同時(shí)識(shí)別溫濕度,并且占用IO資源少,精度高
3.3?功能開(kāi)發(fā)
3.3.1 UI界面開(kāi)發(fā)
????????通過(guò)QT實(shí)現(xiàn)的車載系統(tǒng)界面的設(shè)計(jì),該軟件不僅在市面上得到了廣泛的應(yīng)用,還支持各平臺(tái)的兼容性,因此可靠性得到了極大的保證,并且QT中還提供了多種UI界面的選擇,也為車載系統(tǒng)UI界面美化設(shè)計(jì)提供了便利。
3.3.2?上位機(jī)APP開(kāi)發(fā)
????????手機(jī)上位機(jī)APP也是通過(guò)QT進(jìn)行開(kāi)發(fā),因此能夠完美地實(shí)現(xiàn)與車載系統(tǒng)的通信,無(wú)論是基本的數(shù)據(jù)傳輸還是車載系統(tǒng)控制,該APP都能過(guò)完美地實(shí)現(xiàn)。
3.3.3?定位功能實(shí)現(xiàn)
????????通過(guò)GPS模塊實(shí)現(xiàn),該模塊連接北斗系統(tǒng),能夠?qū)崟r(shí)地獲取當(dāng)前模塊所處的經(jīng)緯度信息,并且通過(guò)串口,將數(shù)據(jù)傳給車載系統(tǒng)與上位機(jī)中。
3.3.4?底層驅(qū)動(dòng)實(shí)現(xiàn)
????????該項(xiàng)目需要實(shí)現(xiàn)陀螺儀(MPU6050),蜂鳴器,DHT11,串口等底層驅(qū)動(dòng)的實(shí)現(xiàn),因?yàn)椴煌哪K所需要的底層驅(qū)動(dòng)代碼不同,而公用一個(gè)設(shè)備樹(shù),因此就需要將所有的驅(qū)動(dòng)和設(shè)備樹(shù)進(jìn)行匹配,并且完成設(shè)備的初始化與注冊(cè)。
3.4?QT部分源碼
#include "main_window.h"
#include "ui_main_window.h"
#include <QDebug>
#include <QRect>
#include <QToolButton>
#include <QColor>
#include <QMovie>
#include <QTimer>
#include <QtNetwork/QNetworkAccessManager>
#include <QtNetwork/QNetworkRequest>
#include <QtNetwork/QNetworkReply>
#include <QtWidgets/QWidget>
#include <QTextCodec>
#include <QString>
#include <QUrl>
#include <QThread>
#include <QMediaPlayer>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <QString>
#include "mpu6050.h"
Main_Window::Main_Window(QWidget *parent) :
QWidget(parent),
ui(new Ui::Main_Window)
{
ui->setupUi(this);
this->Beep_page = new Beep_window;//實(shí)例化led窗口
this->Music_page = new Music_window;
this->Pichoose_page = new Pichoose_window;
this->Map_page = new Map_window;
this->dht11_obj = new dht11;
this->mpu6050_obj = new Mpu6050;
/*dht11與mpu6050的初始化*/
ui->dht11temp->setText("x");
ui->dht11hum->setText("x");
mpu6050_dht11_init();
ui->change->installEventFilter(this);
time_weather_data my_data(this);
weather_init(city_id);
my_data.get_time(&(this->year),&(this->month),&(this->day),&(this->hour),&(this->minute),&(this->second),&(this->time_flag));
timer_obj = new QTimer(this);
connect(this->timer_obj,&QTimer::timeout,[=](){
this->second++;
/*更新dht11和mpu6050的值*/
if(this->second%2==0){
show_mpu6050_dht11();
}
if(old_picture_flag != picture_flag){
QPixmap pbuty;
//QString str = QString::number();
picture_name.append(Pichoose_page->PicturePath);
picture_name.append(Pichoose_page->fileList.at(picture_flag));
pbuty.load(picture_name);
ui->gif_label->setPixmap(pbuty);
ui->gif_label->setScaledContents(true);
picture_name = "\0";
old_picture_flag = picture_flag;
}
if(this->second >= 60){
this->second = 0;
this->minute++;
// weather_init();
if(this->minute >=60){
this->minute = 0;
this->hour++;
if(this->hour>=24){
this->hour = 0;
this->day++;
weather_init(city_id);
//接下來(lái)做月份,閏年判斷,不想寫了
}
}
update();
}
});
this->show_mainwindow();
timer_obj->start(1000);
}
void Main_Window::show_mpu6050_dht11(){
int ret = dht11_obj->read_dht11_data(dht11_obj->dht11_temp,dht11_obj->dht11_hum);
if(ret == 0){
QString str1(dht11_obj->dht11_temp);
ui->dht11temp->setText(str1);
QString str2(dht11_obj->dht11_hum);
ui->dht11hum->setText(str2);
}
// qDebug()<<"read mpu6050\r\n";
mpu6050_obj->read_mpu6050_data(mpu6050_obj->acce_x,mpu6050_obj->acce_y,mpu6050_obj->acce_z,mpu6050_obj->gyro_x,mpu6050_obj->gyro_y,mpu6050_obj->gyro_z);
QString str1(mpu6050_obj->acce_x);
ui->accex->setText(str1);
QString str2(mpu6050_obj->acce_y);
ui->accey->setText(str2);
QString str3(mpu6050_obj->acce_z);
ui->accez->setText(str3);
QString str4(mpu6050_obj->gyro_x);
ui->gyrox->setText(str4);
QString str5(mpu6050_obj->gyro_y);
ui->gyroy->setText(str5);
QString str6(mpu6050_obj->gyro_z);
ui->gyroz->setText(str6);
// qDebug()<<mpu6050_data<<"\r\n ok \r\n";
}
void Main_Window::mpu6050_dht11_init(){
QPalette dht11_pe;
dht11_pe.setColor(QPalette::WindowText,Qt::white);
ui->dht11temp->setPalette(dht11_pe);
ui->dht11hum->setPalette(dht11_pe);
ui->accex->setPalette(dht11_pe);
ui->accey->setPalette(dht11_pe);
ui->accez->setPalette(dht11_pe);
ui->gyrox->setPalette(dht11_pe);
ui->gyroy->setPalette(dht11_pe);
ui->gyroz->setPalette(dht11_pe);
}
void Main_Window::show_mainwindow(){
QPalette pe;
pe.setColor(QPalette::WindowText,Qt::white);
QPixmap pic(":/picture/weather_window/切換.png");
ui->change->setPixmap(pic);
ui->change->setScaledContents(true);
/*主菜單欄的右側(cè)*/
QPalette pex;
pex.setColor(QPalette::ButtonText,Qt::white); //文字顏色
pex.setColor(QPalette::Button ,QColor(0,64,128)); //背景色
ui->Beep_but->setStyleSheet("QToolButton{background-color: rgb(0,64,128);border:2px groove gray;border-radius:10px;padding:2px 4px;border-style: outset;}"
"QToolButton:hover{background-color:rgb(0,64,128); color: white;}"
"QToolButton:pressed{background-color:rgb(0,54,108);border-style: inset;}");
ui->Crema_but->setStyleSheet("QToolButton{background-color: rgb(0,64,128);border:2px groove gray;border-radius:10px;padding:2px 4px;border-style: outset;}"
"QToolButton:hover{background-color:rgb(0,64,128); color: white;}"
"QToolButton:pressed{background-color:rgb(0,54,108);border-style: inset;}");
ui->Picture_but->setStyleSheet("QToolButton{background-color: rgb(0,64,128);border:2px groove gray;border-radius:10px;padding:2px 4px;border-style: outset;}"
"QToolButton:hover{background-color:rgb(0,64,128); color: white;}"
"QToolButton:pressed{background-color:rgb(0,54,108);border-style: inset;}");
ui->Music_but->setStyleSheet("QToolButton{background-color: rgb(0,64,128);border:2px groove gray;border-radius:10px;padding:2px 4px;border-style: outset;}"
"QToolButton:hover{background-color:rgb(0,64,128); color: white;}"
"QToolButton:pressed{background-color:rgb(0,54,108);border-style: inset;}");
ui->Beep_but->setPalette(pex);
ui->Crema_but->setPalette(pex);
ui->Picture_but->setPalette(pex);
ui->Music_but->setPalette(pex);
ui->Beep_but->setIcon(QIcon(":/picture/main_window/喇叭.png"));
ui->Beep_but->setIconSize(QSize(201,105));
ui->Beep_but->setText(QString::fromLocal8Bit("喇叭"));
ui->Beep_but->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
ui->Crema_but->setIcon(QIcon(":/picture/main_window/天氣.png"));
ui->Crema_but->setIconSize(QSize(201,105));
ui->Crema_but->setText(QString::fromLocal8Bit("天氣"));
ui->Crema_but->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
ui->Picture_but->setIcon(QIcon(":/picture/main_window/picture.png"));
ui->Picture_but->setIconSize(QSize(201,105));
ui->Picture_but->setText(QString::fromLocal8Bit("照片"));
ui->Picture_but->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
ui->Music_but->setIcon(QIcon(":/picture/main_window/music.png"));
ui->Music_but->setIconSize(QSize(201,105));
ui->Music_but->setText(QString::fromLocal8Bit("音樂(lè)"));
ui->Music_but->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
/*桌面照片*/
QPixmap pbuty;
QString str = QString::number(picture_flag);
picture_name.append(Pichoose_page->PicturePath);
picture_name.append(str);
picture_name.append(".jpg");
pbuty.load(picture_name);
ui->gif_label->setPixmap(pbuty);
ui->gif_label->setScaledContents(true);
picture_name = "\0";
}
Main_Window::~Main_Window()
{
delete ui;
}
void Main_Window::paintEvent(QPaintEvent *event){
QPainter my_painter(this);
QPen pen(QColor(255,255,255));
QFont font;
font.setFamily("Microsoft YaHei");
my_painter.setPen(pen);
/*背景顏色*/
my_painter.setBrush(QBrush(QColor(234,254,254)));
my_painter.drawRect(this->rect());
/*第一個(gè)框*/
my_painter.setBrush(QBrush(QColor(0,64,128)));
QRectF first_rect(9,9,330,151);
my_painter.drawRoundedRect(first_rect, 10, 10);
//時(shí)分妙
font.setPointSize(60);
my_painter.setFont(font);
char strNum[5];
sprintf(strNum,"%02d",this->hour);//整形到字符串的轉(zhuǎn)換,并且自動(dòng)補(bǔ)0
my_painter.drawText(QRect(14,5,150,100),strNum);
my_painter.drawText(QRect(105,0,20,100),":");
sprintf(strNum,"%02d",this->minute);
my_painter.drawText(QRect(130,5,150,100),strNum);
font.setPointSize(30);
my_painter.setFont(font);
if(this->time_flag == 0) my_painter.drawText(QRect(235,50,100,100),"AM");
else if(this->time_flag == 1) my_painter.drawText(QRect(235,50,100,100),"PM");
//分界線
my_painter.drawLine(QPoint(9,120),QPoint(338,120));
//年月日
font.setPointSize(16);
my_painter.setFont(font);
sprintf(strNum,"%04d",this->year);
my_painter.drawText(QRect(16,125,100,100),strNum);
my_painter.drawText(QRect(70,125,100,100),"年");
sprintf(strNum,"%02d",this->month);
my_painter.drawText(QRect(100,125,100,100),strNum);
my_painter.drawText(QRect(130,125,100,100),"月");
sprintf(strNum,"%02d",this->day);
for(int i=1;i<=31;i++){
if(i==this->day) my_painter.drawText(QRect(160,125,100,100),strNum);
}
my_painter.drawText(QRect(190,125,100,100),"日");
/*第二個(gè)框*/
QRectF second_rect(9,166,330,151);
my_painter.drawRoundedRect(second_rect, 10, 10);
//天氣
font.setPointSize(13);
my_painter.setFont(font);
// qputenv("QT_IM_MODULE", QByteArray("xyinput"));
switch (this->weather) {
case 0:{my_painter.drawPixmap(200,180,100,100,QPixmap(":/picture/main_window/weather/晴天.png"));
my_painter.drawText(QRect(230,285,150,50),"晴天");
}break;
case 1:{my_painter.drawPixmap(200,180,100,100,QPixmap(":/picture/main_window/weather/雨天.png"));
my_painter.drawText(QRect(230,285,150,50),"雨天");
}break;
case 2:{my_painter.drawPixmap(200,180,100,100,QPixmap(":/picture/main_window/weather/多云.png"));
my_painter.drawText(QRect(230,285,150,50),"多云");
}break;
case 3:{my_painter.drawPixmap(200,180,100,100,QPixmap(":/picture/main_window/weather/陣雪.png"));
my_painter.drawText(QRect(230,285,150,50),"雪天");
}break;
case 4:{my_painter.drawPixmap(200,180,100,100,QPixmap(":/picture/main_window/weather/陰天.png"));
my_painter.drawText(QRect(230,285,150,50),"陰天");
}break;
}
//地點(diǎn)
font.setPointSize(25);
my_painter.setFont(font);
my_painter.drawText(QRect(14,166,150,50),Map_page->city_name);
//溫度
font.setPointSize(45);
my_painter.setFont(font);
sprintf(strNum,"%02d",this->tempature);
my_painter.drawText(QRect(14,210,150,80),strNum);
my_painter.drawText(QRect(90,210,150,80),"°C");
//第三個(gè)框
QRectF third_rect(9,323,330,151);
my_painter.drawRoundedRect(third_rect, 10, 10);
font.setPointSize(13);
my_painter.setFont(font);
/* if(this->wifi_state == 1){
my_painter.drawPixmap(50,340,100,100,QPixmap(":/picture/main_window/wifi.png"));
my_painter.drawText(QRect(70,440,150,80),"已連接");
}
else{
my_painter.drawPixmap(50,340,100,100,QPixmap(":/picture/main_window/沒(méi)wifi.png"));
my_painter.drawText(QRect(70,440,150,80),"未連接");
}*/
/* if(this->lanya_state == 0){
my_painter.drawPixmap(200,340,100,100,QPixmap(":/picture/main_window/藍(lán)牙-關(guān).png"));
my_painter.drawText(QRect(220,440,150,80),"未連接");
}
else{
my_painter.drawPixmap(200,340,100,100,QPixmap(":/picture/main_window/藍(lán)牙.png"));
my_painter.drawText(QRect(220,440,150,80),"已連接");
}*/
}
void Main_Window::on_Beep_but_clicked()
{
this->hide();
this->Beep_page->show();
this->GPIO_File->open(QIODevice::WriteOnly);
this->GPIO_File->write("19",2);
this->GPIO_File->close();
}
void Main_Window::on_Crema_but_clicked()
{
this->hide();
this->Map_page->show();
}
void Main_Window::on_Music_but_clicked()
{
this->hide();
this->Music_page->show();
}
void Main_Window::weather_init(QString id){
QString webaddr="http://wthrcdn.etouch.cn/weather_mini?citykey=";
webaddr.append(id);
QNetworkRequest network_request;
network_request.setUrl(QUrl(webaddr));
connect(manage,SIGNAL(finished(QNetworkReply *)),this,SLOT(replyfinished(QNetworkReply*)));
manage->get(network_request);
}
void Main_Window::replyfinished(QNetworkReply *reply)
{
QVariant status_code = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute);
if(reply->error() == QNetworkReply::NoError)
{
QString all = reply->readAll();
// qDebug()<<all;
weather_dispose(all);
}
reply->deleteLater();
}
void Main_Window::weather_dispose(QString str){
QByteArray byte_array;
QJsonParseError json_error;
QJsonDocument document = QJsonDocument::fromJson(byte_array.append(str),&json_error);
if(json_error.error == QJsonParseError::NoError)
{
QJsonObject obj = document.object();
QJsonValue value = obj.take("desc");//qjsonvalue生成json文檔中對(duì)象的值的對(duì)象
if(value.toString() != "OK")
{
QMessageBox::warning(this,QString::fromLocal8Bit("抱歉"),QString::fromLocal8Bit("暫無(wú)此城市信息"),QMessageBox::Ok,QMessageBox::Ok);
QMessageBox::warning(this,"抱歉","暫無(wú)此城市的天氣情況",QMessageBox::Ok,QMessageBox::Ok);
return;
}
QJsonValue da = obj.take("data");//獲取data數(shù)據(jù)對(duì)象里面的值
QString wendu = da.toObject().take("low").toString();
this->tempature = wendu.toInt();
QJsonValue da1 = da.toObject().take("forecast");
QJsonArray array = da1.toArray();
qDebug()<<array;
QJsonValue value1 = array.at(0);
QJsonObject obj1 = value1.toObject();
QString type1 = obj1.take("type").toString();
QString low1 = obj1.take("low").toString();
QString high1 = obj1.take("high").toString();
QString date1 = obj1.take("date").toString();
this->Map_page->day1_l = low1.mid(3);
this->Map_page->temp_now = low1.mid(3);
QStringList list = low1.mid(3).split("℃");
this->tempature = list.at(0).toInt();
qDebug()<<list.at(0);
this->Map_page->day1_h = high1.mid(3);
this->Map_page->day1_time = date1;
// qDebug()<<low1<< this->Map_page->day1_l<<high1<<high1.toInt();
if(type1 == "晴"){
this->Map_page->day1_tq = 0;
this->Map_page->tq_flag = 0;
}
else if(type1 == "大雨" || type1 == "小雨"){
this->Map_page->day1_tq = 1;
this->Map_page->tq_flag = 1;
}
else if(type1 == "多云"){
this->Map_page->day1_tq = 2;
this->Map_page->tq_flag = 2;
}
else if(type1 == "小雪" ||type1 == "大雪"){
this->Map_page->day1_tq = 3;
this->Map_page->tq_flag = 3;
}
else if(type1 == "陰"){
this->Map_page->day1_tq = 4;
this->Map_page->tq_flag = 4;
}
QJsonValue value2 = array.at(1);
QJsonObject obj2 = value2.toObject();
QString type2 = obj2.take("type").toString();
QString low2 = obj2.take("low").toString();
QString high2 = obj2.take("high").toString();
QString date2 = obj2.take("date").toString();
this->Map_page->day2_l = low2.mid(3);
// this->tempature = this->Map_page->temp_now;
this->Map_page->day2_h = high2.mid(3);
this->Map_page->day2_time = date2;
if(type2 == "晴"){
this->Map_page->day2_tq = 0;
}
else if(type2 == "小雨"||type2 == "大雨"){
this->Map_page->day2_tq = 1;
}
else if(type2 == "多云"){
this->Map_page->day2_tq = 2;
}
else if(type2 == "小雪"||type2 == "大雪"){
this->Map_page->day2_tq = 3;
}
else if(type2 == "陰"){
this->Map_page->day2_tq =4;
}
QJsonValue value3 = array.at(2);
QJsonObject obj3 = value3.toObject();
QString type3 = obj3.take("type").toString();
QString low3 = obj3.take("low").toString();
QString high3 = obj3.take("high").toString();
QString date3 = obj3.take("date").toString();
this->Map_page->day3_l = low3.mid(3);
// this->tempature = this->Map_page->temp_now;
this->Map_page->day3_h = high3.mid(3);
this->Map_page->day3_time = date3;
if(type3 == "晴"){
this->Map_page->day3_tq = 0;
}
else if(type3 == "小雨"||type3 == "大雨"){
this->Map_page->day3_tq = 1;
}
else if(type3 == "多云"){
this->Map_page->day3_tq = 2;
}
else if(type3 == "小雪"||type3=="大雪"){
this->Map_page->day3_tq = 3;
}
else if(type3 == "陰"){
this->Map_page->day3_tq =4;
}
QJsonValue value4 = array.at(3);
QJsonObject obj4 = value4.toObject();
QString type4 = obj4.take("type").toString();
QString low4 = obj4.take("low").toString();
QString high4 = obj4.take("high").toString();
QString date4 = obj4.take("date").toString();
this->Map_page->day4_l = low4.mid(3);
// this->tempature = this->Map_page->temp_now;
this->Map_page->day4_h = high4.mid(3);
this->Map_page->day4_time = date4;
if(type4 == "晴"){
this->Map_page->day4_tq = 0;
}
else if(type4 == "小雨"||type4 =="大雨"){
this->Map_page->day4_tq = 1;
}
else if(type4 == "多云"){
this->Map_page->day4_tq = 2;
}
else if(type4 == "小雪"||type4 =="大雪"){
this->Map_page->day4_tq = 3;
}
else if(type4 == "陰"){
this->Map_page->day4_tq =4;
}
QJsonValue value5 = array.at(4);
QJsonObject obj5 = value5.toObject();
QString type5 = obj5.take("type").toString();
QString low5 = obj5.take("low").toString();
QString high5 = obj5.take("high").toString();
QString date5 = obj5.take("date").toString();
this->Map_page->day5_l = low5.mid(3);
// this->tempature = this->Map_page->temp_now;
this->Map_page->day5_h = high5.mid(3);
this->Map_page->day5_time = date5;
if(type5 == "晴"){
this->Map_page->day5_tq = 0;
}
else if(type5 == "小雨"||type5 == "大雨"){
this->Map_page->day5_tq = 1;
}
else if(type5 == "多云"){
this->Map_page->day5_tq = 2;
}
else if(type5 == "小雪"||type5 == "大雪"){
this->Map_page->day5_tq = 3;
}
else if(type5 == "陰"){
this->Map_page->day5_tq =4;
}
if(type1 == "晴"){
this->weather = 0;
}
else if(type1 == "小雨"|| type1 =="大雨"){
this->weather = 1;
}
else if(type1 == "多云"){
this->weather = 2;
}
else if(type1 == "小雪"||type1 == "大雪"){
this->weather = 3;
}
else if(type1 =="陰"){
this->weather = 4;
}
}
update();
}
bool Main_Window::eventFilter(QObject *obj, QEvent *event)
{
QPixmap pic;
if (obj == ui->change)//指定某個(gè)QLabel
{
if (event->type() == QEvent::MouseButtonPress) //鼠標(biāo)點(diǎn)擊
{
QMouseEvent *mouseEvent = static_cast<QMouseEvent*>(event); // 事件轉(zhuǎn)換
if(mouseEvent->button() == Qt::LeftButton)
{
if(this->Map_page->city_flag == 0){
this->Map_page->city_name = "廈門";
city_id = "101230201";
this->Map_page->city_flag=1;
}
else if(this->Map_page->city_flag == 1){
this->Map_page->city_name = "泉州";
this->Map_page->city_flag=2;
city_id = "101230501";
}
else if(this->Map_page->city_flag == 2){
this->Map_page->city_name = "蘭州";
this->Map_page->city_flag=0;
city_id = "101160101";
}
weather_init(city_id);
return true;
}
else
{
return false;
}
}
else
{
return false;
}
}
}
void Main_Window::on_Picture_but_clicked()
{
this->hide();
Pichoose_page->show();
}
3.5?電路原理圖:?
3.5.1 短信模塊
3.5.2 紅外傳感器
3.6 APP頁(yè)面?
?
四、項(xiàng)目框圖
4.1?具體框圖
4.1.1?硬件框圖
4.1.2?軟件流程圖
4.2?開(kāi)發(fā)目標(biāo)
3.2.1 APP開(kāi)發(fā)目標(biāo)
????????能夠?qū)崿F(xiàn)與車載系統(tǒng)的通信與控制功能,并保證不會(huì)發(fā)生誤觸斷連,無(wú)效控制或數(shù)據(jù)出錯(cuò)的情況,并且盡量保證APP界面的美觀
3.2.2 UI界面開(kāi)發(fā)目標(biāo)
????????作為車載系統(tǒng)的UI界面,要在實(shí)現(xiàn)市面上車載系統(tǒng)所擁有的功能的基礎(chǔ)上,增加界面的美觀性,并且提供安全保障的額外功能
3.2.3 安全保障實(shí)現(xiàn)
????????作為該項(xiàng)目的特色,需要在實(shí)現(xiàn)傾倒報(bào)警與溫度過(guò)高報(bào)警功能的基礎(chǔ)上,保證不會(huì)因?yàn)槠嚿掀禄蛘邆鞲衅鳈z測(cè)錯(cuò)誤而導(dǎo)致的誤報(bào)警
五、系統(tǒng)測(cè)試方案及結(jié)果
5.1?系統(tǒng)測(cè)試方案
????????1,通過(guò)對(duì)主界面圖片的更改測(cè)試圖片切換功能
????????2,傾倒車載系統(tǒng),測(cè)試能否獲得到GPS信息,并把GPS信息發(fā)送到指定的手機(jī)上
????????3,通過(guò)APP調(diào)節(jié)最高溫度,測(cè)試當(dāng)溫度過(guò)高并且紅外傳感器檢測(cè)到有人時(shí)能否觸發(fā)蜂鳴器報(bào)警
????????4,APP連接車載系統(tǒng)后,通過(guò)對(duì)音樂(lè)播放器的選擇,測(cè)試能否和車載系統(tǒng)進(jìn)行通信
????????5,在車載系統(tǒng)中,在音樂(lè)播放器界面,測(cè)試音樂(lè)播放功能
5.2?測(cè)試結(jié)果
5.2.1 主界面測(cè)試
????????在本項(xiàng)目中,車載系統(tǒng)的UI界面基本設(shè)計(jì)完成,并且在此基礎(chǔ)上進(jìn)行了一定的美化,并且增加了主界面自主選擇功能,滿足了車載系統(tǒng)自主DIY喜歡的界面
5.2.2 汽車傾倒測(cè)試
????????在本項(xiàng)目中,能夠時(shí)刻檢測(cè)汽車的狀態(tài),并且當(dāng)汽車發(fā)生傾倒時(shí),立刻將當(dāng)前的經(jīng)緯度信息發(fā)送到用戶手機(jī),并且,能夠避免清位晃動(dòng)而導(dǎo)致的誤報(bào)警
5.2.3 溫度過(guò)高測(cè)試
????????在本項(xiàng)目中,通過(guò)DHT11模塊,能夠獲取溫度信息,當(dāng)溫度高于最大溫度車內(nèi)又同時(shí)檢測(cè)到有人時(shí),就會(huì)觸發(fā)蜂鳴器警報(bào),其中最大溫度可以通過(guò)手機(jī)APP進(jìn)行設(shè)置,能夠滿足不同環(huán)境的要求
5.2.4 APP測(cè)試
????????在本項(xiàng)目中,通過(guò)QT實(shí)現(xiàn)了手機(jī)APP的設(shè)計(jì),能夠滿足與車載系統(tǒng)的基本通信與控制,控制與顯示效果能夠滿足與其,不會(huì)發(fā)生中途斷連的現(xiàn)象。
5.2.5 音樂(lè)播放器測(cè)試
????????在本項(xiàng)目中,音樂(lè)播放器與市面上的音樂(lè)播放器相同,并且支持三種模式的切換,音量控制,列表播放等基礎(chǔ)功能
?六、實(shí)物演示
6.1?圖片展示
6.2 實(shí)物展示?
?資源鏈接:畢設(shè)&競(jìng)賽&項(xiàng)目&實(shí)訓(xùn)-基于ARM+Linux的車載系統(tǒng)(完整工程代碼用戶開(kāi)發(fā)手冊(cè))資源-CSDN文庫(kù)
資料詳情:
資源總文件夾:
電路圖:?
數(shù)據(jù):
?
應(yīng)用程序:?
源程序?
?用戶手冊(cè):
文章來(lái)源:http://www.zghlxwxcb.cn/news/detail-843521.html
?
到了這里,關(guān)于【嵌入式項(xiàng)目】基于ARM+Linux的車載系統(tǒng)(完整工程資料源碼)的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!