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

📄 lcd_test.c

📁 ARM9200+嵌入式linux下的lcd驱动
💻 C
字号:
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdlib.h>
#include <sys/ioctl.h>
#include <math.h>
#include <asm/types.h>
#include <linux/rtc.h>
#include <time.h>
#include "../include/api.h"
#include "bitmap.h"

unsigned char graphy[4][3]={
	{0xff,0xff,0xff},
	{0xff,0xff,0xff},
	{0xff,0xff,0xff},
	{0xff,0xff,0xff}};

/*******************************************************************/
void test_bitmap(void)
{
	struct point p1,p2;
	lcd_set_graphymode();
	lcd_cls_graphy();
/* 	p1.x=0; 	p1.y=0;	
 * 	p2.x=239;	p2.y=127;
 * 	lcd_write_map(p1,p2,map);	//16*16 chinese font	 */
	p1.x=0;
	p1.y=0;
	p2.x=30;
	p2.y=128;
	printf("biymap test\r\n");
	lcd_write_map(p1,p2,(unsigned char **)map);	//full screen map
}	
	
/*******************************************************************/
void test_cfont(void)
{
	struct point p1,p2;
//	struct point linefirst,linelast;
	unsigned char chinese_zhong[32]={0x01,0x00,0x01,0x00,0x21,0x08,0x3F,0xFC,
	0x21,0x08,0x21,0x08,0x21,0x08,0x21,0x08,
	0x21,0x08,0x3F,0xF8,0x21,0x08,0x01,0x00,
	0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00};	//display zhong character
	unsigned char chinese_wen[32]={0x02,0x00,0x01,0x00,0x01,0x00,0xFF,0xFE,
        0x08,0x20,0x08,0x20,0x08,0x20,0x04,0x40,
		0x04,0x40,0x02,0x80,0x01,0x00,0x02,0x80,
        0x04,0x60,0x18,0x1E,0xE0,0x08,0x00,0x00};	//display wen	character
	
	printf("chinese font test\r\n");
	lcd_set_graphymode();
	lcd_cls_graphy();

	p1.x=0; p1.y=0;	p2.x=2;	p2.y=16;
	lcd_write_map(p1,p2,chinese_wen);	//16*16 chinese font	
}	
/*******************************************************************/
int test_dot(void)
{
	int i,j=0;
	printf("drow dot test\n");
	lcd_set_graphymode();
	lcd_cls_graphy();
	for(i=0;i<239; i++){
		j= (j+4)%127;
		
		lcd_write_dot(i,j,1);
	}
//	sleep(1);
	for(i=0; i<240; i++){
		j = 64 - i & 63;
		lcd_write_dot(i,j,1);
	}

}
/*******************************************************************/
int test_text(void)
{
	char i;
	char msg[300];
	printf("text test\n");
	lcd_set_textmode();
	lcd_cls_text();
	lcd_write_string(1,8,"TEXT MODE STRING SHOW DEMO\0");
//	lcd_write_string(1,9,"1234567890-*+-x/~.?:',{}|`!@#$%^&*\0");
//	sleep(1);
	for(i=1; i<127; i++)
		msg[i]=i;
	msg[127]=0;
	lcd_write_string(0,0,msg);
	lcd_write_string(0,8,msg);
}	

/*******************************************************************/
int main(int argc, char **argv)
{
    struct tm read_tm;
 
	if(lcd_open()<0){
		printf("can't open lcd!\n");
		return 1;
	}
	printf("start LCM Module test\r\n");
	while(1){
//		ds1302_get_time(&read_tm);
 		test_text();	sleep(1);
		test_cfont();	sleep(1);
		test_dot();	sleep(1);
		test_bitmap();	sleep(1);
	}
	lcd_close();
	return 0;
}

⌨️ 快捷键说明

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