📄 main.c
字号:
{
//S5 = 0X08;
S6 = 0x02;
L_Buf[1] = L_Buf[2];
for(i=0;i<2;i++)
{
Buff1 = *(L_Buf+i);
Write_Dat(5-2+i,Buff1);
}
}
}
}
//************* 0 0 . 0************************
if( Flag_New == 1)
{
// Flag_New = 0;
for(i=0;i<3;i++)
{
Buff1 = *(L_Buf+i);
Write_Dat(5-3+i,Buff1);
S6 = 0x02;
}
}
//**************************
CS1 |=S6;
CS1 |=S5;
//**************************
LCDDR0 = CS1;
LCDDR5 = CS2;
LCDDR10 =CS3;
LCDDR15 = CS4;
LCDDR6 = CS5;
LCDDR11 = CS6;
LCDDR16 = CS7;
}
void Write_ON(void)
{
CS1 |=S6;
CS1 |=S5;
LCDDR0 = CS1;
LCDDR5 = CS2;
LCDDR10 =CS3;
LCDDR15 = CS4;
LCDDR6 = CS5;
LCDDR11 = CS6;
LCDDR16 = CS7;
}
//************************************
void Print_Init(void)
{
DDRE = 0xFF;
PORTE = 0X00;
}
//***********************************
void Open_Motor(void)
{
sbi(PORTE,PE0);
}
//***********************************
void Close_Motor(void)
{
cbi(PORTE,PE0);
}
//************************************
void Print_One_Byte(uchar a)
{
while((PIND & 0x02) != 0 );
while((PIND & 0x02) == 0 );
asm("nop");
asm("nop");
asm("nop");
asm("nop");
PORTE = a|0x01;
DelayMs(1);
PORTE = 0x01;
}
//************************************
void Print_Data(void)
{
uchar i,j;
uchar a,len;
uchar x,y;
double Buf;
Print_Init();
Open_Motor();
while( (PINB & 0x01) == 0 );
while( (PINB & 0x01) != 0 );
while((PIND & 0x02) == 0 );
//*********Print Table Head -*****
j = 0;
for(i =0 ;i<120;i++)
{
Print_One_Byte(BB1[j]);
j++;
if(j == 8)
j = 0;
}
//******Print Table KFZ.Kennzeichen ****
while( (PINB & 0x01) == 0 );
while( (PINB & 0x01) != 0 );
while((PIND & 0x02) == 0 );
for(i = 0;i<112;i++)
{
Print_One_Byte(ZF_K[i]);
}
//************Print Table kone line
while( (PINB & 0x01) == 0 );
while( (PINB & 0x01) != 0 );
//**********************************
while( (PINB & 0x01) == 0 );
while( (PINB & 0x01) != 0 );
while((PIND & 0x02) == 0 );
//*********Print Table Head -*****
j = 0;
for(i =0 ;i<120;i++)
{
Print_One_Byte(BB1[j]);
j++;
if(j == 8)
j = 0;
}
//**********Print Table kilometersatand*******
while( (PINB & 0x01) == 0 );
while( (PINB & 0x01) != 0 );
while((PIND & 0x02) == 0 );
for(i = 0;i<105;i++)
{
Print_One_Byte(ZF_21[i]);
}
//************Print Table kone line
while( (PINB & 0x01) == 0 );
while( (PINB & 0x01) != 0 );
//********************************************
while( (PINB & 0x01) == 0 );
while( (PINB & 0x01) != 0 );
while((PIND & 0x02) == 0 );
//**********Print Table Zyl:
for(i = 0;i<28;i++)
{
Print_One_Byte(ZF_Z1[i]);
}
for(i=0;i<63;i++)
{
Print_One_Byte(0x01);//ZF_21[i]);
}
for(i=0;i<21;i++)
{
Print_One_Byte(ZF_B[i]); //Bar
}
//**********************************
while( (PINB & 0x01) == 0 );
while( (PINB & 0x01) != 0 );
while((PIND & 0x02) == 0 );
//***********************************
for(j=1;j<13;j++)
{
if(Table1[j].Flag == 1)
{
if(j<10)
{
for(i=0;i<7;i++)
{
Print_One_Byte(0x01);
}
for(i=0;i<7;i++)
{
Print_One_Byte(*(AA0+j*7+i));
}
}
else
{
utoa(j,Print_Buf,10);
for(x=0;x<2;x++)
{
a = Print_Buf[x];
a -= 48;
for(i=0;i<7;i++)
{
Print_One_Byte(*(AA0+a*7+i));
}
}
}
for(i=0;i<7;i++)
{
Print_One_Byte(ZF_DD[i]); //:
}
a = (uchar)(Table1[j].number*10/10);
if(a>50)
a = 50;
x = 0;
y = 0;
while( x<56)
{
if(y<a)
{
Print_One_Byte(0xFF);
y++;
x++;
}
else
{
Print_One_Byte(0x01);
x++;
}
}
//**********************************
Buf = Table1[j].number;
dtostrf(Buf,2,1,Print_Buf);
len = strnlen(Print_Buf,10);
if(len == 4)
{
for(x=0;x<2;x++)
{
a = Print_Buf[x];
a -= 48;
for(i=0;i<7;i++)
{
Print_One_Byte(*(AA0+a*7+i));
}
}
for(i=0;i<7;i++)
{
Print_One_Byte(ZF_dD[i]);
}
for(x=3;x<4;x++)
{
a = Print_Buf[x];
a -= 48;
for(i=0;i<7;i++)
{
Print_One_Byte(*(AA0+a*7+i));
}
}
}
else
{
for(i=0;i<7;i++)
{
Print_One_Byte(0x01);
}
for(x=0;x<1;x++)
{
a = Print_Buf[x];
a -= 48;
for(i=0;i<7;i++)
{
Print_One_Byte(*(AA0+a*7+i));
}
}
for(i=0;i<7;i++)
{
Print_One_Byte(ZF_dD[i]);
}
for(x=2;x<3;x++)
{
a = Print_Buf[x];
a -= 48;
for(i=0;i<7;i++)
{
Print_One_Byte(*(AA0+a*7+i));
}
}
}
while( (PINB & 0x01) == 0 );
while( (PINB & 0x01) != 0 );
while((PIND & 0x02) == 0 );
}
}
//************Print Table kone line
while( (PINB & 0x01) == 0 );
while( (PINB & 0x01) != 0 );
//**********************************
while( (PINB & 0x01) == 0 );
while( (PINB & 0x01) != 0 );
while((PIND & 0x02) == 0 );
//*********Print Table Head -*****
j = 0;
for(i =0 ;i<120;i++)
{
Print_One_Byte(BB1[j]);
j++;
if(j == 8)
j = 0;
}
//**********Print Table Datum*******
while( (PINB & 0x01) == 0 );
while( (PINB & 0x01) != 0 );
while((PIND & 0x02) == 0 );
for(i=0;i<42;i++)
{
Print_One_Byte(0x01);
}
for(i = 0;i<35;i++)
{
Print_One_Byte(ZF_5D[i]); //Datum
}
for(i=0;i<40;i++)
{
Print_One_Byte(0x01);
}
//************Print Table kone line
while( (PINB & 0x01) == 0 );
while( (PINB & 0x01) != 0 );
//**********************************
while( (PINB & 0x01) == 0 );
while( (PINB & 0x01) != 0 );
while((PIND & 0x02) == 0 );
//*********Print Table Head -*****
j=0;
for(i =0 ;i<120;i++)
{
Print_One_Byte(BB1[j]);
j++;
if(j == 8)
j = 0;
}
//**********Print Table kilometersatand*******
while( (PINB & 0x01) == 0 );
while( (PINB & 0x01) != 0 );
while((PIND & 0x02) == 0 );
for(i=0;i<14;i++)
{
Print_One_Byte(0x01);
}
for(i = 0;i<84;i++)
{
Print_One_Byte(ZF_6U[i]);
}
while( (PINB & 0x01) == 0 );
while( (PINB & 0x01) != 0 );
Close_Motor();
}
//************ T1 *****************************************
static uchar T1_Buf=0;
void Time1_Init(void)
{
TCCR1B = 0x05;
}
void Open_Time1(void)
{
T1_Buf = 0 ;
TCNT1 = 0;
TIMSK1 = 0x01;
}
void Rest_Time1(void)
{
TCNT1 = 0 ;
T1_Buf = 0;
}
SIGNAL(SIG_OVERFLOW1)
{
T1_Buf ++;
if( T1_Buf > 36)
{
Clear_Cs();
CS1 = 0X0A;
Write_ON();
DelayMs(1888);
LCDCRA = 0;
asm("nop");
asm("nop");
asm("nop");
asm("nop");
cli();
eeprom_busy_wait();
eeprom_write_word(0,High2);
eeprom_busy_wait();
sei();
Close_Power();
}
}
//************************************
int main(void)
{
uchar i,j,len;
uint Time=5000;
uchar a;
LCD_Init();
Time1_Init();
len=0;
j = 0;
for(i=0;i<13;i++)
{
Table1[i].Gs = i;
Table1[i].Flag = 0;
Table1[i].number = 0;
}
//
uchar w;
Start: DDRB = 0X0E;
PORTB = 0X11;
DDRD = 0x00;
PORTD = 0XFF;
DelayMs(300);
Open_Power();
//************PRINT****************
// Print_Init();
// Open_Motor();
// Print_Data();
// while(1);
//*********************************
a = PINB;
while( (a & 0x10) != 0 )
{
Close_Power();
a = PINB;
}
//**********************************
eeprom_busy_wait();
i = eeprom_read_byte(0x80);
eeprom_busy_wait();
if( i != 1)
{
j=0;
while(j<120)
{
eeprom_busy_wait();
eeprom_write_byte(j,0);
eeprom_busy_wait();
j++;
}
eeprom_busy_wait();
eeprom_write_byte(0x80,1);
eeprom_busy_wait();
eeprom_busy_wait();
eeprom_write_byte(0,0xc);
eeprom_busy_wait();
}
//**********************************
eeprom_busy_wait();
High2 = eeprom_read_byte(0);
eeprom_busy_wait();
eeprom_busy_wait();
eeprom_read_block(Table1,0x20,84);
eeprom_busy_wait();
j = 0;
for(i=0;i<13;i++)
{
Table1[i].Gs = i;
// Table1[i].Flag = 0;
// Table1[i].number = 0;
}
//********** - 7 - ****************
Clear_Cs();
CS2 = 0X04;
CS3 = 0X26;
CS4 = 0X04;
Write_ON();
//***********************************
DelayMs(1888);
Display();
do
{
w =Key();
}while(w !=0);
Time0_Init();
Open_Time0();
ADC_Init();
sei();
Open_Time1();
while(1)
{
//********************
a = PINB;
while( (a & 0x10) != 0 )
{
Close_Power();
a = PINB;
}
//********************
Flag_New = 0;
Display();
w = Key();
switch(w)
{
case TEP : {
Clear_Cs();
CS1 = 0X0A;
Write_ON();
DelayMs(1888);
LCDCRA = 0;
asm("nop");
asm("nop");
asm("nop");
asm("nop");
if(Print_Flag == 1)
{
j = 0;
for(i=0;i<13;i++)
{
Table1[i].Gs = i;
Table1[i].Flag = 0;
Table1[i].number = 0;
}
}
//*******************
cli();
eeprom_busy_wait();
eeprom_write_word(0,High2);
eeprom_busy_wait();
eeprom_write_block(Table1,0x20,84);
eeprom_busy_wait();
sei();
//*******************
Close_Power();
break;
}
case JIA : {
if( High2 <12 )
{
if(Low3>0)
{
Table1[High2].Flag = 1;
Table1[High2].number = Low3;
}
High2++;
Low3 = Table1[High2].number;
Huan_G = 1;
}
Rest_Time1();
break;
}
case JIAN: {
if( High2 != 1)
{
if(Low3>0)
{
Table1[High2].Flag = 1;
Table1[High2].number =Low3;
}
High2 --;
Low3 = Table1[High2].number;
Huan_G = 1;
}
Rest_Time1();
break;
}
case PRINT: {
cli();
Print_Flag = 1;
Print_Data();
sei();
Rest_Time1();
break;
}
case CLEAR: {
Flag_New = 0;
Huan_G = 0;
Fang_Ad = 0;
ACD1_Data = 0;
ACD_Gs = 0;
Low3 = 0;
Rest_Time1();
break;
}
case SELECT: {
Print_Init();
Open_Motor();
while( (PINB & 0x01) == 0 );
while( (PINB & 0x01) != 0 );
Close_Motor();
Rest_Time1();
break;
}
}
}
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -