PCB抄板Cortex-M3学习LPC1768 - TFT实验
- PCB抄板/********************************************************************************
- * 函数名称 :GLCD_clear (unsigned short color)
- * 函数描述 : 清屏
- * 入口参数 : 无
- * 出口参数 : 无
- * 备 注:
- *******************************************************************************/
- void GLCD_clear (unsigned short color)
- {
- unsigned int i;
- wr_reg(0x20, 0); // 1st line GRAM Data(AD0-AD7)
- wr_reg(0x21, 0); // 1st line GRAM Data(AD8-AD16)
- wr_cmd(0x22);
- for(i = 0; i < (WIDTH*HEIGHT); i++){
- wr_dat(color); // Set color of background
- }
- }
- /********************************************************************************
- * 函数名称 :void GLCD_bitmap (unsigned int x, unsigned int y, unsigned int w,
- * unsigned int h, unsigned char *bitmap)
- * 函数描述 : 显示图片
- * 入口参数 : unsigned int x -- Vertical GRAM Start Address
- * unsigned int y -- Horizontal GRAM Start Address
- * unsigned int w -- The width of picture
- * unsigned int h -- The high of picture
- * unsigned char *bitmap -- The array which store picture
- * 出口参数 : 无
- * 备 注:
- *******************************************************************************/
- void GLCD_bitmap (unsigned int x, unsigned int y, unsigned int w, unsigned int h, unsigned char *bitmap)
- {
- unsigned int i;
- unsigned int len = w*h; /* 数组长度 = 图片的width*high(注:元素是16位的) */
- /* 用Img2Lcd这个软件生成的数组是char型的(元素是8位的),需转换成short型(元素是16位的) */
- unsigned short *bitmap_ptr = (unsigned short *)bitmap;
- wr_reg(0x50, y); /* 水平GRAM起始地址 */
- wr_reg(0x51, y+h-1); /* 水平GRAM结束地址(-1) */
- wr_reg(0x52, x); /* 垂直GRAM起始地址 */
- wr_reg(0x53, x+w-1); /* 垂直GRAM结束地址(-1) */
- wr_reg(0x20, y); /* GRAM水平垂直地址设置 */
- wr_reg(0x21, x);
- wr_cmd(0x22); /* 写数据到GRAM,AC自动加 */
- for (i = 0; i < len; i++) { /* 开始写数据 */
- wr_dat(*bitmap_ptr++); /* 向GRAM写入数据 */
- }
- }

芯片解密