📄 lcdtest.c
字号:
#include <avr/io.h>
#include <util/delay.h>
#include <avr/signal.h>
#include <avr/interrupt.h>
#include "lcd.h"
#define uchar unsigned char
#define uint unsigned int
void DelayMs(uint t);
void display_number(uchar num,uchar hex);
/*
uchar g_aDisplayBuf[16]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,0x77,\
0x7c,0x39,0x5e,0x79,0x71};
uchar g_bCounter=0;
*/
//外部中断 0
#ifndef CP_F
#define CP_F 8
#endif
void DelayMs(uint t)
{
uint i;
for(i=0;i<t;i++)
_delay_loop_2(CP_F * 250);
}
void display_number(uchar num,uchar hex)
{
LCDClear();
if(hex==0)
{
LCDWriteString("now you input:");
LCDWriteIntXY(2,1,num,3);
LCDWriteStringXY(5,1,"continus?");
}
else
{
}
}
/*
SIGNAL(SIG_INTERRUPT0)
{
uchar num;
DelayMs(100);
DDRC|=0xf0; //定义为输入引脚
PORTC=_BV(PC0)|_BV(PC1)|_BV(PC2)|_BV(PC3);//键盘引脚上拉电阻开
num=PINC&0x0f;
display_number(num,0);
GIFR|=_BV(INTF0);//写 1 清除中断标志,
}
*/
void key_process()
{
// unsigned char time,i;
uchar key_num,temp_num;
//if(bit_is_set(PINA,7))
if(PINA&0x80)
{
key_num=(PINB&0x0f);
temp_num=key_num;
_delay_us(0.3);
//time=0;
if((key_num=(PINB&0x0f))==temp_num)
{
// PORTC=key_num;
display_number(key_num,0);
}
else
{
LCDClear();
LCDWriteString("....wait you...");
}
}
/*
else
{
//LCDClear();
LCDWriteString("@wait you...@");
LCDWriteStringXY(0,1,"thanks");
}
*/
}
void main()
{
unsigned char i;
//Initialize LCD module
InitLCD(LS_BLINK|LS_ULINE);
//Clear the screen
LCDClear();
//Simple string printing
LCDWriteString("ready config ");
//A string on line 2
LCDWriteStringXY(0,1,"Loading ");
//Print some numbers
for (i=0;i<10;i+=1)
{
LCDWriteIntXY(9,1,i,3);
LCDWriteStringXY(12,1,"%");
_delay_loop_2(0);
_delay_loop_2(0);
_delay_loop_2(0);
_delay_loop_2(0);
}
//Clear the screen
LCDClear();
//Some more text
LCDWriteString("Hello everyone");
LCDWriteStringXY(0,1,"sign you name "); // <--- Write ur NAME HERE !!!!!!!!!!!
//Wait
for(i=0;i<3;i++) _delay_loop_2(0);
//Some More ......
LCDClear();
LCDWriteString("@welcome to@");
LCDWriteStringXY(0,1,"fenggang space");
/*
MCUCR=_BV(ISC00)|_BV(ISC01);//上升沿触发fg_new
GICR=_BV(INT0);//外部中断 0 允许 fg_new
#ifdef __DOXYGEN__
#undef __DOXYGEN__
#endif
sei(); //总中断允许
*/
DDRA|=0x00; //定义为输入引脚
PORTA=_BV(PA7);
DDRB|=0x00; //定义为输入引脚
PORTB=_BV(PB0)|_BV(PB1)|_BV(PB2)|_BV(PB3);//键盘引脚上拉电阻开
while(1)
{
key_process();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -