testts-ui-070111.tar.gz

  • liuyibing
    了解作者
  • Unix_Linux
    开发工具
  • 12KB
    文件大小
  • gz
    文件格式
  • 0
    收藏次数
  • 1 积分
    下载积分
  • 10
    下载次数
  • 2010-08-15 20:12
    上传日期
触摸屏测试程序:将触摸屏上的触摸轨迹呈现到LCD显示器上
testts-ui-070111.tar.gz
  • test
  • Makefile
    224B
  • peonyui.o
    12.6KB
  • testtsui
    11.9KB
  • peonyui.c
    9.6KB
  • peonyui.h
    734B
  • main.o
    6KB
  • main.c
    5.8KB
内容介绍
#include <fcntl.h> #include <linux/fb.h> #include <stdio.h> #include <sys/ioctl.h> #include <sys/mman.h> #include <unistd.h> #include <stdlib.h> #include <math.h> #include <string.h> #define HEIGHT 480//600 #define WIDTH 640//800 #define BPP 16 #define LINE_LEN ((((WIDTH * BPP + 7)/ 8) + 31) / 32 * 32) #define VIDEO_MEM_SIZE (HEIGHT * LINE_LEN) #define CROSS_LEN 4//40 static int FBHandle = -1; static int Width, Height, LineLen, FrameSize; static unsigned char *FrameAddr; void ui_cursor_show(unsigned short x, unsigned short y, unsigned short color) { unsigned short i, j; unsigned short *tmp = (unsigned short*)(FrameAddr + y * LineLen + x*2); printf("%s: x[%d] y[%d]\n", __FUNCTION__, x, y); #if 0 if((x>CROSS_LEN/2) && (x<WIDTH-CROSS_LEN/2) && (y>CROSS_LEN/2) && (y<HEIGHT-CROSS_LEN/2)) { //for(j=0; j<3; j++) { //tmp += j*LineLen; tmp -= CROSS_LEN/2; for(i=0; i<CROSS_LEN; i++) { tmp[i] |= color; } } tmp += CROSS_LEN/2; tmp -= CROSS_LEN/2*LineLen/2; for(j=0; j<CROSS_LEN; j++) { tmp += LineLen/2; tmp[0] |= color; } return ; } #endif if(x<=CROSS_LEN/2) { tmp -= x; for(i=0; i<CROSS_LEN/2+x; i++) { tmp[i] += color; } tmp += x; } else if(x>=WIDTH-CROSS_LEN/2) { tmp -= CROSS_LEN/2; for(i=0; i<WIDTH-x+CROSS_LEN/2; i++) { tmp[i] += color; } tmp += CROSS_LEN/2; } else { tmp -= CROSS_LEN/2; for(i=0; i<CROSS_LEN; i++) { tmp[i] += color; } tmp += CROSS_LEN/2; } if(y<=CROSS_LEN/2) { tmp -= y*LineLen/2; for(j=0; j<CROSS_LEN/2+y; j++) { tmp += LineLen/2; tmp[0] += color; } } else if(y>=HEIGHT-CROSS_LEN/2) { #if 0 tmp -= CROSS_LEN/2*LineLen/2; for(j=0; j<HEIGHT-y+CROSS_LEN/2; j++) { tmp += LineLen/2; tmp[0] += color; } #endif } else { tmp -= CROSS_LEN/2*LineLen/2; for(j=0; j<CROSS_LEN; j++) { tmp += LineLen/2; tmp[0] += color; } } } void ui_cursor_hide(unsigned short x, unsigned short y, unsigned short color) { unsigned short i, j; unsigned short *tmp = (unsigned short*)(FrameAddr + y * LineLen + x*2); #if 0 if((x>CROSS_LEN/2) && (x<WIDTH-CROSS_LEN/2) && (y>CROSS_LEN/2) && (y<HEIGHT-CROSS_LEN/2)) { //for(j=0; j<3; j++) { //tmp += j*LineLen; tmp -= CROSS_LEN/2; for(i=0; i<CROSS_LEN; i++) { tmp[i] -= color; } } tmp += CROSS_LEN/2; tmp -= CROSS_LEN/2*LineLen/2; for(j=0; j<CROSS_LEN; j++) { tmp += LineLen/2; tmp[0] -= color; } } #endif if(x<=CROSS_LEN/2) { tmp -= x; for(i=0; i<CROSS_LEN/2+x; i++) { tmp[i] -= color; } tmp += x; } else if(x>=WIDTH-CROSS_LEN/2) { tmp -= CROSS_LEN/2; for(i=0; i<WIDTH-x+CROSS_LEN/2; i++) { tmp[i] -= color; } tmp += CROSS_LEN/2; } else { tmp -= CROSS_LEN/2; for(i=0; i<CROSS_LEN; i++) { tmp[i] -= color; } tmp += CROSS_LEN/2; } if(y<=CROSS_LEN/2) { tmp -= y*LineLen/2; for(j=0; j<CROSS_LEN/2+y; j++) { tmp += LineLen/2; tmp[0] -= color; } } else if(y>=HEIGHT-CROSS_LEN/2) { tmp -= CROSS_LEN/2*LineLen/2; for(j=0; j<HEIGHT-y+CROSS_LEN/2; j++) { tmp += LineLen/2; tmp[0] -= color; } } else { tmp -= CROSS_LEN/2*LineLen/2; for(j=0; j<CROSS_LEN; j++) { tmp += LineLen/2; tmp[0] -= color; } } } void ui_line_show(unsigned short fx, unsigned short fy, unsigned short tx, unsigned short ty, unsigned short color) { unsigned short i; unsigned short *tmp; short dx, dy; float dxy; unsigned short tempx, tempy; printf("%s: fx[%d] fy[%d] tx[%d] ty[%d]\n", __FUNCTION__, fx, fy, tx, ty); if((fx>WIDTH) || (fy>HEIGHT) || (tx>WIDTH) || (ty>HEIGHT)) { printf("%s: ERROR++++++++ERROR\n", __FUNCTION__);exit(0); return ; } if(fy == ty) // V line { if(fx > tx) { tempx = fx; fx = tx; tx = tempx; } tmp = (unsigned short*)(FrameAddr + fy * LineLen); for(i=fx; i<tx; i++) { tmp[i] += color; } } else if(fx == tx) // H line { if(fy > ty) { tempy = fy; fy = ty; ty = tempy; } tmp = (unsigned short*)(FrameAddr + fy * LineLen + fx*2); for(i=0; i<ty-fy; i++) { tmp[0] += color; tmp += LineLen/2; } } else { dx = tx - fx; dy = ty - fy; if(abs(dx) > abs(dy)) { dxy = (float)abs(dy)/abs(dx); // printf("%s: dx[%d] dy[%d] dxy[%f]\n", __FUNCTION__, dx, dy, dxy); tmp = (unsigned short*)FrameAddr; for(i=0; i<abs(dx); i++) { if(dy rel='nofollow' onclick='return false;'> 0) tempy = fy + (unsigned short)(dxy*i); else if (fy > (unsigned short)(dxy*i)) tempy = fy - (unsigned short)(dxy*i); else tempy = 0; if(tempy >= Height) { tempy = Height -1; printf("%s: Height++++++++Height\n", __FUNCTION__); } if(dx > 0) { tempx = fx + i; } else { tempx = fx - i; } if(tempx >= Width) { tempx = Width -1; printf("%s: Width++++++++Width\n", __FUNCTION__); } // printf("%s: tempx[%d] tempy[%d]\n", __FUNCTION__, tempx, tempy); if((tempx>=Width) || (tempy>=Height)) { printf("%s: Width++++++++Height\n", __FUNCTION__);exit(0); } tmp[tempy*LineLen/2 + tempx] += color; } if(tempy != ty) tmp[ty*LineLen/2 + tx] += color; } else { dxy = (float)abs(dx)/abs(dy); // printf("%s: dx[%d] dy[%d] dxy[%f] abs(dxy)[%d]\n", __FUNCTION__, dx, dy, dxy, abs(dxy)); tmp = (unsigned short*)FrameAddr; for(i=0; i<abs(dy); i++) { if(dx rel='nofollow' onclick='return false;'> 0) tempx = fx + (unsigned short)(dxy*i); else if (fx > (unsigned short)(dxy*i)) tempx = fx - (unsigned short)(dxy*i); else tempx = 0; if(tempx >= Width) { tempx = Width -1; printf("%s: Width++++++++Width\n", __FUNCTION__); } if(dy > 0) { tempy = fy + i; } else { tempy = fy - i; } if(tempy >= Height) { tempy = Height -1; printf("%s: Height++++++++Height\n", __FUNCTION__); } // printf("%s: tempx[%d] tempy[%d]\n", __FUNCTION__, tempx, tempy); if((tempx>=Width) || (tempy>=Height)) { printf("%s: Width++++++++Height\n", __FUNCTION__);exit(0); } tmp[tempy*LineLen/2 + tempx] += color; } if(tempx != tx) tmp[ty*LineLen/2 + tx] += color; } } } void ui_line_hide(unsigned short fx, unsigned short fy, unsigned short tx, unsigned short ty, unsigned short color) { unsigned short i; unsigned short *tmp; printf("%s: fx[%d] fy[%d] tx[%d] ty[%d]\n", __FUNCTION__, fx, fy, tx, ty); if((fx>WIDTH) || (fy>HEIGHT) || (tx>WIDTH) || (ty>HEIGHT) || (fx>tx) || (fy>ty)) return ; if(fy == ty) // V line { tmp = (unsigned short*)(FrameAddr + fy * LineLen); for(i=fx; i<tx; i++) { tmp[i] -= color; } } else if(fx == tx) // H line { tmp = (unsigned short*)(FrameAddr + fy * LineLen + fx*2); for(i=0; i<ty-fy; i++) { tmp[0] -= color; tmp += LineLen/2; } } } void ui_area_show(unsigned short x, unsigned short y, unsigned short w, unsigned short h, unsigned short color) { printf("%s: x[%d] y[%d] w[%d] h[%d] color[0x%04x]\n", __FUNCTION__, x, y, w, h, color); if((x+w > WIDTH) || (y+h > HEIGHT)) { return ; } ui_line_show(x, y, x, y+h, color); ui_line_show(x, y, x+w, y, color); ui_line_show(x+w, y, x+w, y+h, color); ui_line_show(x, y+h, x+w, y+h, color); } void ui_area_hide(unsigned short x, unsigned short y, unsigned short w, unsigned short h, unsigned short color) { printf("%s: x[%d] y[%d] w[%d] h[%d] color[0x%04x]\n", __FUNCTION__, x, y, w, h, color); if((x+w > WIDTH) || (y+h > HEIGHT)) { return ; } ui_line_hide(x, y, x, y+h, color); ui_line_hide(x, y, x+w, y, color); ui_line_hide(x+w, y, x+w, y+h, color); ui_line_hide(x, y+h, x+w, y+h, color); } void
评论
    相关推荐
    • QtEmbedded_applied_in_ES_Linux.rar
      Qt/Embedded延续了Qt在桌面系统的所有功能,丰富的API接口和基于组件的编程模型使得嵌入式Linux系统中的应用程序开发更加便捷。由于Qt/Embedded本身面向高端的手持设备和移动设备,将成为未来嵌入式系统的主要GUI。
    • uperf:Android的Userspace性能控制器
      Linux层面读取Android的触摸屏输入信号,识别点击和滑动 主动采样系统负载,识别例如APP启动的瞬间重负载 监听cpuset分组更新操作,识别正在操作的APP发生切换 监听唤醒锁更新操作,识别屏幕是否熄灭 监听注入到...
    • 百度地图开发java源码-Record-data:记录数据
      百度地图开发java源码 hosts文件的位置 C:\Windows\System32\drivers\etc 映射 192.168.1.126 js相关资料 [highcharts中文网(各种图:折线、...测试软件 phpstrom 安装GO语言编辑扩展 plugins->Gogland redis Markdown
    • qgc-dev-guide:QGroundControl开发人员指南
      与基于桌面鼠标的用户界面相比,QGC用户界面的目标更多是针对平板电脑+触摸屏风格的用户界面。 这使单个ui易于创建,因为平板电脑风格的ui往往也可以在台式机/笔记本电脑上正常工作。 注意:《 QGroundControl开发...
    • Multimedia-Note
      ###Android Android 是一种基于 Linux 的操作系统,主要用于智能手机和平板电脑等触摸屏移动设备。 开发环境和工具 本项目在与Android开发工具集成的Eclipse IDE上使用J2SE和android SDK 2.1开发,运行在Win7操作...
    • Moblin.org开源项目
      《Moblin.org-project》-中文版 市场上出现了一种新的设备,它能够访问Internet上丰富的内容,同时没有与PC相关的复杂性。这些设备以各种形式出现,从移动互联网设备(Mobile Internet Devices,MID)、便携式媒体...
    • awtk-linux-fb:linux framebuffer的awtk端口
      AWTK 针对 arm-linux 平台的移植。 是为嵌入式系统开发的 GUI 引擎库。 是 AWTK 在 arm-linux 上的移植。 本项目以 为载体移植,其它开发板可能要做些修改,有问题请请创建 issue。 使用方法 获取源码 以下三者...
    • 新版Android开发教程.rar
      Linux (tested on Linux Ubuntu Dapper Drake) Supported Supported Supported Supported Development Development Development Development Environments Environments Environments Environments Eclipse IDE o...
    • mini2440用户手册.zip
      mini2440最新的用户手册,有关于mini2440详细的介绍
    • NS2example.rar
      在ns2下实现无线传感器网络仿真,多个节点进行网络活动