#include <string.h>
#include "lcdlib.h"
#include "2410addr.h"
#include "2410lib.h"
#include "def.h"
//#include "win_gui.h"
int TextEdit_x = 5,TextEdit_y = 32,TextEdit_id = 0;
int g_xMax = 240;
int g_yMax = 320;
int mGuiOrientation = GUI_VERTICAL;
/*===================STN 7寸微彩屏==========================*/
#ifdef STN
int (*frameBuffer12Bit)[640*6/8];
//STN微彩LCD初始化函数 (640*480)
void LCD_Init(void)
{
rLCDCON1=0x548;
// 8-bit single scan,8bpp CSTN,ENVID=off
rLCDCON2=0x790000;
rLCDCON3=0xef10;
rLCDCON4=0xd00;
rLCDCON5=0;
rLCDSADDR1 = 0x18000000; //显存地址
rLCDSADDR2 = 0x71ac0;
rLCDSADDR3 = 0xf01e0;
rDITHMODE = 0x12210;
rREDLUT =0;
rGREENLUT=0;
rBLUELUT =0;
rLCDCON1|=1; // ENVID=ON
rGPGUP = 0xffff;
rGPGDAT = 0xa8ff;
rGPGCON = 0xff95fdba;
}
//清屏函数
void clrsrc(COLOR mcolor)
{
unsigned int *p;
unsigned int P1,P2,P3;
int R,G,B;
R = (mcolor & 0xf00) >> 8;
G = (mcolor & 0x0f0) >> 4;
B = (mcolor & 0x00f);
P1 = (unsigned int) ((R<<28)|(G<<24)|(B<<20)|(R<<16)|(G<<12)|(B<<8)|(R<<4)|G);
P2 = (unsigned int) ((B<<28)|(R<<24)|(G<<20)|(B<<16)|(R<<12)|(G<<8)|(B<<4)|R);
P3 = (unsigned int) ((G<<28)|(B<<24)|(R<<20)|(G<<16)|(B<<12)|(R<<8)|(G<<4)|B);
for(p=(unsigned int*)VideoAddrStart;p<(unsigned int*)VideoAddrEnd;)
{
*p = P1;
p++;
*p = P2;
p++;
*p = P3;
p++;
}
return ;
}
//画点函数
int setpixel(int x,int y,unsigned short pencolor)
{
_PutCstn12Bit(x,Y_MAX-y,pencolor);
return 1;
}
void _PutCstn12Bit(int x,int y,unsigned short c)
{
U32 z;
frameBuffer12Bit= (int (*)[640*6/8])VideoAddrStart;
z=((x)%8);
if(x<640&& y<485)
{
if((z%3)!=2)
frameBuffer12Bit[(y)][(x)*3/8]=( frameBuffer12Bit[(y)][(x)*3/8] & ~(0xfff00000>>(((z/3)*4)+((z)%3)*12) )|((c&0xfff)<<(20-(((z/3)*4)+((z)%3)*12))) );
else
{
if(z==2)
{
frameBuffer12Bit[(y)][(x)*3/8]=( (frameBuffer12Bit[(y)][(x)*3/8]
& ~(0xff)) | ((c&0xff0)>>4) );
frameBuffer12Bit[(y)][((x)*3/8)+1]=( (frameBuffer12Bit[(y)][((x)*3/8)+1]
& ~(0xf0000000)) | ((c&0xf)<<28) );
}
else if(z==5)
{
frameBuffer12Bit[(y)][(x)*3/8]=( (frameBuffer12Bit[(y)][(x)*3/8]
& ~(0xf)) | ((c&0xf00)>>8) );
frameBuffer12Bit[(y)][((x)*3/8)+1]=( (frameBuffer12Bit[(y)][((x)*3/8)+1]
& ~(0xff000000)) | ((c&0xff)<<24) );
}
}
}
}
//取色函数
COLOR getpixel(int x,int y)
{
int color;
color = _GetCstn12Bit(x,y);
return color;
}
unsigned short _GetCstn12Bit(int x,int y)
{
int z;
int total;
int temp_h;
int temp_l;
frameBuffer12Bit= (int (*)[640*6/8])VideoAddrStart;
z=((x)%8);
if(x<640&& y<485)
{
if((z%3)!=2)
{
temp_h =( frameBuffer12Bit[(y)][(x)*3/8] & (0xfff00000>>(((z/3)*4)+((z)%3)*12) ) );
total = temp_h>>(20-((z/3)*4+(z%3)*12));
}
else
{
if(z==2)
{
temp_h=( (frameBuffer12Bit[(y)][(x)*3/8]& (0xff)) );
temp_l=( (frameBuffer12Bit[(y)][((x)*3/8)+1]& (0xf0000000)));
total = temp_h<<4+temp_l>>28;
}
else if(z==5)
{
temp_h =( (frameBuffer12Bit[(y)][(x)*3/8]
& (0xf)) );
temp_l =( (frameBuffer12Bit[(y)][((x)*3/8)+1]
& (0xff000000)) );
total = temp_h<<8 + temp_l>>24;
}
}
return (unsigned short)total;
}
return 0;
}
//24bit红绿蓝转换为12bit
int RGB(unsigned char Red,unsigned char Green,unsigned char Blue)
{
return ( ((Red&0xf0) << 4) | (Green&0xf0) | ((Blue&0xf0) >> 4) );
}
unsigned short ColorPC(unsigned char Msb, unsigned char Lsb)
{
unsigned short color;
unsigned short red, green, blue;
color = (Msb << 8) | Lsb;
red = (color & 0x3C00) >> 2;
green = (color & 0x1E0) >> 1;
blue = (color & 0xF);
color = red | green | blue;
return color;
}
/*===================TFT 3.4寸真彩屏==========================*/
#else
//TFT真彩LCD初始化函数 (320*240)
void LCD_Init(void)
{
rLCDCON2=0x14FC081;
// rLCDCON3=0x188EF0F; // 旧屏
rLCDCON3=0x6<<19 | 0xEF0F; // 新屏
rLCDCON4=0xD;
rLCDCON5=0xB09;
rLCDSADDR1=0x18000000;
rLCDSADDR2=0x12c00;
rLCDCON1=0x479;
rLCDSADDR3=0x0;
rREDLUT=0x0;
rGREENLUT=0x0;
rBLUELUT=0x0;
rDITHMODE=0x0;
rTPAL=0x0;
rLCDINTPND=0x0;
rLCDSRCPND=0x0;
rLCDINTMSK=0x3;
rLPCSEL=0x4;
}
//画点函数
int setpixel(int x,int y,unsigned short pencolor)
{
int movetop; // THE PIXEL ADDRESS
short *p;
if (x<0||x>=g_xMax) return ERROR;
if (y<0||y>=g_yMax) return ERROR;
if (mGuiOrientation == GUI_HORIZONTAL)
movetop=(x*g_yMax+y)<<1; // 指向所要显示的像素偏移地址(一个像素占两个字节)
else
movetop=((g_yMax-y)*g_xMax-(g_xMax-x))<<1; // 指向所要显示的像素偏移地址(一个像素占两个字节)
p=(short *)(VideoAddrStart|movetop);
*p=pencolor;
return 1;
}
// 取色函数
COLOR getpixel(int x,int y)
{
int movetop; // THE PIXEL ADDRESS
short *p;
if (x<0||x>=g_xMax) return ERROR;
if (y<0||y>=g_yMax) return ERROR;
if (mGuiOrientation == GUI_HORIZONTAL)
movetop=(x*g_yMax+y)<<1; // 指向所要显示的像素偏移地址(一个像素占两个字节)
else
movetop=((g_yMax-y)*g_xMax-(g_xMax-x))<<1; // 指向所要显示的像素偏移地址(一个像素占两个字节)
p=(short *)(VideoAddrStart|movetop);
return *p;
}
// 清屏函数
void clrsrc(COLOR mcolor)
{
short *p;
for(p=(short*)VideoAddrStart;p<(short*)VideoAddrEnd;p++) *p = mcolor;
}
// 24bit红绿蓝转换为16bit
int RGB(unsigned char Red,unsigned char Green,unsigned char Blue)
{
return ( ((Red>>3)<<11) | ((Green>>2)<<5) | (Blue >> 3) );
}
unsigned short ColorPC(unsigned char Msb, unsigned char Lsb)
{
unsigned short color;
unsigned short temp;
temp = (Msb << 8) | Lsb;
color = (temp << 1) & 0xFFC0;
color |= temp & 0x1F;
return color;
}
#endif
/*===================共用函数==========================*/
// 画图函数,图像可以是16位,或24位,但尺寸必需为320*240
int ShowImage(unsigned char *p , int StartX, int StratY, int mode)
{
int x,y;
unsigned char red;
unsigned char green;
unsigned char blue;
unsigned short color;
unsigned short fileType;
unsigned short imageColorBit;
int height;
int width;
// int imageSize;
int patch = 0;
imageColorBit = p[28]; // 取得图片的颜色位数
fileType = LINK_HWORD(p[1], p[0]); // 文件类型
// imageSize = LINK_WORD(p[37], p[36], p[35], p[34]); // 取得图象的总大小
height = LINK_WORD(p[25], p[24], p[23], p[22]); // 取得图象的宽度,单位是象素
width = LINK_WORD(p[21], p[20], p[19], p[18]); // 取得图象的宽度,单位是象素
if(mode == 1) // mode为1时以黑色填充背景
memset((short*)VideoAddrStart, 0, g_xMax*g_yMax*2);
p += 54; // 指向图像内容
if(fileType != 0x4D42) // 判断是否BMP文件
{
Rewriteletter((g_xMax>>1)-32 ,g_yMax>>1,"无效位图",1,1,RGB(255,255,255),RGB(0,0,0));
return FALSE; // 显示BMP位图失败
}
else
{
if(imageColorBit == 16) // 判断图片颜色位数是否16位
{
patch = (4 - width * 2 % 4) % 4; // 补0的个数
for(y=StratY; y<height+StratY; y++)
{
for(x=StartX; x<width+StartX; x++)
{
if(y < g_yMax && x < g_xMax)
{
color = ColorPC(p[1], p[0]);
setpixel(x ,y ,color);
}
p += 2;
}
p += patch; // 跳过每行补上的0
}
}
else
{
patch = (4 - (width * 3) % 4) % 4; // 补0的个数
for(y=StratY; y<height+StratY; y++)
{
for(x=StartX; x<width+StartX; x++)
{
blue = p[0];
green = p[1];
red = p[2];
p += 3;
if(y < g_yMax && x < g_xMax)
没有合适的资源?快使用搜索试试~ 我知道了~
基于s3c2410的模块程序-ADC和触摸屏源代码
共273个文件
h:72个
o:56个
c:48个
需积分: 10 11 下载量 36 浏览量
2010-11-10
20:32:11
上传
评论
收藏 2.04MB RAR 举报
温馨提示
基于s3c2410的模块程序-ADC和触摸屏源代码: 包括实现原理ppt讲义,感谢我的专业老师谭曼琼老师,其出版一书《嵌入式linux系 统实训教程》,有兴趣的可以看看,讲的比较详细 实验板:ARM S3C2410开发板 软件:ads1.2 multi-ICE SERVER 2.2
资源推荐
资源详情
资源评论
收起资源包目录
基于s3c2410的模块程序-ADC和触摸屏源代码 (273个子文件)
My_Adc_touch.axf 115KB
test.axf 115KB
test.axf 114KB
MyClock touch.axf 106KB
MyClock touch.axf 106KB
MyClock touch.axf 103KB
touch.axf 101KB
test.axf 100KB
My_Adc_touch.bin 32KB
test.bin 32KB
test.bin 31KB
MyClock touch.bin 29KB
MyClock touch.bin 29KB
MyClock touch.bin 28KB
test.bin 27KB
touch.bin 27KB
练习.bmp 1.83MB
Y坐标转换.bmp 779KB
X坐标转换.bmp 694KB
Y坐标转换.bmp 620KB
X坐标转换.bmp 480KB
触摸屏坐标系.bmp 355KB
lcdlib.c 18KB
lcdlib.c 18KB
lcdlib.c 18KB
consol.c 16KB
consol.c 16KB
consol.c 16KB
consol.c 16KB
consol.c 16KB
consol.c 16KB
consol.c 16KB
consol.c 16KB
main.c 13KB
lcdlib.c 12KB
lcdlib.c 12KB
lcdlib.c 12KB
lcdlib.c 12KB
lcdlib.c 12KB
main.c 12KB
2410lib.c 10KB
2410lib.c 10KB
2410lib.c 10KB
2410lib.c 10KB
2410lib.c 10KB
2410lib.c 10KB
2410lib.c 10KB
2410lib.c 10KB
main.c 10KB
touch.c 8KB
touch.c 8KB
touch.c 8KB
touch.c 7KB
main.c 7KB
main.c 6KB
main.c 6KB
main.c 4KB
main.c 4KB
INT.c 3KB
INT.c 3KB
INT.c 3KB
INT.c 3KB
INT.c 3KB
INT.c 3KB
INT.c 3KB
INT.c 3KB
touch.c 3KB
touch.c 3KB
touch.c 3KB
touch.c 3KB
ARM920T.cfg 127B
ARM920T.cfg 127B
ARM920T.cfg 127B
ARM920T.cfg 127B
Thumbs.db 12KB
Thumbs.db 7KB
Thumbs.db 6KB
S3c2410x.h 39KB
S3c2410x.h 39KB
S3c2410x.h 39KB
S3c2410x.h 39KB
S3c2410x.h 39KB
S3c2410x.h 39KB
S3c2410x.h 39KB
S3c2410x.h 39KB
2410addr.h 35KB
2410addr.h 35KB
2410addr.h 35KB
2410addr.h 35KB
2410addr.h 35KB
2410addr.h 35KB
2410addr.h 35KB
2410addr.h 35KB
consol.h 9KB
consol.h 9KB
consol.h 9KB
consol.h 9KB
consol.h 9KB
consol.h 9KB
consol.h 9KB
共 273 条
- 1
- 2
- 3
资源评论
tangxianghenggood
- 粉丝: 136
- 资源: 65
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功