daScreen.c 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687
  1. #include "daScreen.h"
  2. #include <rtthread.h>
  3. #include "usart.h"
  4. #include "buffer.h"
  5. #include "display.h"
  6. #include <stdlib.h>
  7. unsigned char cmdHead[13] = {0x3A,0x2A,0x48,0x46,0x36,0x30,0x31,0x41,0x41,0x53,0x37,0x30,0x31};
  8. unsigned char cmdEnd[2] = {0x0D,0x0A};
  9. const unsigned char cmd_kpttmrwatch[24] = {0x20, 0x20, 0x20, 0x20, 0x20, 0xBF, 0xC6, 0xC5, 0xC8, 0xCC, 0xDA, 0x54, 0x4D, 0x52,
  10. 0x57, 0x61, 0x74, 0x63, 0x68, 0x20, 0x20, 0x20, 0x20, 0x20
  11. };
  12. const unsigned char cmd_kpttmrwatchxt[24] = {0x20, 0x20, 0x20, 0xC8, 0xAB, 0xBB, 0xEC, 0xBA, 0xCF, 0xC8, 0xD5, 0xC1, 0xB8, 0xBC,
  13. 0xE0, 0xB9, 0xDC, 0xCF, 0xB5, 0xCD, 0xB3, 0x20, 0x20, 0x20
  14. };
  15. const unsigned char cmd_Stop[24] = {0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0xC7, 0xEB, 0xCD, 0xA3, 0xD6, 0xB9, 0xBC,
  16. 0xD3, 0xC1, 0xCF, 0x0D, 0x0A, 0x20, 0x20, 0x20, 0x20, 0x20
  17. };
  18. const unsigned char cmd_Sum[6] = {0xD4, 0xD8, 0xD6, 0xD8, 0xA3, 0xBA};
  19. const unsigned char cmd_Next[6] = {0xC7, 0xEB, 0xB1, 0xB8, 0xA3, 0xBA};
  20. unsigned char TempCmd[100];
  21. //unsigned char Tempdisplay[200]= {0x01,0x00,0x00,0x80,0x00,0x00,0x00,0x00,
  22. // 0x00,0x00,0x63,0x02,0x37,0x00,0xA3,0x06, //6K3
  23. // 0x02,0x01,0x00,0x00,0x01,0x2E,0x00,0x00,
  24. // 0x08,0x80,0x04,0x00,0xB8,0x80,0x10,0x00,
  25. // 0x00,0x00,0x00,0x0A,0x00,0x00,0x00,0x00,
  26. // 0x02,0x01,0x01,0x00,0x00,0x00,0x13,0x00,
  27. // 0x00,0x00
  28. // };
  29. unsigned char Tempdisplay[200]= {0x01,0x00,0x00,0x80,0x00,0x00,0x00,0x00,
  30. 0x00,0x00,0x69,0x02,0x37,0x00,0xA3,0x06, //6K4
  31. 0x02,0x01,0x00,0x00,0x01,0x2E,0x00,0x00,
  32. 0x08,0x80,0x04,0x00,0xB8,0x80,0x10,0x00,
  33. 0x00,0x00,0x00,0x0A,0x00,0x00,0x00,0x00,
  34. 0x02,0x01,0x01,0x00,0x00,0x00,0x13,0x00,
  35. 0x00,0x00
  36. };
  37. unsigned char tmep_Weight[10];
  38. unsigned char i=0;
  39. unsigned char display_productName_v[40] = {0x5C,0x43,0x31};
  40. unsigned char display_Current_v[40] = {0x5C,0x43,0x31};
  41. unsigned char display_Next_v[40] = {0x5C,0x43,0x31};
  42. unsigned char display_Process_v[40] = {0x20,0x20,0x20};
  43. unsigned char display_Total_v[40] = {0x20,0x20,0x20};
  44. unsigned char display_Stop_v[40] = {0x20,0x20,0x20};
  45. extern unsigned char WeightConst_Run;
  46. extern unsigned char WeightConst_Product_Run; //开始运行
  47. extern unsigned char WeightConst_product[];
  48. extern unsigned short WeightConst_productW; //目标总量
  49. extern unsigned char WeightConst_feed[]; //原料名称
  50. extern unsigned char WeightConst_Nextfeed[]; //临时表
  51. extern signed short WeightConst_NextWeightTarget; //目标重量
  52. extern signed long WeightConst_WeightCurTem;
  53. extern unsigned char WeightConst_Weight_display[];
  54. extern unsigned char ScreenBuf_Pop(void);
  55. extern int ScreenBufSize(void);
  56. extern unsigned char WeightConst_SBType;
  57. extern unsigned char WeightConst_remoteDisplay;
  58. extern unsigned char inMenu;
  59. extern unsigned char isn; //是否新大屏
  60. unsigned char finish_send;
  61. void cmd_head(uint8_t *buf, unsigned char j)
  62. {
  63. for(int i=0; i<13; i++) buf[i] = cmdHead[i];
  64. buf[6] = j + '0';
  65. }
  66. void cmd_end(uint8_t *buf, unsigned char j)
  67. {
  68. for(int i=0; i<2; i++)
  69. buf[j+i] = cmdEnd[i];
  70. }
  71. void cmd_null(uint8_t *buf, unsigned char j, unsigned char k)
  72. {
  73. for(int i=0; i<k; i++) buf[13+j+i] = 0x20;
  74. }
  75. void clearScreen(unsigned char j)
  76. {
  77. switch (j){
  78. case 1:
  79. rt_memset(display_productName_v, 0x20, 40);
  80. cmd_head(display_productName_v, j);
  81. cmd_end(display_productName_v, 37);
  82. break;
  83. case 2:
  84. rt_memset(display_Current_v,0x20,40);
  85. cmd_head(display_Current_v, j);
  86. cmd_end(display_Current_v, 37);
  87. break;
  88. case 3:
  89. rt_memset(display_Process_v,0x20,40);
  90. cmd_head(display_Process_v, j);
  91. cmd_end(display_Process_v, 37);
  92. break;
  93. case 4:
  94. rt_memset(display_Total_v,0x20,40);
  95. cmd_head(display_Total_v, j);
  96. cmd_end(display_Total_v, 37);
  97. break;
  98. case 5:
  99. rt_memset(display_Next_v,0x20,40);
  100. cmd_head(display_Next_v, j);
  101. cmd_end(display_Next_v, 37);
  102. break;
  103. case 6:
  104. rt_memset(display_Stop_v,0x20,40);
  105. cmd_head(display_Stop_v, j);
  106. cmd_end(display_Stop_v, 37);
  107. break;
  108. }
  109. }
  110. void display_KPT_TMRWatch(void)
  111. {
  112. clearScreen(1);
  113. for (int j=0; j<39; j++) uart4_send_data[j] = display_productName_v[j];
  114. send_uart4_send_data();
  115. clearScreen(2);
  116. for(int i=0; i<24; i++) display_Current_v[13+i] = cmd_kpttmrwatch[i];
  117. for (int j=0; j<39; j++) uart4_send_data[j] = display_Current_v[j];
  118. send_uart4_send_data();
  119. clearScreen(3);
  120. for (int j=0; j<39; j++) uart4_send_data[j] = display_Process_v[j];
  121. send_uart4_send_data();
  122. clearScreen(4);
  123. for(int i=0; i<24; i++) display_Total_v[13+i] = cmd_kpttmrwatchxt[i];
  124. for (int j=0; j<39; j++) uart4_send_data[j] = display_Total_v[j];
  125. send_uart4_send_data();
  126. clearScreen(5);
  127. for (int j=0; j<39; j++) uart4_send_data[j] = display_Next_v[j];
  128. send_uart4_send_data();
  129. clearScreen(6);
  130. for (int j=0; j<39; j++) uart4_send_data[j] = display_Stop_v[j];
  131. send_uart4_send_data();
  132. }
  133. void display_productName(void) //显示产品名称
  134. {
  135. clearScreen(1);
  136. for (int i = 0; i < 22; i++)
  137. display_productName_v[13+2+i] = WeightConst_product[i];
  138. }
  139. void display_Current(int weight) // 苜蓿 300显示当前加工原料合计重
  140. {
  141. int Weight_displayW, i; //显示重量
  142. clearScreen(2);
  143. if (inMenu)
  144. {
  145. for(i=0; i<8; i++)
  146. display_Current_v[13+2+i] = WeightConst_feed[i];
  147. }
  148. else{
  149. for(i=0; i<16; i++)
  150. display_Current_v[13+2+i] = WeightConst_feed[i];
  151. }
  152. i=35;
  153. Weight_displayW = weight;
  154. for(;;) {
  155. i--;
  156. if (Weight_displayW>0)
  157. {
  158. display_Current_v[i] = (Weight_displayW)%10 + '0';
  159. Weight_displayW = Weight_displayW/10;
  160. } else break;
  161. }
  162. }
  163. void display_Current_noweight(void) // 苜蓿 300显示当前加工原料合计重
  164. {
  165. display_Current(-1);
  166. }
  167. void display_menu(void) // 苜蓿 300显示当前加工原料合计重
  168. {
  169. display_Current_noweight();
  170. }
  171. void display_Now(void) // 少 30显示当前差异重量
  172. {
  173. clearScreen(3);
  174. if (WeightConst_Product_Run || inMenu)
  175. {
  176. cmd_head(display_Process_v, 3);
  177. for(int i = 0; i < 8; i++)
  178. display_Process_v[13+14+i] = WeightConst_Weight_display[7-i];
  179. cmd_end(display_Process_v, 37);
  180. }
  181. }
  182. void display_Next(void) // 请备:羊草 500显示当前合计重
  183. {
  184. int Weight_displayW, i; //显示重量
  185. clearScreen(5);
  186. if(WeightConst_Nextfeed[0]==0xD6 &&
  187. WeightConst_Nextfeed[1]==0xB4 &&
  188. WeightConst_Nextfeed[2]==0xD0 &&
  189. WeightConst_Nextfeed[3]==0xD0
  190. )
  191. {
  192. for(int i=0;i<14;i++)
  193. display_Next_v[13+2+i] = WeightConst_Nextfeed[i];
  194. }
  195. else
  196. {
  197. for(int i=0; i<6; i++)
  198. display_Next_v[13+2+i] = cmd_Next[i];
  199. for(int i=0; i<10; i++)
  200. display_Next_v[13+2+6+i] = WeightConst_Nextfeed[i];
  201. i=35;
  202. Weight_displayW = abs(WeightConst_NextWeightTarget);
  203. for(;;) {
  204. i--;
  205. if (Weight_displayW>0)
  206. {
  207. display_Next_v[i] = (Weight_displayW)%10 + '0';
  208. Weight_displayW = Weight_displayW/10;
  209. } else break;
  210. }
  211. }
  212. }
  213. void display_Total(signed long weight) // 合计: 500显示当前合计重
  214. {
  215. signed long Weight_displayW, i; //显示重量
  216. clearScreen(4);
  217. for(i=0; i<6; i++)
  218. display_Total_v[13+2+i] = cmd_Sum[i];
  219. i=35;
  220. Weight_displayW = abs(WeightConst_WeightCurTem);
  221. if (Weight_displayW==0)
  222. {
  223. i--;
  224. display_Total_v[i] = 0x30;
  225. }
  226. else
  227. for(;;) {
  228. if (Weight_displayW>0)
  229. {
  230. i--;
  231. display_Total_v[i] = (Weight_displayW)%10 + '0';
  232. Weight_displayW = Weight_displayW/10;
  233. }
  234. else break;
  235. }
  236. if (WeightConst_WeightCurTem<0) display_Total_v[i-1] = 0x2d;
  237. }
  238. void display_Stop(void) // 请停止加料
  239. {
  240. clearScreen(6);
  241. for (int i = 0; i < 24; i++)
  242. display_Stop_v[13+i] = cmd_Stop[i];
  243. }
  244. void clearScreenAll(void)
  245. {
  246. for(int i=1; i<7; i++)
  247. clearScreen(i);
  248. }
  249. #define CRC16(crc,byte) (((crc) >> 8 ) ^ tabel[((crc) ^ (unsigned int) (byte)) & 0XFF])
  250. static const unsigned short tabel[256] = {
  251. 0X0000, 0XC0C1, 0XC181, 0X0140, 0XC301, 0X03C0, 0X0280, 0XC241,
  252. 0XC601, 0X06C0, 0X0780, 0XC741, 0X0500, 0XC5C1, 0XC481, 0X0440,
  253. 0XCC01, 0X0CC0, 0X0D80, 0XCD41, 0X0F00, 0XCFC1, 0XCE81, 0X0E40,
  254. 0X0A00, 0XCAC1, 0XCB81, 0X0B40, 0XC901, 0X09C0, 0X0880, 0XC841,
  255. 0XD801, 0X18C0, 0X1980, 0XD941, 0X1B00, 0XDBC1, 0XDA81, 0X1A40,
  256. 0X1E00, 0XDEC1, 0XDF81, 0X1F40, 0XDD01, 0X1DC0, 0X1C80, 0XDC41,
  257. 0X1400, 0XD4C1, 0XD581, 0X1540, 0XD701, 0X17C0, 0X1680, 0XD641,
  258. 0XD201, 0X12C0, 0X1380, 0XD341, 0X1100, 0XD1C1, 0XD081, 0X1040,
  259. 0XF001, 0X30C0, 0X3180, 0XF141, 0X3300, 0XF3C1, 0XF281, 0X3240,
  260. 0X3600, 0XF6C1, 0XF781, 0X3740, 0XF501, 0X35C0, 0X3480, 0XF441,
  261. 0X3C00, 0XFCC1, 0XFD81, 0X3D40, 0XFF01, 0X3FC0, 0X3E80, 0XFE41,
  262. 0XFA01, 0X3AC0, 0X3B80, 0XFB41, 0X3900, 0XF9C1, 0XF881, 0X3840,
  263. 0X2800, 0XE8C1, 0XE981, 0X2940, 0XEB01, 0X2BC0, 0X2A80, 0XEA41,
  264. 0XEE01, 0X2EC0, 0X2F80, 0XEF41, 0X2D00, 0XEDC1, 0XEC81, 0X2C40,
  265. 0XE401, 0X24C0, 0X2580, 0XE541, 0X2700, 0XE7C1, 0XE681, 0X2640,
  266. 0X2200, 0XE2C1, 0XE381, 0X2340, 0XE101, 0X21C0, 0X2080, 0XE041,
  267. 0XA001, 0X60C0, 0X6180, 0XA141, 0X6300, 0XA3C1, 0XA281, 0X6240,
  268. 0X6600, 0XA6C1, 0XA781, 0X6740, 0XA501, 0X65C0, 0X6480, 0XA441,
  269. 0X6C00, 0XACC1, 0XAD81, 0X6D40, 0XAF01, 0X6FC0, 0X6E80, 0XAE41,
  270. 0XAA01, 0X6AC0, 0X6B80, 0XAB41, 0X6900, 0XA9C1, 0XA881, 0X6840,
  271. 0X7800, 0XB8C1, 0XB981, 0X7940, 0XBB01, 0X7BC0, 0X7A80, 0XBA41,
  272. 0XBE01, 0X7EC0, 0X7F80, 0XBF41, 0X7D00, 0XBDC1, 0XBC81, 0X7C40,
  273. 0XB401, 0X74C0, 0X7580, 0XB541, 0X7700, 0XB7C1, 0XB681, 0X7640,
  274. 0X7200, 0XB2C1, 0XB381, 0X7340, 0XB101, 0X71C0, 0X7080, 0XB041,
  275. 0X5000, 0X90C1, 0X9181, 0X5140, 0X9301, 0X53C0, 0X5280, 0X9241,
  276. 0X9601, 0X56C0, 0X5780, 0X9741, 0X5500, 0X95C1, 0X9481, 0X5440,
  277. 0X9C01, 0X5CC0, 0X5D80, 0X9D41, 0X5F00, 0X9FC1, 0X9E81, 0X5E40,
  278. 0X5A00, 0X9AC1, 0X9B81, 0X5B40, 0X9901, 0X59C0, 0X5880, 0X9841,
  279. 0X8801, 0X48C0, 0X4980, 0X8941, 0X4B00, 0X8BC1, 0X8A81, 0X4A40,
  280. 0X4E00, 0X8EC1, 0X8F81, 0X4F40, 0X8D01, 0X4DC0, 0X4C80, 0X8C41,
  281. 0X4400, 0X84C1, 0X8581, 0X4540, 0X8701, 0X47C0, 0X4680, 0X8641,
  282. 0X8201, 0X42C0, 0X4380, 0X8341, 0X4100, 0X81C1, 0X8081, 0X4040
  283. };
  284. unsigned short CalcCRC(unsigned char *data, unsigned short size)//
  285. {
  286. unsigned short i;
  287. unsigned short crc = 0;
  288. for (i = 0; i < size; i++) {
  289. crc = CRC16(crc, data[i]);
  290. }
  291. return crc;
  292. }
  293. void clearScreenAll_(void)
  294. {
  295. unsigned short i;
  296. unsigned short crc16_;
  297. Tempdisplay[12] = 0x07; // 数据长度
  298. Tempdisplay[13] = 0x00; // 数据长度
  299. Tempdisplay[19] = 0xFF; // 是否清除
  300. Tempdisplay[20] = 0x00; //区域数
  301. crc16_ = CalcCRC(Tempdisplay, 21);
  302. Tempdisplay[21] = crc16_&0xFF;
  303. Tempdisplay[22] = (crc16_>>8)&0xFF;
  304. //A5 A5 A5 A5 A5 A5 A5 A5 01 00 00 80 00 00 00 00 00 00 63 02 07 00 A3 06 01 00 00 FF 00 A0 DA 5A
  305. if (isn>1) Tempdisplay[10]=0x69;
  306. for (i=0; i<8; i++)
  307. {
  308. uart4_send_data[i] = 0xA5;
  309. }
  310. for(i=0; i<23; i++)
  311. uart4_send_data[i+8] = Tempdisplay[i];
  312. uart4_send_data[i+8] = 0x5A;
  313. rt_sem_take(uart4_lock, RT_WAITING_FOREVER);
  314. HAL_UART_Transmit_DMA(&huart4, uart4_send_data, i+9);
  315. rt_sem_release(uart4_lock);
  316. rt_thread_mdelay(50);
  317. }
  318. void display_New_(unsigned char *data, unsigned int datasize, unsigned char isclear, unsigned char areacount,
  319. unsigned char areaX, unsigned char areaY, unsigned char areaW, unsigned char areaH,
  320. unsigned char areaID, unsigned char linesize,unsigned char SingleLine,unsigned char NewLine)
  321. {
  322. unsigned short i, j, k;
  323. unsigned short crc16_;
  324. Tempdisplay[12] = (datasize + 0x1B + 0x09) & 0xFF; // 数据长度
  325. Tempdisplay[13] = ((datasize + 0x1B + 0x09)>>8) & 0xFF;; // 数据长度
  326. Tempdisplay[19] = isclear; // 是否清除
  327. Tempdisplay[20] = areacount; // 区域数
  328. Tempdisplay[21] = (datasize + 0x1B) & 0xFF; // 区域长度
  329. Tempdisplay[22] = ((datasize + 0x1B)>>8) & 0xFF; // 区域长度
  330. Tempdisplay[24] = areaX; //区域x
  331. Tempdisplay[25] = 0x80; //区域x
  332. Tempdisplay[26] = areaY; //区域Y
  333. Tempdisplay[27] = 0x00; //区域Y
  334. Tempdisplay[28] = areaW; //区域宽
  335. Tempdisplay[29] = 0x80; //区域宽
  336. Tempdisplay[30] = areaH; //区域高
  337. Tempdisplay[31] = 0x00; //区域高
  338. Tempdisplay[32] = areaID; //区域编号
  339. Tempdisplay[33] = linesize; //行间隔
  340. Tempdisplay[40] = SingleLine; //是否多行
  341. Tempdisplay[41] = NewLine; //是否换行
  342. Tempdisplay[46] = (datasize) & 0xFF; //区域数据长度
  343. Tempdisplay[47] = (datasize>>8) & 0xFF; //区域数据长度
  344. Tempdisplay[48] = 0x00; //区域数据长度
  345. Tempdisplay[49] = 0x00; //区域数据长度
  346. if (isn>1) Tempdisplay[10]=0x69;
  347. i = 50;
  348. for (j=0; j<datasize; j++) Tempdisplay[i++] = data[j];
  349. crc16_ = CalcCRC(Tempdisplay, i);
  350. Tempdisplay[i++] = crc16_&0xFF;
  351. Tempdisplay[i++] = (crc16_>>8)&0xFF;
  352. for(j= 50 + datasize; j>0; j--) {
  353. if (Tempdisplay[j]==0xA5 || Tempdisplay[j]==0xA6 || Tempdisplay[j]==0x5A || Tempdisplay[j]==0x5B) {
  354. for(k = i ; k>j; k--) Tempdisplay[k]=Tempdisplay[k-1];
  355. if (Tempdisplay[j]==0xA5)
  356. {
  357. Tempdisplay[j] = 0xA6;
  358. Tempdisplay[j+1] = 0x02;
  359. }
  360. else if (Tempdisplay[j]==0xA6)
  361. {
  362. Tempdisplay[j] = 0xA6;
  363. Tempdisplay[j+1] = 0x01;
  364. }
  365. else if (Tempdisplay[j]==0x5A)
  366. {
  367. Tempdisplay[j] = 0x5B;
  368. Tempdisplay[j+1] = 0x02;
  369. }
  370. else if (Tempdisplay[j]==0x5B)
  371. {
  372. Tempdisplay[j] = 0x5B;
  373. Tempdisplay[j+1] = 0x01;
  374. }
  375. i++;
  376. }
  377. }
  378. for (j=0; j<8; j++) uart4_send_data[j] = 0xA5;
  379. for(j=0; j<i; j++) uart4_send_data[j+8] = Tempdisplay[j];
  380. uart4_send_data[j+8] = 0x5A;
  381. rt_sem_take(uart4_lock, RT_WAITING_FOREVER);
  382. HAL_UART_Transmit_DMA(&huart4, uart4_send_data, j+9);
  383. rt_sem_release(uart4_lock);
  384. }
  385. void display_KPT_TMRWatch_(void)
  386. {
  387. unsigned char KPT_TMRWatch[0x24] = {0x20,0x20,0xBF,0xC6,0xC5,0xC8,0xCC,0xDA,
  388. 0x54,0x4D,0x52,0x57,0x61,0x74,0x63,0x68,
  389. 0x20,0x20,0xC8,0xAB,0xBB,0xEC,0xBA,0xCF,
  390. 0xC8,0xD5,0xC1,0xB8,0xBC,0xE0,0xBF,0xD8,
  391. 0xCF,0xB5,0xCD,0xB3
  392. };
  393. display_New_(KPT_TMRWatch, 0x24,
  394. 0, // 是否清除
  395. 1, // 区域数
  396. 0x1A, //区域x
  397. 0x1E, //区域Y
  398. 0x96, //区域宽
  399. 0x22,//区域高
  400. 0, //区域编号
  401. 2, //行间隔
  402. 2,//是否多行
  403. 2);//是否换行
  404. rt_thread_mdelay(50);
  405. }
  406. void display_KPT_TMRWatch_weight_()
  407. {
  408. signed long Weight_displayW; //显示重量
  409. unsigned char i;
  410. // unsigned char KPT_TMRWatch[0x24] = {0x20,0x20,0xBF,0xC6,0xC5,0xC8,0xCC,0xDA,
  411. // 0x54,0x4D,0x52,0x57,0x61,0x74,0x63,0x68,
  412. // 0x20,0x20,0xC8,0xAB,0xBB,0xEC,0xBA,0xCF,
  413. // 0xC8,0xD5,0xC1,0xB8,0xBC,0xE0,0xBF,0xD8,
  414. // 0xCF,0xB5,0xCD,0xB3
  415. // };
  416. unsigned char KPT_TMRWatch[0x36] = {0x20,0x20,0xBF,0xC6,0xC5,0xC8,0xCC,0xDA,
  417. 0x54,0x4D,0x52,0x57,0x61,0x74,0x63,0x68,
  418. 0x20,0x20,
  419. 0xC8,0xAB,0xBB,0xEC,0xBA,0xCF,0xC8,0xD5,
  420. 0xC1,0xB8,0xBC,0xE0,0xBF,0xD8,0xCF,0xB5,
  421. 0xCD,0xB3,
  422. 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
  423. 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
  424. 0x20,0x20
  425. };
  426. i=47;
  427. Weight_displayW = abs(WeightConst_WeightCurTem);
  428. if (Weight_displayW==0)
  429. {
  430. i--;
  431. KPT_TMRWatch[i] = 0x30;
  432. }
  433. else
  434. for(;;) {
  435. if (Weight_displayW>0)
  436. {
  437. i--;
  438. KPT_TMRWatch[i] = (Weight_displayW)%10 + '0';
  439. Weight_displayW = Weight_displayW/10;
  440. }
  441. else break;
  442. }
  443. if (WeightConst_WeightCurTem<0) KPT_TMRWatch[40] = 0x2d;
  444. display_New_(KPT_TMRWatch, 0x36,
  445. 0, // 是否清除
  446. 1, // 区域数
  447. 0x1A, //区域x
  448. 0x1E, //区域Y
  449. 0x96, //区域宽
  450. 0x34,//区域高
  451. 0, //区域编号
  452. 2, //行间隔
  453. 2,//是否多行
  454. 2);//是否换行
  455. rt_thread_mdelay(50);
  456. }
  457. extern unsigned short WeightConst_Product_Run_time; //开始运行时间
  458. void display_productName_(unsigned char x) //显示产品名称
  459. {
  460. unsigned char i;
  461. int time_display; //显示时间
  462. for(i=0; i<30; i++) display_productName_v[i] = 0x20;
  463. i = 0;
  464. display_productName_v[i++] = 0x5C;
  465. display_productName_v[i++] = 0x43;
  466. display_productName_v[i++] = 0x33;
  467. if (x == 0) for(i=0; i<14; i++) display_productName_v[i+3] = WeightConst_product[i];
  468. if (WeightConst_Product_Run_time>0){
  469. i = 22;
  470. time_display = WeightConst_Product_Run_time/60;
  471. for(;;) {
  472. i--;
  473. if (time_display>0)
  474. {
  475. display_productName_v[i] = (time_display)%10 + '0';
  476. time_display = time_display/10;
  477. } else break;
  478. }
  479. display_productName_v[22]=0x3A;
  480. time_display = WeightConst_Product_Run_time%60;
  481. display_productName_v[23] = (time_display)/10 + '0';
  482. display_productName_v[24] = (time_display)%10 + '0';
  483. }
  484. }
  485. void display_Current_(int weight) // 苜蓿 300显示当前加工原料合计重
  486. {
  487. int Weight_displayW; //显示重量
  488. unsigned char i;
  489. for(i=0; i<30; i++) display_Current_v[i] = 0x20;
  490. i = 0;
  491. display_Current_v[i++] = 0x5C;
  492. display_Current_v[i++] = 0x43;
  493. display_Current_v[i++] = 0x31;
  494. if (WeightConst_feed[8]!= 0)
  495. for(i=0; i<12; i++) display_Current_v[i+3] = WeightConst_feed[i];
  496. else
  497. for(i=0; i<8; i++) display_Current_v[i+3] = WeightConst_feed[i];
  498. i = 19;
  499. display_Current_v[i++] = 0x5C;
  500. display_Current_v[i++] = 0x43;
  501. display_Current_v[i++] = 0x33;
  502. i=28;
  503. Weight_displayW = weight;
  504. for(;;) {
  505. i--;
  506. if (Weight_displayW>0)
  507. {
  508. display_Current_v[i] = (Weight_displayW)%10 + '0';
  509. Weight_displayW = Weight_displayW/10;
  510. } else break;
  511. }
  512. }
  513. void display_Current_noweight_(void) // 苜蓿 300显示当前加工原料合计重
  514. {
  515. unsigned char i;
  516. for(i=0; i<30; i++) display_Current_v[i] = 0x20;
  517. i = 0;
  518. display_Current_v[i++] = 0x5C;
  519. display_Current_v[i++] = 0x43;
  520. display_Current_v[i++] = 0x31;
  521. if (WeightConst_feed[8]!= 0)
  522. for(i=0; i<12; i++) display_Current_v[i+3] = WeightConst_feed[i];
  523. else
  524. for(i=0; i<8; i++) display_Current_v[i+3] = WeightConst_feed[i];
  525. i = 19;
  526. display_Current_v[i++] = 0x5C;
  527. display_Current_v[i++] = 0x43;
  528. display_Current_v[i++] = 0x33;
  529. }
  530. void display_Now_(signed long weight) // 少 30显示当前差异重量
  531. {
  532. signed long Weight_displayW; //显示重量
  533. unsigned char KPT_TMRWatch[160] = {0x5C,0x43,0x33};
  534. unsigned char i,j;
  535. //0-24
  536. //25-52
  537. //67-77
  538. //78-102
  539. //103-127
  540. display_productName_(0);
  541. for(i=0; i<25; i++) KPT_TMRWatch[i] = display_productName_v[i];
  542. for(i=25; i<53; i++) KPT_TMRWatch[i] = display_Current_v[i-25];
  543. for(i=103; i<128; i++) KPT_TMRWatch[i] = display_Next_v[i-103];
  544. i=67;
  545. KPT_TMRWatch[i++] = 0x5C;
  546. KPT_TMRWatch[i++] = 0x43;
  547. KPT_TMRWatch[i++] = 0x31;
  548. for(int j=7; j>=0; j--) {
  549. if (WeightConst_Product_Run || inMenu)
  550. KPT_TMRWatch[i++] = WeightConst_Weight_display[j];
  551. else
  552. KPT_TMRWatch[i++] =0x20;
  553. }
  554. KPT_TMRWatch[i++] = 0x5C;
  555. KPT_TMRWatch[i++] = 0x43;
  556. KPT_TMRWatch[i++] = 0x33;
  557. for(j=0; j<6; j++)
  558. {
  559. KPT_TMRWatch[i+j] = cmd_Sum[j];
  560. }
  561. i= 103;
  562. Weight_displayW = abs(WeightConst_WeightCurTem);
  563. if (Weight_displayW==0)
  564. {
  565. i--;
  566. KPT_TMRWatch[i] = 0x30;
  567. }
  568. else
  569. for(;;) {
  570. if (Weight_displayW>0)
  571. {
  572. i--;
  573. KPT_TMRWatch[i] = (Weight_displayW)%10 + '0';
  574. Weight_displayW = Weight_displayW/10;
  575. }
  576. else break;
  577. }
  578. if (WeightConst_WeightCurTem<0) KPT_TMRWatch[96] = 0x2d;
  579. if (WeightConst_Run || inMenu==1)
  580. display_New_(KPT_TMRWatch, 128,
  581. 0, // 是否清除
  582. 1, // 区域数
  583. 0x08, //区域x
  584. 0x02, //区域Y
  585. 0xB0, //区域宽
  586. 0x5C,//区域高
  587. 0, //区域编号
  588. 2, //行间隔
  589. 2,//是否多行
  590. 2);//是否换行
  591. }
  592. void display_Next_(void) // 请备:羊草 500显示当前合计重
  593. {
  594. int Weight_displayW; //显示重量
  595. unsigned char i;
  596. for(i=0; i<30; i++) display_Next_v[i] = 0x20;
  597. i = 0;
  598. display_Next_v[i++] = 0x5C;
  599. display_Next_v[i++] = 0x43;
  600. display_Next_v[i++] = 0x32;
  601. if (!(WeightConst_Nextfeed[0]==0xD6 &&
  602. WeightConst_Nextfeed[1]==0xB4 &&
  603. WeightConst_Nextfeed[2]==0xD0 &&
  604. WeightConst_Nextfeed[3]==0xD0 ))
  605. {
  606. if ( WeightConst_Nextfeed[0]!=0x20)
  607. for(; i<9; i++)
  608. display_Next_v[i] = cmd_Next[i-3];
  609. if (WeightConst_Nextfeed[8]!= 0)
  610. for(; i<21; i++) display_Next_v[i] = WeightConst_Nextfeed[i-9];
  611. else
  612. for(; i<17; i++) display_Next_v[i] = WeightConst_Nextfeed[i-9];
  613. i=25;
  614. Weight_displayW = WeightConst_NextWeightTarget;
  615. for(;;) {
  616. if (Weight_displayW>0)
  617. {
  618. i--;
  619. display_Next_v[i] = (Weight_displayW)%10 + '0';
  620. Weight_displayW = Weight_displayW/10;
  621. }
  622. else break;
  623. }
  624. }
  625. }