当前位置:文档之家› 数码相框嵌入式课程设计报告

数码相框嵌入式课程设计报告

武汉工业学院计算机系数码相框设计实验报告课程:嵌入式班级:网络工程081姓名:***学号:*********日期:2011-11-28一.设计目的开设本课程设计的目的是,通过本课程设计,提高学生的分析问题、解决问题的能力,巩固嵌入式系统的基本理论知识,进一步了解和掌握课程中所讲授的概念,方法。

同时通过本课程设计,全面综合应用所学过的基础知识,建立一个完整的嵌入式系统的开发过程的概念,并掌握其中的主要原理和方法本课程设计的目的是通过开发一个消费类电子产品——数字相框,了解嵌入式产品开发的主要步骤,包括需求分析、系统结构设计、图形界面设计、驱动程序、功能优化、系统测试等,从而培养学生独立完成比较复杂的实际系统设计的能力。

二.设计内容和要求2.1设计的内容作为一个消费类电子产品,数码相框整个系统要完成的基本功能大致如下:1、用户界面友好,操作简便。

由于该产品的使用者大多是非专业人士,用户界面是否清晰明了、操作是否简捷方便成为用户是否能迅速接受此产品的重要因素。

2、数字相框的功能应包括以下方面:(1)在LCD屏上全屏循环显示多幅图像文件;(2)根据设定的时间间隔更新图像;(3)显示时间、日期;(4)通过按钮进行操作;2.2 要求本课程设计要求学生根据实际应用的特点对产品进行完整的需求分析,形成比较完善的总体设计方案。

同时,要求学生具备Linux操作系统下简单的设备驱动程序开发、图形用户接口设计的能力。

此外,还要求读者掌握基本的系统功能及性能测试技术,从而具备比较全面的嵌入式应用系统开发能力。

三.总体设计主要步骤和方法根据数字相框的主要特点和设计功能那个要求,我们将课设分为以下几个步骤:3.1、数字相框软硬件平台的选择性能方面,由于数字图像的解码算法比较复杂,而且大量图片需要从外部Flash存储器中读取,所以对嵌入式微处理器的性能要求比较高。

外部接口方面,该芯片最好能在外围直接支持CF卡的Compact Flash接口,还应提供按钮、LCD显示屏、触摸屏、声音输出通道等。

在本课程设计中,采用了Intel的PXA270作为微处理器,完全能满足上述硬件平台的要求。

数字相框属于消费类电子产品,对价格比较敏感,而嵌入式Linux操作系统上有比较丰富的软件资源、驱动程序和开发工具,因此本课程设计采用嵌入式Linux作为软件开发平台。

在Linux操作系统平台上有多种嵌入式图形界面开发工具可供使用,主要包括MicroWindows、MuniGUI、TinyX和Qt/Embedded等几种。

本课程设计将集中讨论在Qt/Embedded系统上数字相框的实现技术,当然也可以通过其他图形开发界面工具实现数字相框功能。

3.2、数字相框的软件总体设计数字相框软件系统功能可以划分为三个模块:1)图片浏览模块,可以通过按键控制选定某个图像或更新图像页(上一页、下一页)。

2)播放模块,对浏览界面选定的图片进行循环播放。

3)系统设置模块,可设置循环播放更换频率等。

3.2.1、功能模块组织架构图3.3、基于Qt的图形界面程序设计本设计中包括了浏览、循环播放和配置三个界面模块。

这些模块之间需要进行通信,利用Qt提供的信号/槽机制很好地解决了这几问题,每个模块中都有自己定义的一些信号和槽,已发送给其他模块或者从其他模块接受到对应信号后作出响应。

数字相框在初始化时会扫描指定目录下(包括子目录)的所有支持图片文件,并将其存放在列表中,以备之后的浏览界面生成缩略图。

本系统使用Qt提供的QDir类实现遍历目录的功能,在遍历目录的同时通过设置文件类型过滤位来获得指定文件,并使用一个双向的字符串指针链表来记录扫描得到的结果。

四.详细设计根据以上的分析,将程序分为2个部分:一部分为用户界面层、一部分为功能模块层。

4.1用户界面层代码设计如下定义头文件库window.h作用于:该类中的函数、用于实现用户界面层的工作按钮添加信号触发槽#ifndef WINDOW_H#define WINDOW_H#include <QPixmap>#include <QWidget>class RenderArea;class Window : public QWidget{Q_OBJECTpublic:Window();RenderArea *renderArea; // RenderArea对象用于显示图片private:protected:void keyPressEvent(QKeyEvent *event);private slots:void start();void start1();void start2();void predisplay();void nextdisplay();void big();void small();};#endif用户层图形界面与按钮信号槽功能实现代码:#include "window.h"#include <QtGui>#include "renderarea.h"Window::Window(){renderArea = new RenderArea;QPushButton *frontbutton=new QPushButton("pre"); //“上一张图片”按钮QPushButton *nextbutton=new QPushButton("next"); //“下一张图片”按钮QPushButton *startbutton=new QPushButton("Fstart"); //“快速播放”按钮QPushButton *startbutton1=new QPushButton("Mstart"); //“中速播放”按钮QPushButton *startbutton2=new QPushButton("Sstart"); //“慢速播放”按钮QPushButton *b=new QPushButton("big"); //“扩放图片”按钮QPushButton *s=new QPushButton("small"); //“缩小图片”按钮QPushButton *exitbutton=new QPushButton("exit"); //“退出”按钮QHBoxLayout *belowlayout=new QHBoxLayout; //水平布局QHBoxLayout *belowlayout1=new QHBoxLayout;QVBoxLayout *mainlayout=new QVBoxLayout; //垂直布局belowlayout->addStretch();belowlayout->addWidget(frontbutton);belowlayout->addWidget(nextbutton);belowlayout->addStretch();belowlayout->addWidget(startbutton);belowlayout->addWidget(startbutton1);belowlayout->addWidget(startbutton2);belowlayout->addStretch();belowlayout->addWidget(b);belowlayout->addWidget(s);belowlayout->addStretch();belowlayout->addWidget(exitbutton);belowlayout1->addWidget(renderArea);mainlayout->addLayout(belowlayout1);mainlayout->addLayout(belowlayout);this->setFocusPolicy(Qt::ClickFocus);frontbutton->setFocusPolicy(Qt::NoFocus);nextbutton->setFocusPolicy(Qt::NoFocus);startbutton->setFocusPolicy(Qt::NoFocus);startbutton1->setFocusPolicy(Qt::NoFocus);startbutton2->setFocusPolicy(Qt::NoFocus);b->setFocusPolicy(Qt::NoFocus);s->setFocusPolicy(Qt::NoFocus);this->setFocusPolicy(Qt::ClickFocus);exitbutton->setFocusPolicy(Qt::NoFocus);setLayout(mainlayout);setWindowTitle(tr("Digital photo frame"));connect(frontbutton,SIGNAL(clicked()), this,SLOT( predisplay() )); //单击按钮触发函数connect(nextbutton,SIGNAL(clicked()), this,SLOT(nextdisplay()));connect(startbutton,SIGNAL(clicked()), this,SLOT(start()));connect(startbutton1,SIGNAL(clicked()), this,SLOT(start1()));connect(startbutton2,SIGNAL(clicked()), this,SLOT(start2()));connect(b,SIGNAL(clicked()), this,SLOT(big()));connect(s,SIGNAL(clicked()), this,SLOT(small()));connect(exitbutton,SIGNAL(clicked()),this,SLOT(close()));}void Window::predisplay(){renderArea->pre_area();}void Window::nextdisplay(){renderArea->fun_area();}void Window::start(){renderArea->Start(1);}void Window::start1(){renderArea->Start(2);}void Window::start2(){renderArea->Start(3);}void Window::big(){renderArea->Big();}void Window::small(){renderArea->Small();}void Window::keyPressEvent(QKeyEvent *event) {if ( event->key() == Qt::Key_Right){predisplay();}if ( event->key() == Qt::Key_Left){nextdisplay();}}效果图如下:4.2.功能模块实现代码:#include <QtGui>#include <qvariant.h>#include <QLabel>#include <qwhatsthis.h>#include <qpainter.h>#include "renderarea.h"RenderArea::RenderArea(QWidget *parent): QWidget(parent){i=0; //指针dir="/home/Katrina/wisdom/fxy1/photo"; //设置图片默认路径QDir DIR;if(!DIR.exists(dir)){return ;}QDir picdir(dir);QStringList filters;filters << "*.bmp" << "*.jpg" << "*.png"<<"*.gif"; //支持显示图片的格式picdir.setNameFilters(filters);list = picdir.entryInfoList();h=1; //图片的高度比例w=1; //图片的水平比例update(); //触发paintEvent画图函数将图片显示}QSize RenderArea::minimumSizeHint() const{return QSize(10,10);}QSize RenderArea::sizeHint() const{return QSize(10000, 10000);}void RenderArea::paintEvent(QPaintEvent *){QPainter painter(this);QFileInfo fileInfo = list.at(i); //通过指针i获取该图片的文件名QString path=fileInfo.filePath(); //通过文件名获得图片的绝对路径QPixmap pixmap;pixmap.load(path); //加载图片的绝对路径qDebug("\n pi=%d\n",i);qDebug(path.toLatin1().data());int x=( size().width()-(int)(pixmap.width()*w))/2;int y=( size().height()-(int)( pixmap.height()*h))/2; //x、y坐标控制显示位置painter.drawPixmap(x,y,(int)(pixmap.width()*w),(int)(pixmap.height()*h),pixmap,0,0,0,0);//通过图片的路径画出该图片用于显示qDebug("update %d,%d",pixmap.width(),pixmap.height());}void RenderArea::fun_area(){ //下一张图片功能实现w=1;h=1;if( (list.size()==0)|| list.size()==1){ //判断是否有图片用于显示return ;}if( ( (i>0) || (i==0) ) && ( (i<list.size()-1) ) ){ //单击按钮则向下显示一张图片i++;}else if(i==(list.size()-1)){ //当图片显示到最后一张将指针指导第一张i=0;}update();}void RenderArea::pre_area(){ //上一张图片功能实现w=1;h=1;if( (list.size()==0)|| list.size()==1){return;}if( (i<list.size() ) && (i>0) ){i--;}else if(i==0){i=list.size()-1;}update();}void RenderArea::Start(int p){ //循环播放图片功能int sum=0; //控制速度if(p==1){sum=1000; //快速播放}else if(p==2){sum=2000; //中速播放}else sum=3000; //慢速播放QTime t;bool b=true;bool a=true;if(i==(list.size()-1)){i=0;repaint();}while(b){if(i!=(list.size()-1)){while(a){if(t.elapsed()%sum== 0){ //Qtime控制时间break;}}i++;}else {b=false;}w=1;h=1;repaint();}}void RenderArea::Big(){ //扩放图片功能if(w<4) //最大比例{w=w*1.1; //每单击按钮图片扩大比例1.1h=h*1.1;update();}}void RenderArea::Small(){ //图片缩小功能if(w>0.1) //最小比例{w=w*0.9;h=h*0.9;update();}}效果图:五.测试与调试程序的功能实现部分是使用Qt 中QDir、QPixmap类实现的。

相关主题