⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 copyprint_voice.c

📁 微型打印机的驱动程序
💻 C
📖 第 1 页 / 共 2 页
字号:
         NEEDLEB_PIN=1;
		 NEEDLEC_PIN=1;
	     NEEDLED_PIN=1;

         SCON=0x90;
         PCON=0x00;
	         TMOD=0x11;       //timer 0 mode 1

             ES=1;
	         EA=1;
	
	         receive_item=0;
	         receive_num=0;
	        
         paper_end_flg=0;
         hired_off_flg=0;
         hired_on_flg=0;

         hired_on_receive_end_flg_for_print=0;
		 hired_off_receive_end_flg_for_print=0;



         for(;;)
		 {

                 if(check_paper_end()&&!paper_end_flg)
				 {
                     paper_end_flg=1;
                     send_to_main_cpu(PAPER_END_COM);
				 }


                 if(!check_paper_end()&&paper_end_flg)
				 {
                     POWER_G=0;
					 while(1)
					 {
                         if(!BLACK_DOT)   //when black dot comes,it is low.waiting when it is high.
                         {
                            delay1ms(200);
							delay1ms(200);
							delay1ms(200);
							if(!BLACK_DOT)
							{
							  while(!BLACK_DOT);
							  
                              if(!PAPER_END)
                              {
				                 paper_end_flg=0;
                                 send_to_main_cpu(PAPER_INSERT_COM);
                              }
					          POWER_G=1;
							  break;
							}
						 }
					  }
				 }

				 
                 if(hired_on_receive_end_flg_for_print)
				 {
				 	   
                                //POWER_G=0;						
                                print_hired_on();
								hired_on_receive_end_flg_for_print=0;
				  }

                 if(hired_off_receive_end_flg_for_print)
				 {
								print_hired_off();
								hired_off_receive_end_flg_for_print=0;
				 }

             if(paper_run_flg){
							paper_run();
							paper_run_flg=0;
								  }
            }
                                               

    }



void receive_data(void) interrupt 4 using 3{
            RI=0;
			   
            if(RB8)
            {
                    switch(SBUF)
                    {
                        case 0xab:
						     paper_run_flg=1;
                             SM2=0;
                             break;
                        case 0xcd:
						     print_start_flg=1;
                             SM2=0;
                             break;
                        case 0xda:
							 hired_on_flg=1;
                             hired_off_flg=0;
                             receive_item++;
                             receive_num=0;
                             SM2=0;
                             break;

                        case 0xdb:
				             hired_off_flg=1;
                             hired_on_flg=0;
                             receive_item++;
                             receive_num=0;
                             SM2=0;
                             break;

                        case 0xee:
                             key_send_ready_start_flg=1;
                             SM2=0;
                             break;

                         case 0xcc:
                               if(key_send_ready_start_flg)
                               {	
                                   if(key_send_ready_com==ALLOW_RECEIVE_KEY_VALUE_COM)key_send_ready_end_flg=1;
								   if(key_send_ready_com==KEY_MULTI_PRESS_ALLOW_COM)key_multi_press_allow_flg=1;
								   if(key_send_ready_com== KEY_MULTI_PRESS_INHIBIT_COM)key_multi_press_allow_flg=0;
                               }
                               SM2=0;
                     }
        
            }

            else if(hired_on_flg)
            {
	                 switch(receive_item)
                     {
    	                 case 1:
        	                   bill_number[receive_num]=SBUF;    //when entering hired on the data is unit
            	               break;  

    	                 case 2:
        	                   unit[receive_num]=SBUF;    //when entering hired on the data is unit
            	               break;  
                      	 case 3:
                        	   tele_num[receive_num]=SBUF;    //when entering hired on the data is tele
                           		break;  
        	             case 4:
      	                       car_num[receive_num]=SBUF;    //when entering hired on the data is car num
              		           break;        
 	                     case 5:
      		                    linsence[receive_num]=SBUF;    //when entering hired on the data is lisence num
            		            break;
	                     case 6:
    		                    get_on_date[receive_num]=SBUF;     //when entering hired on the data is get on data
            		            break;      
		                 case 7:       //for entering hired_on, get on time
        		               get_on_time[receive_num]=SBUF;
                		       if(receive_num==7)
                               {
							     
									hired_on_receive_end_flg_for_print=1;
                                    hired_on_flg=0;
									receive_item=0;
							   }
		                       break;      
                	    }
                        receive_num++;
            }

 		    else if(hired_off_flg)
            {
	                 switch(receive_item)
                     {
    	                 case 1:
        	                   get_off_time[receive_num]=SBUF;    //when entering hired on the data is unit
            	               break;  
                      	 case 2:
                        	   price[receive_num]=SBUF;    //when entering hired on the data is tele
                           		break;  
        	             case 3:
      	                       distance[receive_num]=SBUF;    //when entering hired on the data is car num
              		           break;        
 	                     case 4:
      		                   total_waiting_time[receive_num]=SBUF;    //when entering hired on the data is lisence num
            		           break;
	                     case 5:
    		                   fare[receive_num]=SBUF;     //when entering hired on the data is get on data
            		           if(receive_num==7)
                               {
                    		        hired_off_receive_end_flg_for_print=1;
 							   		receive_item=0;
									hired_off_flg=0;
                            	}
                           		break;      
              	       }
                       receive_num++;
              }
              if(key_send_ready_start_flg)key_send_ready_com=SBUF;
                 
          }








/****************************************************************
*     按顺序打印进入重车时的信息,打印之前先查是否有黑点        *
****************************************************************/
void print_hired_on(void){
//     uchar i;
         POWER_G=0;
        
         NEEDLEB_PIN=1;
         NEEDLEC_PIN=1;
         NEEDLED_PIN=1;
         CLK=1;
      
//         while(!BLACK_DOT);   //when black dot comes,it is low.waiting when it is high.
  //       while(BLACK_DOT);   //when black dot comes,it is low.waiting when it is high.
//         print_some_space_charactor_line(6);

//         insert_some_space_dot_line(12);         
         print_public_part(0);


         while(!RST);
         POWER_G=1;
         paper_end_flg=0;
         NEEDLEB_PIN=1;      
         NEEDLEC_PIN=1;
         NEEDLED_PIN=1;


   }


void print_some_space_charactor_line(uchar lines){
     uchar i;
     for(i=0;i<8;i++)space_data[i]=37;

     for(i=0;i<lines;i++){
	       print_one_charactor_line(space_data,space_data);
	
	       insert_some_space_dot_line(6);

		             }

	 				       }  


				 
/**************************************************************************************************
*此程序打印一个字符行,一个字符行就是一行字符。													  *
*首先加载原始数据到位寻址变量中,根据该变量值的大小,决定是从SECODE1还是从SECODE2中取打印点阵码。**
*在此只考虑了C和D两阵的驱动,打印的是后面8个字符。                                                *
***************************************************************************************************/
void print_one_charactor_line(uchar *item,uchar *printed_data)
{
     uchar dotline,i;

     for(dotline=0;dotline<7;dotline++)
	 {       //一行字符需打印7点行点阵数据
              while(!RST);
		

      for(i=0;i<4;i++){                 //两针打印8个字符,循环4次,将其点阵表中的数据赋于

                    value_a=item[i];  //C 和 D 两针所对应的变量VALUE_C和VALUE_D中
                    if(value_a>35)value_a=secode2[(value_a-36)*7+dotline];
                    else value_a=secode1[(value_a*7+dotline)];
                    value_b=item[i+4];
                    if(value_b>35)value_b=secode2[(value_b-36)*7+dotline];
                    else value_b=secode1[value_b*7+dotline];
					value_a<<=2;
					value_b<<=2;
//					print_one_dot_charactor();

                    value_c=printed_data[i];  //C 和 D 两针所对应的变量VALUE_C和VALUE_D中
                    if(value_c>35)value_c=secode2[(value_c-36)*7+dotline];
                    else value_c=secode1[(value_c*7+dotline)];
                    value_d=printed_data[i+4];
                    if(value_d>35)value_d=secode2[(value_d-36)*7+dotline];
                    else value_d=secode1[value_d*7+dotline];
					value_c<<=2;
					value_d<<=2;
					print_one_dot_charactor();
                            }
      }       
}
            
/***********************************************************************************************
*    打印一个点字符,一个点字符的意思是一个字符的一行点阵,此程序打印了四根针上的各一个点字符

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -