嵌入式Linux驅(qū)動開發(fā)大作業(yè)教育材料_第1頁
嵌入式Linux驅(qū)動開發(fā)大作業(yè)教育材料_第2頁
嵌入式Linux驅(qū)動開發(fā)大作業(yè)教育材料_第3頁
嵌入式Linux驅(qū)動開發(fā)大作業(yè)教育材料_第4頁
嵌入式Linux驅(qū)動開發(fā)大作業(yè)教育材料_第5頁
已閱讀5頁,還剩16頁未讀 繼續(xù)免費閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報或認(rèn)領(lǐng)

文檔簡介

1、嵌入式linux驅(qū)動開發(fā)大作業(yè)專業(yè):計算機(jī)科學(xué)與技術(shù)班級: 計算機(jī)13-1班學(xué)號:名: 劉炳君軟硬件目錄一、系統(tǒng)分析與總體設(shè)計11.1 課題意義11.2 需求分析11.3 概要設(shè)計11.4 總體設(shè)計31.5 系統(tǒng)的開發(fā)環(huán)境31.5.1 嵌入式與android平臺的介紹31.5.2 linux介紹31.6 模塊圖31.6.1 圖片刷新模塊31.6.2 滑動處理模塊4二、系統(tǒng)的詳細(xì)設(shè)計52.1 用戶操作流程52.2 算法實現(xiàn)62.2.1 圖片的數(shù)據(jù)結(jié)構(gòu)62.2.2 圖片的切換72.2.3 消圖7三、系統(tǒng)實現(xiàn)與調(diào)試83.1 調(diào)試過程83.1.1 錯誤信息83.1.2 解決方

2、法83.2 系統(tǒng)運行8四、附有程序代碼10五、總結(jié)16一、系統(tǒng)分析與總體設(shè)計1.1 課題意義隨著嵌入式系統(tǒng)在手機(jī)領(lǐng)域的發(fā)展,消費者對嵌入式系統(tǒng)的相冊功能也越來越關(guān)注,對于嵌入式系統(tǒng)而言,在軟件方面,基于linux的android系統(tǒng)是較為完整的嵌入式操作系統(tǒng),eclipse下的android更是一個極具效率的軟件開發(fā)工具,因此“android”成為主流的嵌入式應(yīng)用開發(fā)系統(tǒng)。1.2 需求分析在相冊功能中,3d顯示是較為流行的功能。可以根據(jù)個人的需要自由的選擇圖片。功能要求如下:界面需求:良好的用戶界面、級別顯示和分?jǐn)?shù)顯示。把圖片放在界面上,用戶通過滑動來觀看圖片和選擇圖片。用一種顏色作為背景,最

3、好為藍(lán)綠色,寬度適中,要實現(xiàn)美感。滑動需求:實現(xiàn)動態(tài)的滑動。當(dāng)切換到另一張圖片時,圖片緩慢的切換到另一張圖片。使用戶的視覺效果更逼真?;瑒犹幚硎录寒?dāng)手觸摸到屏幕時,可通過向左、向右滑動來對圖片進(jìn)行向向左、向右切換。1.3 概要設(shè)計圖1-1為3d相冊的總體流程圖。圖1-1 基于android的3d相冊圖流程圖具體步驟如下:(1)顯示界面;(2)根據(jù)滑動判斷圖片的方向;(3)若是左邊,則向左進(jìn)行滑動。若是右邊,則向右進(jìn)行滑動。(4)圖片開始滑動。(5)圖片停止滑動。1.4 總體設(shè)計本界面簡潔明了,沒有什么花哨的東西,只要向左向右滑動就行了。操作者主要有觸摸屏來完成。觸摸屏可以進(jìn)行左右滑動的操作。

4、相冊中所用到的類如下圖所示:圖1-2 類圖1.5 系統(tǒng)的開發(fā)環(huán)境1.5.1 嵌入式與android平臺的介紹嵌入式系統(tǒng)作為芯片和軟件的集成體,在科學(xué)研究,工業(yè)控制,軍事技術(shù),醫(yī)療衛(wèi)生,消費電子等方面有著普遍的應(yīng)用,本軟件是基于android的研究平臺.android是一種基于linux的自由及開放源代碼的操作系統(tǒng),主要使用于移動設(shè)備,如智能手機(jī)和平板電腦,由google公司和開放手機(jī)聯(lián)盟領(lǐng)導(dǎo)及開發(fā)。尚未有統(tǒng)一中文名稱,中國大陸地區(qū)較多人使用“安卓”或“安致”。android操作系統(tǒng)最初由andy rubin開發(fā),主要支持手機(jī)。1.5.2 linux介紹linux是一套免費使用和自由傳播的類un

5、ix操作系統(tǒng),是一個基于posix和unix的多用戶、多任務(wù)、支持多線程和多cpu的操作系統(tǒng)。它能運行主要的unix工具軟件、應(yīng)用程序和網(wǎng)絡(luò)協(xié)議。它支持32位和64位硬件。linux繼承了unix以網(wǎng)絡(luò)為核心的設(shè)計思想,是一個性能穩(wěn)定的多用戶網(wǎng)絡(luò)操作系統(tǒng)。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;/* * 一個實現(xiàn)了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);setcontentview(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, ;imagead

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論