久久久久久久999_99精品久久精品一区二区爱城_成人欧美一区二区三区在线播放_国产精品日本一区二区不卡视频_国产午夜视频_欧美精品在线观看免费

 找回密碼
 立即注冊

QQ登錄

只需一步,快速開始

搜索
查看: 7329|回復: 8
收起左側

lpc1114熱敏打印機源程序

  [復制鏈接]
ID:189499 發表于 2017-4-14 13:00 | 顯示全部樓層 |閱讀模式
lpc1114單片機做的熱敏打印機程序
0.png
完整源碼下載:
printer.rar (807.16 KB, 下載次數: 60)




主程序預覽:
  1. //本文件主要定義可程序的入口函數main, main函數里主要對系統、參數、硬件接口進新初始化,之后等待讀取串口數據
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4. #include <string.h>
  5. #include "LPC11xx.h" /* LPC11xx definitions */
  6. #include "uart.h"  
  7. #include "timer32.h"
  8. #include"aw_print.h"
  9. #include"aw_init_printHead.h"
  10. #include "aw_config.h"
  11. #include "aw_font.h"
  12. #include"aw_key_led.h"
  13. #include "user.h"
  14. #include"aw_char_app.h"
  15. #include"aw_graph_app.h"
  16. #include"aw_barcode_app.h"
  17. #include "aw_command.h"
  18. #include "pmu.h"
  19. //初始化系統中的部分全局變量
  20. void init_Global_Variables(void)
  21. {
  22.         current_char_index=0;
  23.         DealBuffer_counter=0;
  24.         memset((low_power_t *)&low_power_Paramter,0,sizeof(low_power_t));
  25.         memset((printer_work_Parameter_t *)&printer_work_Parameter,0,sizeof(printer_work_Parameter_t));
  26.         printer_work_Parameter.printer_work_model=PRINTER_IDLE;
  27.         feed_dot_step=0;
  28.         paper_out_flag=0;
  29.         head_up_flag=0;
  30.         clear_buffer();
  31.         memset((Key_IRQ_Parameter *)key_IRQ_Parameter,0,KEY_NUM*sizeof(Key_IRQ_Parameter));
  32. }
  33. int main(void)
  34. {
  35.         #if UART_DEBUG
  36.         char buffer[1024];
  37.         uint32_t counter,timer;
  38.         SystemInit();
  39.         Init_Sys_Parameter();
  40.         init_Global_Varibles();
  41.         UARTInit(sys_Parameter.uart_para.baudrate);
  42.         #ifdef PROJECT_DEBUG
  43.         printf("\n\r-- Printer_Project V1.0 --\n\r");
  44.         printf("\n\r-- Serial Communication test  --\n\r");
  45.         #endif
  46.         counter=0;
  47.         timer=0;
  48.         memset(buffer,0,1024);
  49.         while(1)
  50.         {
  51.                 if(UartBuffer_read()==1)
  52.                 {
  53.                         timer=0;memcpy(buffer+counter,&DealBuffer,DealBuffer_counter);
  54.                         counter+=DealBuffer_counter;
  55. }
  56. else
  57. {
  58.         if(timer<10)
  59.         {
  60.                 timer++;
  61. }
  62. else if(timer==10)
  63. {
  64.         if(counter!=0)
  65.         {
  66.                 #ifdef PROJECT_DEBUG
  67.                 printf("%s",buffer);
  68.                 #endif
  69.                 counter=0;
  70.                 memset(buffer,0,1024);
  71.                 timer=11;
  72. }
  73. }
  74. }
  75. #elif SPIFLASH_DEBUG
  76. uint32_t BaseAdd;
  77. uint32_t Address;
  78. uint8_t MSB=0xce,LSB=0xa1;
  79. uint8_t dot[118];
  80. SystemInit();
  81. spi_flash_init();;
  82. while(1)
  83. {
  84.         BaseAdd=BASEADD_GB2312_11X12;
  85.         if(MSB>=0xA1&&MSB<=0Xa9&&LSB>=0xA1)
  86.         {
  87.                 Address=((MSB-0xA1)*94+(LSB-0xA1))*24+BaseAdd;
  88. }
  89. else if(MSB>=0xB0&&MSB<=0xF7&&LSB>=0xA1)
  90. {
  91.         Address=((MSB-0xA1)*94+(LSB-0xA1)+846)*24+BaseAdd;
  92. }
  93. read_spi_flash(Address,&dot[0],118);          /*取點陣*/
  94. LSB++;
  95. }
  96. #elif PRINTER_HEAD_DEBUG
  97. int i,keyval,keyval_bak;
  98. uint32_t j;
  99. SystemInit();
  100. Init_Sys_Parameter();
  101. init_Global_Variables();
  102. init_Printer_port();
  103. init_key();                          /*4、按鍵初始化*/
  104. while(1)
  105. {
  106.        
  107. }
  108. #elif TIMER_TEST
  109. uint16_t time;
  110. uint8_t i;
  111. SystemInit();
  112. Init_Sys_Parameter();
  113. init_Global_Variables();
  114. UARTInit(115200);
  115. common_timer(1,1000);
  116. while(1);
  117. #else
  118. uint32_t timer=0;                          /*用于記錄連續讀不到串口數據的次數*/
  119. uint16_t get_dot_count;
  120. uint16_t effective_dot,num;                /*可以用于打印的點的個數*/
  121. SystemInit();
  122. Init_Sys_Parameter();
  123. Init_project_Parameter();
  124. init_Global_Variables();
  125. UARTInit(sys_Parameter.uart_para.baudrate);   /*1、數據終端通訊串口初始化*/
  126. init_Printer_port();                         /*2、熱敏打印頭接口初始化         */
  127. spi_flash_init();                           /*3、字庫芯片通訊初始化         */
  128. init_key();                                /*4、按鍵led 初始化*/
  129. init_led();
  130. common_timer(1,COMMON_TIME);              /*啟動公共定時器*/
  131. for(timer=0;timer<0xf000;timer++)         //延時,保證先前的初始化起作用
  132. {
  133.         ;
  134. }
  135. init_cutter_position();   /*讓切紙刀回到 限位開關的位置 */
  136. motor_driver_step40();    /*讓電機先反正轉40        步*/       
  137. Hardware_flow_control(UART_FREE);  /*初始化結束,允許串口接收數據*/
  138. timer=0;
  139. while(1)
  140. {
  141.         current_char_index=0;
  142.         if(UartBuffer_read()==1)  /*讀取串口數據*/
  143.         {
  144.                 timer=0;    /*串口有數據時,將此計數器復位*/
  145.                 while(current_char_index<DealBuffer_counter)
  146.                 {
  147.                         switch(project_Parameter.print_type)  /*處理串口讀出的數據*/                       
  148.                         {
  149.                                 case DATA_TYPE_CHAR_COMMAND:   /*字符或、命令*/
  150.                                         if(determine_data_command((uint8_t *)(DealBuffer+current_char_index))==0)
  151.                                         {
  152.                                                 if(Save_char()==0)
  153.                                                 {
  154.                                                         continue;
  155. }
  156. if(printer_work_Parameter.printer_work_model==PRINTER_IDLE)  /*空閑*/
  157. {
  158.         if(calculate_get_char_num(&num,&get_dot_count)==1)  /*有一行數據需要打印*/
  159.         {
  160.                 start_print(PRINT_CHAR);
  161. }
  162. }
  163. }
  164. else  /*命令處理*/
  165. {
  166.         command_deal((uint8_t *)DealBuffer);
  167. }
  168. break;
  169. #ifdef VERTICAL_GRAPH
  170. case DATA_TYPE_VERTICAL_GRAPH:           /*垂直取模圖形*/
  171.         if(save_graph()==DATA_ENOUGH)   /*數據取完,恢復默認數據類型*/
  172.         {
  173.                 project_Parameter.print_type=DATA_TYPE_CHAR_COMMAND;
  174. }
  175. break;
  176. #endif
  177. case DATA_TYPE_HORIZONTAL_GRAPH:  /*水平取模圖形*/
  178.         if(save_graph()==DATA_ENOUGH)  /*數據取完*/
  179.         {
  180.                 graph_data.data_finish=1;
  181.                 project_Parameter.print_type=DATA_TYPE_CHAR_COMMAND;
  182. }   /*空閑時,并且有一行以上的數據需要打印*/
  183. if((printer_work_Parameter.printer_work_model==PRINTER_IDLE)&&(graph_data.buffer_counter/graph_data.horizontal_mode.horizontal_byteCount>0))
  184. {
  185.         start_print(PRINT_HORIZONTAL_GRAPH);
  186. }
  187. else if((printer_work_Parameter.printer_pause==1)&&(printer_work_Parameter.printer_work_model==PRINT_HORIZONTAL_GRAPH))
  188. {     /*從暫停狀態恢復打印*/    /*        數據接收結束*/
  189.         if((graph_data.data_finish==1)||((graph_data.buffer_counter-graph_data.printed_byteCount)/graph_data.horizontal_mode.horizontal_byteCount>0))
  190.         {     /*還有至少一整行數據*/
  191.                 Resume_Print_from_pause(printer_work_Parameter.printer_work_model);
  192. }
  193. }
  194. else if((graph_data.data_finish==1)&&(printer_work_Parameter.printer_work_model!=PRINT_HORIZONTAL_GRAPH))
  195. {      /*圖片數據接收完,并且打印機還在做別的工作, 取消本次圖片打印*/
  196.         memset((graph_data_t *)&graph_data,0,sizeof(graph_data_t));
  197. }
  198. break;
  199. //case DATA_TYPE_BARCODE:  /*條形碼圖形*/
  200. //        num=save_barcode((uint8_t *)(DealBuffer+current_char_index));
  201. //if(num==DATA_ENOUGH)
  202. //{
  203. //        save_barcode_parity_bit();  /*數據取完開始打印*/
  204. //        while(printer_work_Parameter.printer_work_model!=PRINTER_IDLE)
  205. //        {
  206.         //        ;
  207. //}   /*條形碼超出打印范圍不打印*/
  208. //if(project_Parameter.cursor_position==0)  /*本行還是空的*/
  209. //{
  210. //        effective_dot=MAX_DOT_PERLINE-project_Parameter.print_position-project_Parameter.Limited_width_left_para-project_Parameter.Limited_width_right_para;
  211. //}
  212. //else
  213. //{
  214. //        effective_dot=MAX_DOT_PERLINE-project_Parameter.Limited_width_right_para-project_Parameter.cursor_position;
  215. //}
  216. //if(get_barcode_dot_width()<=effective_dot)
  217. //{
  218. //        start_print(PRINT_BARCODE);
  219. //}
  220. //else
  221. //{
  222. //        memset((barcode_data_t *)&barcode_data,0,sizeof(barcode_data_t));
  223. //}
  224. //project_Parameter.print_type=DATA_TYPE_CHAR_COMMAND;
  225. //}
  226. //else if(num==DATA_ERROR)   /*條碼數據出錯*/
  227. //{
  228. //        goto barcode_error;
  229. //}
  230. //current_char_index++;
  231. //break;
  232. }
  233. }
  234. }
  235. else  /*串口中無數據*/
  236. {
  237.         if(timer<5)
  238.         {
  239.                 timer++;
  240.                 continue;
  241. }
  242. switch(project_Parameter.print_type)
  243. {
  244.         case DATA_TYPE_CHAR_COMMAND:     
  245.                 if((printer_work_Parameter.printer_work_model==PRINTER_IDLE)&&(char_data.printed_byteCount<char_data.buffer_counter))
  246.                 {     /*空閑時,并且還有數據*/
  247.                         start_print(PRINT_CHAR);
  248. }
  249. break;
  250. #ifdef VERTICAL_GRAPH
  251. case DATA_TYPE_VERTICAL_GRAPH:           /*垂直取模圖形*/
  252.         project_Parameter.print_type=DATA_TYPE_CHAR_COMMAND;  /*丟棄原來的數據*/
  253. memset((graph_data_t *)&graph_data,0,sizeof(graph_data_t));
  254. break;
  255. #endif
  256. case DATA_TYPE_HORIZONTAL_GRAPH:
  257.         project_Parameter.print_type=DATA_TYPE_CHAR_COMMAND;   /*三次讀不到數據,認為結束*/
  258. graph_data.data_finish=1;
  259. if((printer_work_Parameter.printer_pause==1)&&(printer_work_Parameter.printer_work_model==PRINT_HORIZONTAL_GRAPH))  /*圖片打印過程中暫停*/
  260. {
  261.         Resume_Print_from_pause(printer_work_Parameter.printer_work_model);
  262. }
  263. break;
  264. case DATA_TYPE_BARCODE:
  265.         barcode_error:
  266. project_Parameter.print_type=DATA_TYPE_CHAR_COMMAND;
  267. memset((barcode_data_t *)&barcode_data,0,sizeof(barcode_data_t));
  268. break;
  269. default:
  270.         break;
  271. }
  272. }
  273. }
  274. #endif
  275. }
復制代碼


回復

使用道具 舉報

ID:234818 發表于 2018-1-31 13:02 | 顯示全部樓層
用的是哪款打印機機芯???
回復

使用道具 舉報

ID:427771 發表于 2018-11-16 15:48 | 顯示全部樓層
有沒有硬件圖紙
回復

使用道具 舉報

ID:438978 發表于 2018-12-6 15:01 | 顯示全部樓層
這個不官網上的嗎?
回復

使用道具 舉報

ID:124631 發表于 2019-10-8 13:54 | 顯示全部樓層
謝謝分享
回復

使用道具 舉報

ID:82944 發表于 2019-10-27 14:27 | 顯示全部樓層
這個不官網上的嗎?
回復

使用道具 舉報

ID:612877 發表于 2019-11-12 13:22 | 顯示全部樓層
非常厲害
回復

使用道具 舉報

ID:665260 發表于 2019-12-16 15:58 | 顯示全部樓層
熱敏打印機的選型是什么?
回復

使用道具 舉報

ID:421595 發表于 2019-12-18 08:25 | 顯示全部樓層
用的是哪款打印機機芯
回復

使用道具 舉報

您需要登錄后才可以回帖 登錄 | 立即注冊

本版積分規則

小黑屋|51黑電子論壇 |51黑電子論壇6群 QQ 管理員QQ:125739409;技術交流QQ群281945664

Powered by 單片機教程網

快速回復 返回頂部 返回列表
主站蜘蛛池模板: 亚洲国产成人精品女人久久久 | 日韩视频免费看 | 久久另类 | 亚洲欧美精品在线观看 | 99精品视频免费在线观看 | 欧美亚洲国产一区 | 国产二区精品视频 | 日本精品视频在线观看 | 国产精品一级 | 亚洲一区二区三区在线 | 国产精品mv在线观看 | 自拍偷拍亚洲欧美 | 久久久无码精品亚洲日韩按摩 | 国产日韩精品在线 | 91国自视频 | 国产欧美一区二区三区久久手机版 | 亚洲福利一区 | 成人夜晚看av | www国产亚洲精品久久网站 | 国产精品成人国产乱 | 一区二区三区视频在线免费观看 | 久久久精品国产 | 日韩a| 欧美 日韩 国产 在线 | 久久在线 | 乳色吐息在线观看 | 亚洲一区二区三区国产 | 男人天堂手机在线视频 | 日本高清aⅴ毛片免费 | 男女视频免费 | 在线免费中文字幕 | 成人黄页在线观看 | 久久一日本道色综合久久 | 日韩av一区在线观看 | 99热这里都是精品 | 国产91视频一区二区 | 国产免费一区二区 | 免费观看的黄色网址 | 国产伦精品一区二区三区高清 | 国产精品极品美女在线观看免费 | 日韩有码一区 |