?? csygreen.c
字號:
//LCD12864P.c
#include <iom16.h>
#include <ina90.h>
#include <stdio.h>
#include <pgmspace.h>
#include <string.h>
#include <stdlib.h>
#include "HZ.h"
#include "menu.h"
#include "asc1608a.h"
#define SET_CS2 PORTD|=0x08
#define SET_CS1 PORTD|=0x10
#define CLR_CS2 PORTD&=0xF7
#define CLR_CS1 PORTD&=0xEF
#define SET_E PORTD|=0x80
#define CLR_E PORTD&=0x7f
#define SET_RW PORTD|=0x20
#define CLR_RW PORTD&=0xDf
#define SET_RS PORTD|=0x40
#define CLR_RS PORTD&=0xBF
#define UP_KEY 0xfd
#define DOWN_KEY 0xf7
#define BG_KEY 0xfb
#define Version 1.00
#pragma vector=TIMER1_OVF_vect
__interrupt void TIMER1VF_Handler(void);
char Line_str[16],BUF[6];
char Languageflag,M_flag,Synflag;
unsigned char Col,Line,Cur_Y=0,Line_nums,CurRow;
char Key_pressed,KeyCode,MenuNumbers=0;
char TimerCount,TimerOffflag,LowOffflag,SampleTime;
unsigned int TimerOff;
__eeprom char unuse @0x00;
__eeprom char EE_Languageflag=0;
__eeprom unsigned char EE_RecordDown1[5]="24000",EE_RecordDown2[5]="24000",EE_RecordDown3[5]="24000";
__eeprom unsigned char EE_RecordUP1[5]="1024 ",EE_RecordUP2[5]="1024 ",EE_RecordUP3[5]="1024 ";
char Battery;
unsigned int LowAlarmCount;
void Disp1608(void);
void Disp1608E(void);
void Read_BF(void);
void Clr_Row(char Row);
void Clr_LCD(void);
void Clr_4Row(void);
void CLR1608(void);
void IniLCD(void);
void LCDCommand(void);
void Key(void);
void Get_Keycode(void);
void Initial(void);
void KeyWaite(void);
void MainMenu(void);
void DisplayOne(void);
void DisplayTwo(void);
void DisplayThree(void);
void DisplayFour(void);
void DisplayFive(void);
void DisplaySix(void);
void SetupLanguage(void);
void SetupLanguageUpdate(void);
void DelayTime(unsigned int);
void BeeSpeak(unsigned int time);
void Disp2(void);
void DrawDot(unsigned char x,unsigned char y);
void DrawLine(unsigned char x,unsigned char y);
void BackLight(void);
char Get_BackLightKey(void);
char ReceiveComm(void);
void WriteComm(unsigned char Data);
void ReadComm(void);
void Start(void);
void ADCBattery(void);
struct dsl{
char standard[15];
char Local_Tx_Power[5];
char Remote_Tx_Power[5];
char Local_Line_Att[5];
char Remote_Line_Att[5];
char Local_SNR_Margin[5];
char Remote_SNR_Margin[5];
char Tx_Line_Rate[5];
char Rx_Line_Rate[5];
char Up_Capability[5];
char Down_Capability[5];
// char Up_Dvalue[10];
// char Down_Dvalue[10];
}Dsl;
void main(void)
{
char Synflag1,i;
DDRD=0xff;
Synflag=0;
Synflag1=0;
PORTD|=0x77;
IniLCD();
Clr_LCD();
BeeSpeak(10);
Languageflag=EE_Languageflag;
if(Get_BackLightKey())
SetupLanguage();
Initial();
SampleTime=0;
//adc set
ADMUX=0xE0;//Set VREF=2.56V Select PA0
ADCSRA=0x87;
LowAlarmCount=0;
ADCBattery();
if(LowOffflag)
{
DDRC|=0x02;
PORTC|=0x02;
DelayTime(30);
PORTC&=0xfd;
}
Start();
DDRA=0;
PORTA&=0x7f;
DelayTime(600);
Clr_LCD();
MenuNumbers=0;
TimerCount=0;
MainMenu();
TimerOffflag=0;
TimerOff=0;
Synflag=0;
Synflag1=0;
while(1)
{
SampleTime++;
if(SampleTime&0x10)
ADCBattery();
if(LowOffflag||TimerOffflag)
{
BeeSpeak(10);
DDRC|=0x02;
PORTC|=0x02;
DelayTime(100);
PORTC&=0xfd;
}
if(Synflag!=Synflag1)
{
if(Synflag)
{
ReadComm();
ReadComm();
}
else
{
for(i=0;i<5;i++)
{
EE_RecordDown1[i]=EE_RecordDown2[i];
EE_RecordDown2[i]=EE_RecordDown3[i];
EE_RecordDown3[i]=Dsl.Rx_Line_Rate[i];
EE_RecordUP1[i]=EE_RecordUP2[i];
EE_RecordUP2[i]=EE_RecordUP3[i];
EE_RecordUP3[i]=Dsl.Tx_Line_Rate[i];
}
for(i=0;i<5;i++)
{
Dsl.standard[i]=' ';
Dsl.Local_Tx_Power[i]=' ';
Dsl.Remote_Tx_Power[i]=' ';
Dsl.Local_Line_Att[i]=' ';
Dsl.Remote_Line_Att[i]=' ';
Dsl.Local_SNR_Margin[i]=' ';
Dsl.Remote_SNR_Margin[i]=' ';
Dsl.Tx_Line_Rate[i]=' ';
Dsl.Rx_Line_Rate[i]=' ';
Dsl.Up_Capability[i]=' ';
Dsl.Down_Capability[i]=' ';
}
for(i=0;i<10;i++)
{
Dsl.standard[i+5]=' ';
}
}
BeeSpeak(10);
Clr_LCD();
MainMenu();
Synflag1=Synflag;
}
Key();
if(Key_pressed)
{
Get_Keycode();
if(KeyCode==DOWN_KEY)
{
if(MenuNumbers<5)
{
MenuNumbers++;
BeeSpeak(10);
Clr_LCD();
MainMenu();
}
KeyWaite();
}
else if(KeyCode==UP_KEY)
{
if(MenuNumbers>0)
{
MenuNumbers--;
Clr_LCD();
BeeSpeak(10);
MainMenu();
}
KeyWaite();
}
}
}
}
void Start(void)
{
char rrr[]="ADSL Tester";
Clr_LCD();
if(!Languageflag)
{
/*strncpy_P(Line_str,StartMenu,16);
Line=0;
Col=0;Line_nums=16;
Disp1608();*/
strncpy_P(Line_str,Start2Menu,16);
Line=1;//Line=2;
Col=0;Line_nums=16;
Disp1608();
strncpy_P(Line_str,Start3Menu,16);
Line=2;//Line=3;
Col=0;Line_nums=16;
Disp1608();
}
else
{
strncpy_P(Line_str,StartMenuE,16);
//strncpy(Line_str,rrr,11);
Line=1;
Col=0;Line_nums=16;
Disp1608();
}
}
void ReadComm(void)
{
char Command[]="get dsl params",chr;
unsigned int i,j,n;
_CLI();
for(i=0;i<14;i++)
WriteComm(Command[i]);
WriteComm(0x0a);
WriteComm(0x0d);
i=0;j=0,n=0;
while(1)
{
chr=ReceiveComm();
if(chr=='$')
break;
else if(chr==':')
{
j++;
i=0;
while(1)
{
chr=ReceiveComm();
if(chr!=' ')
break;
}
do
{
n++;
//chr=ReceiveComm();
if(j==6)
Dsl.standard[i++]=chr;
else if(j==8)
Dsl.Local_Tx_Power[i++]=chr;
else if(j==9)
Dsl.Remote_Tx_Power[i++]=chr;
else if(j==10)
Dsl.Local_Line_Att[i++]=chr;
else if(j==11)
Dsl.Remote_Line_Att[i++]=chr;
else if(j==12)
Dsl.Local_SNR_Margin[i++]=chr;
else if(j==13)
Dsl.Remote_SNR_Margin[i++]=chr;
else if(j==14)
Dsl.Tx_Line_Rate[i++]=chr;
else if(j==15)
Dsl.Rx_Line_Rate[i++]=chr;
else if(j==29)
Dsl.Down_Capability[i++]=chr;
else if(j==30)
Dsl.Up_Capability[i++]=chr;
// else if(j==18)
// Dsl.Up_Dvalue[i++]=chr;
// else if(j==19)
// Dsl.Down_Dvalue[i++]=chr;
chr=ReceiveComm();
}while((chr!=' '));
}
if(n>2048)
break;
}
_SEI();
}
char ReceiveComm(void)
{
// unsigned int i=20000;
while(!(UCSRA&0x80));
return UDR;
}
void WriteComm(unsigned char Data)
{
while ((UCSRA&0x20)==0);
UDR=Data;
}
void BeeSpeak(unsigned int time)
{
DDRC|=0x01;
PORTC|=0x01;
DelayTime(time);
PORTC&=0xfe;
DelayTime(time);
}
char Get_BackLightKey(void)
{
char temp,BackLightKey;
unsigned int i;
DDRA=0x00;
temp=PINA|0xfb;
BackLightKey=0;
if(temp!=0xff)
{
for(i=0;i<100;i++);
temp=PINA|0xfb;
if(temp!=0xff)
{
BackLightKey=1;
_CLI();
TimerOff=0;
_SEI();
}
}
return BackLightKey;
}
void BackLight(void)
{
char temp;
unsigned int i;
DDRA=0x00;
temp=PINA|0xfb;
if(temp!=0xff)
{
for(i=0;i<100;i++);
temp=PINA|0xfb;
if(temp!=0xff)
{
DDRD|=0x04;
PORTD|=0x04;
}
else
{
DDRD|=0x04;
PORTD&=0xfb;
}
}
else
{
DDRD|=0x04;
PORTD&=0xfb;
}
}
void MainMenu(void)
{
if(MenuNumbers==0)
DisplayOne();
else if(MenuNumbers==1)
DisplaySix();
else if(MenuNumbers==2)
DisplayTwo();
else if(MenuNumbers==3)
DisplayThree();
else if(MenuNumbers==4)
DisplayFour();
else if(MenuNumbers==5)
DisplayFive();
// else if(MenuNumbers==5)
// DisplaySix();
}
void DisplayOne(void)
{
char i;
for(i=0;i<3;i++)
{
if(!Languageflag)
strncpy_P(Line_str,&DisplayOneMenu[i*9],9);
else
strncpy_P(Line_str,&DisplayOneMenuE[i*9],9);
Line=i;
Line_nums=10;
Col=0;
Disp1608();
}
if(!Synflag)
{
for(i=0;i<3;i++)
{
strncpy(Line_str," -- ",6);
Line=i;
Line_nums=6;
Col=9;
Disp1608();
}
Line_str[0]=25;
Line_nums=1;
Col=15;
Disp1608();
}
else
{
if(Dsl.standard[6]=='2')
Dsl.standard[5]='+',Dsl.standard[6]=' ';//RE-ADSL ADSL2+
strncpy(Line_str,Dsl.standard,7);
Line=0;
Line_nums=7;
Col=9;Disp1608();
strncpy(Line_str,Dsl.Rx_Line_Rate,5);
Line_nums=5;
Line=1;
Disp1608();
strncpy(Line_str,Dsl.Tx_Line_Rate,6);
Line_nums=4;
Line=2;
Disp1608();
}
Line_str[0]='K';
Line=1;
Line_nums=1;
Col=15;
Disp1608();
Line=2;
Disp1608();
Line_str[0]=25;
Line=3;
Disp1608();
}
void DisplaySix(void)
{
if(!Languageflag)
strncpy_P(Line_str,DisplaySixMenu,15);
else
strncpy_P(Line_str,DisplaySixMenuE,15);
Line=0;
Line_nums=15;
Col=0;
Disp1608();
if(!Languageflag)
strncpy_P(Line_str,DiplayThreeMenu2,5);
else
strncpy_P(Line_str,DiplayThreeMenu2E,5);
Line=1;
Line_nums=5;
Col=0;
Disp1608();
if(!Languageflag)
strncpy_P(Line_str,&DiplayThreeMenu2[5],5);
else
strncpy_P(Line_str,&DiplayThreeMenu2E[5],5);
Line_nums=5;
Line=2;
Col=0;
Disp1608();
if(!Synflag)
{
strncpy(Line_str,"-- ",5);
Line=1;
Line_nums=5;
Col=5;
Disp1608();
Line=2;
Disp1608();
}
else
{
strncpy(Line_str,Dsl.Down_Capability,5);
Line=1;
Line_nums=7;
Col=8;
Line_str[5]='K';
Line_str[6]='b';
Disp1608();
strncpy(Line_str,Dsl.Up_Capability,5);
Line=2;
Col=8;
Disp1608();
}
Line_str[0]=24;
Line=0;
Col=15;
Line_nums=1;
Disp1608();
Line_str[0]=25;
Line=3;
Disp1608();
}
void DisplayTwo(void)
{
if(!Languageflag)
strncpy_P(Line_str,DisplayTwoMenu1,15);
else
strncpy_P(Line_str,DisplayTwoMenu1E,15);
Line=0;
Line_nums=15;
Col=0;
Disp1608();
if(!Languageflag)
strncpy_P(Line_str,DisplayTwoMenu2,15);
else
strncpy_P(Line_str,DisplayTwoMenu2E,15);
Line=2;
Line_nums=15;
Col=0;
Disp1608();
Line_str[0]=24;
Line=0;
Col=15;
Line_nums=1;
Disp1608();
Line_str[0]=25;
Line=3;
Disp1608();
if(!Languageflag)
strncpy_P(Line_str,DiplayTwoMenu3,3);
else
strncpy_P(Line_str,DiplayTwoMenu3E,3);
Line=3;
Line_nums=3;
Col=0;
Disp1608();
Line=1;
Disp1608();
if(!Languageflag)
strncpy_P(Line_str,&DiplayTwoMenu3[3],3);
else
strncpy_P(Line_str,&DiplayTwoMenu3E[3],3);
Line=3;
Line_nums=3;
Col=8;
Disp1608();
Line=1;
Disp1608();
if(!Synflag)
{
strncpy(Line_str," -- ",4);
Line=1;
Line_nums=4;
Col=3;
Disp1608();
Col=11;
Disp1608();
strncpy(Line_str,"-- ",4);
Line=3;
Line_nums=4;
Col=11;
Disp1608();
Col=3;
Disp1608();
}
else
{
strncpy(Line_str,Dsl.Remote_Tx_Power,4);
Line=1;
Col=3;
Line_nums=4;
Disp1608();
strncpy(Line_str,Dsl.Remote_Tx_Power,4);
Col=11;
Line_nums=4;
Disp1608();
strncpy(Line_str,Dsl.Remote_SNR_Margin,4);
Line=3;
Col=3;
Line_nums=4;
Disp1608();
strncpy(Line_str,Dsl.Local_SNR_Margin,4);
Line=3;
Col=11;
Line_nums=4;
Disp1608();
}
}
void DisplayThree(void)
{
if(!Languageflag)
strncpy_P(Line_str,DisplayThreeMenu1,15);
else
strncpy_P(Line_str,DisplayThreeMenu1E,15);
Line=0;
Line_nums=15;
Col=0;
Disp1608();
/* if(!Languageflag)
strncpy_P(Line_str,DisplayThreeMenu2,15);
else
strncpy_P(Line_str,DisplayThreeMenu2E,15);
Line=2;
Line_nums=15;
Col=0;
Disp1608(); */
if(!Languageflag)
strncpy_P(Line_str,DiplayThreeMenu2,5);
else
strncpy_P(Line_str,DiplayThreeMenu2E,5);
Line=1;
Line_nums=5;
Col=0;
Disp1608();
if(!Languageflag)
strncpy_P(Line_str,&DiplayThreeMenu2[5],5);
else
strncpy_P(Line_str,&DiplayThreeMenu2E[5],5);
Line_nums=5;
Line=2;
Col=0;
Disp1608();
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -