📄 ra8835.c
字号:
// Parameters: unsigned char x, unsigned char y
// Return: none
// Description: Go to position.
//------------------------------------------------------------------------------
void Gotoxy(unsigned char x, unsigned char y)
{
LCDCmdWrite(0x46); //Set Cursor Address
LCDDataWrite(x);
LCDDataWrite(y);
}
//------------------------------------------------------------------------------
// Function Name: LCDMemWrite
// Parameters: unsigned char x, unsigned char y
// Return: none
// Description: Go to position.
//------------------------------------------------------------------------------
void LCDMemWrite(unsigned char x, unsigned char y)
{
LCDCmdWrite(0x46); //Set Cursor Address
LCDDataWrite(x);
LCDDataWrite(y);
LCDCmdWrite(0x42); //Write to memory
}
//------------------------------------------------------------------------------
// Function Name: InitDisplay
// Parameters: none
// Return: none
// Description: function to initialize the graphics display
//------------------------------------------------------------------------------
void InitDisplay(void)
{
LCDIOInit ();
ResetDisplay();
LCDCmdWrite(0x40); //Writng into command register System set
LCDDataWrite(0x30); //P1 M0: Internal CG ROM
// M1: CG RAM is 32 characters maximum
// M2: 8-pixel character height
// W/S: Two-panel drive
// IV: No top-line compensation
LCDDataWrite(0x87); //P2 FX: Horizontal character size = 8 pixels
// WF: Two-frame AC drive
LCDDataWrite(0x07); //P3 FY: Vertical character size = 8 pixels
LCDDataWrite(0x27); //P4 C/R: 39 display addresses per line
LCDDataWrite(0x2f); //P5 TC/R: Total address range per line =
// fOSC = MHz, fFR = Hz
LCDDataWrite(0xEF); //P6 L/F: 239 display lines
LCDDataWrite(0x28); //P7 APL: Virtual screen horizontal size is 40 addresses
LCDDataWrite(0x00); //P8 APH: Virtual screen horizontal size is 40 addresses
LCDCmdWrite(0x44); //Scrolling
LCDDataWrite(0x00); //P1 First screen block start address set to 0x0000
LCDDataWrite(0x00); //P2 First screen block start address set to 0x0000
LCDDataWrite(0xef); //P3 Display lines in first screen block = 240
LCDDataWrite(0x00); //P4 Second screen block start address set to 0x1000
LCDDataWrite(0x10); //P5 Second screen block start address set to 0x1000
LCDDataWrite(0xef); //P6 Display lines in second screen block = 240
LCDDataWrite(0x00); //P7 Third screen block start address set to 0x0000
LCDDataWrite(0x00); //P8 Third screen block start address set to 0x0000
LCDDataWrite(0x00); //P9 Fourth screen block start address set to 0x0000
LCDDataWrite(0x00); //P10 Fourth screen block start address set to 0x0000
LCDCmdWrite(0x5a); //HDOT
LCDDataWrite(0x00);
LCDCmdWrite(0x5b); //OVERLAY
LCDDataWrite(0x01); // MX 1, MX 0: Inverse video superposition
// DM 1: First screen block is text mode
// DM 2: Third screen block is text mode
LCDCmdWrite(0x58); //Display off
LCDDataWrite(0x14); //FC1, FC0: Flash cursor at 2 Hz
//FP1, FP0: First screen block ON
//FP3, FP2: Second and fourth screen blocks ON
//FP5, FP4: Third screen block ON
ClearGraphics();
ClearText();
LCDCmdWrite(0x5d); //Cursor type CSRFORM
LCDDataWrite(0x05); //Horizontal cursor size = 6 pixels
LCDDataWrite(0x88); //Vertical cursor size = 9 pixels
LCDCmdWrite(0x59); // Display on
LCDDataWrite(0x14);
LCDCmdWrite(0x4c); // Cursor direction
}
//------------------------------------------------------------------------------
// Function Name: LCDChar
// Parameters: char Ch,unsigned short Line,unsigned short Pos
// Return: none
// Description: function to initialize the graphics display
//------------------------------------------------------------------------------
void LCDChar(char Ch,unsigned short Line,unsigned short Pos)
{
unsigned char Lobyte = 0x00,Hibyte = 0x00;
Line = Line * 40 + Pos;
Lobyte = Line & 0xff;
Hibyte = (Line>>8) & 0xff;
LCDMemWrite(Lobyte,Hibyte);
LCDDataWrite(Ch);
}
//------------------------------------------------------------------------------
// Function Name: LCDText
// Parameters: unsigned char ch,unsigned short lineno,unsigned short charpos
// Return: none
// Description: function to initialize the graphics display
//------------------------------------------------------------------------------
void LCDText(char *Str,unsigned short Line,unsigned short Pos)
{
unsigned char Lobyte = 0x00,Hibyte = 0x00;
Line = Line * 40 + Pos;
Lobyte = Line & 0xff;
Hibyte = (Line>>8) & 0xff;
LCDMemWrite(Lobyte,Hibyte);
while( *Str )
LCDDataWrite(*Str++);
}
//------------------------------------------------------------------------------
// Function Name: LCDputPixel
// Parameters: unsigned short x,unsigned short y
// Return: none
// Description: function to initialize the graphics display
//------------------------------------------------------------------------------
void LCDputPixel(unsigned short x,unsigned short y,unsigned short status)
{
unsigned char setbyte = 0;
unsigned short addr = 0x1000 + (40 * y) + (x/8);
Gotoxy((unsigned char)addr&0xff,(unsigned char)(addr>>8)&0xff);
setbyte = LCDDataRead();
if(status)
setbyte |= (1 << (7 - (x % 8)));
else
setbyte &= ~(1 << (7 - (x % 8)));
LCDMemWrite(addr&0xff,(addr>>8)&0xff);
LCDDataWrite(setbyte);
}
//------------------------------------------------------------------------------
// Function Name: LCDHorzLine
// Parameters: unsigned short left, unsigned short right,unsigned short row,unsigned short set
// Return: none
// Description: function to Draws a line into the display memory starting at
//left going to right, on the given row. No runtime error checking is performed.
//It is assumed that left is less than right.This is an indirect write routine.
//------------------------------------------------------------------------------
void LCDHorzLine(unsigned short left, unsigned short right,unsigned short row,unsigned short set)
{
unsigned short addr,i;
row = row*40;
for(i=left;i<=right;i++)
{
addr = 0x1000 + row + i;
LCDMemWrite(addr&0xff,(addr>>8)&0xff);
if(set)
LCDDataWrite(0xff);
else
LCDDataWrite(0x00);
}
}
//------------------------------------------------------------------------------
// Function Name: LCDVertLine
// Parameters: unsigned short top, unsigned short bottom,unsigned short column,unsigned short set
// Return: none
// Description: function to Draws a vertical line into display memory starting
//at the top going to the bottom in the given column. No runtime error checking
//is performed. It is assumed that top is less than bottom and that the column
//is in range.
//------------------------------------------------------------------------------
void LCDVertLine(unsigned short top, unsigned short bottom,unsigned short column,unsigned short set)
{
unsigned short addr,i;
top = top*40;
bottom = bottom*40;
for(i=top;i<bottom;i+=40)
{
addr = 0x1000 + i + column;
LCDMemWrite(addr&0xff,(addr>>8)&0xff);
if(set)
LCDDataWrite(0x80);
else
LCDDataWrite(0x01);
}
}
//------------------------------------------------------------------------------
// Function Name: LCDBox
// Parameters: unsigned short left, unsigned short top,unsigned short right, unsigned short bottom
// Return: none
// Description: function to Draw a box in display memory starting at the
//left/top and going to the right/bottom. No runtime error checking is performed.
//It is assumed that left is less than right and that top is less than bottom.
//------------------------------------------------------------------------------
void LCDBox(unsigned short left, unsigned short top,unsigned short right, unsigned short bottom)
{
// to draw a box requires two vertical lines
LCDVertLine(top+1,bottom,left,1) ;
LCDVertLine(top+1,bottom,right,0) ;
// and two horizonal lines
LCDHorzLine(left,right,top,1) ;
LCDHorzLine(left,right,bottom,1) ;
}
//------------------------------------------------------------------------------
// Function Name: LCDBox
// Parameters: unsigned short left, unsigned short top,unsigned short right, unsigned short bottom,unsigned short Fill
//Fill = 1/0
// Return: none
// Description: function to Fill a box in display memory starting at the
//left/top and going to the right/bottom. No runtime error checking is performed.
//It is assumed that left is less than right and that top is less than bottom.
//------------------------------------------------------------------------------
void LCDFillBox(unsigned short left, unsigned short top,unsigned short right, unsigned short bottom,unsigned short Fill)
{
unsigned short i;
for(i=top;i<bottom;i++)
LCDHorzLine(left,right,i,Fill);
}
//------------------------------------------------------------------------------
// Function Name: DisplayClock
// Parameters: None
// Return: none
// Description: Displays the Date & time on warning area
//------------------------------------------------------------------------------
void DisplayClock(void)
{
//Read RTC Date
RTC_GetDate(BINARY,&Gc.ActDate);
//Display RTC Date
sprintf(Buffer,"%02d:%02d:%02d%02d",Gc.ActDate.day,Gc.ActDate.month,Gc.ActDate.century,Gc.ActDate.year);
LCDText(Buffer,28,7);
LCDText(Day[Gc.ActDate.weekday-1],28, 18);
//Read RTC Time
RTC_GetTime(BINARY,&Gc.ActTime);
//Display RTC Time
sprintf(Buffer,"%02d:%02d:%02d",(Gc.ActTime.hours>=13)?Gc.ActTime.hours-12:Gc.ActTime.hours,Gc.ActTime.minutes,Gc.ActTime.seconds);
LCDText(Buffer,28,23);
sprintf(Buffer,"%s",(Gc.ActTime.hours>=12)?"PM":"AM");
LCDText(Buffer,28,32);
}
//------------------------------------------------------------------------------
// Function Name: Draw screen
// Parameters: none
// Return: none
// Description: function to Draw screen
//------------------------------------------------------------------------------
void DrawScreen(void)
{
CurrScreen = Screen ;
PrevScreen = CurrScreen ;
ClearGraphics();
ClearText();
LCDBox(0,0,39,239);
LCDBox(1,20,38,220);
LCDBox(2,40,37,200);
LCDText(" Processor : STR912FAW44 ",11,6);
LCDText(" LCD : WG320240C0-FMIVZ#000 ",13,6);
LCDText(" DISPLAY CONTROLLER : RA8835 ",17,6);
LCDText(" IDE : IAR WORKBENCH ",19,6);
LCDFillBox(4,60,35,180,1);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -