⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gpcdrv.c

📁 基于东南大学开发的SEP3203的ARM7中的所有驱动
💻 C
📖 第 1 页 / 共 2 页
字号:
///////////////////////////////////////////////////////////////////////////////////
//
//      Copyright (C) 1999 SEIKO EPSON Corp.
//      All Rights Reserved
//
//      File name :gpcdrv.c
//      Function  :
//          This is a device driver(HAL) program
//      Revision history
//          Ver 0.10 1999/09/10  SungYoung Shin       Start        
//          Ver 0.11 2001/05/11  Catherine Ni	      Add that initialize TCM-A1263 
//          Ver 0.20 2000/04/13  SungYoung Shin       Update For Alpha2
//
///////////////////////////////////////////////////////////////////////////////////

#include "gpc.h"
//#include "gpcdrv.h"
//#include "gpc.h"
//#include "c33208.h"

unsigned char VRAM[SCREEN_HEIGHT][SCREEN_WIDTH];
static void seSetMonoImageLine( PPHYIMAGEINFO ppii );

//-------------------------------------------------------------------------
//    seGetScreenSize()
//
//  alculates and returns the width and height, in pixels, and returns the
//  the value in 'width' and 'height'.
//
//  Parameters:
//      width        - pointer to an integer to receive the width of the display
//      height       - pointer to an integer to receive the height of the display.
//    Returns:
//      GPC_ERR_OK
//-------------------------------------------------------------------------
U16 seGetScreenSize(S16 *width, S16 *height)
{

    // If we're in portrait mode exchange the width and height calculations.
    // if (0x80 == (seGetReg(REG_PORTRAIT_MODE) & 0x80))
    {
        *width  = 120;
        *height = 160;
    }
   // else    // Landscape mode
   // {
    //    *width  = 160;
    //    *height = 120;
   // }

    return GPC_ERR_OK;
}



//-------------------------------------------------------------------------
//    seInit()
//
//This program Initial TCM-A1263:
//
//	Text & Graphic mode:
//	Total pages:		160 	(   page 00: up side 	to     page 160:    down side)
//	Columns in each page:	120	( Column 0: left side 	to  Column 119: right side)
//	Bits in each column:	8 bits 	(   R:D7~D5	G:D4~D2	    B:D1~D0)
//	Dot Matrix mode:
//	Total resolution:
//	X:	120 dots;	Y:	160 dots
//	 (0,0) left-up corner to (119,159) right-down corner
//
//
//  Parameters: unsigned long para
//
//    Returns:
//      GPC_ERR_OK
//-------------------------------------------------------------------------

U16 seInit(U32 para)
{
	/*
    plc_IO = (struct c_IOtag *)para;
    
	//#1263 initialize
	*(volatile unsigned char *)LCD_Command = 0x95; // Sleep in
	*(volatile unsigned char *)LCD_Command = 0xAE; // Display Off
	*(volatile unsigned char *)LCD_Command = 0xA6; // Display normal
	*(volatile unsigned char *)LCD_Command = 0xCA; // Display Control
	*(volatile unsigned char *)LCD_Data = 0x00; // Test mode,divid ratio,driving pattern
	*(volatile unsigned char *)LCD_Data = 0x27; // Duty=1/160
	*(volatile unsigned char *)LCD_Data = 0x0A; // FR-frequency=11H-inversion
	*(volatile unsigned char *)LCD_Command = 0x75; // Pager address set
	*(volatile unsigned char *)LCD_Data = 0x00; // page 0 (start)
	*(volatile unsigned char *)LCD_Data = 0xA7; // page 167 (end)
	*(volatile unsigned char *)LCD_Command = 0x15; // Column address set
	*(volatile unsigned char *)LCD_Data = 0x00; // Column 0 (start)
	*(volatile unsigned char *)LCD_Data = 0xEF; // Column 239 (end)
	*(volatile unsigned char *)LCD_Command = 0xBC; // Data scan direction
	*(volatile unsigned char *)LCD_Data = 0x4A; // Page 0 address location=line1 , Scan direction=column direction
	*(volatile unsigned char *)LCD_Data = 0x01; // Column 0 address location
	*(volatile unsigned char *)LCD_Command = 0xC6; // Volumn control
	*(volatile unsigned char *)LCD_Data = 0x14; // Vclk,Vu/d=L
	*(volatile unsigned char *)LCD_Command = 0xAF; // Display on
 

   */
    memset( VRAM, 0xff, SCREEN_HEIGHT*SCREEN_WIDTH );

    return GPC_ERR_OK;
}


//-------------------------------------------------------------------------
//    seSetPixel()
//
//      This function sets the pixel at the specified coordinates to specified color.
//	ColorIndex is interrupted by HAL.GPC can use function seRGBtoIndex to convert a RGB value to a color index
//
//  Parameters:
//     X: the x-coordinate , in pixel , of the point to be painted
//     Y: the y-coordinate , in pixel , of the point to be painted
//     ColorIndex : the color to be use to paint the pixel
//
//    Returns:
//      GPC_ERR_OK
//-------------------------------------------------------------------------

void seSetPixel(S16 x,S16 y,U16 ColorIndex)
{
 	//*(volatile unsigned char *)column = x; 
	//*(volatile unsigned char *)page = y; 
	VRAM[y][x] = (unsigned char)ColorIndex;   	

    //return GPC_ERR_OK;
}


//-------------------------------------------------------------------------
//    seGetPixel()
//
//      This function retrives the color value of the pixel at the specified coordinates 
//
//  Parameters:
//     X: the x-coordinate , in pixel , of the point to be examined
//     Y: the y-coordinate , in pixel , of the point to be examined
//     ColorIndex : the color of the pixel
//
//    Returns:
//      GPC_ERR_OK
//-------------------------------------------------------------------------
void seGetPixel(S16 x,S16 y,U16 *ColorIndex)
{
 	//*(volatile unsigned char *)x =column; 
	//*(volatile unsigned char *)y =page; 
	*ColorIndex=VRAM[y][x];   	

 }


//-------------------------------------------------------------------------
//    seDrawLine()
//
//  draws a line
//
//  Parameters:
//      x1,y1:specified the coordinate of the lines start point in pixel
//      x2,y2:specified the coordinate of the lines end point in pixel
//	ColorIndex:the color of the pixel
//	mask:line style mask
//
//    Returns:
//      GPC_ERR_OK
//-------------------------------------------------------------------------

void seDrawLine(S16 x1,S16 y1,S16 x2, S16 y2,U16 ColorIndex,U16 mask)
{
	int dx,dy,incrE,incrNE,d,x,y;
	int x0, y0;

	if (x2==x1)
	{//*write stright line*//
		if (y1<y2)
		{
			for (y=y1;y<=y2;y++)
				if( ( mask&0x8000 ) == 0x8000 )
		 		{	VRAM[y][x1]=(unsigned char)ColorIndex;
			 		mask=( mask<<1 )|0x0001 ;
				}
				else
					mask=mask<<1;
		}						
		else 
		{	for (y=y2;y<=y1;y++)
				if( ( mask&0x8000 ) == 0x8000 )
		 		{	VRAM[y][x1]=(unsigned char)ColorIndex;
		 			mask=( mask<<1 )|0x0001 ;
				}
			else
				mask=mask<<1;
		}
	}			
			
	else if (y2==y1)
	{//*write horizental line*//
		if (x1<x2)
		{
			for (x=x1;x<=x2;x++)
				if( ( mask&0x8000 ) == 0x8000 )
		 		{	VRAM[y1][x]=(unsigned char)ColorIndex;
		 			mask=( mask<<1 )|0x0001 ;
				}
				else
					mask=mask<<1;
		}						
		else 
		{
			for (x=x2;x<=x1;x++)
				if( ( mask&0x8000 ) == 0x8000 )
		 		{	VRAM[y1][x]=(unsigned char)ColorIndex;
		 			mask=( mask<<1 )|0x0001 ;
				}
				else
					mask=mask<<1;
		}
	}										
	
	else
	{// * start point definition*//
		if (x1<x2)
		{	x0=x1;
			y0=y1;
			x1=x2;
			y1=y2;
		}
		else
		{	x0=x2;
			y0=y2;
		}
	
		dx=x1-x0;
		if (y0<y1)
		{
			dy=y1-y0;
		    if (dy<dx)
		    {	d=-(2*dy-dx);		/*初始化判别式d*/
		    	incrE=-2*dy;		/*取像素E时判别式的增量*/
		    	incrNE=-2*(dy-dx);	/*取像素NE时判别式的增量*/
		    	x=x0,y=y0;
		    	while (x<=x1)
				{ 
					if( ( mask&0x8000 ) == 0x8000 )
		 			{
						VRAM[y][x]=(unsigned char)ColorIndex;
		 				mask=( mask<<1 )|0x0001 ;
					}
					else
						mask=mask<<1;
					if (d>=0)	/*取像素E*/
					{
						d+=incrE;
						x++;
					}
					else	/*取像素NE*/
					{
						d+=incrNE;
						x++;
						y++;
					}
				}
		    }			
		    else 
		    {	d=-(2*dx-dy);		/*初始化判别式d*/
		    	incrE=-2*dx;		/*取像素E时判别式的增量*/
		    	incrNE=-2*(dx-dy);	/*取像素NE时判别式的增量*/
		    	x=x0,y=y0;
		    	while (y<=y1)
		    	{	if( ( mask&0x8000 ) == 0x8000 )
		 			{	VRAM[y][x]=(unsigned char)ColorIndex;
		 				mask=( mask<<1 )|0x0001 ;
					}
					else
						mask=mask<<1;
					if (d>=0)	/*取像素E*/
					{	d+=incrE;
						y++;
					}
					else	/*取像素NE*/
					{	d+=incrNE;
						y++;
						x++;
					}
				}
		    }				
		}		
		else 
		{	dy=y0-y1;
			if (dy<dx)
			{	d=-(2*dy-dx);		/*初始化判别式d*/
		    	incrE=-2*dy;		/*取像素E时判别式的增量*/
		    	incrNE=-2*(dy-dx);	/*取像素NE时判别式的增量*/
		    	x=x0,y=y0;
		    	while (x<=x1)
		    	{	if( ( mask&0x8000 ) == 0x8000 )
		 			{	VRAM[y][x]=(unsigned char)ColorIndex;
		 				mask=( mask<<1 )|0x0001 ;
					}
					else
						mask=mask<<1;
					if (d>=0)	/*取像素E*/
					{	d+=incrE;
						x++;
					}
					else	/*取像素NE*/
					{	d+=incrNE;
						x++;
						y--;
					}
			 	}
			}	
			else 
		    {	d=-(2*dx-dy);		/*初始化判别式d*/
		    	incrE=-2*dx;		/*取像素E时判别式的增量*/
		    	incrNE=-2*(dx-dy);	/*取像素NE时判别式的增量*/
		    	x=x0,y=y0;
		    	while (y>=y1)
		    	{	if( ( mask&0x8000 ) == 0x8000 )
		 			{	VRAM[y][x]=(unsigned char)ColorIndex;
		 				mask=( mask<<1 )|0x0001 ;
					}
					else
						mask=mask<<1;
					if (d>=0)	/*取像素E*/
					{	d+=incrE;
						y--;
					}
					else	/*取像素NE*/
					{	d+=incrNE;
						y--;
						x++;
					}
				}
		    }				
		}		 
	}
	
	
	//return GPC_ERR_OK;	
}



//-------------------------------------------------------------------------
//    seInvertLine()
//
//  Invert a line
//
//  Parameters:
//      x1,y1:specified the coordinate of the lines start point in pixel
//      x2,y2:specified the coordinate of the lines end point in pixel
//	mask:line style mask
//
//    Returns:
//      GPC_ERR_OK
//-------------------------------------------------------------------------
void seInvertLine(S16 x1,S16 y1, S16 x2, S16 y2 , U16 mask)
{
	int dx,dy,incrE,incrNE,d,x,y;
	int x0, y0;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -