嵌入式Linux驱动开发大作业[教育材料].doc

上传人:rrsccc 文档编号:9559381 上传时间:2021-03-05 格式:DOC 页数:21 大小:1.16MB
返回 下载 相关 举报
嵌入式Linux驱动开发大作业[教育材料].doc_第1页
第1页 / 共21页
嵌入式Linux驱动开发大作业[教育材料].doc_第2页
第2页 / 共21页
亲,该文档总共21页,到这儿已超出免费预览范围,如果喜欢就下载吧!
资源描述

《嵌入式Linux驱动开发大作业[教育材料].doc》由会员分享,可在线阅读,更多相关《嵌入式Linux驱动开发大作业[教育材料].doc(21页珍藏版)》请在三一文库上搜索。

1、嵌入式Linux驱动开发大作业专业:计算机科学与技术班级: 计算机13-1班学号: 13034480149姓名: 刘炳君软硬件目录一、系统分析与总体设计11.1 课题意义11.2 需求分析11.3 概要设计11.4 总体设计31.5 系统的开发环境31.5.1 嵌入式与Android平台的介绍31.5.2 Linux介绍31.6 模块图31.6.1 图片刷新模块31.6.2 滑动处理模块4二、系统的详细设计52.1 用户操作流程52.2 算法实现62.2.1 图片的数据结构62.2.2 图片的切换72.2.3 消图7三、系统实现与调试83.1 调试过程83.1.1 错误信息83.1.2 解决方

2、法83.2 系统运行8四、附有程序代码10五、总结16一、系统分析与总体设计1.1 课题意义随着嵌入式系统在手机领域的发展,消费者对嵌入式系统的相册功能也越来越关注,对于嵌入式系统而言,在软件方面,基于Linux的Android系统是较为完整的嵌入式操作系统,Eclipse下的Android更是一个极具效率的软件开发工具,因此“Android”成为主流的嵌入式应用开发系统。1.2 需求分析在相册功能中,3D显示是较为流行的功能。可以根据个人的需要自由的选择图片。功能要求如下:界面需求:良好的用户界面、级别显示和分数显示。把图片放在界面上,用户通过滑动来观看图片和选择图片。用一种颜色作为背景,最

3、好为蓝绿色,宽度适中,要实现美感。滑动需求:实现动态的滑动。当切换到另一张图片时,图片缓慢的切换到另一张图片。使用户的视觉效果更逼真。滑动处理事件:当手触摸到屏幕时,可通过向左、向右滑动来对图片进行向向左、向右切换。1.3 概要设计图1-1为3D相册的总体流程图。图1-1 基于Android的3D相册图流程图具体步骤如下:(1)显示界面;(2)根据滑动判断图片的方向;(3)若是左边,则向左进行滑动。若是右边,则向右进行滑动。(4)图片开始滑动。(5)图片停止滑动。1.4 总体设计本界面简洁明了,没有什么花哨的东西,只要向左向右滑动就行了。操作者主要有触摸屏来完成。触摸屏可以进行左右滑动的操作。

4、相册中所用到的类如下图所示:图1-2 类图1.5 系统的开发环境1.5.1 嵌入式与Android平台的介绍嵌入式系统作为芯片和软件的集成体,在科学研究,工业控制,军事技术,医疗卫生,消费电子等方面有着普遍的应用,本软件是基于Android的研究平台.Android是一种基于Linux的自由及开放源代码的操作系统,主要使用于移动设备,如智能手机和平板电脑,由Google公司和开放手机联盟领导及开发。尚未有统一中文名称,中国大陆地区较多人使用“安卓”或“安致”。Android操作系统最初由Andy Rubin开发,主要支持手机。1.5.2 Linux介绍Linux是一套免费使用和自由传播的类Un

5、ix操作系统,是一个基于POSIX和UNIX的多用户、多任务、支持多线程和多CPU的操作系统。它能运行主要的UNIX工具软件、应用程序和网络协议。它支持32位和64位硬件。Linux继承了Unix以网络为核心的设计思想,是一个性能稳定的多用户网络操作系统。1.6 模块图1.6.1 图片刷新模块在图片刷新模块中可以获取新的图片private void transformImageBitmap(ImageView child, Transformation t,int rotationAngle) mCamera.save();final Matrix imageMatrix = t.getMat

6、rix();final int imageHeight = child.getLayoutParams().height;final int imageWidth = child.getLayoutParams().width;final int rotation = Math.abs(rotationAngle);mCamera.translate(0.0f, 0.0f, 100.0f);/ As the angle of the view gets less, zoom inif (rotation mMaxRotationAngle) rotationAngle = (rotationA

7、ngle mMaxRotationAngle) rotationAngle = (rotationAngle 0) ? -mMaxRotationAngle: mMaxRotationAngle;transformImageBitmap(ImageView) child, t, rotationAngle);return true;protected void onSizeChanged(int w, int h, int oldw, int oldh) mCoveflowCenter = getCenterOfCoverflow();super.onSizeChanged(w, h, old

8、w, oldh);private void transformImageBitmap(ImageView child, Transformation t,int rotationAngle) mCamera.save();final Matrix imageMatrix = t.getMatrix();final int imageHeight = child.getLayoutParams().height;final int imageWidth = child.getLayoutParams().width;final int rotation = Math.abs(rotationAn

9、gle);mCamera.translate(0.0f, 0.0f, 100.0f);/ As the angle of the view gets less, zoom inif (rotation mMaxRotationAngle) float zoomAmount = (float) (mMaxZoom + (rotation * 1.5);mCamera.translate(0.0f, 0.0f, zoomAmount);(ImageView) (child).setAlpha(int) (255 - rotation * 2.5);mCamera.rotateY(rotationA

10、ngle);mCamera.getMatrix(imageMatrix);imageMatrix.preTranslate(-(imageWidth / 2), -(imageHeight / 2);imageMatrix.postTranslate(imageWidth / 2), (imageHeight / 2);mCamera.restore();ImageAdapter.javapackage com.android.CustomGallery;import android.content.Context;import android.graphics.Bitmap;import a

11、ndroid.graphics.BitmapFactory;import android.graphics.Canvas;import android.graphics.LinearGradient;import android.graphics.Matrix;import android.graphics.Paint;import android.graphics.PorterDuffXfermode;import android.graphics.Bitmap.Config;import android.graphics.PorterDuff.Mode;import android.gra

12、phics.Shader.TileMode;import android.graphics.drawable.BitmapDrawable;import android.view.View;import android.view.ViewGroup;import android.widget.BaseAdapter;import android.widget.ImageView;public class ImageAdapter extends BaseAdapter int mGalleryItemBackground;private Context mContext;private int

13、 mImageIds;private ImageView mImages;public ImageAdapter(Context c, int ImageIds) mContext = c;mImageIds = ImageIds;mImages = new ImageViewmImageIds.length;public boolean createReflectedImages() / The gap we want between the reflection and the original imagefinal int reflectionGap = 4;int index = 0;

14、for (int imageId : mImageIds) Bitmap originalImage = BitmapFactory.decodeResource(mContext.getResources(), imageId);int width = originalImage.getWidth();int height = originalImage.getHeight();/ This will not scale but will flip on the Y axisMatrix matrix = new Matrix();matrix.preScale(1, -1);Bitmap

15、reflectionImage = Bitmap.createBitmap(originalImage, 0,height / 2, width, height / 2, matrix, false);Bitmap bitmapWithReflection = Bitmap.createBitmap(width,(height + height / 2), Config.ARGB_8888);Canvas canvas = new Canvas(bitmapWithReflection);canvas.drawBitmap(originalImage, 0, 0, null);Paint de

16、afaultPaint = new Paint();canvas.drawRect(0, height, width, height + reflectionGap,deafaultPaint);/ Draw in the reflectioncanvas.drawBitmap(reflectionImage, 0, height + reflectionGap, null);Paint paint = new Paint();LinearGradient shader = new LinearGradient(0, originalImage.getHeight(), 0, bitmapWi

17、thReflection.getHeight()+ reflectionGap, 0x70ffffff, 0x00ffffff, TileMode.CLAMP);/ Set the paint to use this shader (linear gradient)paint.setShader(shader);/ Set the Transfer mode to be porter duff and destination inpaint.setXfermode(new PorterDuffXfermode(Mode.DST_IN);/ Draw a rectangle using the

18、paint with our linear gradientcanvas.drawRect(0, height, width, bitmapWithReflection.getHeight()+ reflectionGap, paint);BitmapDrawable bd = new BitmapDrawable(bitmapWithReflection);bd.setAntiAlias(true);ImageView imageView = new ImageView(mContext);/imageView.setImageBitmap(bitmapWithReflection);ima

19、geView.setImageDrawable(bd);imageView.setLayoutParams(new GalleryFlow.LayoutParams(160, 240);/ imageView.setScaleType(ScaleType.MATRIX);mImagesindex+ = imageView;return true;public int getCount() return mImageIds.length;public Object getItem(int position) return position;public long getItemId(int po

20、sition) return position;public View getView(int position, View convertView, ViewGroup parent) return mImagesposition;public float getScale(boolean focused, int offset) /* Formula: 1 / (2 offset) */return Math.max(0, 1.0f / (float) Math.pow(2, Math.abs(offset);MainActivity.javapackage com.android.Cus

21、tomGallery;/* * 一个实现了3D效果的Gallery,就像iPhone中的相册浏览一样炫 */import android.app.Activity;import android.os.Bundle;public class MainActivity extends Activity /* Called when the activity is first created. */Overridepublic void onCreate(Bundle savedInstanceState) super.onCreate(savedInstanceState);setContentV

22、iew(R.layout.main);int images = R.drawable.photo1, R.drawable.photo2,R.drawable.photo3, R.drawable.photo4, R.drawable.photo5,R.drawable.photo6, R.drawable.photo7, R.drawable.photo8, ;ImageAdapter adapter = new ImageAdapter(this, images);adapter.createReflectedImages();GalleryFlow galleryFlow = (Gall

23、eryFlow) findViewById(R.id.gallery_flow);galleryFlow.setAdapter(adapter);AA.javapackage com.android.CustomGallery;import android.content.Context;import android.util.AttributeSet;import android.widget.Gallery;public class AA extends Gallery public AA(Context context, AttributeSet attrs) super(context

24、, attrs);/ TODO Auto-generated constructor stubmain.xml五、总结经过这次课程的学习,我加深了关于linux的知识。对于今后的学习有一定的帮助。同时也发现很多问题自己还是解决不了的,需要通过老师和同学们的帮助。过程中遇到了很多问题,有的是知识存储不足,有的是考虑不够周全,但最后还是做出来的。与此同时,我还学到了Android方面 的不少知识,为以后的Android开发之路打下了坚实的基础。通过这次的学习,让我懂得了思考的重要性。我们不可能做到面面俱到,但一定要做到步步扎实,作为一个程序编程人员,要保持清醒的头脑,以现实为依据,让自己的每一行代码都能实现自己的意义。

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 社会民生


经营许可证编号:宁ICP备18001539号-1