📄 displayandkey.c
字号:
/******************************************************************************
* Compiler: WinAVR(GCC)
* Device: ATtiny13
* File Name: DisplayAndKey.c
* Description: Display and key C Program
* Programmer: Liansen.Wang
* Revision: 1.0
* Modification time: 2005-08-22 10:18
******************************************************************************/
#include "DisplayAndKey.h"
/*****************************************************************************/
extern unsigned char Display_data[Display_bit];
const unsigned char Display_Code[] PROGMEM = {
0x3F,0x06,0x5B,0x4F,0x66,0x6D,0x7D,0x07, //0,1,2,3,4,5,6,7
0x7F,0x6F,0x00,0x00,0x00,0x00,0x00,0x00, //8,9, : , ; ,<,=,>,?
0x00,0x77,0x7C,0x39,0x5E,0x79,0x71,0x7D, //@,A,B,C,D,E,F,G
0x76,0x30,0x0F,0x00,0x38,0x00,0x37,0x3F, //H,I,J,K,L,M,N,O
0x73,0x67,0x50,0x6D,0x4E,0x3E,0x00,0x00, //P,O,R,S,T,U,V,W
0x00,0x6E,0x00 }; //X,Y,Z
/*============================================================
============================================================*/
/*void Display_All_Bit(uint8_t data)
{
unsigned char i;
for(i=0; i<Display_bit; i++)
Display_data[i] =data;
}*/
/*============================================================
FUNCTION:
============================================================*/
void V_SPI_SEND(unsigned char data)
{
unsigned char i,outdata;
outdata = data;
for(i=0; i<8; i++)
{
if (outdata & 0x01)
PORTB |= (1<<DATA);
else
PORTB &= ~(1<<DATA);
PORTB &= ~(1<<SCK);
PORTB |= (1<<SCK);
outdata >>= 1;
}
}
/*============================================================
FUNCTION: Display data send out
============================================================*/
void V_DISPLAYDATA_SEND(void)
{
unsigned char i,j;
//send LED Display Modle command
PORTB &= ~(1<<STB);
V_SPI_SEND(Vfd_Display_Modle);
PORTB|= (1<<STB);
//Send Led Display Data modle command
PORTB &= ~(1<<STB);
V_SPI_SEND(Vfd_Display_DataOut);
PORTB|= (1<<STB);
//Send LED Display Data address
PORTB &= ~(1<<STB);
V_SPI_SEND(Vfd_Display_Addr);
//send LED Display Data
for (i=0; i<7; i++)
{
for(j=0; j<16;j++)
{
if(Display_data[j] & (1<< i))
{
PORTB |= (1<<DATA);
}
else
{
PORTB &= ~(1<<DATA);
}
PORTB &= ~(1<<SCK);
PORTB |= (1<<SCK);
}
}
PORTB |= (1<<STB);
//Send Led Display ON command
PORTB &= ~(1<<STB);
V_SPI_SEND(Vfd_Display_Corl);
PORTB|= (1<<STB);
}
/*============================================================
FUNCTION: VFD KEY DATA IN
============================================================*/
unsigned char V_Kay_Scan(void)
{
unsigned char i;
unsigned char data;
PORTB &= ~(1<<STB);
//send Key value read command
V_SPI_SEND(Vfd_Display_DataIn);
data = 0xFF;
//read key value
DDRB &= ~(1<<DATA);
for(i=0; i<40;i++ )
{
PORTB &= ~(1<<SCK);
PORTB &= ~(1<<SCK);
PORTB |= (1<<SCK);
PORTB |= (1<<SCK);
if(PINB & (1<<DATA))
{
data = i;
}
}
DDRB |= (1<<DATA);
PORTB|= (1<<STB);
return data;
}
/*============================================================
============================================================*/
void Display (char *Keydata)
{
Display_data[9]=pgm_read_byte(Display_Code+((*(Keydata+0)) -0x30));
Display_data[8]=pgm_read_byte(Display_Code+((*(Keydata+1)) -0x30));
Display_data[7]=pgm_read_byte(Display_Code+((*(Keydata+2)) -0x30));
Display_data[0]=pgm_read_byte(Display_Code+((*(Keydata+3)) -0x30));
Display_data[1]=pgm_read_byte(Display_Code+((*(Keydata+4)) -0x30));
Display_data[2]=pgm_read_byte(Display_Code+((*(Keydata+5)) -0x30));//AVR Flash
Display_data[3]=pgm_read_byte(Display_Code+((*(Keydata+6)) -0x30));
Display_data[4]=pgm_read_byte(Display_Code+((*(Keydata+7)) -0x30));
Display_data[5]=pgm_read_byte(Display_Code+((*(Keydata+8)) -0x30));
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -