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

📄 1783.c

📁 液晶驱动C程序,SSD1783芯片,液晶型号1760B0
💻 C
📖 第 1 页 / 共 3 页
字号:
  unsigned int i,j;

  for (i=0;i<n;i++)
    for (j=0;j<350;j++)
    {;}

}

void resetchip()        // MCU board need to be modified
{                       // cut header pin2 from MCU pin2 and connect to pin7
        P3=DISCS;
        delay(10);
	P3=RESET;
	delay(10);
	P3=DISCS;
        delay(100);
}

void load_pattern(s_col,s_page,e_col,e_page,unsigned char code *pattern) // only for 18-bits pattern
{
  int i,j,total_col,total_page;

  total_col=e_col-s_col;
  total_page=e_page-s_page;

  comm_out(0x15);		// Set col address
  data_out(s_col);		// Start col address
  data_out(e_col-1);		// End col address

  comm_out(0x75);		// Set page address
  data_out(s_page);		// Start page address
  data_out(e_page);		// End page address

  comm_out(0x5c);		// Write Display Data
  for(i=0;i<total_page;i++)
  {
    for(j=0;j<total_col*3;j++)
      data_out(pattern[(i*total_col*3)+(j)]);
  }
}


void draw_line(x1,y1,x2,y2,int byte_A,int byte_B)
{
  comm_out(0x83);
  data_out(x1);
  data_out(y1);
  data_out(x2);
  data_out(y2);
  data_out(byte_A);
  data_out(byte_B);
}

void draw_rect(x1,y1,x2,y2,int line_byte_A,int line_byte_B,int fill_byte_A,int fill_byte_B)
{
  comm_out(0x84);		// draw rectangle
  data_out(x1);
  data_out(y1);
  data_out(x2);
  data_out(y2);
  data_out(line_byte_A);	// line color
  data_out(line_byte_B);
  data_out(fill_byte_A);	// fill color
  data_out(fill_byte_B);
}

void draw_circle(x1,y1,radius,int line_byte_A,int line_byte_B,int fill_byte_A,int fill_byte_B)
{
  comm_out(0x86);
  data_out(x1);
  data_out(y1);
  data_out(radius);
  data_out(line_byte_A);	// line color
  data_out(line_byte_B);
  data_out(fill_byte_A);	// fill color
  data_out(fill_byte_B);
}

void copy_region(x1,y1,x2,y2,Z1,Z2)
{
  comm_out(0x8A);
  data_out(x1);
  data_out(y1);
  data_out(x2);
  data_out(y2);
  data_out(Z1);
  data_out(Z2);
}

void clear_region(x1,y1,x2,y2)
{
  comm_out(0x8E);
  data_out(x1);
  data_out(y1);
  data_out(x2);
  data_out(y2);
}

void fill(unsigned char Mode)
{
switch(Mode)
  {
    case 0: 	comm_out(0x92);   		// Fill command
		data_out(0x00);   		// no fill, only border
		break;
    case 1: 	comm_out(0x92);   		// Fill command
		data_out(0x01);   		// enable plain fill color
		break;
    case 2: 	comm_out(0x92);   		// Fill command
		data_out(0x03);   		// enable x-direction gradient fill color
		break;
    case 3: 	comm_out(0x92);   		// Fill command
		data_out(0x05);   		// enable y-direction gradient fill color
		break;
    case 4: 	comm_out(0x92);   		// Fill command
		data_out(0x07);   		// enable x & y-direction gradient fill color
		break;
  }
}


void zoom_in(unsigned char start_x,start_y,w,h,ratio,unsigned char code *obj)
{
  int i,j;
  unsigned char color_r,color_g,color_b;

  for(i=0;i<h;i++)
  {
    for(j=0;j<w;j++)
    {
	color_r=obj[(i*w*3)+(j*3)]&0xF8;
	color_g=obj[(i*w*3)+(j*3)+1];
	color_b=(color_g>>5);
	color_r|=color_b;
        color_b=(color_g<<3);
        color_g=color_b&0xE0;
	color_b=obj[(i*w*3)+(j*3)+2]>>3;
	color_b|=color_g;
	draw_rect(start_x+(j*ratio),start_y+(i*ratio),start_x+ratio+(j*ratio),start_y+ratio+(i*ratio),color_r,color_b,color_r,color_b);
    }
  }
}


void init_lcd()		// for Lanser Panel
{
unsigned char i;
/*do{
P3=PREREAD;
P3=READ;
i=P1;
P3=DISCS;
}while(i!=0xE4);*/
comm_out(0xD1);
comm_out(0x20);
data_out(0x0F);
comm_out(0x81);
data_out(0x1a);
data_out(0x05);
comm_out(0xFB);
data_out(0x02);
comm_out(0xF2);
data_out(0x06);
data_out(0x10);
comm_out(0xA7);
comm_out(0xBC);
data_out(0x02);
data_out(0x01);
data_out(0x03);
comm_out(0xBB);
data_out(0x02);
comm_out(0x94);
comm_out(0xAF);

comm_out(0xce); // set color look-up table
for(i=0;i<32;i++)
	data_out(i);
}

/****************************************************
* Demo Program for SSD1783                          *
****************************************************/

void Note_line()
{
  int i;

  draw_line(9,151,9,8,0x00,0x00);  // outline
  draw_line(9,8,122,8,0x00,0x00);
  draw_line(122,8,122,151,0x00,0x00);
  draw_line(122,151,9,151,0x00,0x00);

  draw_line(123,12,123,153,0x7b,0xef);  // vertical shadow
  draw_line(11,152,123,152,0x7b,0xef);
  draw_line(124,13,124,153,0x7b,0xef);  // horizontal shadow
  draw_line(12,153,124,153,0x7b,0xef);

  for(i=0;i<130;i+=10)
  {
    draw_line(15,20+i,117,20+i,0x00,0x00);
    delay(wait*10);
  }
}

void rotate_line()
{
  int i,line_count,r,d,color1,color2;

  color1=0x00;
  color2=0x00;

  for(i=0;i<4;i++)
  {
    r=50;
    d=3-r*2;
    for(line_count=0; line_count<r; line_count++)
    {
       color1++;
       color2++;
       if(i%2)
       {
	  draw_line(64-r,64+line_count,64+r,64-line_count,color1+0x80,color2);
       }
       else
       {
	  draw_line(64-line_count,64-r,64+line_count,64+r,color1+0x0C,color2+0x0C);
       }
       if(d<0)
       {
          d+=4*line_count+6;
       }
       else
       {
       d+=4*(line_count-r)+10;
       r--;
       }
       delay(wait);
    }
  }
}

void Bubbles_circle()
{
  int i;

  fill(1);
  draw_rect(0,0,127,159,0xF7,0x80,0xF7,0x80);  //line & fill brown
  delay(wait);
  draw_rect(10,10,117,149,0x00,0x00,0x00,0x00); //line & fill Black
  delay(wait*10);

  fill(0);
  draw_circle(64,149,15,0xC0,0x18,0xC0,0x18); // half circle with line purple

  fill(1);
  draw_rect(10,150,117,159,0xF7,0x00,0xF7,0x00); // cover below half circle with line & fill brown
  draw_line(64,125,64,149,0xFF,0xC0); // pointer with line yellow
  draw_line(64,125,61,129,0xFF,0xC0); // pointer with line yellow
  draw_line(64,125,67,129,0xFF,0xC0); // pointer with line yellow
  delay(wait*10);

  fill(4);  //bubbles
  draw_circle(33,21,5,0xF8,0x00,0xF8,0x00);  	delay(wait*5);
  draw_circle(57,21,5,0xFF,0xC0,0xFF,0xC0);  	delay(wait*5);
  draw_circle(81,21,5,0x00,0x1F,0x00,0x1F);  	delay(wait*5);
  draw_circle(93,21,5,0x07,0xE0,0x07,0xE0);  	delay(wait*5);
  draw_circle(105,21,5,0xF8,0x00,0xF8,0x00);  	delay(wait*5);
  draw_circle(27,30,5,0x00,0x1F,0x00,0x1F);  	delay(wait*5);
  draw_circle(63,30,5,0x00,0x1F,0x00,0x1F);  	delay(wait*5);
  draw_circle(87,30,5,0xF8,0x00,0xF8,0x00);  	delay(wait*5);

⌨️ 快捷键说明

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