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

📄 lcmdisp._c

📁 ssd1325控制器液晶的驱动程序
💻 _C
字号:
/****************************************************************************************
* 文件名:LCMDISP.C
* 功能:GUI测试及演示程序。
* 作者:黄绍斌
* 日期:2003.09.09
****************************************************************************************/
#include "config.h"
 

// 一个单色图标的数据,宽度x高度=40x40
uint8 const ICO1[] = 
{
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0x00,0x00,0x00,0x07,0x00,0xE0,0x00,0x00,0x18,
0x00,0x18,0x00,0x00,0x30,0x00,0x0C,0x00,0x00,0x40,0x00,0x02,0x00,0x00,0x80,0x00,
0x01,0x00,0x01,0x00,0x00,0x00,0x80,0x03,0x00,0x00,0x00,0xC0,0x02,0x01,0x81,0x80,
0x40,0x04,0x03,0xC3,0xC0,0x20,0x04,0x03,0xC3,0xC0,0x20,0x04,0x03,0xC3,0xC0,0x20,
0x08,0x03,0xC3,0xC0,0x10,0x08,0x03,0xC3,0xC0,0x10,0x08,0x01,0x81,0x80,0x10,0x08,
0x08,0x00,0x10,0x10,0x08,0x08,0x00,0x10,0x10,0x08,0x10,0x00,0x08,0x10,0x08,0xF0,
0x00,0x0F,0x10,0x08,0x08,0x00,0x10,0x10,0x04,0x04,0x00,0x20,0x20,0x04,0x06,0x00,
0x60,0x20,0x04,0x03,0x81,0xC0,0x20,0x02,0x01,0x7E,0x80,0x40,0x03,0x00,0x81,0x00,
0xC0,0x01,0x00,0x42,0x00,0x80,0x00,0x80,0x3C,0x01,0x00,0x00,0x40,0x00,0x02,0x00,
0x00,0x30,0x00,0x0C,0x00,0x00,0x18,0x00,0x18,0x00,0x00,0x07,0x00,0xE0,0x00,0x00,
0x00,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
};
unsigned char KeyNew,KeyDown; 
char* p; 
// 样条曲线的4个端点
PointXY log_pin[] = { {40,  30},
                      {60, 60},
                      {80, 30},
                      {100, 60}
                    };

// 封闭多边形的各个顶点                    
uint32  const poly6[] = {750,55, 85,40, 90,45, 100,42, 115,55, 75,55};
unsigned char hz0[]=				//韩

{
0x10, 0x20, 0x10, 0x20, 0xfd, 0xfe, 0x10, 0x20, 0x7c, 0x20, 0x44, 0xfc, 0x7c, 0x20, 0x44, 0x20, 
0x7d, 0xfe, 0x10, 0x22, 0xfe, 0x22, 0x10, 0x22, 0x10, 0x2a, 0x10, 0x24, 0x10, 0x20, 0x10, 0x20 

};  

WINDOWS *first_win;

void Port_Init()
{
 PORTD = 0XFF;
 DDRD  = 0XFF;
 PORTB = 0XFF;
 DDRB  = 0X00;
 PORTF = 0x00;
 DDRF  = 0x1F;
 PORTE = 0x0F;
 DDRE  = 0x00;
}    
//call this routine to initialize all peripherals
void init_devices(void)
{
 //stop errant interrupts until set up
 CLI(); //disable all interrupts
 XDIV  = 0x00; //xtal divider
 XMCRA = 0x00; //external memory
 Port_Init();

 MCUCR = 0x00;
 EICRA = 0x00; //extended ext ints
 EICRB = 0x00; //extended ext ints
 EIMSK = 0x00;
 TIMSK = 0x00; //timer interrupt sources
 ETIMSK = 0x00; //extended timer interrupt sources
 SEI(); //re-enable interrupts
 //all peripherals are now initialized
}          
void key_scan(void)
{
 unsigned char i,j,shift;

	//if (key_scan_begin==0) return;
	//key_scan_begin=0; 
	PORTE|=0X0f;//UP PULL
	PORTF|=0x1f;//OUT	  
    for (i=0;i<5;i++)
        {
         PORTF&=~(1<<i); //键盘线扫描
		 //delay_us(1);		 
         KeyNew=PINE&0x0f;//读取键盘扫描信号,屏蔽高四位PC0~3
         if (KeyNew!=0x0f)//如果有键按下,延时10ms消抖
            {   
			 //key_up=0;  
			 KeyDown = 1;      
			 KeyNew=KeyNew<<4;
			 KeyNew=KeyNew|i;//get key scan code
			 return;
			 //putchar(KeyNew);
			}
			 //memmove(&key_buf[0],&key_buf[1],KEY_BUF_LEN-1);   
        }//for (i=0;i<5;i++) 
}   
Hex2Ascii(unsigned char h)
{
 unsigned char ascii[2];
 unsigned char temp;
 
 temp = (h&0xf0)>>4;
 if(temp<0x0a){ascii[0] = temp + 0x30;}
    else {ascii[0] = temp + 0x37;}
	
 temp = h&0x0f;
 if(temp<0x0a){ascii[1] = temp + 0x30;}
    else {ascii[1] = temp + 0x37;}
 p = &ascii[0];
 //return (ascii);
}
/***********************************************************************
* 名称:main()
* 功能:主程序,用于GUI测试及演示。
***********************************************************************/
main(void)
{   
   WINDOWS win={0, 0, 128, 32,"my", "first" };
   first_win = &win;
   init_devices();
       
   GUI_Initialize();				// 初始化LCM 
   GUI_SetColor(1, 0);				// 设置前景色及背景色
   //LCD_FillAll(0x01);
   //GUI_LoadPic(0,0, (uint8 *)ICO1, 40, 40);	// 显示40×40的图标
   //GUI_Spline(log_pin, 4, 1); 					// 画样条曲线
   //GUI_LineS(poly6, 6, 1);						// 画封闭的多边形
   //GUI_FloodFill(0,0, 1);					// 填充多边形
   GUI_PutString(0,0,"09:23 01/10/07");		// 显示字符串 
   //GUI_PutChar24_32(48,32,'8');
   //GUI_PutChar8_8(0,0,'8');
   //GUI_PutHZ(0,0,hz0,16,16);
   //GUI_PutNoStr(0,0,"3244",4);
   //GUI_WindowsDraw(first_win);
   //while(1);
   //return(0);
   //GUI_PutChar8_8(0,8,'p');
   //GUI_PutChar8_8(0,16,'m');
   //GUI_PutChar8_8(0,24,'s');
   GUI_DrawBat(86,0,0);
   GUI_PutChar16_16(0,8,'P');
   GUI_PutChar16_16(0,24,'M');
   
   while(1)
   {
    key_scan();
	if(KeyDown)
    {
	 //Hex2Ascii(KeyNew); 
  	 //GUI_PutString(0,0,p);
	 
	 KeyDown = 0;
	}
   }
}

⌨️ 快捷键说明

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