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

📄 main1.c

📁 arm7驱动液晶屏显示图片
💻 C
📖 第 1 页 / 共 3 页
字号:
/*--  文字:  e  --*/
/*--  宋体12;  此字体下对应的点阵为:宽x高=8x16   --*/
/* 纵向取模,字节倒序 */
uint8 char_e_[]={
0x00,0x00,0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x1F,0x22,0x22,0x22,0x22,0x13,0x00,
};

/*--  文字:  t  --*/
/*--  宋体12;  此字体下对应的点阵为:宽x高=8x16   --*/
/* 纵向取模,字节倒序 */
uint8 char_t_[]={
0x00,0x80,0x80,0xE0,0x80,0x80,0x00,0x00,0x00,0x00,0x00,0x1F,0x20,0x20,0x00,0x00,
};

/* 开机画面------斯凯科技 */
/*--  宽度x高度=128x64  --*/
/* 纵向取模,字节倒序 */
uint8 ARMSKY_logo[]={                                    
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xE0,0x00,0x00,0x00,0x00,
0x00,0x00,0x80,0xC0,0x60,0x30,0x08,0x00,0x00,0x00,0x00,0x00,0x80,0x80,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0xF8,0x52,0xFE,0x08,0x00,
0xF0,0x90,0x8C,0xC0,0x40,0x40,0x00,0x00,0x00,0x40,0x70,0xA0,0xBC,0xA0,0x38,0x00,
0xE0,0x10,0xF0,0x30,0x00,0x00,0x00,0x00,0x80,0x80,0x80,0x90,0xF8,0x4C,0x40,0x00,
0x50,0x20,0xFC,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x42,0xFC,0xA0,0x20,0x20,
0xFC,0xAC,0xA0,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0x80,0x2E,0xF9,0x00,0x00,0xE0,0xF8,
0xFE,0xEE,0x63,0x70,0x38,0xB8,0x9C,0x0C,0x86,0x83,0x83,0xC1,0x41,0x00,0x20,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x24,0x12,0x0B,0x03,0x09,0x30,0x18,
0x07,0x00,0x00,0x7F,0x00,0x00,0x00,0x00,0x00,0x00,0x7C,0x24,0x52,0x31,0x10,0x0C,
0x03,0x00,0x1F,0x20,0x20,0x30,0x20,0x00,0x08,0x08,0x04,0x03,0x7F,0x01,0x03,0x02,
0x02,0x02,0xFF,0x01,0x01,0x01,0x00,0x00,0x04,0x04,0x02,0x22,0x3F,0x20,0x13,0x15,
0x08,0x16,0x31,0x20,0x20,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x11,0xDB,0x2D,0x60,0xD0,0x31,0x75,
0x77,0xE6,0xE3,0xC3,0x83,0x03,0x03,0x01,0x01,0x01,0x00,0x00,0x20,0xE0,0x00,0x20,
0xE0,0x20,0x80,0x60,0x20,0x20,0xE0,0x00,0x20,0xE0,0x20,0x80,0x60,0x20,0x20,0xE0,
0x00,0x20,0xE0,0x20,0x80,0x60,0x20,0x00,0x00,0x00,0x00,0x40,0xA0,0xA0,0xC0,0x00,
0x40,0xE0,0x40,0x20,0x40,0xE0,0x40,0x20,0xE0,0x40,0x20,0xC0,0x00,0x00,0xC0,0xA0,
0x20,0x60,0x00,0x08,0xFC,0x80,0x40,0x20,0x20,0x20,0xE0,0x20,0x00,0xA0,0x60,0x20,
0x00,0x00,0x00,0x40,0xE0,0x40,0x20,0x20,0xC0,0x00,0x00,0xC0,0xA0,0xA0,0xC0,0x00,
0x20,0xF8,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x0C,0x02,0x01,0x00,0x00,0x00,0x01,0x00,0x00,
0x00,0x00,0x01,0x01,0x03,0x01,0x03,0x02,0x02,0x04,0x00,0x00,0x00,0x01,0x06,0x01,
0x01,0x06,0x01,0x00,0x00,0x00,0x01,0x06,0x01,0x01,0x06,0x01,0x00,0x00,0x00,0x01,
0x06,0x01,0x01,0x06,0x01,0x00,0x00,0x00,0x04,0x00,0x00,0x03,0x04,0x04,0x07,0x04,
0x04,0x07,0x04,0x00,0x04,0x07,0x04,0x00,0x07,0x04,0x00,0x07,0x04,0x00,0x06,0x04,
0x05,0x03,0x00,0x04,0x07,0x04,0x01,0x06,0x04,0x10,0x10,0x13,0x0C,0x03,0x00,0x00,
0x00,0x04,0x00,0x04,0x07,0x04,0x00,0x04,0x07,0x04,0x00,0x03,0x04,0x04,0x02,0x00,
0x00,0x07,0x04,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0xFE,0x28,
0x28,0xF8,0xAE,0x48,0xB8,0x28,0xAE,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x82,0x62,0x1C,0x60,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x48,0x48,0x48,0xC8,0x48,0x48,0xFE,0x08,0x0A,0x0C,0x08,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x04,0x94,0x94,0xDC,0xB4,0x92,0x92,0xCA,0x82,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x90,0xD8,0xB6,0x98,0x00,0x64,0xD4,0x4E,0xC4,0x64,0x44,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0F,0x05,
0x05,0x0F,0x08,0x04,0x03,0x02,0x04,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,
0x04,0x02,0x01,0x00,0x00,0x00,0x01,0x02,0x04,0x08,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x08,0x08,0x08,0x07,0x04,0x04,0x00,0x03,0x04,0x08,0x0E,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x08,0x04,0x02,0x09,0x08,0x0F,0x00,0x01,0x02,0x04,0x08,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x04,0x04,0x02,0x0A,0x08,0x04,0x03,0x00,0x0F,0x08,0x0E,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0xA0,0x98,0xA6,0xC8,0x90,0x02,0xFA,0x0E,0xEA,0x0A,
0xFA,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3E,0x4A,0x4A,0x4A,0x4A,0xCA,
0x4E,0x40,0x30,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x80,0xBE,0x92,0x12,
0x92,0x92,0xBE,0x80,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFC,0x90,0x9E,0x90,
0x00,0x7C,0xD4,0x7E,0xD4,0x54,0x7C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x04,0x0A,0x01,0x08,0x05,0x02,0x03,0x04,
0x09,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x01,0x03,0x05,0x09,0x09,0x0F,
0x01,0x01,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0F,0x04,0x04,0x0F,0x00,
0x0F,0x04,0x04,0x04,0x0F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0F,0x00,0x00,0x0F,
0x02,0x03,0x02,0x02,0x0F,0x02,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
};

/********************************************************************************************
* 函数名称:Delay()
* 功    能:软件延时
* 入口参数:count    延时参数,值越大,延时越长
* 出口参数:无
*********************************************************************************************/
void Delay(uint16 count)
{
  uint8 i;                

  while(--count != 0)        
    {
     for(i = 0; i < 125; i++);                // ";" 表示空语句,CPU空转。
   }                                // i 从0加到125,在12M晶体下CPU大概耗时1毫秒
}

/********************************************************************************************
* 函数名称:LCM12864_TestBusy()
* 功    能:LCM12864测忙函数
* 入口参数:无
* 出口参数:无
*********************************************************************************************/
void LCM12864_TestBusy(void)
{
  IO0SET=LCM12864_RW; 
  IO0CLR=LCM12864_RS;
  IO0SET=LCM12864_E;
  while(((IO0PIN&LCM12864_DB7_DB0)>>8) & LCM12864_STATUS_BUSY);
}

/********************************************************************************************
* 函数名称:LCM12864_WriteCMD()
* 功    能:写命令到LCM12864
* 入口参数:LCM12864_command    LCM12864的命令字节
* 出口参数:无
*********************************************************************************************/
void LCM12864_WriteCMD(uint8 LCM12864_command)
{
  IO0CLR=LCM12864_RW;
  IO0CLR=LCM12864_RS; 
  IO0SET=LCM12864_command<<8;
  IO0CLR=((~LCM12864_command)<<8)&LCM12864_DB7_DB0;
  IO0SET=LCM12864_E;
  IO0CLR=LCM12864_E;
  LCM12864_TestBusy();
}

/********************************************************************************************
* 函数名称:LCM12864_WriteData()
* 功    能:写数据到LCM12864
* 入口参数:LCM12864    LCM12864的命令字节
* 出口参数:无
*********************************************************************************************/
void LCM12864_WriteData(uint8 LCM12864_data)
{
  IO0CLR=LCM12864_RW; 
  IO0SET=LCM12864_RS;
  IO0SET=LCM12864_data<<8;
  IO0CLR=((~LCM12864_data)<<8)&LCM12864_DB7_DB0; 
  IO0SET=LCM12864_E;
  IO0CLR=LCM12864_E;
  LCM12864_TestBusy();
}

/********************************************************************************************
* 函数名称:LCM12864_ReadData()
* 功    能:从LCM12864读一字节数据
* 入口参数:无
* 出口参数:返回值为从LCM12864读出的一字节数据
*********************************************************************************************/
uint8 LCM12864_ReadData(void)
{
  uint8 LCM12864_data;
  IO0SET=LCM12864_RW;
  IO0SET=LCM12864_RS; 
  IO0SET=LCM12864_E;
  /* 按LCM12864数据手册,先空读一次 */
  LCM12864_data = (IO0PIN&LCM12864_DB7_DB0)>>8;
  LCM12864_TestBusy();
  /* 按LCM12864数据手册,再读一次 */
  LCM12864_data = (IO0PIN&LCM12864_DB7_DB0)>>8;
  LCM12864_TestBusy();
  return LCM12864_data;
}

/******************************************************************************************************************
* 函数名称:LCM12864_Write1Byte_X_Y()
* 功    能:向LCM12864指定点写一字节数据。
* 入口参数:x           x坐标值(0-127)
*           y               y坐标值(0-63)
*           LCM12864_data 所要写的数据
* 出口参数:无
*******************************************************************************************************************/
void LCM12864_Write1Byte_X_Y(uint8 x, uint8 y, uint8 LCM12864_data) 
{ 
  /* 参数过滤 */
  x = x&0x7f;                         
  y = y&0x3f;

  IO0CLR=LCM12864_CS1;
  IO0CLR=LCM12864_CS2;            // 不选中左半屏及右半屏
     
  /* 更新LCD12864显示 */
  if(x<64)                                // 判断选择左、右半屏
   { 
     IO0SET=LCM12864_CS1;                           // 选中左半屏
   }
  else
   { 
     IO0SET=LCM12864_CS2;                           // 选中右半屏
     x = x-64;
   }
  LCM12864_WriteCMD(LCM12864_COL_START_ADDR+x);  // 设置当前列地址,即x坐标
  LCM12864_WriteCMD(LCM12864_PAGE_START_ADDR+y); // 设置当前页地址,即y坐标
  LCM12864_WriteData(LCM12864_data);             // 向LCM12864写数据
}

/******************************************************************************************************************
* 函数名称:LCM12864_Read1Byte_X_Y()
* 功    能:从LCM12864指定点上读取一字数据。
* 入口参数:x   x坐标值(0-127)
*           y       y坐标值(0-63)
* 出口参数:返回该点上的字节数据。
*******************************************************************************************************************/
uint8  LCM12864_Read1Byte_X_Y(uint8 x, uint8 y)
{ 
  uint8 LCM12864_data;
  /* 参数过滤 */
  x = x&0x7f;                         
  y = y&0x3f;
  IO0CLR=LCM12864_CS1; 
  IO0CLR=LCM12864_CS2;            // 不选中左半屏及右半屏
  if(x<64)                                // 判断选择左、右半屏
   { 
     IO0SET=LCM12864_CS1;                           // 选中左半屏
   }
  else
   { 
     IO0SET=LCM12864_CS2;                           // 选中右半屏
     x = x-64;
   }
  LCM12864_WriteCMD(LCM12864_COL_START_ADDR+x);  // 设置当前列地址,即x坐标
  LCM12864_WriteCMD(LCM12864_PAGE_START_ADDR+y); // 设置当前页地址,即y坐标
  LCM12864_data = LCM12864_ReadData();           // 向LCM12864写数据
  return LCM12864_data;
}

/********************************************************************************************
* 函数名称:LCM12864_Init()
* 功    能:LCM12864初始化
* 入口参数:无
* 出口参数:无
*********************************************************************************************/
void LCM12864_Init(void)
{
  IO0CLR=LCM12864_RESET;
  IO0SET=LCM12864_RESET;
  IO0SET=LCM12864_CS1; 
  IO0SET=LCM12864_CS2;
  LCM12864_WriteCMD(LCM12864_DISP_OFF);
  LCM12864_WriteCMD(LCM12864_PAGE_START_ADDR+0);
  LCM12864_WriteCMD(LCM12864_START_ROW+0);
  LCM12864_WriteCMD(LCM12864_COL_START_ADDR+0);

⌨️ 快捷键说明

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