📄 lcda_example.c
字号:
/************************************************************************************
* Copyright (c), 2004-2007,西安铭朗电子科技有限责任公司
* All rights reserved.
*
* Http: www.mlarm.com
* Email: mlarm@mlarm.com
*
* File name: LCDA_Example.c
* Project : ML-F020ICB
* Processor: C8051F020
* Compiler : Keil C51 Compiler
*
* Author: 李林利
* Version: 1.20
* Date: 2007.6.1
* Email: GavinLi@126.com
*
* Description: LCDA测试程序文件;
*
* Others: none;
*
* Function List:
* 1. void LCDA_Proc(void)
*
* History:
* 1. Author: 李林利
* Version: 1.10
* Date: 2007.3.12
* Modification: none
*
* 2. Author: 李林利
* Version: 1.00
* Date: 2004.11.24
* Modification: 建立文件
*
*************************************************************************************/
/************************************************************************************/
// 引用外部头文件
#include "..\config\Const.h"
#include "..\driver\uart.h"
#include "..\driver\delay.h"
#include "..\driver\LCDA.h"
/************************************************************************************/
/************************************************************************************/
// 常量及全局变量定义
/************************************************************************************/
/////////////////////////////////////////////////////////////////////////
// 汉字字模表 //
// 汉字库: 宋体16.dot,横向取模左高位,数据排列:从左到右从上到下 //
/////////////////////////////////////////////////////////////////////////
unsigned char code HZ_MING_32X32[72] = // "铭",
{
0x04,0x02,0x00,0x07,0x03,0x80,0x06,0x03,
0x00,0x0C,0x06,0x0C,0x0C,0xC7,0xFE,0x1F,
0xE6,0x0C,0x10,0x0C,0x18,0x30,0x08,0x30,
0x21,0x96,0x60,0x3F,0xD3,0x60,0x4C,0x20,
0xC0,0x8C,0x01,0x80,0x0D,0x83,0x00,0x7F,
0xC6,0x0C,0x0C,0x1F,0xFE,0x0C,0x6C,0x0C,
0x0C,0x8C,0x0C,0x0C,0x0C,0x0C,0x0C,0x4C,
0x0C,0x0D,0x8C,0x0C,0x0F,0x0F,0xFC,0x1E,
0x0C,0x0C,0x08,0x0C,0x0C,0x00,0x08,0x08
};
unsigned char code HZ_LANG_32X32[72] = // "朗",
{
0x04,0x00,0x00,0x06,0x00,0x00,0x03,0x04,
0x18,0x22,0x67,0xFC,0x3F,0xF6,0x18,0x30,
0x66,0x18,0x30,0x66,0x18,0x30,0x66,0x18,
0x3F,0xE7,0xF8,0x30,0x66,0x18,0x30,0x66,
0x18,0x30,0x66,0x18,0x3F,0xE6,0x18,0x30,
0x67,0xF8,0x30,0x46,0x18,0x31,0x86,0x18,
0x30,0xC6,0x18,0x31,0x6C,0x18,0x36,0x4C,
0x18,0x3C,0x18,0x18,0x70,0x30,0x18,0x20,
0x21,0xF8,0x00,0x40,0x70,0x00,0x80,0x20
};
unsigned char code HZ_KE_32X32[72] = // "科",
{
0x00,0x80,0x40,0x03,0xC0,0x70,0x0F,0xE8,
0x60,0x7E,0x04,0x60,0x06,0x06,0x60,0x06,
0x03,0x60,0x06,0x02,0x60,0x06,0x40,0x60,
0x7F,0xE0,0x60,0x06,0x0C,0x60,0x0F,0x06,
0x60,0x0E,0x86,0x60,0x0E,0xC2,0x60,0x16,
0x60,0x64,0x16,0x40,0x7E,0x26,0x07,0xE0,
0x26,0xF8,0x60,0x46,0x00,0x60,0x06,0x00,
0x60,0x06,0x00,0x60,0x06,0x00,0x60,0x06,
0x00,0x60,0x06,0x00,0x60,0x04,0x00,0x40
};
unsigned char code HZ_JI_32X32[72] = // "技",
{
0x04,0x02,0x00,0x07,0x03,0x80,0x06,0x03,
0x00,0x06,0x03,0x08,0x06,0x03,0x1C,0x06,
0xBF,0xFE,0x7F,0xC3,0x00,0x06,0x03,0x00,
0x06,0x03,0x00,0x06,0x83,0x10,0x07,0x3F,
0xF8,0x06,0x10,0x30,0x1E,0x10,0x30,0x76,
0x10,0x60,0x26,0x08,0x60,0x06,0x08,0x60,
0x06,0x04,0xC0,0x06,0x07,0x80,0x06,0x03,
0x80,0x06,0x06,0xC0,0x06,0x0C,0x78,0x7E,
0x18,0x3E,0x0E,0x20,0x18,0x04,0x40,0x00
};
// 汉字表:
// 铭朗科技
/*************************************************************************************/
//
// LCDA测试程序函数定义
//
/*************************************************************************************/
/***********************************************************************************
* Function: LCDA_Proc;
*
* Description: LCDA测试程序;
*
* Input: none;
*
* Return: none;
*
* Note: none;
************************************************************************************/
void LCDA_Proc(void)
{
unsigned char i,cmd;
unsigned int val,m,n;
int buf[23];
Uart0_SendBlock("LCDA test starting!\n\r",21,&i);
LCDA_Init(128,240,FS8x8);
while(1)
{
cmd = 0;
if (Uart0_GetCharsRxBuf()>0)
{
Uart0_RecvChar(&cmd);
}
switch (cmd)
{
case '0':case '1':case '2':case '3':case '4':case '5':case '6':case '7':case '8':case '9':
Uart0_SendBlock("Update map!\n\r",14,&i);
LCDA_ClearTextScreen();
LCDA_SetGraphMaps(cmd-0x30);
//LCDA_ShowChar(cmd-0x30,cmd-0x30,cmd);
cmd = 0;
break;
case 'A':
Uart0_SendBlock("Draw Dot!\n\r",12,&i);
LCDA_ClearScreen();
for (m=0;m<128;m++)
for (n=0;n<240;n++)
LCDA_DrawPixel(m, n, 1);
/*
Delay_s(2);
for (m=0;m<128;m++)
for (n=0;n<240;n++)
LCDA_DrawPixel(m, n, 0);
*/
cmd = 0;
break;
case 'B':
Uart0_SendBlock("Draw Line!\n\r",13,&i);
LCDA_ClearScreen();
for (m=0;m<240;m+=8)
{
Delay_ms(100);
LCDA_DrawLine(0,0,128,m,1);
}
Delay_s(1);
for (n=0;n<128;n+=8)
{
Delay_ms(100);
LCDA_DrawLine(0,0,n,240,1);
}
Delay_s(1);
/*
for (m=0;m<240;m+=8)
{
Delay_ms(100);
LCDA_DrawLine(0,0,128,m,0);
}
Delay_s(1);
for (n=0;n<128;n+=8)
{
Delay_ms(100);
LCDA_DrawLine(0,0,n,240,0);
}
Delay_s(1);
*/
cmd = 0;
break;
case 'C':
Uart0_SendBlock("Rectangle Line!\n\r",18,&i);
LCDA_ClearScreen();
for (m=0;m<8;m++)
{
Delay_ms(100);
LCDA_DrawRectangle(64-m*8+1, 120-m*15+1, 64+m*8-1, 120+m*15-1, 1);
}
/*Delay_s(2);
for (m=0;m<8;m++)
{
Delay_ms(100);
LCDA_DrawRectangle(64-m*8+1, 120-m*15+1, 64+m*8-1, 120+m*15-1, 0);
}
*/
cmd = 0;
break;
case 'D':
Uart0_SendBlock("FillRectangle Line!\n\r",22,&i);
LCDA_ClearScreen();
LCDA_DrawFillRectangle(16,32,120,220,1);
/*
Delay_s(2);
LCDA_DrawFillRectangle(16,32,120,220,0);
*/
cmd = 0;
break;
case 'F':
Uart0_SendBlock("Circle Line!\n\r",15,&i);
LCDA_ClearScreen();
for (m=0;m<120;m+=8)
{
Delay_ms(100);
LCDA_DrawCircle(64, 120, m, 1);
}
/*
Delay_s(2);
for (m=0;m<120;m+=8)
{
Delay_ms(100);
LCDA_DrawCircle(64, 120, m, 0);
}
*/
cmd = 0;
break;
case 'H':
Uart0_SendBlock("HZ32X32 Line!\n\r",16,&i);
LCDA_ClearScreen();
for (m=4;m<240;m+=24)
{
Delay_ms(100);
LCDA_ShowHZxy(m, m, 24,24,HZ_MING_32X32);
LCDA_ShowHZxy(m, m+24,24,24, HZ_LANG_32X32);
LCDA_ShowHZxy(m, m+48,24,24, HZ_KE_32X32);
LCDA_ShowHZxy(m, m+72,24,24, HZ_JI_32X32);
}
Delay_s(2);
cmd = 0;
break;
case 'E':
Uart0_SendBlock("LCDA test end!\n\r",16,&i);
cmd = 0;
break;
default:
break;
}
}
}
/***********************************************************************************/
// 文件结束
/***********************************************************************************/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -