乌市泽哥 发表于 2024-8-31 22:22:35

基于(Linux)IM6ULL开辟板的车载终端体系(Qt开辟)

项目先容


[*]这个项目是基于正点原子阿尔法I.M6ULL开辟板编写的,本项目分为3个大模块(生存、应用、工具)。
[*]硬件需求:正点原子阿尔法I.M6ULL开辟板、usbwifi模块(购买板自带)、RGB屏(建议7寸)、OV5640摄像头。
[*]相信大家肯定关注一件事那就是开源,没错本项目开源下载毗连在文章底部。本人感觉,作为毕业课设难度应该够。
生存

https://i-blog.csdnimg.cn/direct/98f861c7641346b1809dcbdb4b8bd85e.jpeg#pic_center
其中有小模块,天气、相册、钟表、日历(Qt自带控件)
life.h
#ifndef LIFE_H
#define LIFE_H

#include <QWidget>
#include <QLabel>
#include <QTimer>
#include <QDebug>
#include <weather/weather.h>
#include <photoViem/photoviem.h>
#include <date_biao/date_biao.h>

namespace Ui {
class Life;
}

class Life : public QWidget
{
    Q_OBJECT

public:
    explicit Life(QWidget *parent = nullptr,QWidget *parent1 = nullptr);
    ~Life();

    void weather_diaplay(bool);//显示天气界面
    void wifi_judge(bool);       //获取wifi是否可以使用
    void hide_all();

private slots:
    void on_pushButton_photo_clicked();

signals:
    void hide_show_life();

private:
    Ui::Life *ui;
    QLabel *photoLabel;
    QTimer *photoTimer;
    QWidget *life_ui;
    Date_biao *date_biao;
    PhotoViem *photoViem;
    Weather *weather;
    bool wifi_judge_;
};

#endif // LIFE_H

life.cpp
#include "life.h"
#include "ui_life.h"

Life::Life(QWidget *parent,QWidget *parent1) :
    QWidget(parent),
    ui(new Ui::Life)
{
    ui->setupUi(this);

    //相册label下的按键
    ui->pushButton_photo->setFixedSize(ui->widget_photo->size());
    ui->pushButton_photo->setFlat(true);
    ui->pushButton_photo->raise();

    life_ui = new QWidget(parent1);
    life_ui->setFixedSize(1024,600);
    life_ui->hide();

    //相册
    photoViem = new PhotoViem(life_ui);
    photoViem->hide();
    photoLabel = new QLabel(ui->widget_photo);

    //钟表
    date_biao = new Date_biao(ui->widget_meter);
    date_biao->move(ui->widget_meter->width()/2-this->height()/4,-15);
    date_biao->resize(this->width()/3,this->height()*2/3);//ui->widget_meter->width(), ui->widget_meter->height()
    date_biao->raise();

    //天气
    weather = new Weather(life_ui);
    weather->hide();

    ui->widget_meter->raise();//最上层

    connect(weather,&Weather::pixmap_data,[=](QPixmap pixm){
      pixm = pixm.scaled(ui->widget_meter->width(), ui->widget_meter->height(), Qt::KeepAspectRatio, Qt::SmoothTransformation);
      ui->label_watcher->setPixmap(pixm);
      ui->label_watcher->lower();
    });
    connect(photoViem,&PhotoViem::at_pixmap,[=](QPixmap pix){
      photoLabel->setFixedSize(ui->widget_photo->size());
      photoLabel->setPixmap(pix.scaled(ui->widget_photo->width(), ui->widget_photo->height(), Qt::KeepAspectRatio, Qt::SmoothTransformation));
      photoLabel->lower();
      ui->pushButton_photo->move(0,0);
      ui->pushButton_photo->setFixedSize(pix.scaled(ui->widget_photo->width(), ui->widget_photo->height(), Qt::KeepAspectRatio, Qt::SmoothTransformation).size());
      //qDebug()<<ui->pushButton_photo->size()<<ui->pushButton_photo->x()<<ui->pushButton_photo->y()<<ui->widget_photo->x();
    });
}

Life::~Life()
{
    delete ui;
}

void Life::weather_diaplay(bool aaa)
{
    if(wifi_judge_)//wifi_judge_
    {
      if(aaa) //显示
      {
            weather->show();
            life_ui->show();
            emit hide_show_life();
      }
      else
      {
            weather->hide();
      }
    }
    else
      qDebug()<<"没用检测到网络信号!!!!";

}

void Life::wifi_judge(bool wifiJudge)
{
    wifi_judge_ = wifiJudge;
}

void Life::hide_all()
{
    photoViem->hide__();
    weather->hide();
    life_ui->hide();
    weather_diaplay(false);
}

void Life::on_pushButton_photo_clicked()
{
    //qDebug()<<ui->widget_photo->size()<<photoLabel->width()<<photoLabel->height()<<ui->pushButton_photo->width()<<ui->pushButton_photo->height();
    photoViem->show();
    life_ui->show();
    emit hide_show_life();
}

天气

会获取当前天气显示到钟表模块后,做为配景。应用模块的天气模块是以信号的形式打开该天气模块的ui界面(建议更换一个api)。
weather.h
wforecast.h
wather.cpp
wforecast.cpp
相册

获取相册文件夹的图片,轮流显示,单机ui图片打开相册功能,在功能中双击放大(有点卡必要等候)。
https://i-blog.csdnimg.cn/direct/46df086546e942aba459bde687efe0d0.jpeg#pic_center
photoviem.h
pitherbig.h
photoviem.cpp
pitherbig.cpp
钟表

生存模块ui上的大表盘,获取体系时间显示。
data_biao.h
data_biao.cpp
应用

https://i-blog.csdnimg.cn/direct/1d02b613525c4ff6bc949929d1c2171d.jpeg#pic_center
其中有视频、音乐、天气、地图模块。
use.h
#ifndef USE_H
#define USE_H

#include <QWidget>
#include <QDebug>
#include <myMap/mymap.h>
#include <musicplay/musicplay.h>
#include <video/video.h>

namespace Ui {
class Use;
}

class Use : public QWidget
{
    Q_OBJECT

public:
    explicit Use(QWidget *parent = nullptr,QWidget *parent1 = nullptr);
    ~Use();

    void useName(bool);
    void wifi_judge(bool);       //获取wifi是否可以使用
    void hide_all();

private slots:
    void on_pushButton_video_clicked();

    void on_pushButton_music_clicked();

    void on_pushButton_browser_clicked();

    void on_pushButton_weather_clicked();

    void on_pushButton_map_clicked();

    void on_pushButton_radio_clicked();

signals:
    void weather_show();
    void hide_show_use();

private:
    Ui::Use *ui;
    MyMap *mymap;
    MusicPlay *musicPlay;
    Video *video;
    QWidget *use_ui;
    bool wifi_judge_;
};

#endif // USE_H

use.cpp
#include "use.h"
#include "ui_use.h"

Use::Use(QWidget *parent,QWidget *parent1) :
    QWidget(parent),
    ui(new Ui::Use)
{
    ui->setupUi(this);

    use_ui = new QWidget(parent1);
    use_ui->setFixedSize(1024,600);
    use_ui->hide();

    mymap = new MyMap(use_ui);
    mymap->hide();
    musicPlay = new MusicPlay(use_ui);
    musicPlay->setAttribute(Qt::WA_StyledBackground); //脱离父类窗口
    musicPlay->hide();
    video = new Video(use_ui);
    video->hide();
}

Use::~Use()
{
    delete ui;
}

void Use::useName(bool use_name)
{
    if(use_name)//显示
    {
      ui->label_browser->show();
      ui->label_map->show();
      ui->label_music->show();
      ui->label_raido->show();
      ui->label_video->show();
      ui->label_weather->show();
    }
    else
    {
      ui->label_browser->hide();
      ui->label_map->hide();
      ui->label_music->hide();
      ui->label_raido->hide();
      ui->label_video->hide();
      ui->label_weather->hide();
    }
}

void Use::wifi_judge(bool wifiJudge)
{
    wifi_judge_ = wifiJudge;
}

void Use::hide_all()
{
    mymap->hide();
    musicPlay->hide();
    video->hide();
    use_ui->hide();
    //use_ui->setStyleSheet("background-color: rgb(0, 0, 0);");
}

void Use::on_pushButton_video_clicked()
{
    use_ui->show();
    video->show();
    emit hide_show_use();
}

void Use::on_pushButton_music_clicked()
{
    use_ui->show();
    //use_ui->setStyleSheet("background-color: rgb(81, 81, 81);");
    musicPlay->show();
    emit hide_show_use();
}

void Use::on_pushButton_browser_clicked() //浏览器
{
    qDebug()<<"\n暂无“浏览器”功能,作者会努力的!!!";
}

void Use::on_pushButton_weather_clicked()
{
    if(wifi_judge_)
      emit weather_show();
    else
      qDebug()<<"没用检测到网络信号!!!";
}

void Use::on_pushButton_map_clicked()
{
    if(wifi_judge_)
    {
      use_ui->show();
      mymap->show();
      emit hide_show_use();
    }
    else
      qDebug()<<"没用检测到网络信号!!!";
}

void Use::on_pushButton_radio_clicked()
{
    qDebug()<<"\n暂无“收音机”功能,作者会努力的!!!";
}

视频

https://i-blog.csdnimg.cn/direct/712e7f74ff68407b9c63cc371f4fc5c9.jpeg#pic_center
video.h
video.cpp
音乐

https://i-blog.csdnimg.cn/direct/1e60d8e4356f4a13aba0f49dc4174e23.jpeg#pic_center
musicplay.h
lyic.h
musicplay.cpp
lyic.cpp
地图

https://i-blog.csdnimg.cn/direct/043b7c21ada04edf869d15079f245a1b.jpeg#pic_center
mymap.h
map.h
longitudelatitude.h
mymap.cpp
map.cpp
longitudelatitude.cpp
工具

https://i-blog.csdnimg.cn/direct/4719b914ca88452dabc6ab79a55d0029.jpeg#pic_center
其中有wifi、灯、倒车影像、文件夹、设置、使用先容、指南针模块。
tool.h
#ifndef TOOL_H
#define TOOL_H

#include <QWidget>
#include <QTimer>
#include <QTextEdit>
#include <QLabel>
#include <QDebug>
#include <compass/compass.h>
#include <key/ap3216c.h>
#include <key/icm20608.h>
#include <key/led.h>
#include <folder/folder.h>
#include <wifi/wifi.h>
#include <set_arm/set_arm.h>
//#include <camera/camera.h>

namespace Ui {
class Tool;
}

class Tool : public QWidget
{
    Q_OBJECT

public:
    explicit Tool(QWidget *parent = nullptr,QWidget *parent1 = nullptr);
    ~Tool();

    void useName(bool);
    void hide_all();

private slots:
    void on_pushButton_folder_clicked();

    void on_pushButton_light_clicked();

    void on_pushButton_backcar_clicked();

    void on_pushButton_wifi_clicked();

    void on_pushButton_instructions_clicked();

    void on_pushButton_set_clicked();

signals:
    void wifi_judge(bool);
    void hide_show_tool();
    void bizi_path(QString);
    void use_name(bool);

private:
    Ui::Tool *ui;
    Folder *folder;
    //Camera *camera;
    QWidget *tool_ui;
    QTextEdit *textEdit_instructions;
    Compass *compss;
    QLabel *compss_label;
    Set_arm *set_arm;
#ifdef Q_OS_LINUX
    Led *led;
    ICM20608 *icm20608;
    Ap3216c *ap3216c;
    Wifi *wifi;
    bool led_state;
    int led_big;
#endif
    QString instructions_QString = "\n#####使用说明#####\n\n"
                                 "#欢迎大家使用,借鉴。本程序借鉴了很多网上大佬的开源资料,勿喷。\n"
                                 "\n#程序是按照正点原子IMX6U阿尔法开发板来编写的,其中几个模块功能需要"
                                 "板载硬件才可以实现。\n"
                                 "\n#WiFi功能模块,是需要板子购买时赠送的wifiUSB模块的,wifi程序是直接"
                                 "调用板载驱动,进行连接wifi和查看周围wifi。\n"
                                 "\n#地图功能模块是(天地图)连接api,获取地图、经纬度数据,地名搜索经纬"
                                 "度不太准确,导致地图图片不太准确,搜索地标性建筑还是可以的,建议"
                                 "把api改为高德或者百度的应该会好一点。\n"
                                 "\n#指南针是根据板载硬件ICM20608六轴传感器其中的x、y轴来计算的,指南"
                                 "针不准(作者较为废物,建议修改一下)。\n"
                                 "\n#倒车影像功能模块,使用OpenCV来实现的。\n"
                                 "\n#天气功能模块,连接api获取天气,作者这个api比较捞(次数少),建议更"
                                 "换,钟表后面显示当前天气状况,天气应用有两个界面,界面1,当天的天气情"
                                 "况,单机屏幕切换界面2,未来5天的天气情况。\n"
                                 "\n#键盘输入中文功能模块,是应用开源大佬\n"
                                 "https://github.com/justdoit-mqr/softkeyboard。\n"
                                 "\n#浏览器功能和收音机功能,暂时还没有开发,各位大佬可以自行研究。\n\n"
                                 "\n#####建议#####\n\n"
                                 "#有一些默认的路径可以自己根据自己电脑进行更改,如:默认连接的wifi,文件"
                                 "夹功能模块下windows下的路径等。\n"
                                 "\n#键盘功能开启了两次,可以自己优化为一次。\n"
                                 "\n#语音识别功能模块(voice)是根据百度语音识别来实现的,因为有时不太"
                                 "准确,本程序没有使用,可以自行添加该功能。也可以购买模块编写驱动来实现语音功能。\n";
};

#endif // TOOL_H

tool.cpp
#include "tool.h"
#include "ui_tool.h"

#include <math.h>

Tool::Tool(QWidget *parent,QWidget *parent1) :
    QWidget(parent),
    ui(new Ui::Tool)
{
    ui->setupUi(this);

    tool_ui = new QWidget(parent1);
    tool_ui->setFixedSize(1024,600);
    tool_ui->hide();
    //使用介绍
    textEdit_instructions = new QTextEdit(tool_ui);
    textEdit_instructions->setReadOnly(true);//只读
    textEdit_instructions->setStyleSheet("font: 13pt \"宋体\";");
    textEdit_instructions->resize(tool_ui->size());
    textEdit_instructions->append(instructions_QString);
    textEdit_instructions->hide();
    //指南针
    compss = new Compass(ui->widget_compass);
    compss_label = new QLabel(this);
    compss_label->resize(140,40);
    compss_label->move(this->width()*2/3+6,this->height()*7/8);
    compss_label->setAlignment(Qt::AlignCenter);
    compss_label->setStyleSheet("font: 28pt \"宋体\";");
    compss_label->setText("指南针");
    //文件夹
    folder = new Folder(tool_ui);
    folder->hide();
    //设置
    set_arm = new Set_arm(tool_ui);
    set_arm->hide();
    //倒车影像
    //camera = new Camera(tool_ui);
    //camera->hide();
#ifdef Q_OS_LINUX
    //灯
    led = new Led(this);
    led_state = false;
    //六轴传感器
    icm20608 = new ICM20608(this);
    //光、距离、红外传感器i
    ap3216c = new Ap3216c(this);
    //WFi
    wifi = new Wifi(tool_ui);//会默认连接wifi
    wifi->hide();

    connect(wifi,&Wifi::wifi_judge,[=](bool judge){ //获取wifi连接是否成功
      emit wifi_judge(judge);
    });
    connect(ap3216c,&Ap3216c::ap3216cDataChanged,[=]{

      if(ap3216c->alsData().toInt() <= 5 || ap3216c->alsData().toInt() >= 700)
      {
            if(led_big <= 0)
            {
                on_pushButton_light_clicked();
                led_big=1;
            }
      }
    });
    connect(icm20608,&ICM20608::icm20608DataChanged,[=]{
      //温度
      if(icm20608->tempData()>= 36)
      {
            ui->label_temp_number->setStyleSheet("color:red;");
      }
      else
      {
            ui->label_temp_number->setStyleSheet("color:black;");
      }
            ui->label_temp_number->setText(icm20608->tempData() + "℃");
      //指南针数据改变
      float gxdata = icm20608->gxData().toFloat() * 10;
      float gydata = icm20608->gyData().toFloat() * 10;
      if(gxdata < 0)
      {
            if(gydata < 0)
                compss->set_direction(180+sqrt((-gxdata)*(-gxdata)+(-gydata)*(-gydata)));
            else
                compss->set_direction(270+sqrt((-gxdata)*(-gxdata)+(-gydata)*(-gydata)));
      }else{
            if(gydata < 0)
                compss->set_direction(90+sqrt((-gxdata)*(-gxdata)+(-gydata)*(-gydata)));
            else
                compss->set_direction(sqrt((-gxdata)*(-gxdata)+(-gydata)*(-gydata)));
      }
    });
#endif
    connect(set_arm,&Set_arm::bizi_path,(QString bizi_path_){
                emit bizi_path(bizi_path_);
            });
    connect(set_arm,&Set_arm::use_name,(bool use_name_){
                emit use_name(use_name_);
            });
    //connect(camera,&Camera::close_camera,this,&Tool::hide_all);
}

Tool::~Tool()
{
    delete ui;
}

void Tool::useName(bool use_name_xianshi)//名字显示?
{
    if(use_name_xianshi)//显示
    {
      ui->label_backcar->show();
      ui->label_folder->show();
      ui->label_instructions->show();
      ui->label_light->show();
      ui->label_set->show();
      ui->label_wifi->show();
      compss_label->show();
    }
    else
    {
      ui->label_backcar->hide();
      ui->label_folder->hide();
      ui->label_instructions->hide();
      ui->label_light->hide();
      ui->label_set->hide();
      ui->label_wifi->hide();
      compss_label->hide();
    }
}

void Tool::hide_all() // 关闭
{
    textEdit_instructions->hide();
    folder->hide();
    //camera->close_camera();//关闭摄像头
    //camera->hide();
    tool_ui->hide();
    set_arm->hide();
#ifdef Q_OS_LINUX
    wifi->hide();
#endif
}

void Tool::on_pushButton_folder_clicked()
{
    folder->show();
    tool_ui->show();
    emit hide_show_tool();
}

void Tool::on_pushButton_light_clicked()
{
#ifdef Q_OS_LINUX
    if(!led_state)
    {
      led->on_led_clicked(true);
      ui->pushButton_light->setStyleSheet("border-image: url(:/car_terminall/light1.png);");
      led_state = true;
    }
    else // 关灯
    {
      led->on_led_clicked(false);
      ui->pushButton_light->setStyleSheet("border-image: url(:/car_terminall/light0.png);");
      led_state = false;
    }
#endif
#ifdef Q_OS_WIN32
    qDebug()<<"\nWindow无法启用该模块!!!";
#endif
}

void Tool::on_pushButton_backcar_clicked()
{
    //camera->show();
    //camera->open_camera();
    tool_ui->show();
    emit hide_show_tool();
}

void Tool::on_pushButton_wifi_clicked()
{

#ifdef Q_OS_LINUX
    wifi->show();
    tool_ui->show();
    emit hide_show_tool();
#endif
#ifdef Q_OS_WIN32
    qDebug()<<"\nWindow无法启用该模块!!!";
#endif

}

void Tool::on_pushButton_instructions_clicked()
{
    textEdit_instructions->show();
    tool_ui->show();
    emit hide_show_tool();

}

void Tool::on_pushButton_set_clicked()
{
    set_arm->show();
    tool_ui->show();
    emit hide_show_tool();
}

wifi

https://i-blog.csdnimg.cn/direct/74fd8556dc7d4664ae7717fb71951b31.jpeg#pic_center
wifi.h
mima.h
wifi.cpp
mima.cpp


板载资源,按键旁的小灯。
led.h
led.cpp
倒车影像

window可以使用,linux也可以使用,就是烧录不到arm板。
camera.h
camera.cpp
文件夹

https://i-blog.csdnimg.cn/direct/1a8e09c802f84d6bb4389ae96d923f3a.jpeg#pic_center
folder.h
folder.cpp
设置

https://i-blog.csdnimg.cn/direct/d2cf1482840c434cb6377d7797909f44.jpeg#pic_center
set_arm.h
set_arm.cpp
指南针

https://i-blog.csdnimg.cn/direct/8391e8d679464043aeb0bfdb037491ec.jpeg#pic_center
compass.h
compass.cpp
留意


[*]该程序先毗连网络在启动,否则可能打不开
[*]打开应用后,按板子黄色按键退出应用。
[*]地图不支持双指超作,由于板子不支持,所以没法编写。
[*]浏览器和收音机模块,暂无开辟。
下载毗连

百度网盘:下载
链接:https://pan.baidu.com/s/10HYNU7tbgD5BJQ1SK5Zd9w?pwd=1111
提取码:1111
感谢各位大大的点赞。

免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。
页: [1]
查看完整版本: 基于(Linux)IM6ULL开辟板的车载终端体系(Qt开辟)