嵌入式開發第16天(開發板觸控驅動,mmap)

2021-07-15 19:44:53 字數 3047 閱讀 7646

********************=lcd***************

lcd驅動檔案或者它的路徑:/dev/fb0

測試是否是lcd驅動檔案:cat /smarthome/jpg_dir/10.jpg > /dev/fb0

觸控庫安裝

1、將觸控庫放在ubuntu與windows共享目錄中

2、sudo -s (密碼:123456)

3、cp /mnt/hgfs/linuxshare/tslib-1.4.tar.bz2 /home/gec/     //將觸控庫複製到家目錄

4、cd /home/gec

5、tar -jxvf tslib-1.4.tar.bz2   //解壓觸控庫檔案

6、cd tslib-1.4/               //進入觸控庫目錄

7、./configure --host=arm-linux --prefix=/usr/local/arm ac_cv_func_malloc_0_nonnull=yes

配置觸控庫 

8、編譯:make

9、安裝庫:make install

linux下以so結尾的為動態庫,以.a結尾的為靜態庫

存放座標的相關資訊的結構體

/usr/local/arm/include/tslib.h標頭檔案

struct ts_sample ;

編譯命令:arm-linux-gcc ts.c -o ts -i /usr/local/arm/include/ -l /usr/local/arm/lib -lts

指定頭的路徑              指定庫存路徑           指定庫名

螢幕校準:

cd /tslib/bin/

./ts_calibrate

練習:在螢幕上面自定義兩個控制,通過控制來切換效果(一張橫的七色圖,一張是堅的八色圖)

mmap() 檔案對映:將乙個檔案或者其它物件對映進記憶體。

#include

void *mmap(void *addr, size_t len, int prot, int flags,

int fildes, off_t off);

返回值: 成功:對映記憶體的位址

失敗: map_failed

void *addr:對映時給定的位址,如果設定為null,則系統會自動尋找最佳的對映起始位址

size_t len:對映記憶體的大小

int prot  :

prot_read           data can be read.

prot_write          data can be written.

prot_exec           data can be executed.

prot_none           data cannot be accessed.

int flags:

map_shared          changes are shared.

map_private         changes are private.

map_fixed           interpret addr exactly.

int fildes:檔案描述符

off_t off:檔案對映開始區的偏移量

munmap 撤消對映

#include

int munmap(void *addr, size_t len);

void *addr:對映的位址

size_t len:對映的大小

練習:1、在指向的區域(350,200)畫乙個(150x100)紅色控制項

2、劃屏操作,向左划動藍色,右劃黃色

#include

#include "tslib.h"

#include

#include

#include

#include

#include

#define dev_name "/dev/fb0"

int main(void)

addr=(unsigned int *)mmap(null, 480*800*4,prot_read|prot_write,map_shared,ts,0);

if (addr == map_failed)

perror("error mmap");

for(j=200;j<300;j++)

for(i=0;i<150;i++)

*(addr+((800*j)+350+i))=color;

munmap(addr,480*800*4);

close(ts);

return 0;

}22222222222222222222222222222222222

#include

#include "tslib.h"

#include

#include

#include

#include

#define dev_name "/dev/event0"

left(void)

; //rgb

//開啟螢幕lcd

lcd_fd = open("/dev/fb0",o_rdwr);

if(lcd_fd == -1)

for(x=0;x<480;x++)}}

};right(void)

; //rgb

//開啟螢幕lcd

lcd_fd = open("/dev/fb0",o_rdwr);

if(lcd_fd == -1)

for(j=0;j<7;j++)

}close(lcd_fd);

lcd_fd=0;

return 0;

};int main(void)

//配置觸控螢幕,配置外掛程式

ret = ts_config(ts);

if(ret == -1)

while(1)

if(sub<0&&samp.pressure==200)

right();}}

return 0;}

嵌入式開發板 嵌入式Linux開發板的選擇

很多電子軟體工程師使用stm32系列的微控制器入門,學習linux是技術公升級的最好選擇之一。很多小夥伴對linux的認知為只知道它是乙個開源作業系統,有乙個核心,僅此而已。但是掌握了linux技術之後卻能夠在技術領域大有一番作為。我們來看一下學習linux之後的一些出路 那麼在進行linux知識的...

嵌入式開發板系統安裝

在我們桌面的作業系統,無論是windows還是 ubuntu系統一般都安裝在電腦的硬碟中,那麼,嵌入式linux系統類似,也安裝在它的 硬碟 中,nandflash。首先明白嵌入式linux系統包含的幾個主要部分,linux kernel 檔案系統 國嵌開發板 mini2440 ok210 ok64...

嵌入式up tech開發板觸控螢幕的配置

export qtdir pwd export ld library path pwd lib lib export tslib tsdevice dev event0 export tslib plugindir pwd lib ts export tslib consoledevice none...