📄 zj__.c
字号:
for( p1 = 0 ; p1 < sizeof( chn_zj ) ; p1 ++ )
{
print_char( chn_zj[p1] ) ;
}
if( printtype ) ;
else
{
print_char( 0x1b ) ;
print_char( 0x36 ) ;
}
if ( pnt_zj >= 0 )
{
zsf_long.dblword = (unsigned long int)pnt_zj ;
if( printtype ) ;
else
{
print_char( 13 ) ;
print_char( 10 ) ;
send_pnt_data() ;
}
print_long( zsf_long.dblword , 1 ) ;
}
else
{
zsf_long.dblword = - (unsigned long int)pnt_zj ;
if( printtype ) ;
else
{
print_char( 13 ) ;
print_char( 10 ) ;
send_pnt_data() ;
}
print_long( zsf_long.dblword , 0 ) ;
}
print_char( 13 ) ;
print_char( 10 ) ;
send_pnt_data() ;
if( printtype )
{
for( p1 = 0 ; p1 < 14 ; p1 ++ )
{
print_char( 32 ) ;
}
}
else
{
for( p1 = 0 ; p1 < 8 ; p1 ++ )
{
print_char( 32 ) ;
}
print_char( 0x1b ) ;
print_char( 0x38 ) ;
}
for( p1 = 0 ; p1 < sizeof( chn_finish ) ; p1 ++ )
{
print_char( chn_finish[p1] ) ;
}
if( printtype ) ;
else
{
print_char( 0x1b ) ;
print_char( 0x36 ) ;
}
send_pnt_data() ;
if( printtype ) ;
else
{
for( p1 = 0 ; p1 < 9 ; p1 ++ )
{
print_char( 13 ) ;
print_char( 10 ) ;
print_char( 32 ) ;
}
}
print_char( 13 ) ;
print_char( 10 ) ;
print_char( 13 ) ;
print_char( 10 ) ;
print_char( 13 ) ;
print_char( 10 ) ;
print_char( 13 ) ;
print_char( 10 ) ;
print_char( 13 ) ;
print_char( 10 ) ;
print_char( 13 ) ;
print_char( 10 ) ;
send_pnt_data() ;
statue_sys = ZJ_BOARDCOLOR ;
time_boardcolor = MAXTIME_BOARDCOLOR ;
}
void print_data( unsigned char no )
{
unsigned char p1 ;
send_order( BOARD_IP , CMD_PRINT ) ;
if ( no < 10 )
{
print_char( no + 48 ) ;
}
else
{
print_char( ( no / 10 ) + 48 ) ;
print_char( ( no % 10 ) + 48 ) ;
}
if( printtype ) ;
else
{
print_char( 0x1b ) ;
print_char( 0x38 ) ;
}
for( p1 = 0 ; p1 < sizeof( chn_fj ) ; p1 ++ )
{
print_char( chn_fj[p1] ) ;
}
if( printtype ) ;
else
{
print_char( 0x1b ) ;
print_char( 0x36 ) ;
}
print_char( 13 ) ;
print_char( 10 ) ;
send_pnt_data() ;
if( printtype ) ;
else
{
print_char( 0x1b ) ;
print_char( 0x38 ) ;
}
for( p1 = 0 ; p1 < sizeof( chn_zsf ) ; p1 ++ )
{
print_char( chn_zsf[p1] ) ;
}
if( printtype ) ;
else
{
print_char( 0x1b ) ;
print_char( 0x36 ) ;
print_char( 13 ) ;
print_char( 10 ) ;
}
print_long( zsf_long.dblword , 1 ) ;
print_char( 13 ) ;
print_char( 10 ) ;
send_pnt_data() ;
if( printtype ) ;
else
{
print_char( 0x1b ) ;
print_char( 0x38 ) ;
}
for( p1 = 0 ; p1 < sizeof( chn_ztf ) ; p1 ++ )
{
print_char( chn_ztf[p1] ) ;
}
if( printtype ) ;
else
{
print_char( 0x1b ) ;
print_char( 0x36 ) ;
print_char( 13 ) ;
print_char( 10 ) ;
}
print_long( ztf_long.dblword , 1 ) ;
print_char( 13 ) ;
print_char( 10 ) ;
send_pnt_data() ;
if( printtype ) ;
else
{
print_char( 0x1b ) ;
print_char( 0x38 ) ;
}
for( p1 = 0 ; p1 < sizeof( chn_xj ) ; p1 ++ )
{
print_char( chn_xj[p1] ) ;
}
if( printtype ) ;
else
{
print_char( 0x1b ) ;
print_char( 0x36 ) ;
print_char( 13 ) ;
print_char( 10 ) ;
}
if ( ztf_long.dblword == 0xffffffff && zsf_long.dblword == 0xffffffff )
{
print_long( 0xffffffff , 1 ) ;
}
else
{
if ( ztf_long.dblword > zsf_long.dblword )
{
ztf_long.dblword -= zsf_long.dblword ;
pnt_zj -= (signed long int)ztf_long.dblword ;
p1 = 0 ;
}
else
{
ztf_long.dblword = zsf_long.dblword - ztf_long.dblword ;
pnt_zj += (signed long int)ztf_long.dblword ;
p1 = 1 ;
}
print_long( ztf_long.dblword , p1 ) ;
}
print_char( 13 ) ;
print_char( 10 ) ;
send_pnt_data() ;
}
void print_title( void )
{
unsigned char p1 ;
pnt_zj = 0 ;
send_order( BOARD_IP , CMD_PRINT ) ;
if( printtype )
{
print_char( 13 ) ;
print_char( 10 ) ;
print_char( 32 ) ;
print_char( 32 ) ;
print_char( 32 ) ;
print_char( 32 ) ;
}
else
{
print_char( 0x1b ) ;
print_char( 0x63 ) ;
print_char( 0x0 ) ;
print_char( 0x1b ) ;
print_char( 0x36 ) ;
print_char( 13 ) ;
print_char( 10 ) ;
print_char( 0x1b ) ;
print_char( 0x38 ) ;
}
for( p1 = 0 ; p1 < sizeof( chn_title ) ; p1 ++ )
{
print_char( chn_title[p1] ) ;
}
if( printtype )
{
print_char( 32 ) ;
print_char( 32 ) ;
}
else
{
print_char( 0x1b ) ;
print_char( 0x36 ) ;
}
print_char( 32 ) ;
print_char( 32 ) ;
print_char( 13 ) ;
print_char( 10 ) ;
send_pnt_data() ;
if( printtype )
{
print_char( 13 ) ;
print_char( 10 ) ;
print_char( 32 ) ;
print_char( 32 ) ;
print_char( 32 ) ;
print_char( 32 ) ;
}
else
{
// print_char( 0x1b ) ;
// print_char( 0x63 ) ;
// print_char( 0x0 ) ;
print_char( 0x1b ) ;
print_char( 0x36 ) ;
print_char( 13 ) ;
print_char( 10 ) ;
print_char( 0x1b ) ;
print_char( 0x38 ) ;
}
for( p1 = 0 ; p1 < sizeof( chn_xh ) ; p1 ++ )
{
print_char( chn_xh[p1] ) ;
}
if( printtype ) ;
else
{
print_char( 0x1b ) ;
print_char( 0x36 ) ;
// print_char( 13 ) ;
// print_char( 10 ) ;
}
if( ++ bianhao >= 1000 )
{
bianhao = 1 ;
}
print_long1( bianhao , 1 ) ;
//bianhao ++ ;
print_char( 13 ) ;
print_char( 10 ) ;
send_pnt_data() ;
if( printtype )
{
for( p1 = 0 ; p1 < 24 ; p1 ++ )
{
print_char( '=' ) ;
}
}
else
{
for( p1 = 0 ; p1 < 16 ; p1 ++ )
{
print_char( '=' ) ;
}
}
print_char( 13 ) ;
print_char( 10 ) ;
send_pnt_data() ;
}
unsigned char this_sensor( void )
{
unsigned char m2 ;
if ( keys_old & 0x80 ) //通过按键报中了什么颜色
{
//manu
m2 = in_sensor_old ;
}
else
{
m2 = in_key_old ;
}
return m2 ;
}
void main( void )
{
unsigned char m1 , m2 , m3 , m4 ;
PORTC = 0xf0 ;
DDRC = 0xff ;
PORTD = 0xfc ;
DDRD = 0xfc ;
result = NO_RESULT ;
TIMSK = 0x1 ;
TCNT0 = - 125 ;
TCCR0 = 0x3 ;
WDTCR = 0xc ;//256ms
#asm("sei") ;
UCSRB = 0xdc ;
UBRRL = 204 ;
time_delay = 10 ; //延时0.5s
while( time_delay )
{
#asm("wdr") ;
}
in_key_new = read245( HC245_IN_KEY ) ;
in_key_old = in_key_new ;
in_sensor_new = read245( HC245_IN_SENSOR ) ;
in_sensor_old = in_sensor_new ;
keys_new = read245( HC245_KEYS ) ;
keys_old = keys_new ;
sw1_old = ~ read245( HC245_SW1 ) ;
sw2_old = ~ read245( HC245_SW2 ) ;
//选择热敏还是针式打印机
if( sw2_old & 0x80 )
{
printtype = 1 ; //选择热敏
}
else
printtype = 0 ; //选择针式打印机
time_delay = 40 ; //延时2s
while( time_delay )
{
#asm("wdr") ;
}
in_key_new = read245( HC245_IN_KEY ) ;
in_key_old = in_key_new ;
in_sensor_new = read245( HC245_IN_SENSOR ) ;
in_sensor_old = in_sensor_new ;
if ( in_sensor_old != 0xff || in_key_old != 0xff )
{
errcode = ERR_SELFTEST ;
statue_sys = ZJ_ERR ;
while( 1 )
{
if ( keys_down & 0x70 )
{
while(1) ;
}
#asm("wdr") ;
}
}
if ( sw1_old & 0x8 )
{
//清零
time_delay = 20 ;
while( time_delay )
{
#asm("wdr") ;
}
send_order( BOARD_IP , CMD_CLEAR ) ;
while( 1 )
{
check_send() ;
if ( send_in == send_read )
{
statue_sys = ZJ_CLEAR_OK ;
goto label_while ;
}
}
}
max_fj = con_fenji_count[sw1_old&0x7] ;
statue_sys = ZJ_WAITING ;
m2 = 0 ;
if( limit_yf % 50 ) limit_yf = 50 ;
if( limit_yf1 % 50 ) limit_yf1 = 50 ;
if( limit_yf2 % 50 ) limit_yf2 = 50 ;
if( limit_yf3 % 50 ) limit_yf3 = 50 ;
if( limit_yf4 % 50 ) limit_yf4 = 50 ;
if( limit_yf5 % 50 ) limit_yf5 = 50 ;
if( first_yf > 2000 ) first_yf = 5 ;
if( second_yf > 2000 ) second_yf = 1 ;
if( bianma >= 127 ) bianma = 0 ;
if( bianma1 >= 255 ) bianma1 = 0 ;
if( bianma2 >= 10 ) bianma2 = 0 ;
for( m1 = 0 ; m1 < COLOR_COUNT ; m1 ++ ) // 4
{
color_order[m1] = eep_color_order[m1] ; // =1,2,3,4
if ( color_order[m1] == 0 || color_order[m1] >= 9 )
{
color_order[m1] = m1 + 1 ;
eep_color_order[m1] = m1 + 1 ;
}
color_pl[m1] = eep_color_pl[m1] ; //30,10,1,1
if ( color_pl[m1] == 0 || color_pl[m1] >= 301 )
{
color_pl[m1] = con_color_pl[m1] ;//30,10,1,1
eep_color_pl[m1] = color_pl[m1] ;
}
}
time_delay = 30 ;
while( time_delay )
{
#asm("wdr") ;
}
if ( KEY1_DOWN )
{
change_statue( ZJ_TEST ) ;
}
else
{
if ( KEY2_DOWN )
{
change_statue( ZJ_SET ) ;
}
else
{
change_statue( ZJ_WELCOME ) ;
}
}
label_while:
while(1)
{
switch( statue_sys )
{
case ZJ_GET_ACCOUNT :
if ( time_get_account >= MAXTIME_GETACC ) // >=21
{
//开始打印
time_get_account = 0 ;
if( check_fen != 1 ) print_title() ;
send_order( 0x1 , CMD_CHAZHANG ) ; // , 11
}
break ;
case ZJ_BOARDCOLOR :
if ( time_boardcolor >= MAXTIME_BOARDCOLOR )
{
time_boardcolor = MAXTIME_BOARDCOLOR ;
while( this_sensor() != 0xff )
{
#asm("wdr") ;
}
if( check_fen )
{
this_earn = this_zsf - this_ztf ;
last_earn = last_zsf - last_ztf ;
between_earn = this_earn - last_earn ;
#asm("wdr") ;
if( KEY2_CLICK )
{
keys_down &= 0xdf ;
if( ++ checkmode > MAX_CHECK )
{
checkmode = 1 ;
}
}
if( KEY1_CLICK )
{
keys_down &= 0xef ;
check_fen = 0 ;
change_statue( ZJ_WELCOME ) ;
time_boardcolor = 0 ;
checkmode = 0 ;
}
}
else
{
change_statue( ZJ_WELCOME ) ;
time_boardcolor = 0 ;
checkmode = 0 ;
count_flag = 0 ;
}
}
break ;
case ZJ_WELCOME :
if ( time_welcome >= 80 )
{
change_statue( ZJ_COUNTDOWN ) ;
}
break ;
case ZJ_SET :
if ( KEY1_CLICK )
{
keys_down &= 0xef ;
if ( ++ setmode >= MAX_SET )
{
while(1) ;
}
}
if ( keys_old & 0x20 )
{
time_add = 0 ;
time_long1 = 0 ;
}
if ( KEY2_CLICK )
{
time_add = 1 ;
time_long1 = 0 ;
keys_down &= 0xdf ;
switch( setmode )
{
case SET_LIMIT_YF :
limit_yf += 50 ;
if( limit_yf > 50000 ) limit_yf = 50 ;
break ;
case SET_LIMIT_YF1 :
limit_yf1 += 50 ;
if( limit_yf1 > 50000 ) limit_yf1 = 50 ;
break ;
case SET_LIMIT_YF2 :
limit_yf2 += 50 ;
if( limit_yf2 > 50000 ) limit_yf2 = 50 ;
break ;
case SET_LIMIT_YF3 :
limit_yf3 += 50 ;
if( limit_yf3 > 50000 ) limit_yf3 = 50 ;
break ;
case SET_LIMIT_YF4 :
limit_yf4 += 50 ;
if( limit_yf4 > 50000 ) limit_yf4 = 50 ;
break ;
case SET_LIMIT_YF5 :
limit_yf5 += 50 ;
if( limit_yf5 > 50000 ) limit_yf5 = 50 ;
break ;
case SET_FIRST_YF :
first_yf += 1 ;
if( first_yf > 2000 ) first_yf = 1 ;
break ;
case SET_SECOND_YF :
second_yf += 1 ;
if( second_yf > 2000 ) second_yf = 1 ;
break ;
}
}
if ( time_add >= 20 )
{
time_add = 0 ;
time_long1 = 1 ;
}
if ( time_long1 >= 30 )
{
time_long1 = 1 ;
switch( setmode )
{
case SET_LIMIT_YF :
limit_yf += 50 ;
if( limit_yf > 50000 ) limit_yf = 50 ;
break ;
case SET_LIMIT_YF1 :
limit_yf1 += 50 ;
if( limit_yf1 > 50000 ) limit_yf1 = 50 ;
break ;
case SET_LIMIT_YF2 :
limit_yf2 += 50 ;
if( limit_yf2 > 50000 ) limit_yf2 = 50 ;
break ;
case SET_LIMIT_YF3 :
limit_yf3 += 50 ;
if( limit_yf3 > 50000 ) limit_yf3 = 50 ;
break ;
case SET_LIMIT_YF4 :
limit_yf4 += 50 ;
if( limit_yf4 > 50000 ) limit_yf4 = 50 ;
break ;
case SET_LIMIT_YF5 :
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -