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

📄 ra8835.c

📁 SSD1963.zip
💻 C
📖 第 1 页 / 共 5 页
字号:
void ClearGraphics(void)
{
  unsigned short i;
  LCDMemWrite(0x00,0x10);
  for(i=0;i<9600;i++)
    LCDDataWrite(0x00);   
}
//------------------------------------------------------------------------------
// Function Name: ClearText
// Parameters: none
// Return: none
// Description: function to clear the Text screen
//------------------------------------------------------------------------------
void ClearText(void)
{
  unsigned short i;

  LCDMemWrite(0x00,0x00);
  for(i=0;i<1200;i++)
    LCDDataWrite(0x00);
}
//------------------------------------------------------------------------------
// Function Name: CurserOnOff
// Parameters: unsigned char Data
// Return: none
// Description: Cursor On/Off
//------------------------------------------------------------------------------
void CurserOnOff(unsigned char Data)
{
  LCDCmdWrite(0x59);           //Display cursor on
  LCDDataWrite(Data?0x16:0x14);
//  Data?currson = 1:currson = 0;
}
//------------------------------------------------------------------------------
// Function Name: Gotoxy
// 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: LCDMemRead
// Parameters: unsigned char x, unsigned char y
// Return: none
// Description: Go to position.
//------------------------------------------------------------------------------
void LCDMemRead(unsigned char x, unsigned char y)
{
  LCDCmdWrite(0x46);    //Set Cursor Address
  LCDDataWrite(x);
  LCDDataWrite(y);  
  LCDCmdWrite(0x43);    //Read memory
}
//------------------------------------------------------------------------------
// Function Name: InitDisplay
// Parameters: none
// Return: none
// Description: function to initialize the graphics display
//------------------------------------------------------------------------------
void InitDisplay(void)
{    
  LCDIOInit ();
  
  ResetDisplay();

#ifndef TFT
  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  
#else
  LCDCmdWrite(0xb0);        //SET LCD MODE  
  LCDDataWrite(0x0c);       //SET TFT 18Bits MODE & Data latch in falling edge
  LCDDataWrite(0x80);       //SET TFT MODE & hsync+Vsync+DEN MODE
  LCDDataWrite(0x01);       
  LCDDataWrite(0x3f);       //SET horizontal size=320-1 LowByte  
  LCDDataWrite(0x00);	    
  LCDDataWrite(0xef);	    //SET vertical size=240-1 LowByte  
  LCDDataWrite(0x00);	    //SET even/odd line RGB seq.=RGB

  LCDCmdWrite(0xf0);	    //SET pixel data IF format=8bit
  LCDDataWrite(0x00);
  LCDCmdWrite(0x3a);        // SET RGB format = 6 6 6 : 18 bit/pixel
  LCDDataWrite(0x60);
  
  LCDCmdWrite(0xe6);   	    //SET PCLK freq=6.4MHz ; pixel clock frequency
  LCDDataWrite(0x00);
  LCDDataWrite(0xe7);
  LCDDataWrite(0x4f);

  LCDCmdWrite(0xb4);	    //SET HBP, 
  LCDDataWrite(0x01);	    //SET HSYNC Tatol 440
  LCDDataWrite(0xb8);
  LCDDataWrite(0x00);	    //SET HBP 68
  LCDDataWrite(0x44);
  LCDDataWrite(0x0f);	    //SET VBP 16=15+1
  LCDDataWrite(0x00);	    //SET Hsync pulse start position
  LCDDataWrite(0x00);
  LCDDataWrite(0x00);	    //SET Hsync pulse subpixel start position
          
  LCDCmdWrite(0xb6); 	    //SET VBP, 
  LCDDataWrite(0x01);	    //SET Vsync total 265=264+1
  LCDDataWrite(0x08);
  LCDDataWrite(0x00);	    //SET VBP=19
  LCDDataWrite(0x13);
  LCDDataWrite(0x07);	    //SET Vsync pulse 8=7+1
  LCDDataWrite(0x00);	    //SET Vsync pulse start position
  LCDDataWrite(0x00);
  
  LCDCmdWrite(0x2a);	    //SET column address
  LCDDataWrite(0x00);	    //SET start column address=0
  LCDDataWrite(0x00);
  LCDDataWrite(0x01);	    //SET end column address=319
  LCDDataWrite(0x3f);
  
  LCDCmdWrite(0x2b);	    //SET page address
  LCDDataWrite(0x00);	    //SET start page address=0
  LCDDataWrite(0x00);
  LCDDataWrite(0x00);	    //SET end page address=239
  LCDDataWrite(0xef);
  
  LCDCmdWrite(0x29);	    //SET display on  
  LCDCmdWrite(0x2c);	    //SET 
#endif    
}
//------------------------------------------------------------------------------
// Function Name: LCDColorWrite
// Parameters: unsigned color
// Return: none
// Description: function to color of pixle
//------------------------------------------------------------------------------
void LCDColorWrite(unsigned int color)
{
  LCDDataWrite((color)>>16);    // color is red
  LCDDataWrite((color)>>8);  	// color is green
  LCDDataWrite(color);  	// color is blue  
}  
//------------------------------------------------------------------------------
// Function Name: WindowSet
// Parameters: unsigned short left, unsigned short right,unsigned short top,unsigned short bottom
// Return: none
// Description: function to set page & column address.
//------------------------------------------------------------------------------
void WindowSet(unsigned int left,unsigned int right,unsigned int top,unsigned int bottom)
{
  LCDCmdWrite(0x2a);	      //SET page address
  LCDDataWrite((left)>>8);    //SET start page address=0
  LCDDataWrite(left);
  LCDDataWrite((right)>>8);   //SET end page address=319
  LCDDataWrite(right);
  
  LCDCmdWrite(0x2b);	      //SET column address
  LCDDataWrite((top)>>8);     //SET start column address=0
  LCDDataWrite(top);
  LCDDataWrite((bottom)>>8);  //SET end column address=239
  LCDDataWrite(bottom);
}
//------------------------------------------------------------------------------
// Function Name: FullOn
// Parameters: unsigned Color
// Return: none
// Description: function to write full display.
//------------------------------------------------------------------------------
void FullOn(unsigned int color)
{
  unsigned int x,y;
  WindowSet(0,319,0,239);
  LCDCmdWrite(0x2c);
  for(x=0;x<240;x++)
  {
    for(y= 0;y<320;y++)
      LCDColorWrite(color);
  }
}
//------------------------------------------------------------------------------
// 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 write string to 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: LCDTextRead
// Parameters: unsigned char ch,unsigned short lineno,unsigned short charpos
// Return: none
// Description: function to initialize the graphics display
//------------------------------------------------------------------------------
void LCDTextRead(char count,unsigned short Line,unsigned short Pos)
{
  unsigned char Lobyte = 0x00,Hibyte = 0x00,i;
  Line = Line * 40 + Pos;
  Lobyte = Line & 0xff;
  Hibyte = (Line>>8) & 0xff;
  LCDMemRead(Lobyte,Hibyte);
  for (i=0;i<= count;i++)
    Buffer[count++] = LCDDataRead();
}
//------------------------------------------------------------------------------
// 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) ;

⌨️ 快捷键说明

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