yc_paint.c 95 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944
  1. #include "user_config.h"
  2. #include "esp_log.h"
  3. #include "qr_encode.h"
  4. #include "qr_consts.h"
  5. #include "list.h"
  6. #include "esp_timer.h"
  7. static const char *LOG_TAG = "yc_paint";
  8. #include "esp_sleep.h"
  9. #include "user_sleep.h"
  10. #include "esp_mac.h"
  11. #include "freertos/FreeRTOS.h"
  12. #include "freertos/task.h"
  13. #include "freertos/queue.h"
  14. #include "freertos/semphr.h"
  15. extern TERMINAL_INFO_T terminal_info;
  16. int last_batt_precent;
  17. #if 0
  18. #define DISPLAY_BUFFER_SIZE (480 * 648 / 8)
  19. uint32_t display_size = DISPLAY_BUFFER_SIZE;
  20. unsigned char tmp_paint_buf[480*81] = {0};
  21. unsigned char last_paint_buf_left[480*81] = {0};
  22. unsigned char last_paint_buf_right[480*81] = {0};
  23. #else
  24. #define DISPLAY_BUFFER_SIZE (480 * 648 / 8)
  25. uint32_t display_size = DISPLAY_BUFFER_SIZE;
  26. unsigned char tmp_paint_buf[480 * 81] = {0};
  27. unsigned char *last_paint_buf_left = NULL;
  28. unsigned char *last_paint_buf_right = NULL;
  29. static RTC_FAST_ATTR unsigned int compressedSize = 0;
  30. static RTC_FAST_ATTR unsigned int decompressedSize = 0;
  31. static RTC_FAST_ATTR unsigned int right_compressedSize = 0;
  32. static RTC_FAST_ATTR unsigned int right_decompressedSize = 0;
  33. // #if 0 //压缩
  34. // int compressedSize = compressRLE(Paint_info.Image, 480*81, old_buffer);
  35. // printf(" src size = %d, zip size:%d\r\n",480*81,compressedSize);
  36. // memset((uint8_t*)tmp_paint_buf,0,sizeof(tmp_paint_buf));
  37. // int decompressedSize = decompressRLE(old_buffer, compressedSize, tmp_paint_buf);
  38. // printf("src size = %d unzip %d\r\n",480*81,decompressedSize);
  39. // #endif
  40. #endif
  41. RTC_FAST_ATTR uint32_t arr_heights[6] = {0};
  42. char str_operation[6] = {0xd4, 0xcb, 0xd0, 0xd0, 0x00, 0x00}; // 运行
  43. char str_upKeep[6] = {0xb1, 0xa3, 0xd1, 0xf8, 0x00, 0x00}; // 保养
  44. char str_shutDown[6] = {0xcd, 0xa3, 0xbb, 0xfa, 0x00, 0x00}; // 停机
  45. char str_safeKeep[6] = {0xb7, 0xe2, 0xb4, 0xe6, 0x00, 0x00}; // 封存
  46. char str_waitMaterials[6] = {0xb4, 0xfd, 0xc1, 0xcf, 0x00, 0x00}; // 待料
  47. char str_breakDown[6] = {0xb9, 0xca, 0xd5, 0xcf, 0x00, 0x00}; // 故障
  48. char str_inspection[6] = {0xd1, 0xb2, 0xbc, 0xec, 0x00, 0x00};
  49. char str_production[6] = {0xc9, 0xfa, 0xb2, 0xfa, 0x00, 0x00};
  50. char str_repair[6] = {0xce, 0xac, 0xd0, 0xde, 0x00, 0x00};
  51. // char str_0[14] = {0xb9,0xdc,0x20,0x20,0xc0,0xed,0x20,0x20,0xd4,0xb1,0xa3,0xba,0x00,0x00};
  52. // char str_1[14] = {0xc9,0xfa,0xb2,0xfa,0xd4,0xf0,0xc8,0xce,0xc8,0xcb,0xa3,0xba,0x00,0x00};
  53. // char str_2[14] = {0xce,0xac,0xd0,0xde,0xd4,0xf0,0xc8,0xce,0xc8,0xcb,0xa3,0xba,0x00,0x00};
  54. // char str_3[14] = {0xb1,0xa3,0xd1,0xf8,0xd4,0xf0,0xc8,0xce,0xc8,0xcb,0xa3,0xba,0x00,0x00};
  55. // char str_4[14] = {0xd1,0xb2,0xbc,0xec,0xd4,0xf0,0xc8,0xce,0xc8,0xcb,0xa3,0xba,0x00,0x00};
  56. static bool isASCII(char c);
  57. static bool isGBKChinese(char c1, char c2);
  58. static void countCharacters(const char *str, int *chineseCount, int *asciiCount);
  59. static int calculateStringWidth(const char *str, int en_px, int cn_px);
  60. static void QRGenerator(char *input);
  61. static void displayQRCode(int side, uint8_t *bitdata, int x, int y)
  62. {
  63. int i = 0;
  64. int j = 0;
  65. int a = 0;
  66. for (i = 0; i < side; i++)
  67. {
  68. for (j = 0; j < side; j++)
  69. {
  70. a = j * side + i;
  71. if ((bitdata[a / 8] & (1 << (7 - a % 8)))) // 画点
  72. {
  73. Paint_SetPixel(x + j, y + i, WHITE); // 画一个点
  74. }
  75. else
  76. {
  77. }
  78. }
  79. }
  80. }
  81. static void QRGenerator(char *input)
  82. {
  83. // printf("%s \n",(char*)input);
  84. int side;
  85. uint8_t bitdata[QR_MAX_BITDATA];
  86. // remove newline
  87. if (input[strlen(input) - 1] == '\n')
  88. {
  89. input[strlen(input) - 1] = 0;
  90. }
  91. side = qr_encode(QR_LEVEL_L, 0, input, 0, bitdata); // 生成二维码
  92. // printf("总 %dx%d\n\nlen =%d\n", side, side,strlen((char*)bitdata)); //二维码大小
  93. memset(tmp_paint_buf, 0, DISPLAY_BUFFER_SIZE /*sizeof(tmp_paint_buf)*/);
  94. Paint_NewImage((UBYTE *)tmp_paint_buf, 40, 40, ROTATE_0, WHITE);
  95. displayQRCode(side, bitdata, 0, 0);
  96. epd_partial_cache(440, 0, 480, 80, SCREEN_LEFT, Paint_info.Image);
  97. }
  98. static void displayQRCode_expand(int side, uint8_t *bitdata, int x, int y, int expand) // expand 扩大边长的倍数
  99. {
  100. int i = 0;
  101. int j = 0;
  102. int a = 0;
  103. for (i = 0; i < side; i++)
  104. {
  105. for (j = 0; j < side; j++)
  106. {
  107. a = j * side + i;
  108. if ((bitdata[a / 8] & (1 << (7 - a % 8)))) // 画点
  109. { // Paint_SetPixel(x+j, y+i, WHITE);//画一个点
  110. Paint_DrawPoint(x + j * expand, y + i * expand, WHITE, DOT_PIXEL_2X2, DOT_FILL_RIGHTUP);
  111. }
  112. else
  113. {
  114. }
  115. }
  116. }
  117. }
  118. #include <stdio.h>
  119. #include <stdbool.h>
  120. #include <string.h>
  121. // 函数用于判断字符是否是ASCII字符
  122. static bool isASCII(char c)
  123. {
  124. return (c >= 32 && c <= 126);
  125. }
  126. // 函数用于判断字符是否是GBK编码的汉字
  127. static bool isGBKChinese(char c1, char c2)
  128. {
  129. return (c1 >= 0x81 && c1 <= 0xFE && c2 >= 0x40 && c2 <= 0xFE);
  130. }
  131. // 统计字符串中GBK编码的汉字和ASCII字符的个数
  132. static void countCharacters(const char *str, int *chineseCount, int *asciiCount)
  133. {
  134. *chineseCount = 0;
  135. *asciiCount = 0;
  136. int len = strlen(str);
  137. for (int i = 0; i < len; i++)
  138. {
  139. char c1 = str[i];
  140. if (isASCII(c1))
  141. {
  142. (*asciiCount)++;
  143. }
  144. else if (i + 1 < len)
  145. {
  146. char c2 = str[i + 1];
  147. if (isGBKChinese(c1, c2))
  148. {
  149. (*chineseCount)++;
  150. i++; // 跳过下一个字节
  151. }
  152. }
  153. }
  154. }
  155. // 函数用于计算字符串的宽度
  156. static int calculateStringWidth(const char *str, int en_px, int cn_px)
  157. {
  158. int len = 0;
  159. // if(str[0]==0)
  160. // {
  161. // len = strlen(str+1);
  162. // len++;
  163. // }
  164. // else
  165. // {
  166. len = strlen(str);
  167. // }
  168. int width = 0;
  169. for (int i = 0; i < len; i++)
  170. {
  171. // 判断字符是中文还是英文,并累加宽度
  172. if (str[i] >= 0 && str[i] <= 127)
  173. {
  174. // 英文字符
  175. width += en_px; // 假设英文字符宽度为12像素
  176. }
  177. else
  178. {
  179. // 中文字符
  180. width += cn_px; // 假设中文字符宽度为24像素
  181. i += 1;
  182. }
  183. }
  184. return width;
  185. }
  186. /*******下面是全屏缓冲区,快刷代码******/
  187. // Function to calculate and return an array of bar chart heights
  188. // Function to calculate and return an array of bar chart heights in pixels
  189. // Function to calculate and return an array of bar chart heights in pixels
  190. static unsigned int *calculateBarChartHeights(unsigned int data[], int size, unsigned int chartHeight)
  191. {
  192. unsigned int max = data[0];
  193. for (int i = 1; i < size; i++)
  194. {
  195. if (data[i] > max)
  196. {
  197. max = data[i];
  198. }
  199. }
  200. // Allocate memory for the array of heights
  201. unsigned int *heights = (unsigned int *)malloc(size * sizeof(unsigned int));
  202. for (int i = 0; i < size; i++)
  203. {
  204. if (data[i] == 0)
  205. {
  206. heights[i] = 0;
  207. }
  208. else if (data[i] == max)
  209. {
  210. // If data[i] is the maximum value, set height to chartHeight
  211. heights[i] = chartHeight;
  212. }
  213. else
  214. {
  215. // Calculate height in pixels based on proportion
  216. heights[i] = (unsigned int)(((double)data[i] / max) * chartHeight);
  217. }
  218. }
  219. return heights; // 返回高度数组
  220. }
  221. // 获得百分比曲线高度,最大值10000,为100%.XXxx为XX. 。整数位XX.小数位xx。
  222. static unsigned int *getBarChartHeights(unsigned int data[], int size, unsigned int chartHeight)
  223. {
  224. unsigned int *heights = (unsigned int *)malloc(size * sizeof(unsigned int));
  225. for (int i = 0; i < size; i++)
  226. {
  227. if (data[i] == 0)
  228. {
  229. heights[i] = 0;
  230. }
  231. else if (data[i] > 0 && data[i] < 10000)
  232. {
  233. heights[i] = (unsigned int)(((double)data[i] / 10000) * chartHeight);
  234. }
  235. else if (data[i] == 10000)
  236. {
  237. heights[i] = chartHeight;
  238. }
  239. else
  240. {
  241. ESP_LOGE(LOG_TAG, "ERR:>10000[%d]", i);
  242. heights[i] = 0;
  243. }
  244. }
  245. return heights; // 返回高度数组
  246. }
  247. // 字符居中对齐
  248. // 参数:展示字符串,屏幕宽度,单个英文字符像素,单个中文字符像素
  249. // 返回值:字符展示开始位置
  250. static int center_align(char *str, int screenWidth, int en_px, int cn_px)
  251. {
  252. // int chineseCount, asciiCount;
  253. // countCharacters(str, &chineseCount, &asciiCount);
  254. int textWidth = calculateStringWidth(str, en_px, cn_px);
  255. int x = (screenWidth - textWidth) / 2;
  256. return x;
  257. }
  258. static void QRGenerator_quick(char *input)
  259. {
  260. // printf("%s \n",(char*)input);
  261. int side;
  262. uint8_t bitdata[QR_MAX_BITDATA];
  263. // remove newline
  264. if (input[strlen(input) - 1] == '\n')
  265. {
  266. input[strlen(input) - 1] = 0;
  267. }
  268. side = qr_encode(QR_LEVEL_L, 0, input, 0, bitdata); // 生成二维码
  269. // printf("总 %dx%d\n\nlen =%d\n", side, side,strlen((char*)bitdata)); //二维码大小
  270. // memset(tmp_paint_buf,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
  271. // displayQRCode(side,bitdata,450,435);
  272. // displayQRCode(side,bitdata,500,435);
  273. displayQRCode_expand(side, bitdata, 478, 394, 2);
  274. }
  275. static uint8_t *partial_bar_chart_07_02_quick(Machine_info_t *info);
  276. static uint8_t *partial_bar_chart_07_03_quick(Machine_info_t *info);
  277. static uint8_t *partial_bar_chart_07_04_quick(Machine_info_t *info);
  278. static uint8_t *partial_bar_chart_07_02_quick(Machine_info_t *info)
  279. {
  280. #if 0
  281. // extern Node *clockIn_list;
  282. // int production_num = countClockNodes_byCMD(clockIn_list,0x00);
  283. // int repair_num = countClockNodes_byCMD(clockIn_list,0x01);
  284. // int inspection_num = countClockNodes_byCMD(clockIn_list,0x02);
  285. // int upKeep_num = countClockNodes_byCMD(clockIn_list,0x03);
  286. #else
  287. // 签到人数只加不减
  288. // int production_num = Machine_info.personnel_check_in[0];
  289. // int repair_num = Machine_info.personnel_check_in[1];
  290. // int inspection_num = Machine_info.personnel_check_in[2];
  291. // int upKeep_num = Machine_info.personnel_check_in[3];
  292. #endif
  293. char arr_string[20];
  294. uint32_t arr_num[4] = {Machine_info.checkIn_set[0].number, Machine_info.checkIn_set[1].number, Machine_info.checkIn_set[2].number, Machine_info.checkIn_set[3].number};
  295. unsigned int *numHeights = calculateBarChartHeights(arr_num, 4, 200);
  296. ESP_LOGW(LOG_TAG, "当前在岗:%ld ,%ld,%ld,%ld", arr_num[0], arr_num[1], arr_num[2], arr_num[3]);
  297. uint8_t *bar_chart_07_02_buf = (uint8_t *)calloc(480 * 300 / 8, sizeof(uint8_t)); // free();
  298. memset(tmp_paint_buf, 0, DISPLAY_BUFFER_SIZE /*sizeof(tmp_paint_buf)*/);
  299. Paint_NewImage((uint8_t *)tmp_paint_buf, 480, 300, ROTATE_0, WHITE);
  300. Paint_DrawLine(40, 250, 440, 250, WHITE, DOT_PIXEL_2X2, LINE_STYLE_SOLID);
  301. // S:screen
  302. // R:rectangle
  303. // C:CN
  304. // E:EN
  305. // L:LINE
  306. // ITV:(interval)
  307. #define BAR_LINE_Y_POS 250
  308. #define BAR_CHART_Y_MAX 250
  309. #define BAR_CHART_Y_MIN 50
  310. #define BAR_07_02_S_L_ITV 40
  311. #define BAR_07_02_L_R_ITV 18
  312. #define BAR_07_02_R_R_ITV 100
  313. #define BAR_07_02_R_WIDTH 64
  314. #define BAR_07_02_C_SKEW 2
  315. #define BAR_07_02_E_SKEW (24 + 4)
  316. #define BAR_07_02_R1 (BAR_07_02_S_L_ITV + BAR_07_02_L_R_ITV)
  317. #define BAR_07_02_C1 (BAR_07_02_R1 + BAR_07_02_C_SKEW)
  318. #define BAR_07_02_E1 (BAR_07_02_C1)
  319. #define BAR_07_02_R2 (BAR_07_02_R1 + BAR_07_02_R_R_ITV)
  320. #define BAR_07_02_C2 (BAR_07_02_C1 + BAR_07_02_R_R_ITV)
  321. #define BAR_07_02_E2 (BAR_07_02_E1 + BAR_07_02_R_R_ITV)
  322. #define BAR_07_02_R3 (BAR_07_02_R2 + BAR_07_02_R_R_ITV)
  323. #define BAR_07_02_C3 (BAR_07_02_C2 + BAR_07_02_R_R_ITV)
  324. #define BAR_07_02_E3 (BAR_07_02_E2 + BAR_07_02_R_R_ITV)
  325. #define BAR_07_02_R4 (BAR_07_02_R3 + BAR_07_02_R_R_ITV)
  326. #define BAR_07_02_C4 (BAR_07_02_C3 + BAR_07_02_R_R_ITV)
  327. #define BAR_07_02_E4 (BAR_07_02_E3 + BAR_07_02_R_R_ITV)
  328. char tmp_12[4][6] = {0};
  329. char tmp_34[4][6] = {0};
  330. memcpy(tmp_12[0], Machine_info.checkIn_set[0].other_name, 4);
  331. memcpy(tmp_34[0], Machine_info.checkIn_set[0].other_name + 4, 4);
  332. memcpy(tmp_12[1], Machine_info.checkIn_set[1].other_name, 4);
  333. memcpy(tmp_34[1], Machine_info.checkIn_set[1].other_name + 4, 4);
  334. memcpy(tmp_12[2], Machine_info.checkIn_set[2].other_name, 4);
  335. memcpy(tmp_34[2], Machine_info.checkIn_set[2].other_name + 4, 4);
  336. memcpy(tmp_12[3], Machine_info.checkIn_set[3].other_name, 4);
  337. memcpy(tmp_34[3], Machine_info.checkIn_set[3].other_name + 4, 4);
  338. memset(arr_string, 0, 20);
  339. itoa(arr_num[0], arr_string, 10);
  340. Paint_DrawRectangle(BAR_07_02_R1, BAR_LINE_Y_POS - numHeights[0], BAR_07_02_R1 + BAR_07_02_R_WIDTH, BAR_LINE_Y_POS, WHITE, 1, 1);
  341. // Paint_DrawString_CN(BAR_07_02_C1, BAR_LINE_Y_POS+BAR_07_02_C_SKEW,(char*)str_production, &chinese_type_24,FONT_FOREGROUND,FONT_BACKGROUND );
  342. Paint_DrawString_CN(BAR_07_02_C1, BAR_LINE_Y_POS + BAR_07_02_C_SKEW, tmp_12[0], &chinese_type_24, FONT_FOREGROUND, FONT_BACKGROUND);
  343. Paint_DrawString_CN(BAR_07_02_C1, BAR_LINE_Y_POS + BAR_07_02_C_SKEW + 24, tmp_34[0], &chinese_type_24, FONT_FOREGROUND, FONT_BACKGROUND);
  344. Paint_DrawString_EN(BAR_07_02_E1, BAR_LINE_Y_POS - BAR_07_02_E_SKEW - numHeights[0], (char *)arr_string, &ascii_type_12x24, FONT_FOREGROUND, FONT_BACKGROUND);
  345. memset(arr_string, 0, 20);
  346. itoa(arr_num[1], arr_string, 10);
  347. Paint_DrawRectangle(BAR_07_02_R2, BAR_LINE_Y_POS - numHeights[1], BAR_07_02_R2 + BAR_07_02_R_WIDTH, BAR_LINE_Y_POS, WHITE, 1, 1);
  348. // Paint_DrawString_CN(BAR_07_02_C2, BAR_LINE_Y_POS+BAR_07_02_C_SKEW, (char*)str_repair, &chinese_type_24,FONT_FOREGROUND,FONT_BACKGROUND );
  349. Paint_DrawString_CN(BAR_07_02_C2, BAR_LINE_Y_POS + BAR_07_02_C_SKEW, tmp_12[1], &chinese_type_24, FONT_FOREGROUND, FONT_BACKGROUND);
  350. Paint_DrawString_CN(BAR_07_02_C2, BAR_LINE_Y_POS + BAR_07_02_C_SKEW + 24, tmp_34[1], &chinese_type_24, FONT_FOREGROUND, FONT_BACKGROUND);
  351. Paint_DrawString_EN(BAR_07_02_E2, BAR_LINE_Y_POS - BAR_07_02_E_SKEW - numHeights[1], (char *)arr_string, &ascii_type_12x24, FONT_FOREGROUND, FONT_BACKGROUND);
  352. memset(arr_string, 0, 20);
  353. itoa(arr_num[2], arr_string, 10);
  354. Paint_DrawRectangle(BAR_07_02_R3, BAR_LINE_Y_POS - numHeights[2], BAR_07_02_R3 + BAR_07_02_R_WIDTH, BAR_LINE_Y_POS, WHITE, 1, 1);
  355. // Paint_DrawString_CN(BAR_07_02_C3, BAR_LINE_Y_POS+BAR_07_02_C_SKEW, (char*)str_inspection, &chinese_type_24,FONT_FOREGROUND,FONT_BACKGROUND );
  356. Paint_DrawString_CN(BAR_07_02_C3, BAR_LINE_Y_POS + BAR_07_02_C_SKEW, tmp_12[2], &chinese_type_24, FONT_FOREGROUND, FONT_BACKGROUND);
  357. Paint_DrawString_CN(BAR_07_02_C3, BAR_LINE_Y_POS + BAR_07_02_C_SKEW + 24, tmp_34[2], &chinese_type_24, FONT_FOREGROUND, FONT_BACKGROUND);
  358. Paint_DrawString_EN(BAR_07_02_E3, BAR_LINE_Y_POS - BAR_07_02_E_SKEW - numHeights[2], (char *)arr_string, &ascii_type_12x24, FONT_FOREGROUND, FONT_BACKGROUND);
  359. memset(arr_string, 0, 20);
  360. itoa(arr_num[3], arr_string, 10);
  361. Paint_DrawRectangle(BAR_07_02_R4, BAR_LINE_Y_POS - numHeights[3], BAR_07_02_R4 + BAR_07_02_R_WIDTH, BAR_LINE_Y_POS, WHITE, 1, 1);
  362. // Paint_DrawString_CN(BAR_07_02_C4, BAR_LINE_Y_POS+BAR_07_02_C_SKEW, (char*)str_upKeep, &chinese_type_24,FONT_FOREGROUND,FONT_BACKGROUND );
  363. Paint_DrawString_CN(BAR_07_02_C4, BAR_LINE_Y_POS + BAR_07_02_C_SKEW, tmp_12[3], &chinese_type_24, FONT_FOREGROUND, FONT_BACKGROUND);
  364. Paint_DrawString_CN(BAR_07_02_C4, BAR_LINE_Y_POS + BAR_07_02_C_SKEW + 24, tmp_34[3], &chinese_type_24, FONT_FOREGROUND, FONT_BACKGROUND);
  365. Paint_DrawString_EN(BAR_07_02_E4, BAR_LINE_Y_POS - BAR_07_02_E_SKEW - numHeights[3], (char *)arr_string, &ascii_type_12x24, FONT_FOREGROUND, FONT_BACKGROUND);
  366. memcpy(bar_chart_07_02_buf, Paint_info.Image, sizeof(uint8_t) * 480 * 300 / 8);
  367. free(numHeights);
  368. return bar_chart_07_02_buf;
  369. }
  370. static uint8_t *partial_bar_chart_07_03_quick(Machine_info_t *info)
  371. {
  372. char arr_string[20];
  373. uint32_t *timeHeights = calculateBarChartHeights(arr_heights, 6, 200);
  374. uint8_t *bar_chart_07_03_buf = (uint8_t *)calloc(480 * 300 / 8, sizeof(uint8_t));
  375. memset(tmp_paint_buf, 0, DISPLAY_BUFFER_SIZE /*sizeof(tmp_paint_buf)*/);
  376. Paint_NewImage((UBYTE *)tmp_paint_buf, 480, 300, ROTATE_0, WHITE);
  377. Paint_DrawLine(30, 250, 450, 250, WHITE, DOT_PIXEL_2X2, LINE_STYLE_SOLID);
  378. memset(arr_string, 0, 20);
  379. itoa(arr_heights[0], arr_string, 10);
  380. Paint_DrawRectangle(30 + 10, 250 - timeHeights[0], 30 + 10 + 50, 250, WHITE, 1, 1);
  381. // Paint_DrawString_CN(30+10+8, 250+8,(char*)str_operation, &chinese_type_24,FONT_FOREGROUND,FONT_BACKGROUND );
  382. Paint_DrawString_CN(30 + 10 + 8, 250 + 8, (char *)Machine_info.btn_operation, &chinese_type_24, FONT_FOREGROUND, FONT_BACKGROUND);
  383. Paint_DrawString_EN(30 + 10 + 8, 250 - timeHeights[0] - 4 - 24, arr_string, &ascii_type_12x24, FONT_FOREGROUND, FONT_BACKGROUND);
  384. memset(arr_string, 0, 20);
  385. itoa(arr_heights[1], arr_string, 10);
  386. Paint_DrawRectangle(30 + 10 + 70, 250 - timeHeights[1], 30 + 10 + 50 + 70, 250, WHITE, 1, 1);
  387. // Paint_DrawString_CN(30+10+8+70, 250+8,(char*)str_shutDown, &chinese_type_24,FONT_FOREGROUND,FONT_BACKGROUND );
  388. Paint_DrawString_CN(30 + 10 + 8 + 70, 250 + 8, (char *)Machine_info.btn_shutDown_info, &chinese_type_24, FONT_FOREGROUND, FONT_BACKGROUND);
  389. Paint_DrawString_EN(30 + 10 + 8 + 70, 250 - timeHeights[1] - 4 - 24, arr_string, &ascii_type_12x24, FONT_FOREGROUND, FONT_BACKGROUND);
  390. memset(arr_string, 0, 20);
  391. itoa(arr_heights[2], arr_string, 10);
  392. Paint_DrawRectangle(30 + 10 + 140, 250 - timeHeights[2], 30 + 10 + 50 + 140, 250, WHITE, 1, 1);
  393. // Paint_DrawString_CN(30+10+8+140, 250+8,(char*)str_breakDown, &chinese_type_24,FONT_FOREGROUND,FONT_BACKGROUND );
  394. Paint_DrawString_CN(30 + 10 + 8 + 140, 250 + 8, (char *)Machine_info.btn_breakDown_info, &chinese_type_24, FONT_FOREGROUND, FONT_BACKGROUND);
  395. Paint_DrawString_EN(30 + 10 + 8 + 140, 250 - timeHeights[2] - 4 - 24, arr_string, &ascii_type_12x24, FONT_FOREGROUND, FONT_BACKGROUND);
  396. memset(arr_string, 0, 20);
  397. itoa(arr_heights[3], arr_string, 10);
  398. Paint_DrawRectangle(30 + 10 + 210, 250 - timeHeights[3], 30 + 10 + 50 + 210, 250, WHITE, 1, 1);
  399. // Paint_DrawString_CN(30+10+8+210, 250+8,(char*)str_safeKeep, &chinese_type_24,FONT_FOREGROUND,FONT_BACKGROUND );
  400. Paint_DrawString_CN(30 + 10 + 8 + 210, 250 + 8, (char *)Machine_info.btn_safeKeep_info, &chinese_type_24, FONT_FOREGROUND, FONT_BACKGROUND);
  401. Paint_DrawString_EN(30 + 10 + 8 + 210, 250 - timeHeights[3] - 4 - 24, arr_string, &ascii_type_12x24, FONT_FOREGROUND, FONT_BACKGROUND);
  402. memset(arr_string, 0, 20);
  403. itoa(arr_heights[4], arr_string, 10);
  404. Paint_DrawRectangle(30 + 10 + 280, 250 - timeHeights[4], 30 + 10 + 50 + 280, 250, WHITE, 1, 1);
  405. // Paint_DrawString_CN(30+10+8+280, 250+8,(char*)str_upKeep, &chinese_type_24,FONT_FOREGROUND,FONT_BACKGROUND );
  406. Paint_DrawString_CN(30 + 10 + 8 + 280, 250 + 8, (char *)Machine_info.btn_upKeep_info, &chinese_type_24, FONT_FOREGROUND, FONT_BACKGROUND);
  407. Paint_DrawString_EN(30 + 10 + 8 + 280, 250 - timeHeights[4] - 4 - 24, arr_string, &ascii_type_12x24, FONT_FOREGROUND, FONT_BACKGROUND);
  408. memset(arr_string, 0, 20);
  409. itoa(arr_heights[5], arr_string, 10);
  410. Paint_DrawRectangle(30 + 10 + 350, 250 - timeHeights[5], 30 + 10 + 50 + 350, 250, WHITE, 1, 1);
  411. // Paint_DrawString_CN(30+10+8+350, 250+8,(char*)str_waitMaterials, &chinese_type_24,FONT_FOREGROUND,FONT_BACKGROUND );
  412. Paint_DrawString_CN(30 + 10 + 8 + 350, 250 + 8, (char *)Machine_info.btn_waitMaterials_info, &chinese_type_24, FONT_FOREGROUND, FONT_BACKGROUND);
  413. Paint_DrawString_EN(30 + 10 + 8 + 350, 250 - timeHeights[5] - 4 - 24, arr_string, &ascii_type_12x24, FONT_FOREGROUND, FONT_BACKGROUND);
  414. memcpy(bar_chart_07_03_buf, Paint_info.Image, sizeof(uint8_t) * 480 * 300 / 8);
  415. free(timeHeights);
  416. return bar_chart_07_03_buf;
  417. }
  418. static uint8_t *partial_bar_chart_07_04_quick(Machine_info_t *info)
  419. {
  420. char arr_string[20];
  421. uint32_t arr_num[4] = {Machine_info.checkIn_set[0].number, Machine_info.checkIn_set[1].number, Machine_info.checkIn_set[2].number, Machine_info.checkIn_set[3].number};
  422. uint32_t *arrHeights = calculateBarChartHeights(arr_heights, 6, 200);
  423. uint32_t *numHeights = calculateBarChartHeights(arr_num, 4, 200);
  424. uint8_t *bar_chart_07_04_buf = (uint8_t *)calloc(480 * 300 / 8, sizeof(uint8_t));
  425. memset(tmp_paint_buf, 0, DISPLAY_BUFFER_SIZE /*sizeof(tmp_paint_buf)*/);
  426. Paint_NewImage((UBYTE *)tmp_paint_buf, 480, 300, ROTATE_0, WHITE);
  427. Paint_DrawLine(10, 250, 274, 250, WHITE, DOT_PIXEL_2X2, LINE_STYLE_SOLID);
  428. Paint_DrawLine(294, 250, 470, 250, WHITE, DOT_PIXEL_2X2, LINE_STYLE_SOLID);
  429. memset(arr_string, 0, 20);
  430. itoa(arr_heights[0], arr_string, 10);
  431. Paint_DrawRectangle(10 + 2, 250 - arrHeights[0], 10 + 2 + 40, 250, WHITE, 1, 1);
  432. Paint_DrawString_CN(10 + 2 + 8, 250 + 2, (char *)Machine_info.btn_operation, &chinese_type_16, FONT_FOREGROUND, FONT_BACKGROUND);
  433. Paint_DrawString_EN(10 + 2 + 5, 250 - arrHeights[0] - 2 - 16, (char *)arr_string, &ascii_type_8x16, FONT_FOREGROUND, FONT_BACKGROUND);
  434. memset(arr_string, 0, 20);
  435. itoa(arr_heights[1], arr_string, 10);
  436. Paint_DrawRectangle(10 + 2 + 44, 250 - arrHeights[1], 10 + 2 + 40 + 44, 250, WHITE, 1, 1);
  437. Paint_DrawString_CN(10 + 2 + 8 + 44, 250 + 2, (char *)Machine_info.btn_shutDown_info, &chinese_type_16, FONT_FOREGROUND, FONT_BACKGROUND);
  438. Paint_DrawString_EN(10 + 2 + 5 + 44, 250 - arrHeights[1] - 2 - 16, (char *)arr_string, &ascii_type_8x16, FONT_FOREGROUND, FONT_BACKGROUND);
  439. memset(arr_string, 0, 20);
  440. itoa(arr_heights[2], arr_string, 10);
  441. Paint_DrawRectangle(10 + 2 + 88, 250 - arrHeights[2], 10 + 2 + 40 + 88, 250, WHITE, 1, 1);
  442. Paint_DrawString_CN(10 + 2 + 8 + 88, 250 + 2, (char *)Machine_info.btn_breakDown_info, &chinese_type_16, FONT_FOREGROUND, FONT_BACKGROUND);
  443. Paint_DrawString_EN(10 + 2 + 5 + 88, 250 - arrHeights[2] - 2 - 16, (char *)arr_string, &ascii_type_8x16, FONT_FOREGROUND, FONT_BACKGROUND);
  444. memset(arr_string, 0, 20);
  445. itoa(arr_heights[3], arr_string, 10);
  446. Paint_DrawRectangle(10 + 2 + 132, 250 - arrHeights[3], 10 + 2 + 40 + 132, 250, WHITE, 1, 1);
  447. Paint_DrawString_CN(10 + 2 + 8 + 132, 250 + 2, (char *)Machine_info.btn_safeKeep_info, &chinese_type_16, FONT_FOREGROUND, FONT_BACKGROUND);
  448. Paint_DrawString_EN(10 + 2 + 5 + 132, 250 - arrHeights[3] - 2 - 16, (char *)arr_string, &ascii_type_8x16, FONT_FOREGROUND, FONT_BACKGROUND);
  449. memset(arr_string, 0, 20);
  450. itoa(arr_heights[4], arr_string, 10);
  451. Paint_DrawRectangle(10 + 2 + 176, 250 - arrHeights[4], 10 + 2 + 40 + 176, 250, WHITE, 1, 1);
  452. Paint_DrawString_CN(10 + 2 + 8 + 176, 250 + 2, (char *)Machine_info.btn_upKeep_info, &chinese_type_16, FONT_FOREGROUND, FONT_BACKGROUND);
  453. Paint_DrawString_EN(10 + 2 + 5 + 176, 250 - arrHeights[4] - 2 - 16, (char *)arr_string, &ascii_type_8x16, FONT_FOREGROUND, FONT_BACKGROUND);
  454. memset(arr_string, 0, 20);
  455. itoa(arr_heights[5], arr_string, 10);
  456. Paint_DrawRectangle(10 + 2 + 220, 250 - arrHeights[5], 10 + 2 + 40 + 220, 250, WHITE, 1, 1);
  457. Paint_DrawString_CN(10 + 2 + 8 + 220, 250 + 2, (char *)Machine_info.btn_waitMaterials_info, &chinese_type_16, FONT_FOREGROUND, FONT_BACKGROUND);
  458. Paint_DrawString_EN(10 + 2 + 5 + 220, 250 - arrHeights[5] - 2 - 16, (char *)arr_string, &ascii_type_8x16, FONT_FOREGROUND, FONT_BACKGROUND);
  459. // next
  460. char tmp_12[4][6] = {0};
  461. char tmp_34[4][6] = {0};
  462. memcpy(tmp_12[0], Machine_info.checkIn_set[0].other_name, 4);
  463. memcpy(tmp_34[0], Machine_info.checkIn_set[0].other_name + 4, 4);
  464. memcpy(tmp_12[1], Machine_info.checkIn_set[1].other_name, 4);
  465. memcpy(tmp_34[1], Machine_info.checkIn_set[1].other_name + 4, 4);
  466. memcpy(tmp_12[2], Machine_info.checkIn_set[2].other_name, 4);
  467. memcpy(tmp_34[2], Machine_info.checkIn_set[2].other_name + 4, 4);
  468. memcpy(tmp_12[3], Machine_info.checkIn_set[3].other_name, 4);
  469. memcpy(tmp_34[3], Machine_info.checkIn_set[3].other_name + 4, 4);
  470. memset(arr_string, 0, 20);
  471. itoa(arr_num[0], arr_string, 10);
  472. Paint_DrawRectangle(294 + 2, 250 - numHeights[0], 294 + 2 + 40, 250, WHITE, 1, 1);
  473. // Paint_DrawString_CN(294+2+8, 250+2,(char*)str_production, &chinese_type_16,FONT_FOREGROUND,FONT_BACKGROUND );
  474. Paint_DrawString_CN(294 + 2 + 8, 250 + 2, tmp_12[0], &chinese_type_16, FONT_FOREGROUND, FONT_BACKGROUND);
  475. Paint_DrawString_CN(294 + 2 + 8, 250 + 2 + 16, tmp_34[0], &chinese_type_16, FONT_FOREGROUND, FONT_BACKGROUND);
  476. Paint_DrawString_EN(292 + 2 + 5, 250 - numHeights[0] - 2 - 16, (char *)arr_string, &ascii_type_8x16, FONT_FOREGROUND, FONT_BACKGROUND);
  477. memset(arr_string, 0, 20);
  478. itoa(arr_num[1], arr_string, 10);
  479. Paint_DrawRectangle(294 + 2 + 44, 250 - numHeights[1], 294 + 2 + 40 + 44, 250, WHITE, 1, 1);
  480. // Paint_DrawString_CN(294+2+8+44, 250+2,(char*)str_repair, &chinese_type_16,FONT_FOREGROUND,FONT_BACKGROUND );
  481. Paint_DrawString_CN(294 + 2 + 8 + 44, 250 + 2, tmp_12[1], &chinese_type_16, FONT_FOREGROUND, FONT_BACKGROUND);
  482. Paint_DrawString_CN(294 + 2 + 8 + 44, 250 + 2 + 16, tmp_34[1], &chinese_type_16, FONT_FOREGROUND, FONT_BACKGROUND);
  483. Paint_DrawString_EN(292 + 2 + 5 + 44, 250 - numHeights[1] - 2 - 16, (char *)arr_string, &ascii_type_8x16, FONT_FOREGROUND, FONT_BACKGROUND);
  484. memset(arr_string, 0, 20);
  485. itoa(arr_num[2], arr_string, 10);
  486. Paint_DrawRectangle(294 + 2 + 88, 250 - numHeights[2], 294 + 2 + 40 + 88, 250, WHITE, 1, 1);
  487. // Paint_DrawString_CN(294+2+8+88, 250+2, (char*)str_inspection, &chinese_type_16,FONT_FOREGROUND,FONT_BACKGROUND );
  488. Paint_DrawString_CN(294 + 2 + 8 + 88, 250 + 2, tmp_12[2], &chinese_type_16, FONT_FOREGROUND, FONT_BACKGROUND);
  489. Paint_DrawString_CN(294 + 2 + 8 + 88, 250 + 2 + 16, tmp_34[2], &chinese_type_16, FONT_FOREGROUND, FONT_BACKGROUND);
  490. Paint_DrawString_EN(292 + 2 + 5 + 88, 250 - numHeights[2] - 2 - 16, (char *)arr_string, &ascii_type_8x16, FONT_FOREGROUND, FONT_BACKGROUND);
  491. memset(arr_string, 0, 20);
  492. itoa(arr_num[3], arr_string, 10);
  493. Paint_DrawRectangle(294 + 2 + 132, 250 - numHeights[3], 294 + 2 + 40 + 132, 250, WHITE, 1, 1);
  494. // Paint_DrawString_CN(294+2+8+132, 250+2, (char*)str_upKeep, &chinese_type_16,FONT_FOREGROUND,FONT_BACKGROUND );
  495. Paint_DrawString_CN(294 + 2 + 8 + 132, 250 + 2, tmp_12[3], &chinese_type_16, FONT_FOREGROUND, FONT_BACKGROUND);
  496. Paint_DrawString_CN(294 + 2 + 8 + 132, 250 + 2 + 16, tmp_34[3], &chinese_type_16, FONT_FOREGROUND, FONT_BACKGROUND);
  497. Paint_DrawString_EN(292 + 2 + 5 + 132, 250 - numHeights[3] - 2 - 16, (char *)arr_string, &ascii_type_8x16, FONT_FOREGROUND, FONT_BACKGROUND);
  498. free(arrHeights);
  499. free(numHeights);
  500. memcpy(bar_chart_07_04_buf, Paint_info.Image, sizeof(uint8_t) * 480 * 300 / 8);
  501. return bar_chart_07_04_buf;
  502. }
  503. #define RIGHT1_HIGHT 100
  504. #define RIGHT2_HIGHT 172
  505. static uint8_t *partial_right1_quick(Machine_info_t *info)
  506. {
  507. // Machine_info.batt_precent = 100;
  508. uint8_t *partial_right1_buf = (uint8_t *)calloc(RIGHT1_HIGHT * 480 / 8, sizeof(uint8_t));
  509. memset((uint8_t *)tmp_paint_buf, 0, DISPLAY_BUFFER_SIZE /*sizeof(tmp_paint_buf)*/);
  510. Paint_NewImage((uint8_t *)tmp_paint_buf, 480, RIGHT1_HIGHT, ROTATE_0, WHITE);
  511. Paint_DrawLine(10, 95, 470, 95, WHITE, DOT_PIXEL_1X1, LINE_STYLE_SOLID);
  512. int x = center_align(&info->station_name, 480, 16, 32);
  513. Paint_DrawString_CN(x, 25, &info->station_name, &chinese_type_32, FONT_FOREGROUND, FONT_BACKGROUND);
  514. // 显示终端号码
  515. // printf(" terminal name x=%d--------------%s----------------\r\n",x,(char *)&info->terminal_name);
  516. x = center_align(&info->station_number, 480, 8, 16);
  517. Paint_DrawString_CN(x, 70, &info->station_number, &chinese_type_16, FONT_FOREGROUND, FONT_BACKGROUND);
  518. // printf(" terminal_number x=%d--------------%s----------------\r\n",x,(char *)&info->terminal_number);
  519. #define BAT_X_OFFSET 2
  520. #define BAT_Y_OFFSET 2
  521. // batt
  522. Paint_DrawBitMap_Paste((uint8_t *)gImage_battery, 480 - 50 - BAT_X_OFFSET, 24, 37, 18, 1);
  523. #if 1
  524. switch (Machine_info.batt_precent)
  525. {
  526. case 0:
  527. break;
  528. case 1 ... 25:
  529. Paint_DrawRectangle(433 - BAT_X_OFFSET, 27, 439 - BAT_X_OFFSET, 41, WHITE, 1, 1);
  530. break;
  531. case 26 ... 50:
  532. Paint_DrawRectangle(433 - BAT_X_OFFSET, 27, 439 - BAT_X_OFFSET, 41, WHITE, 1, 1);
  533. Paint_DrawRectangle(441 - BAT_X_OFFSET, 27, 447 - BAT_X_OFFSET, 41, WHITE, 1, 1);
  534. break;
  535. case 51 ... 75:
  536. Paint_DrawRectangle(433 - BAT_X_OFFSET, 27, 439 - BAT_X_OFFSET, 41, WHITE, 1, 1);
  537. Paint_DrawRectangle(441 - BAT_X_OFFSET, 27, 447 - BAT_X_OFFSET, 41, WHITE, 1, 1);
  538. Paint_DrawRectangle(449 - BAT_X_OFFSET, 27, 455 - BAT_X_OFFSET, 41, WHITE, 1, 1);
  539. break;
  540. case 76 ... 100:
  541. Paint_DrawRectangle(433 - BAT_X_OFFSET, 27, 439 - BAT_X_OFFSET, 41, WHITE, 1, 1);
  542. Paint_DrawRectangle(441 - BAT_X_OFFSET, 27, 447 - BAT_X_OFFSET, 41, WHITE, 1, 1);
  543. Paint_DrawRectangle(449 - BAT_X_OFFSET, 27, 455 - BAT_X_OFFSET, 41, WHITE, 1, 1);
  544. Paint_DrawRectangle(457 - BAT_X_OFFSET, 27, 462 - BAT_X_OFFSET, 41, WHITE, 1, 1);
  545. break;
  546. default:
  547. break;
  548. }
  549. if (!decection_state_0()) // 判断充电中逻辑
  550. {
  551. Machine_info.batt_precent = read_battery_voltage();
  552. if (Machine_info.batt_precent >= 95)
  553. {
  554. Paint_DrawBitMap_Paste((uint8_t *)gImage_charging, 480 - 47 + 37, 27 - BAT_Y_OFFSET, 8, 18, 1);
  555. }
  556. else
  557. {
  558. Paint_DrawBitMap_Paste((uint8_t *)gImage_charging, 480 - 47 + 35, 27 - BAT_Y_OFFSET, 8, 18, 1);
  559. }
  560. }
  561. #else
  562. Paint_DrawBitMap_Paste((uint8_t *)gImage_filled, 480 - 47 + 37, 24, 8, 18, 1);
  563. Paint_DrawRectangle(433, 27, 439, 41, WHITE, 1, 1);
  564. Paint_DrawRectangle(441, 27, 447, 41, WHITE, 1, 1);
  565. Paint_DrawRectangle(449, 27, 455, 41, WHITE, 1, 1);
  566. Paint_DrawRectangle(457, 27, 462, 41, WHITE, 1, 1);
  567. #endif
  568. // 添加在线离线
  569. uint8_t online[6] = {0xd4, 0xda, 0xcf, 0xdf, 0x00, 0x00}; // 在线
  570. uint8_t outline[6] = {0xc0, 0xeb, 0xcf, 0xdf, 0x00, 0x00}; // 离线
  571. Paint_DrawBitMap_Paste((uint8_t *)gImage_online, 480 - 50 - BAT_X_OFFSET - 50, 24, 37, 18, 1);
  572. if (Machine_info.paired)
  573. {
  574. Paint_DrawString_CN(480 - 50 - BAT_X_OFFSET - 50 + 3, 25, (char *)online, &chinese_type_16, FONT_BACKGROUND, FONT_FOREGROUND);
  575. }
  576. else
  577. {
  578. Paint_DrawString_CN(480 - 50 - BAT_X_OFFSET - 50 + 3, 25, (char *)outline, &chinese_type_16, FONT_BACKGROUND, FONT_FOREGROUND);
  579. }
  580. memcpy(partial_right1_buf, Paint_info.Image, sizeof(uint8_t) * 480 * RIGHT1_HIGHT / 8);
  581. return partial_right1_buf;
  582. }
  583. #define MAX_NAME_STRING_LEN 52
  584. static void dis_name(char *tmp, int len) // times为空格的次数,如果为管理员要多加4次,管理员字符串->char str_0[14] = {0xb9,0xdc,0x20,0x20,0xc0,0xed,0x20,0x20,0xd4,0xb1,0xa3,0xba,0x00,0x00};
  585. {
  586. if (len < MAX_NAME_STRING_LEN)
  587. {
  588. return;
  589. }
  590. ESP_LOGW(LOG_TAG, "------dis name----");
  591. ESP_LOG_BUFFER_HEX(LOG_TAG, tmp, len);
  592. strcpy(&tmp[MAX_NAME_STRING_LEN], " ...");
  593. tmp[MAX_NAME_STRING_LEN + 4] = 0;
  594. tmp[MAX_NAME_STRING_LEN + 5] = 0;
  595. }
  596. static uint8_t *partial_right2_quick(void)
  597. {
  598. uint8_t *partial_right2_buf = (uint8_t *)calloc(RIGHT2_HIGHT * 480 / 8, sizeof(uint8_t));
  599. char buffer[200] = {0};
  600. memset((uint8_t *)tmp_paint_buf, 0, DISPLAY_BUFFER_SIZE /*sizeof(tmp_paint_buf)*/);
  601. Paint_NewImage((UBYTE *)tmp_paint_buf, 480, RIGHT2_HIGHT, ROTATE_0, WHITE);
  602. ESP_LOGD(LOG_TAG, "paint Charge_close %d %d %d %d %d", Machine_info.person[0].Charge_close, Machine_info.person[1].Charge_close, Machine_info.person[2].Charge_close,
  603. Machine_info.person[3].Charge_close, Machine_info.person[4].Charge_close);
  604. ESP_LOGD(LOG_TAG, "责任人人数 [%d][%d][%d][%d][%d]", person_get_num(0), person_get_num(1), person_get_num(2), person_get_num(3), person_get_num(4)); // 获取当前类型人员数量
  605. // 管理员不会关闭
  606. memset((uint8_t *)buffer, 0, sizeof(buffer));
  607. strcat(buffer, (char *)Machine_info.person[0].other_name);
  608. strcat(buffer, Machine_info.person[0].string_name);
  609. dis_name(buffer, strlen(buffer));
  610. Paint_DrawString_CN(10, 7, (char *)buffer, &chinese_type_16, FONT_FOREGROUND, FONT_BACKGROUND);
  611. if (!Machine_info.person[1].Charge_close)
  612. {
  613. memset((uint8_t *)buffer, 0, sizeof(buffer));
  614. strcat(buffer, (char *)Machine_info.person[1].other_name);
  615. strcat(buffer, Machine_info.person[1].string_name);
  616. dis_name(buffer, strlen(buffer));
  617. Paint_DrawString_CN(10, 41, (char *)buffer, &chinese_type_16, FONT_FOREGROUND, FONT_BACKGROUND);
  618. }
  619. if (!Machine_info.person[2].Charge_close)
  620. {
  621. memset((uint8_t *)buffer, 0, sizeof(buffer));
  622. strcat(buffer, (char *)Machine_info.person[2].other_name);
  623. strcat(buffer, Machine_info.person[2].string_name);
  624. dis_name(buffer, strlen(buffer));
  625. Paint_DrawString_CN(10, 75, (char *)buffer, &chinese_type_16, FONT_FOREGROUND, FONT_BACKGROUND);
  626. }
  627. if (!Machine_info.person[4].Charge_close)
  628. {
  629. memset((uint8_t *)buffer, 0, sizeof(buffer));
  630. strcat(buffer, (char *)Machine_info.person[4].other_name);
  631. strcat(buffer, Machine_info.person[4].string_name);
  632. dis_name(buffer, strlen(buffer));
  633. Paint_DrawString_CN(10, 109, (char *)buffer, &chinese_type_16, FONT_FOREGROUND, FONT_BACKGROUND);
  634. }
  635. if (!Machine_info.person[3].Charge_close)
  636. {
  637. memset((uint8_t *)buffer, 0, sizeof(buffer));
  638. strcat(buffer, (char *)Machine_info.person[3].other_name);
  639. strcat(buffer, Machine_info.person[3].string_name);
  640. dis_name(buffer, strlen(buffer));
  641. Paint_DrawString_CN(10, 143, (char *)buffer, &chinese_type_16, FONT_FOREGROUND, FONT_BACKGROUND);
  642. }
  643. // ESP_LOG_BUFFER_HEX(LOG_TAG,buffer,strlen(buffer));
  644. Paint_DrawLine(10, 170, 470, 170, WHITE, DOT_PIXEL_1X1, LINE_STYLE_DOTTED);
  645. memcpy(partial_right2_buf, Paint_info.Image, sizeof(uint8_t) * 480 * RIGHT2_HIGHT / 8);
  646. return partial_right2_buf;
  647. }
  648. static char *right3_change_time_to_dis(bool flag) // flag为true 显示前四个小时 ,flag为false,显示最近
  649. {
  650. char arr_int[5];
  651. char arr_dec[5];
  652. char *arr_string = (char *)malloc(20 * sizeof(char));
  653. uint8_t time_min, time_hour;
  654. if (Machine_info.min >= 30)
  655. {
  656. if (Machine_info.hour >= 4)
  657. {
  658. time_hour = Machine_info.hour - 4;
  659. time_min = 30;
  660. }
  661. else
  662. {
  663. time_hour = Machine_info.hour + 20;
  664. time_min = 30;
  665. }
  666. }
  667. else
  668. {
  669. if (Machine_info.hour >= 4)
  670. {
  671. time_hour = Machine_info.hour - 4;
  672. time_min = 0;
  673. }
  674. else
  675. {
  676. time_hour = Machine_info.hour + 20;
  677. time_min = 0;
  678. }
  679. }
  680. if (flag)
  681. { // 前4小时
  682. memset(arr_string, 0, 20);
  683. itoa(time_hour, arr_int, 10);
  684. if (time_min == 0)
  685. {
  686. strcpy(arr_string, arr_int);
  687. strcat(arr_string, ":");
  688. strcat(arr_string, "00");
  689. }
  690. else
  691. {
  692. itoa(time_min, arr_dec, 10);
  693. strcpy(arr_string, arr_int);
  694. strcat(arr_string, ":");
  695. strcat(arr_string, arr_dec);
  696. }
  697. }
  698. else
  699. {
  700. memset(arr_string, 0, 20);
  701. itoa(Machine_info.hour, arr_int, 10);
  702. strcpy(arr_string, arr_int);
  703. strcat(arr_string, ":");
  704. if (Machine_info.min >= 30)
  705. {
  706. time_min = 30;
  707. itoa(time_min, arr_dec, 10);
  708. strcat(arr_string, arr_dec);
  709. }
  710. else
  711. {
  712. strcat(arr_string, "00");
  713. }
  714. }
  715. return arr_string;
  716. }
  717. static uint8_t *partial_right3_quick(void)
  718. {
  719. /* Get timestamp before entering sleep */
  720. // int64_t t_before_us = esp_timer_get_time();
  721. // //ESP_LOGW(LOG_TAG,"-=-=-=-=-=-=-=");
  722. // printf(" ==>[%lld]",t_before_us);
  723. uint8_t *partial_right3_buf = (uint8_t *)calloc(224 * 480 / 8, sizeof(uint8_t));
  724. #define __MAX_PIXEL 140
  725. uint32_t num_max = 0, i = 0, sum_products = 0;
  726. uint32_t num_totalProducts[8];
  727. uint32_t scale_UR[8];
  728. uint32_t scale_YR[8];
  729. uint8_t time_min, time_hour;
  730. char arr_string[20];
  731. char arr_int[5];
  732. char arr_dec[5];
  733. for (i = 0; i < 8; i++)
  734. {
  735. num_totalProducts[i] = Machine_info.num_goodProducts[i] + Machine_info.num_badProducts[i];
  736. scale_UR[i] = (Machine_info.scale_UR_int[i]) * 100 + Machine_info.scale_UR_dec[i];
  737. scale_YR[i] = (Machine_info.scale_YR_int[i]) * 100 + Machine_info.scale_YR_dec[i];
  738. // ESP_LOGW(LOG_TAG,"good:[%ld] bad[%ld]",num_goodProducts[i],num_badProducts[i]);
  739. // ESP_LOGW(LOG_TAG,"total:[%ld]",num_totalProducts[i]);
  740. // sum_products+=num_totalProducts[i];
  741. if (num_max < (Machine_info.num_goodProducts[i] + Machine_info.num_badProducts[i]))
  742. num_max = Machine_info.num_goodProducts[i] + Machine_info.num_badProducts[i];
  743. }
  744. memset((uint8_t *)tmp_paint_buf, 0, DISPLAY_BUFFER_SIZE /*sizeof(tmp_paint_buf)*/);
  745. Paint_NewImage((UBYTE *)tmp_paint_buf, 480, 224, ROTATE_0, WHITE);
  746. // Paint_DrawLine(10,2,470,2,WHITE,DOT_PIXEL_1X1,LINE_STYLE_DOTTED );
  747. Paint_DrawLine(10, 220, 470, 220, WHITE, DOT_PIXEL_1X1, LINE_STYLE_DOTTED);
  748. unsigned int *chartHeights = calculateBarChartHeights(num_totalProducts, sizeof(num_totalProducts) / sizeof(num_totalProducts[0]), __MAX_PIXEL);
  749. for (i = 0; i < 8; i++)
  750. {
  751. // chartHeights[i] = 140;
  752. Paint_DrawRectangle(60 + i * 25, 192 - chartHeights[i], 80 + i * 25, 192, WHITE, 1, 1);
  753. memset(arr_string, 0, 20);
  754. // itoa((int)num_totalProducts[i],arr_string,10);
  755. // 取消柱状图上方数值
  756. // Paint_DrawString_EN(60+i*25 ,192 - chartHeights[i]-8,(char*)arr_string, &ascii_type_5x7,FONT_FOREGROUND,FONT_BACKGROUND );
  757. // ESP_LOGW(LOG_TAG,"heights = %d",chartHeights[i]);
  758. }
  759. free(chartHeights);
  760. char *time_before = right3_change_time_to_dis(true);
  761. Paint_DrawString_EN(60, 192 + 2, time_before, &ascii_type_8x16, FONT_FOREGROUND, FONT_BACKGROUND);
  762. free(time_before);
  763. time_before = right3_change_time_to_dis(false);
  764. Paint_DrawString_EN(60 + 150, 192 + 2, time_before, &ascii_type_8x16, FONT_FOREGROUND, FONT_BACKGROUND);
  765. free(time_before);
  766. memset(arr_string, 0, 20);
  767. itoa(num_totalProducts[7], arr_string, 10);
  768. int x = center_align(&arr_string, 160, 16, 0);
  769. Paint_DrawString_EN(300 + x, 70, (char *)arr_string, &ascii_type_16x32, FONT_FOREGROUND, FONT_BACKGROUND);
  770. uint32_t tmp = 0;
  771. memset(arr_string, 0, 20);
  772. sprintf(arr_string, "%lu", num_max);
  773. Paint_DrawString_EN(10, 48, (char *)arr_string, &ascii_type_5x7, FONT_FOREGROUND, FONT_BACKGROUND);
  774. for (i = 1; i < 5; i++)
  775. {
  776. memset(arr_string, 0, 20); // 140 5
  777. tmp = (num_max / 5) * (5 - i);
  778. sprintf(arr_string, "%lu", tmp);
  779. // ESP_LOGW(LOG_TAG,"%s",arr_string);
  780. Paint_DrawString_EN(10, 48 + i * 38, (char *)arr_string, &ascii_type_5x7, FONT_FOREGROUND, FONT_BACKGROUND);
  781. // Paint_DrawString_EN(20,40+i*28,(char*)arr_string, &ascii_type_8x16,FONT_FOREGROUND,FONT_BACKGROUND );
  782. }
  783. for (i = 0; i < 4; i++) // ur yr y坐标
  784. {
  785. memset(arr_string, 0, 20);
  786. tmp = (100 / 4) * (4 - i);
  787. // strcpy(arr_string,tmp);
  788. itoa(tmp, arr_string, 10);
  789. strcat(arr_string, ".00%");
  790. Paint_DrawString_EN(60 + 200, 48 + i * 38, (char *)arr_string, &ascii_type_5x7, FONT_FOREGROUND, FONT_BACKGROUND);
  791. }
  792. char str_ur[8] = {0xbc, 0xda, 0xb6, 0xaf, 0xc2, 0xca, 0x00, 0x00};
  793. Paint_DrawString_CN(320, 170, (char *)str_ur, &chinese_type_16, FONT_FOREGROUND, FONT_BACKGROUND); // ur
  794. Paint_DrawLine(320, 170 + 16 + 3, 368, 170 + 16 + 3, WHITE, DOT_PIXEL_2X2, LINE_STYLE_SOLID);
  795. char str_yr[8] = {0xc1, 0xbc, 0xc6, 0xb7, 0xc2, 0xca, 0x00, 0x00};
  796. Paint_DrawString_CN(390, 170, (char *)str_yr, &chinese_type_16, FONT_FOREGROUND, FONT_BACKGROUND); // yr
  797. Paint_DrawLine(390, 170 + 16 + 3, 438, 170 + 16 + 3, WHITE, DOT_PIXEL_1X1, LINE_STYLE_DOTTED_2);
  798. memset(arr_int, 0, 5);
  799. memset(arr_dec, 0, 5);
  800. memset(arr_string, 0, 20);
  801. itoa(Machine_info.scale_UR_int[7], arr_int, 10);
  802. itoa(Machine_info.scale_UR_dec[7], arr_dec, 10);
  803. strcpy(arr_string, arr_int);
  804. strcat(arr_string, ".");
  805. strcat(arr_string, arr_dec);
  806. strcat(arr_string, "%");
  807. x = center_align(&arr_string, 48, 8, 16);
  808. Paint_DrawString_EN(320 + x, 170 - 16 - 1, (char *)arr_string, &ascii_type_8x16, FONT_FOREGROUND, FONT_BACKGROUND);
  809. memset(arr_int, 0, 5);
  810. memset(arr_dec, 0, 5);
  811. memset(arr_string, 0, 20);
  812. itoa(Machine_info.scale_YR_int[7], arr_int, 10);
  813. itoa(Machine_info.scale_YR_dec[7], arr_dec, 10);
  814. strcpy(arr_string, arr_int);
  815. strcat(arr_string, ".");
  816. strcat(arr_string, arr_dec);
  817. strcat(arr_string, "%");
  818. x = center_align(&arr_string, 48, 8, 16);
  819. Paint_DrawString_EN(390 + x, 170 - 16 - 1, (char *)arr_string, &ascii_type_8x16, FONT_FOREGROUND, FONT_BACKGROUND);
  820. // drawQuadraticBezierCurve(uint8_t* framebuffer, int width, int height,
  821. // int x0, int y0, int x1, int y1, int x2, int y2,
  822. // uint8_t color, int thickness)
  823. unsigned int *UR_Heights = getBarChartHeights(scale_UR, sizeof(scale_UR) / sizeof(scale_UR[0]), __MAX_PIXEL);
  824. unsigned int *YR_Heights = getBarChartHeights(scale_YR, sizeof(scale_YR) / sizeof(scale_YR[0]), __MAX_PIXEL);
  825. unsigned int tmp_heihgts[6];
  826. unsigned int tmp1_heihgts[6];
  827. // https://zhuanlan.zhihu.com/p/46676386
  828. #if 1
  829. for (i = 0; i < 6; i++)
  830. {
  831. tmp_heihgts[i] = (UR_Heights[i + 1] + UR_Heights[i + 2]) / 2;
  832. tmp1_heihgts[i] = (YR_Heights[i + 1] + YR_Heights[i + 2]) / 2;
  833. }
  834. #else
  835. for (i = 0; i < 6; i++)
  836. {
  837. tmp_heihgts[i] = 30 + i * 10;
  838. tmp1_heihgts[i] = 10 + i * 10;
  839. }
  840. #endif
  841. // UR
  842. drawQuadraticBezierCurve(Paint_info.Image, 480, 224, 72, 192 - UR_Heights[0], 72 + 25, 192 - UR_Heights[1], 72 + 25 + 12, 192 - tmp_heihgts[0], 0xff, 2);
  843. drawQuadraticBezierCurve(Paint_info.Image, 480, 224, 72 + 25 + 12, 192 - tmp_heihgts[0], 72 + 25 * 2, 192 - UR_Heights[2], 72 + 25 * 2 + 12, 192 - tmp_heihgts[1], 0xff, 2);
  844. drawQuadraticBezierCurve(Paint_info.Image, 480, 224, 72 + 25 * 2 + 12, 192 - tmp_heihgts[1], 72 + 25 * 3, 192 - UR_Heights[3], 72 + 25 * 3 + 12, 192 - tmp_heihgts[2], 0xff, 2);
  845. drawQuadraticBezierCurve(Paint_info.Image, 480, 224, 72 + 25 * 3 + 12, 192 - tmp_heihgts[2], 72 + 25 * 4, 192 - UR_Heights[4], 72 + 25 * 4 + 12, 192 - tmp_heihgts[3], 0xff, 2);
  846. drawQuadraticBezierCurve(Paint_info.Image, 480, 224, 72 + 25 * 4 + 12, 192 - tmp_heihgts[3], 72 + 25 * 5, 192 - UR_Heights[5], 72 + 25 * 5 + 12, 192 - tmp_heihgts[4], 0xff, 2);
  847. drawQuadraticBezierCurve(Paint_info.Image, 480, 224, 72 + 25 * 5 + 12, 192 - tmp_heihgts[4], 72 + 25 * 6, 192 - UR_Heights[6], 72 + 25 * 7, 192 - UR_Heights[7], 0xff, 2);
  848. drawQuadraticBezierCurve(Paint_info.Image, 480, 224, 72, 192 - UR_Heights[0] + 2, 72 + 25, 192 - UR_Heights[1] + 2, 72 + 25 + 12, 192 - tmp_heihgts[0] + 2, 0, 2);
  849. drawQuadraticBezierCurve(Paint_info.Image, 480, 224, 72 + 25 + 12, 192 - tmp_heihgts[0] + 2, 72 + 25 * 2, 192 - UR_Heights[2] + 2, 72 + 25 * 2 + 12, 192 - tmp_heihgts[1] + 2, 0, 2);
  850. drawQuadraticBezierCurve(Paint_info.Image, 480, 224, 72 + 25 * 2 + 12, 192 - tmp_heihgts[1] + 2, 72 + 25 * 3, 192 - UR_Heights[3] + 2, 72 + 25 * 3 + 12, 192 - tmp_heihgts[2] + 2, 0, 2);
  851. drawQuadraticBezierCurve(Paint_info.Image, 480, 224, 72 + 25 * 3 + 12, 192 - tmp_heihgts[2] + 2, 72 + 25 * 4, 192 - UR_Heights[4] + 2, 72 + 25 * 4 + 12, 192 - tmp_heihgts[3] + 2, 0, 2);
  852. drawQuadraticBezierCurve(Paint_info.Image, 480, 224, 72 + 25 * 4 + 12, 192 - tmp_heihgts[3] + 2, 72 + 25 * 5, 192 - UR_Heights[5] + 2, 72 + 25 * 5 + 12, 192 - tmp_heihgts[4] + 2, 0, 2);
  853. drawQuadraticBezierCurve(Paint_info.Image, 480, 224, 72 + 25 * 5 + 12, 192 - tmp_heihgts[4] + 2, 72 + 25 * 6, 192 - UR_Heights[6] + 2, 72 + 25 * 7, 192 - UR_Heights[7] + 2, 0, 2);
  854. // YR
  855. drawQuadraticBezierCurve(Paint_info.Image, 480, 224, 72, 192 - YR_Heights[0], 72 + 25, 192 - YR_Heights[1], 72 + 25 + 12, 192 - tmp1_heihgts[0], 0xff, 1);
  856. drawQuadraticBezierCurve(Paint_info.Image, 480, 224, 72 + 25 + 12, 192 - tmp1_heihgts[0], 72 + 25 * 2, 192 - YR_Heights[2], 72 + 25 * 2 + 12, 192 - tmp1_heihgts[1], 0xff, 1);
  857. drawQuadraticBezierCurve(Paint_info.Image, 480, 224, 72 + 25 * 2 + 12, 192 - tmp1_heihgts[1], 72 + 25 * 3, 192 - YR_Heights[3], 72 + 25 * 3 + 12, 192 - tmp1_heihgts[2], 0xff, 1);
  858. drawQuadraticBezierCurve(Paint_info.Image, 480, 224, 72 + 25 * 3 + 12, 192 - tmp1_heihgts[2], 72 + 25 * 4, 192 - YR_Heights[4], 72 + 25 * 4 + 12, 192 - tmp1_heihgts[3], 0xff, 1);
  859. drawQuadraticBezierCurve(Paint_info.Image, 480, 224, 72 + 25 * 4 + 12, 192 - tmp1_heihgts[3], 72 + 25 * 5, 192 - YR_Heights[5], 72 + 25 * 5 + 12, 192 - tmp1_heihgts[4], 0xff, 1);
  860. drawQuadraticBezierCurve(Paint_info.Image, 480, 224, 72 + 25 * 5 + 12, 192 - tmp1_heihgts[4], 72 + 25 * 6, 192 - YR_Heights[6], 72 + 25 * 7, 192 - YR_Heights[7], 0xff, 1);
  861. drawQuadraticBezierCurve(Paint_info.Image, 480, 224, 72, 192 - YR_Heights[0] + 1, 72 + 25, 192 - YR_Heights[1] + 1, 72 + 25 + 12, 192 - tmp1_heihgts[0], 0, 1);
  862. drawQuadraticBezierCurve(Paint_info.Image, 480, 224, 72 + 25 + 12, 192 - tmp1_heihgts[0] + 1, 72 + 25 * 2, 192 - YR_Heights[2] + 1, 72 + 25 * 2 + 12, 192 - tmp1_heihgts[1] + 1, 0, 1);
  863. drawQuadraticBezierCurve(Paint_info.Image, 480, 224, 72 + 25 * 2 + 12, 192 - tmp1_heihgts[1] + 1, 72 + 25 * 3, 192 - YR_Heights[3] + 1, 72 + 25 * 3 + 12, 192 - tmp1_heihgts[2] + 1, 0, 1);
  864. drawQuadraticBezierCurve(Paint_info.Image, 480, 224, 72 + 25 * 3 + 12, 192 - tmp1_heihgts[2] + 1, 72 + 25 * 4, 192 - YR_Heights[4] + 1, 72 + 25 * 4 + 12, 192 - tmp1_heihgts[3] + 1, 0, 1);
  865. drawQuadraticBezierCurve(Paint_info.Image, 480, 224, 72 + 25 * 4 + 12, 192 - tmp1_heihgts[3] + 1, 72 + 25 * 5, 192 - YR_Heights[5] + 1, 72 + 25 * 5 + 12, 192 - tmp1_heihgts[4] + 1, 0, 1);
  866. drawQuadraticBezierCurve(Paint_info.Image, 480, 224, 72 + 25 * 5 + 12, 192 - tmp1_heihgts[4] + 1, 72 + 25 * 6, 192 - YR_Heights[6] + 1, 72 + 25 * 7, 192 - YR_Heights[7] + 1, 0, 1);
  867. free(UR_Heights);
  868. free(YR_Heights);
  869. Paint_DrawLine(60, 192, 80 + 7 * 25, 192, WHITE, DOT_PIXEL_2X2, LINE_STYLE_SOLID); // 表格线
  870. extern Node *clockIn_list;
  871. // int production_num = countClockNodes_byCMD(clockIn_list,0x00);
  872. // int repair_num = countClockNodes_byCMD(clockIn_list,0x01);
  873. // int upKeep_num = countClockNodes_byCMD(clockIn_list,0x03);
  874. // int inspection_num = countClockNodes_byCMD(clockIn_list,0x02);
  875. int type_num[4] = {countClockNodes_byCMD(clockIn_list, 0x00), countClockNodes_byCMD(clockIn_list, 0x01), countClockNodes_byCMD(clockIn_list, 0x02), countClockNodes_byCMD(clockIn_list, 0x03)};
  876. ESP_LOGI(LOG_TAG, "在岗人数 :[%d] [%d] [%d] [%d]", type_num[0], type_num[1], type_num[2], type_num[3]);
  877. char str_arr[20];
  878. char str_ren[] = {0xc8, 0xcb, 0x00, 0x00};
  879. char str_Currently[] = {0xb5, 0xb1, 0xc7, 0xb0, 0xd4, 0xda, 0xb8, 0xda, 0x3a, 0xba, 0x00, 0x00}; // 当前在岗B5B1C7B0D4DAB8DAA3BA
  880. // char str_test[] = {0xB2,0xE2,0xCA,0xD4,0xB8,0xBA,0xD4,0xF0,0x00,0x00};
  881. // memcpy((char*)Machine_info.checkIn_set[3].other_name,str_test,strlen(str_test));//测试签到人数
  882. int all_len = 0;
  883. int other_name_len = 0;
  884. Paint_DrawString_CN(10, 5, (char *)str_Currently, &chinese_type_16, FONT_FOREGROUND, FONT_BACKGROUND);
  885. memset(str_arr, 0, 20);
  886. itoa(type_num[0], str_arr, 10);
  887. other_name_len = strlen((char *)Machine_info.checkIn_set[0].other_name) * 8;
  888. all_len = other_name_len + strlen(str_arr) * 8;
  889. if (!Machine_info.checkIn_set[0].checkIn_close)
  890. {
  891. Paint_DrawString_CN(10 + 16 * 5, 5, (char *)Machine_info.checkIn_set[0].other_name, &chinese_type_16, FONT_FOREGROUND, FONT_BACKGROUND);
  892. Paint_DrawString_EN(10 + 16 * 5 + other_name_len, 5, (char *)str_arr, &ascii_type_8x16, FONT_FOREGROUND, FONT_BACKGROUND);
  893. Paint_DrawString_CN(10 + 16 * 5 + all_len, 5, (char *)str_ren, &chinese_type_16, FONT_FOREGROUND, FONT_BACKGROUND);
  894. }
  895. memset(str_arr, 0, 20);
  896. itoa(type_num[1], str_arr, 10);
  897. other_name_len = strlen((char *)Machine_info.checkIn_set[1].other_name) * 8;
  898. all_len = other_name_len + strlen(str_arr) * 8;
  899. if (!Machine_info.checkIn_set[1].checkIn_close)
  900. {
  901. Paint_DrawString_CN(186, 5, (char *)Machine_info.checkIn_set[1].other_name, &chinese_type_16, FONT_FOREGROUND, FONT_BACKGROUND);
  902. Paint_DrawString_EN(186 + other_name_len, 5, (char *)str_arr, &ascii_type_8x16, FONT_FOREGROUND, FONT_BACKGROUND);
  903. Paint_DrawString_CN(186 + all_len, 5, (char *)str_ren, &chinese_type_16, FONT_FOREGROUND, FONT_BACKGROUND);
  904. }
  905. memset(str_arr, 0, 20);
  906. itoa(type_num[2], str_arr, 10);
  907. other_name_len = strlen((char *)Machine_info.checkIn_set[2].other_name) * 8;
  908. all_len = other_name_len + strlen(str_arr) * 8;
  909. if (!Machine_info.checkIn_set[2].checkIn_close)
  910. {
  911. Paint_DrawString_CN(282, 5, (char *)Machine_info.checkIn_set[2].other_name, &chinese_type_16, FONT_FOREGROUND, FONT_BACKGROUND);
  912. Paint_DrawString_EN(282 + other_name_len, 5, (char *)str_arr, &ascii_type_8x16, FONT_FOREGROUND, FONT_BACKGROUND);
  913. Paint_DrawString_CN(282 + all_len, 5, (char *)str_ren, &chinese_type_16, FONT_FOREGROUND, FONT_BACKGROUND);
  914. }
  915. memset(str_arr, 0, 20);
  916. itoa(type_num[3], str_arr, 10);
  917. other_name_len = strlen((char *)Machine_info.checkIn_set[3].other_name) * 8;
  918. all_len = other_name_len + strlen(str_arr) * 8;
  919. if (!Machine_info.checkIn_set[3].checkIn_close)
  920. {
  921. Paint_DrawString_CN(378, 5, (char *)Machine_info.checkIn_set[3].other_name, &chinese_type_16, FONT_FOREGROUND, FONT_BACKGROUND);
  922. Paint_DrawString_EN(378 + other_name_len, 5, (char *)str_arr, &ascii_type_8x16, FONT_FOREGROUND, FONT_BACKGROUND);
  923. Paint_DrawString_CN(378 + all_len, 5, (char *)str_ren, &chinese_type_16, FONT_FOREGROUND, FONT_BACKGROUND);
  924. }
  925. memcpy(partial_right3_buf, Paint_info.Image, sizeof(uint8_t) * 480 * 224 / 8);
  926. return partial_right3_buf;
  927. }
  928. static uint8_t *partial_right3_2_quick(void)
  929. {
  930. uint8_t *partial_right3_buf = (uint8_t *)calloc(224 * 480 / 8, sizeof(uint8_t));
  931. memset((uint8_t *)tmp_paint_buf, 0, DISPLAY_BUFFER_SIZE /*sizeof(tmp_paint_buf)*/);
  932. Paint_NewImage((UBYTE *)tmp_paint_buf, 480, 224, ROTATE_0, WHITE);
  933. Paint_DrawLine(10, 220, 470, 220, WHITE, DOT_PIXEL_1X1, LINE_STYLE_DOTTED); // 分隔右屏第三部分和第四部分线表格线
  934. #if 0
  935. extern Node *clockIn_list;
  936. int production_num = countClockNodes_byCMD(clockIn_list,0x00);
  937. int repair_num = countClockNodes_byCMD(clockIn_list,0x01);
  938. int upKeep_num = countClockNodes_byCMD(clockIn_list,0x03);
  939. int inspection_num = countClockNodes_byCMD(clockIn_list,0x02);
  940. ESP_LOGD(LOG_TAG,"(2)生产【%d】,巡检【%d】,保养【%d】,维修【%d】",production_num,repair_num,upKeep_num,inspection_num);
  941. char str_arr[20];
  942. char str_ren[4] = {0xc8,0xcb,0x00,0x00};
  943. char str_now_and_production[16] = {0xb5,0xb1,0xc7,0xb0,0xd4,0xda,0xb8,0xda,0xa3,0xba,0xc9,0xfa,0xb2,0xfa,0x00,0x00};//当前在岗:生产
  944. // char str_inspection[6] = {0xd1,0xb2,0xbc,0xec,0x00,0x00};
  945. // char str_upKeep[]
  946. memset(str_arr,0,20);
  947. itoa(production_num,str_arr,10);
  948. Paint_DrawString_CN(10, 5,(char*)str_now_and_production, &chinese_type_16,FONT_FOREGROUND,FONT_BACKGROUND );
  949. Paint_DrawString_EN(10+16*7,5,(char*)str_arr, &ascii_type_8x16,FONT_FOREGROUND,FONT_BACKGROUND );
  950. Paint_DrawString_CN(10+16*7+strlen(str_arr)*8, 5,(char*)str_ren, &chinese_type_16,FONT_FOREGROUND,FONT_BACKGROUND );
  951. memset(str_arr,0,20);
  952. itoa(inspection_num,str_arr,10);
  953. Paint_DrawString_CN(180, 5,(char*)str_inspection, &chinese_type_16,FONT_FOREGROUND,FONT_BACKGROUND );
  954. Paint_DrawString_EN(180+16*2,5,(char*)str_arr, &ascii_type_8x16,FONT_FOREGROUND,FONT_BACKGROUND );
  955. Paint_DrawString_CN(180+16*2+strlen(str_arr)*8, 5,(char*)str_ren, &chinese_type_16,FONT_FOREGROUND,FONT_BACKGROUND );
  956. memset(str_arr,0,20);
  957. itoa(upKeep_num,str_arr,10);
  958. Paint_DrawString_CN(280, 5,(char*)str_upKeep, &chinese_type_16,FONT_FOREGROUND,FONT_BACKGROUND );
  959. Paint_DrawString_EN(280+16*2,5,(char*)str_arr, &ascii_type_8x16,FONT_FOREGROUND,FONT_BACKGROUND );
  960. Paint_DrawString_CN(280+16*2+strlen(str_arr)*8, 5,(char*)str_ren, &chinese_type_16,FONT_FOREGROUND,FONT_BACKGROUND );
  961. memset(str_arr,0,20);
  962. itoa(repair_num,str_arr,10);
  963. Paint_DrawString_CN(380, 5,(char*)str_repair, &chinese_type_16,FONT_FOREGROUND,FONT_BACKGROUND );
  964. Paint_DrawString_EN(380+16*2,5,(char*)str_arr, &ascii_type_8x16,FONT_FOREGROUND,FONT_BACKGROUND );
  965. Paint_DrawString_CN(380+16*2+strlen(str_arr)*8, 5,(char*)str_ren, &chinese_type_16,FONT_FOREGROUND,FONT_BACKGROUND );
  966. #else
  967. extern Node *clockIn_list;
  968. int type_num[4] = {countClockNodes_byCMD(clockIn_list, 0x00), countClockNodes_byCMD(clockIn_list, 0x01), countClockNodes_byCMD(clockIn_list, 0x02), countClockNodes_byCMD(clockIn_list, 0x03)};
  969. char str_arr[20];
  970. ESP_LOGI(LOG_TAG, "#在岗人数 :[%d] [%d] [%d] [%d]", type_num[0], type_num[1], type_num[2], type_num[3]);
  971. char str_ren[] = {0xc8, 0xcb, 0x00, 0x00};
  972. char str_Currently[] = {0xb5, 0xb1, 0xc7, 0xb0, 0xd4, 0xda, 0xb8, 0xda, 0x3a, 0xba, 0x00, 0x00}; // 当前在岗B5B1C7B0D4DAB8DAA3BA
  973. int all_len = 0;
  974. int other_name_len = 0;
  975. Paint_DrawString_CN(10, 5, (char *)str_Currently, &chinese_type_16, FONT_FOREGROUND, FONT_BACKGROUND);
  976. memset(str_arr, 0, 20);
  977. itoa(type_num[0], str_arr, 10);
  978. other_name_len = strlen((char *)Machine_info.checkIn_set[0].other_name) * 8;
  979. all_len = other_name_len + strlen(str_arr) * 8;
  980. if (!Machine_info.checkIn_set[0].checkIn_close)
  981. {
  982. Paint_DrawString_CN(10 + 16 * 5, 5, (char *)Machine_info.checkIn_set[0].other_name, &chinese_type_16, FONT_FOREGROUND, FONT_BACKGROUND);
  983. Paint_DrawString_EN(10 + 16 * 5 + other_name_len, 5, (char *)str_arr, &ascii_type_8x16, FONT_FOREGROUND, FONT_BACKGROUND);
  984. Paint_DrawString_CN(10 + 16 * 5 + all_len, 5, (char *)str_ren, &chinese_type_16, FONT_FOREGROUND, FONT_BACKGROUND);
  985. }
  986. memset(str_arr, 0, 20);
  987. itoa(type_num[1], str_arr, 10);
  988. other_name_len = strlen((char *)Machine_info.checkIn_set[1].other_name) * 8;
  989. all_len = other_name_len + strlen(str_arr) * 8;
  990. if (!Machine_info.checkIn_set[1].checkIn_close)
  991. {
  992. Paint_DrawString_CN(186, 5, (char *)Machine_info.checkIn_set[1].other_name, &chinese_type_16, FONT_FOREGROUND, FONT_BACKGROUND);
  993. Paint_DrawString_EN(186 + other_name_len, 5, (char *)str_arr, &ascii_type_8x16, FONT_FOREGROUND, FONT_BACKGROUND);
  994. Paint_DrawString_CN(186 + all_len, 5, (char *)str_ren, &chinese_type_16, FONT_FOREGROUND, FONT_BACKGROUND);
  995. }
  996. memset(str_arr, 0, 20);
  997. itoa(type_num[2], str_arr, 10);
  998. other_name_len = strlen((char *)Machine_info.checkIn_set[2].other_name) * 8;
  999. all_len = other_name_len + strlen(str_arr) * 8;
  1000. if (!Machine_info.checkIn_set[2].checkIn_close)
  1001. {
  1002. Paint_DrawString_CN(282, 5, (char *)Machine_info.checkIn_set[2].other_name, &chinese_type_16, FONT_FOREGROUND, FONT_BACKGROUND);
  1003. Paint_DrawString_EN(282 + other_name_len, 5, (char *)str_arr, &ascii_type_8x16, FONT_FOREGROUND, FONT_BACKGROUND);
  1004. Paint_DrawString_CN(282 + all_len, 5, (char *)str_ren, &chinese_type_16, FONT_FOREGROUND, FONT_BACKGROUND);
  1005. }
  1006. memset(str_arr, 0, 20);
  1007. itoa(type_num[3], str_arr, 10);
  1008. other_name_len = strlen((char *)Machine_info.checkIn_set[3].other_name) * 8;
  1009. all_len = other_name_len + strlen(str_arr) * 8;
  1010. if (!Machine_info.checkIn_set[3].checkIn_close)
  1011. {
  1012. Paint_DrawString_CN(378, 5, (char *)Machine_info.checkIn_set[3].other_name, &chinese_type_16, FONT_FOREGROUND, FONT_BACKGROUND);
  1013. Paint_DrawString_EN(378 + other_name_len, 5, (char *)str_arr, &ascii_type_8x16, FONT_FOREGROUND, FONT_BACKGROUND);
  1014. Paint_DrawString_CN(378 + all_len, 5, (char *)str_ren, &chinese_type_16, FONT_FOREGROUND, FONT_BACKGROUND);
  1015. }
  1016. memcpy(partial_right3_buf, Paint_info.Image, sizeof(uint8_t) * 480 * 224 / 8);
  1017. #endif
  1018. // 画表格
  1019. int i;
  1020. char arr_string[20];
  1021. uint32_t tmp = 0;
  1022. // 柱状图
  1023. uint16_t num_max_manHour = 0;
  1024. uint32_t num_tmp[8];
  1025. for (i = 0; i < 8; i++)
  1026. {
  1027. num_tmp[i] = (uint32_t)Machine_info.num_manHour[i];
  1028. }
  1029. unsigned int *manHour_Heights = calculateBarChartHeights(num_tmp, 8, __MAX_PIXEL);
  1030. for (i = 0; i < 8; i++)
  1031. {
  1032. if (num_max_manHour < Machine_info.num_manHour[i])
  1033. {
  1034. num_max_manHour = Machine_info.num_manHour[i];
  1035. }
  1036. // Paint_DrawRectangle(60+i*25 ,192 - manHour_Heights[i] ,80+i*25, 192,WHITE,1,1 );
  1037. Paint_DrawRectangle(60 + i * 25, 193 - manHour_Heights[i], 80 + i * 25, 193, WHITE, 1, 1);
  1038. memset(arr_string, 0, 20);
  1039. itoa((int)Machine_info.num_manHour[i], arr_string, 10);
  1040. // ESP_LOGW(LOG_TAG,"%s",arr_string);
  1041. // 取消柱状图上方数值
  1042. Paint_DrawString_EN(60 + i * 25, 192 - manHour_Heights[i] - 8, (char *)arr_string, &ascii_type_5x7, FONT_FOREGROUND, FONT_BACKGROUND);
  1043. // ESP_LOGW(LOG_TAG,"manHour_Heights = %d,num_manHour = %d,max_manHour = %d ",manHour_Heights[i],Machine_info.num_manHour[i],num_max_manHour);
  1044. }
  1045. for (i = 0; i < 5; i++)
  1046. {
  1047. tmp = ((int)(num_max_manHour / 5)) * (5 - i);
  1048. memset(arr_string, 0, 20); // 140 5
  1049. // strcpy(arr_string,tmp);
  1050. // itoa(tmp,arr_string,10);//这里导致数值错误
  1051. sprintf(arr_string, "%lu", tmp);
  1052. // ESP_LOGW(LOG_TAG,"3——2 %s",arr_string);
  1053. Paint_DrawString_EN(20, 48 + i * 30, (char *)arr_string, &ascii_type_5x7, FONT_FOREGROUND, FONT_BACKGROUND);
  1054. }
  1055. // 右屏3_2 贝塞尔曲线
  1056. uint16_t num_max_people = 0;
  1057. for (i = 0; i < 8; i++)
  1058. {
  1059. num_tmp[i] = (uint32_t)Machine_info.num_people[i];
  1060. }
  1061. unsigned int *people_Heights = calculateBarChartHeights(num_tmp, sizeof(Machine_info.num_people) / sizeof(Machine_info.num_people[0]), __MAX_PIXEL);
  1062. unsigned int tmp_heihgts[6];
  1063. for (i = 0; i < 8; i++)
  1064. {
  1065. if (num_max_people < Machine_info.num_people[i])
  1066. {
  1067. num_max_people = Machine_info.num_people[i];
  1068. }
  1069. // ESP_LOGW(LOG_TAG,"num_people[%d]=(%d),max :[%d]",i,Machine_info.num_people[i],num_max_people);
  1070. }
  1071. // https://zhuanlan.zhihu.com/p/46676386
  1072. for (i = 0; i < 6; i++)
  1073. {
  1074. tmp_heihgts[i] = (people_Heights[i + 1] + people_Heights[i + 2]) / 2;
  1075. }
  1076. drawQuadraticBezierCurve(Paint_info.Image, 480, 224, 72, 192 - people_Heights[0], 72 + 25, 192 - people_Heights[1], 72 + 25 + 12, 192 - tmp_heihgts[0], 0xff, 1);
  1077. drawQuadraticBezierCurve(Paint_info.Image, 480, 224, 72 + 25 + 12, 192 - tmp_heihgts[0], 72 + 25 * 2, 192 - people_Heights[2], 72 + 25 * 2 + 12, 192 - tmp_heihgts[1], 0xff, 1);
  1078. drawQuadraticBezierCurve(Paint_info.Image, 480, 224, 72 + 25 * 2 + 12, 192 - tmp_heihgts[1], 72 + 25 * 3, 192 - people_Heights[3], 72 + 25 * 3 + 12, 192 - tmp_heihgts[2], 0xff, 1);
  1079. drawQuadraticBezierCurve(Paint_info.Image, 480, 224, 72 + 25 * 3 + 12, 192 - tmp_heihgts[2], 72 + 25 * 4, 192 - people_Heights[4], 72 + 25 * 4 + 12, 192 - tmp_heihgts[3], 0xff, 1);
  1080. drawQuadraticBezierCurve(Paint_info.Image, 480, 224, 72 + 25 * 4 + 12, 192 - tmp_heihgts[3], 72 + 25 * 5, 192 - people_Heights[5], 72 + 25 * 5 + 12, 192 - tmp_heihgts[4], 0xff, 1);
  1081. drawQuadraticBezierCurve(Paint_info.Image, 480, 224, 72 + 25 * 5 + 12, 192 - tmp_heihgts[4], 72 + 25 * 6, 192 - people_Heights[6], 72 + 25 * 7, 192 - people_Heights[7], 0xff, 1);
  1082. drawQuadraticBezierCurve(Paint_info.Image, 480, 224, 72, 192 - people_Heights[0] - 1, 72 + 25, 192 - people_Heights[1] - 1, 72 + 25 + 12, 192 - tmp_heihgts[0], 0, 1);
  1083. drawQuadraticBezierCurve(Paint_info.Image, 480, 224, 72 + 25 + 12, 192 - tmp_heihgts[0] - 1, 72 + 25 * 2, 192 - people_Heights[2] - 1, 72 + 25 * 2 + 12, 192 - tmp_heihgts[1] - 1, 0, 1);
  1084. drawQuadraticBezierCurve(Paint_info.Image, 480, 224, 72 + 25 * 2 + 12, 192 - tmp_heihgts[1] - 1, 72 + 25 * 3, 192 - people_Heights[3] - 1, 72 + 25 * 3 + 12, 192 - tmp_heihgts[2] - 1, 0, 1);
  1085. drawQuadraticBezierCurve(Paint_info.Image, 480, 224, 72 + 25 * 3 + 12, 192 - tmp_heihgts[2] - 1, 72 + 25 * 4, 192 - people_Heights[4] - 1, 72 + 25 * 4 + 12, 192 - tmp_heihgts[3] - 1, 0, 1);
  1086. drawQuadraticBezierCurve(Paint_info.Image, 480, 224, 72 + 25 * 4 + 12, 192 - tmp_heihgts[3] - 1, 72 + 25 * 5, 192 - people_Heights[5] - 1, 72 + 25 * 5 + 12, 192 - tmp_heihgts[4] - 1, 0, 1);
  1087. drawQuadraticBezierCurve(Paint_info.Image, 480, 224, 72 + 25 * 5 + 12, 192 - tmp_heihgts[4] - 1, 72 + 25 * 6, 192 - people_Heights[6] - 1, 72 + 25 * 7, 192 - people_Heights[7] - 1, 0, 1);
  1088. for (i = 0; i < 5; i++)
  1089. {
  1090. memset(arr_string, 0, 20);
  1091. if ((num_max_people <= 5) && (i == 0))
  1092. {
  1093. tmp = num_max_people;
  1094. }
  1095. else
  1096. {
  1097. tmp = (num_max_people / 5) * (5 - i);
  1098. }
  1099. sprintf(arr_string, "%lu", tmp);
  1100. // ESP_LOGW(LOG_TAG,"%s",arr_string);
  1101. // ESP_LOG_BUFFER_HEX(LOG_TAG,arr_string,30);
  1102. Paint_DrawString_EN(60 + 200, 48 + i * 30, (char *)arr_string, &ascii_type_5x7, FONT_FOREGROUND, FONT_BACKGROUND);
  1103. }
  1104. free(manHour_Heights);
  1105. free(people_Heights);
  1106. Paint_DrawLine(60, 193, 80 + 7 * 25, 193, WHITE, DOT_PIXEL_1X1, LINE_STYLE_SOLID);
  1107. // 画表格结束
  1108. memset(arr_string, 0, 20);
  1109. itoa(Machine_info.num_manHour[7], arr_string, 10); // 最近工时显示
  1110. i = center_align(&arr_string, 160, 16, 32);
  1111. Paint_DrawString_EN(300 + i, 70, (char *)arr_string, &ascii_type_16x32, FONT_FOREGROUND, FONT_BACKGROUND);
  1112. memset(arr_string, 0, 20);
  1113. itoa(Machine_info.num_people[7], arr_string, 10); // 最近人数显示
  1114. // strcat(arr_string,"123456");
  1115. i = center_align(&arr_string, 160, 8, 16);
  1116. Paint_DrawString_EN(300 + i, 150, (char *)arr_string, &ascii_type_8x16, FONT_FOREGROUND, FONT_BACKGROUND);
  1117. char str_people[8] = {0xC8, 0xCB, 0xCA, 0xFD, 0x00, 0x00};
  1118. // i = center_align(&arr_string,160,8,16);
  1119. Paint_DrawString_CN(300 + i + strlen(arr_string) * 4 - 16, 165, (char *)str_people, &chinese_type_16, FONT_FOREGROUND, FONT_BACKGROUND); // ur
  1120. // Paint_DrawLine(300+i,167+18,300+i+strlen(arr_string)*8,167+18,WHITE,DOT_PIXEL_1X1,LINE_STYLE_DOTTED );
  1121. Paint_DrawLine(300 + i + strlen(arr_string) * 4 - 16, 167 + 18, 300 + i + strlen(arr_string) * 4 + 16, 167 + 18, WHITE, DOT_PIXEL_1X1, LINE_STYLE_SOLID);
  1122. char *time_before = right3_change_time_to_dis(true);
  1123. Paint_DrawString_EN(60, 192 + 2, time_before, &ascii_type_8x16, FONT_FOREGROUND, FONT_BACKGROUND);
  1124. free(time_before);
  1125. time_before = right3_change_time_to_dis(false);
  1126. Paint_DrawString_EN(60 + 150, 192 + 2, time_before, &ascii_type_8x16, FONT_FOREGROUND, FONT_BACKGROUND);
  1127. free(time_before);
  1128. memcpy(partial_right3_buf, Paint_info.Image, sizeof(uint8_t) * 480 * 224 / 8);
  1129. return partial_right3_buf;
  1130. }
  1131. static uint8_t *partial_right4_quick(void)
  1132. {
  1133. uint8_t *partial_right4_buf = (uint8_t *)calloc(152 * 480 / 8, sizeof(uint8_t));
  1134. memset((uint8_t *)tmp_paint_buf, 0, DISPLAY_BUFFER_SIZE /*sizeof(tmp_paint_buf)*/);
  1135. char str_announcement[8] = {0xb9, 0xab, 0xb8, 0xe6, 0x3a, 0x00, 0x00, 0x00};
  1136. Paint_NewImage((UBYTE *)tmp_paint_buf, 480, 152, ROTATE_0, WHITE);
  1137. uint8_t *string_infor = malloc(120);
  1138. memset(string_infor, 0x00, 120);
  1139. strcat((char *)string_infor, str_announcement);
  1140. strcat((char *)string_infor, (char *)Machine_info.announcement);
  1141. Paint_DrawString_CN(10, 6, (char *)string_infor, &chinese_type_16, FONT_FOREGROUND, FONT_BACKGROUND);
  1142. free(string_infor);
  1143. // #if 0//系统消息固定
  1144. // //系统提示:系统3.01固件版本更新了新的功能,请及时更新。
  1145. // //CFB5CDB3CCE1CABE3ACFB5CDB3332E302E31B9CCBCFEB0E6B1BEB8FCD0C2C1CBD0C2B5C4B9A6C4DCA3ACC7EBBCB0CAB1B8FCD0C2A1A30A
  1146. // uint8_t string_system_message[] = {0xCF,0xB5,0xCD,0xB3,0xCC,0xE1,0xCA,0xBE,0x3A,0xCF,0xB5,0xCD,0xB3,0x33,0x2E,0x30,0x2E,0x31,0xB9,0xCC,0xBC,0xFE,0xB0,0xE6,0xB1,0xBE
  1147. // ,0xB8,0xFC,0xD0,0xC2,0xC1,0xCB,0xD0,0xC2,0xB5,0xC4,0xB9,0xA6,0xC4,0xDC,0xA3,0xAC, 0xC7,0xEB,0xBC,0xB0,0xCA,0xB1,0xB8,0xFC,0xD0,0xC2,0xA1,0xA3,0x0A,0x00,0x00};
  1148. // Paint_DrawString_CN(20, 122,(char*)string_system_message, &chinese_type_16,FONT_FOREGROUND,FONT_BACKGROUND );
  1149. // #else
  1150. // uint8_t *string_sys = malloc(120);
  1151. // char str_xitong[12] = {0xcf,0xb5,0xcd,0xb3,0xcc,0xe1,0xca,0xbe,0x3a,0x00,0x00,0x00};
  1152. // memset(string_sys,0x00,120);
  1153. // strcat((char *)string_sys,str_xitong);
  1154. // strcat((char *)string_sys,(char *)Machine_info.systemMessage);
  1155. // Paint_DrawString_CN(10, 90,(char*)string_sys, &chinese_type_16,FONT_FOREGROUND,FONT_BACKGROUND );
  1156. // free(string_sys);
  1157. // #endif
  1158. memcpy(partial_right4_buf, Paint_info.Image, sizeof(uint8_t) * 480 * 152 / 8);
  1159. return partial_right4_buf;
  1160. }
  1161. // 下面是2023.12.31 把屏幕显示全部统一
  1162. static void dis_left_sms(void)
  1163. {
  1164. ESP_LOGW(LOG_TAG, "dis left instruction book");
  1165. memset((uint8_t *)tmp_paint_buf, 0, DISPLAY_BUFFER_SIZE /*sizeof(tmp_paint_buf)*/);
  1166. Paint_NewImage((uint8_t *)tmp_paint_buf, 648, 480, ROTATE_180, WHITE);
  1167. Paint_DrawBitMap_Paste(gImage_left_instructions, 0, 0, 648, 480, 1);
  1168. // qrcode
  1169. char qrcode_string[1024] = {0};
  1170. qrcode_protocol_create(qrcode_string, Machine_info);
  1171. QRGenerator_quick(qrcode_string);
  1172. Paint_DrawBitMap_Paste((uint8_t *)gImage_nfc, 573, 215, 44, 44, 1);
  1173. epd_init_cmd(SCREEN_LEFT);
  1174. epd_display(SCREEN_LEFT, Paint_info.Image);
  1175. memcpy(last_paint_buf_left, Paint_info.Image, sizeof(uint8_t) * 648 * 480 / 8);
  1176. // int ret = memcmp(last_paint_buf_left,Paint_info.Image,38880);
  1177. // ESP_LOGW(LOG_TAG,"memcmp :ret = %d",ret);
  1178. if (memcmp(last_paint_buf_left, Paint_info.Image, 38880))
  1179. {
  1180. ESP_LOGE(LOG_TAG, "err:last_paint_buf_left");
  1181. }
  1182. }
  1183. static void dis_right_sms(void)
  1184. {
  1185. ESP_LOGW(LOG_TAG, "dis right instruction book");
  1186. memset((uint8_t *)tmp_paint_buf, 0, DISPLAY_BUFFER_SIZE /*sizeof(tmp_paint_buf)*/);
  1187. Paint_NewImage((uint8_t *)tmp_paint_buf, 648, 480, ROTATE_270, WHITE);
  1188. Paint_DrawBitMap_Paste(gImage_right_instruction, 0, 0, 480, 648, 1);
  1189. //关机显示工站名称
  1190. int x = center_align(Machine_info.station_name, 480, 16, 32);
  1191. Paint_DrawString_CN(x, 25, &Machine_info.station_name, &chinese_type_32, FONT_FOREGROUND, FONT_BACKGROUND);
  1192. if (!decection_state_0()) // 判断充电中逻辑
  1193. {
  1194. #define BAT_X_OFFSET 2
  1195. #define BAT_Y_OFFSET 2
  1196. Paint_DrawBitMap_Paste((uint8_t *)gImage_battery, 480 - 50 - BAT_X_OFFSET, 24, 37, 18, 1);
  1197. ESP_LOGW(LOG_TAG, "判断充电中逻辑batt_precent = %d", Machine_info.batt_precent);
  1198. switch (Machine_info.batt_precent)
  1199. {
  1200. case 0:
  1201. break;
  1202. case 1 ... 24:
  1203. Paint_DrawRectangle(433 - BAT_X_OFFSET, 27, 439 - BAT_X_OFFSET, 41, WHITE, 1, 1);
  1204. break;
  1205. case 25 ... 49:
  1206. Paint_DrawRectangle(433 - BAT_X_OFFSET, 27, 439 - BAT_X_OFFSET, 41, WHITE, 1, 1);
  1207. Paint_DrawRectangle(441 - BAT_X_OFFSET, 27, 447 - BAT_X_OFFSET, 41, WHITE, 1, 1);
  1208. break;
  1209. case 50 ... 74:
  1210. Paint_DrawRectangle(433 - BAT_X_OFFSET, 27, 439 - BAT_X_OFFSET, 41, WHITE, 1, 1);
  1211. Paint_DrawRectangle(441 - BAT_X_OFFSET, 27, 447 - BAT_X_OFFSET, 41, WHITE, 1, 1);
  1212. Paint_DrawRectangle(449 - BAT_X_OFFSET, 27, 455 - BAT_X_OFFSET, 41, WHITE, 1, 1);
  1213. break;
  1214. case 75 ... 99:
  1215. Paint_DrawRectangle(433 - BAT_X_OFFSET, 27, 439 - BAT_X_OFFSET, 41, WHITE, 1, 1);
  1216. Paint_DrawRectangle(441 - BAT_X_OFFSET, 27, 447 - BAT_X_OFFSET, 41, WHITE, 1, 1);
  1217. Paint_DrawRectangle(449 - BAT_X_OFFSET, 27, 455 - BAT_X_OFFSET, 41, WHITE, 1, 1);
  1218. Paint_DrawRectangle(457 - BAT_X_OFFSET, 27, 462 - BAT_X_OFFSET, 41, WHITE, 1, 1);
  1219. break;
  1220. case 100:
  1221. Paint_DrawRectangle(433 - BAT_X_OFFSET, 27, 439 - BAT_X_OFFSET, 41, WHITE, 1, 1);
  1222. Paint_DrawRectangle(441 - BAT_X_OFFSET, 27, 447 - BAT_X_OFFSET, 41, WHITE, 1, 1);
  1223. Paint_DrawRectangle(449 - BAT_X_OFFSET, 27, 455 - BAT_X_OFFSET, 41, WHITE, 1, 1);
  1224. Paint_DrawRectangle(457 - BAT_X_OFFSET, 27, 462 - BAT_X_OFFSET, 41, WHITE, 1, 1);
  1225. break;
  1226. default:
  1227. break;
  1228. }
  1229. Machine_info.batt_precent = read_battery_voltage();
  1230. if (Machine_info.batt_precent >= 95)
  1231. {
  1232. Paint_DrawBitMap_Paste((uint8_t *)gImage_filled, 480 - 47 + 37, 27 - BAT_Y_OFFSET, 8, 18, 1);
  1233. }
  1234. else
  1235. {
  1236. Paint_DrawBitMap_Paste((uint8_t *)gImage_charging, 480 - 47 + 35, 27 - BAT_Y_OFFSET, 8, 18, 1);
  1237. }
  1238. }
  1239. else
  1240. {
  1241. if (read_battery_voltage() < 10)
  1242. {
  1243. Paint_DrawBitMap_Paste(gImage_low_batt, 30, 428, 420, 154, 1); // 低电量请充电
  1244. Paint_DrawRectangle(30, 428+154, 420, 640, BLACK, 1, 1);
  1245. }
  1246. }
  1247. epd_init_cmd(SCREEN_RIGHT);
  1248. epd_display(SCREEN_RIGHT, Paint_info.Image);
  1249. memcpy(last_paint_buf_right, Paint_info.Image, sizeof(uint8_t) * 648 * 480 / 8);
  1250. if (memcmp(last_paint_buf_right, Paint_info.Image, 38880))
  1251. {
  1252. ESP_LOGE(LOG_TAG, "err:右屏说明书保存失败");
  1253. }
  1254. }
  1255. void Paint_leftScreen(bool is_poweron, bool is_quick)
  1256. {
  1257. ESP_LOGI(LOG_TAG, "Paint_leftScreen %s - %s ", is_quick ? "quick" : "low", is_poweron ? "poweron" : "poweroff");
  1258. if (!is_poweron)
  1259. {
  1260. // 关机展示说明书
  1261. dis_left_sms();
  1262. return;
  1263. }
  1264. int x = 0; // 居中偏移
  1265. // 先利用NewImage,得到各个部分的图像buf
  1266. // 再画图
  1267. uint8_t *image_320x384_buf = (uint8_t *)calloc(320 * 384 / 8, sizeof(uint8_t));
  1268. #if 1
  1269. uint8_t *tmp = NULL;
  1270. switch (Machine_info.left_display_mode)
  1271. {
  1272. case 0x00:
  1273. // ESP_LOGW(LOG_TAG,"left_display_mode 0x01:");
  1274. break;
  1275. case 0x01:
  1276. /* code */
  1277. tmp = partial_bar_chart_07_02_quick(&Machine_info);
  1278. break;
  1279. case 0x02:
  1280. /* code */
  1281. tmp = partial_bar_chart_07_03_quick(&Machine_info);
  1282. break;
  1283. case 0x03:
  1284. /* code */
  1285. tmp = partial_bar_chart_07_04_quick(&Machine_info);
  1286. break;
  1287. default:
  1288. break;
  1289. }
  1290. #else
  1291. tmp = partial_bar_chart_07_04_quick(info);
  1292. #endif
  1293. memset((uint8_t *)tmp_paint_buf, 0, DISPLAY_BUFFER_SIZE /*sizeof(tmp_paint_buf)*/);
  1294. Paint_NewImage((uint8_t *)tmp_paint_buf, 64, 32, ROTATE_0, WHITE);
  1295. x = center_align(&Machine_info.btn_operation, 64, 16, 32);
  1296. Paint_DrawString_CN(0 + x, 0, (char *)Machine_info.btn_operation, &chinese_type_32, FONT_FOREGROUND, FONT_BACKGROUND);
  1297. uint8_t *operation_64x32_buf = (uint8_t *)calloc(64 * 32 / 8, sizeof(uint8_t));
  1298. memcpy(operation_64x32_buf, Paint_info.Image, sizeof(uint8_t) * 64 * 32 / 8);
  1299. memset((uint8_t *)tmp_paint_buf, 0, DISPLAY_BUFFER_SIZE /*sizeof(tmp_paint_buf)*/);
  1300. Paint_NewImage((uint8_t *)tmp_paint_buf, 96, 48, ROTATE_0, WHITE);
  1301. Paint_DrawBitMap_Paste(operation_64x32_buf, 16, 8, 64, 32, 1);
  1302. uint8_t *operation_background_96x48_buf = (uint8_t *)calloc(96 * 48 / 8, sizeof(uint8_t));
  1303. memcpy(operation_background_96x48_buf, Paint_info.Image, sizeof(uint8_t) * 96 * 48 / 8);
  1304. free(operation_64x32_buf);
  1305. // str_shutDown
  1306. memset((uint8_t *)tmp_paint_buf, 0, DISPLAY_BUFFER_SIZE /*sizeof(tmp_paint_buf)*/);
  1307. Paint_NewImage((uint8_t *)tmp_paint_buf, 32, 64, ROTATE_90, WHITE);
  1308. x = center_align(&Machine_info.btn_shutDown_info, 64, 16, 32);
  1309. Paint_DrawString_CN(0, 0, (char *)Machine_info.btn_shutDown_info, &chinese_type_32, FONT_FOREGROUND, FONT_BACKGROUND);
  1310. uint8_t *shutDown_64x32_buf = (uint8_t *)calloc(64 * 32 / 8, sizeof(uint8_t));
  1311. memcpy(shutDown_64x32_buf, Paint_info.Image, sizeof(uint8_t) * 64 * 32 / 8);
  1312. memset((uint8_t *)tmp_paint_buf, 0, DISPLAY_BUFFER_SIZE /*sizeof(tmp_paint_buf)*/);
  1313. Paint_NewImage((uint8_t *)tmp_paint_buf, 48, 96, ROTATE_0, WHITE);
  1314. Paint_DrawBitMap_Paste(shutDown_64x32_buf, 8, 16, 32, 64, 1);
  1315. uint8_t *shutDown_background_96x48_buf = (uint8_t *)calloc(96 * 48 / 8, sizeof(uint8_t));
  1316. memcpy(shutDown_background_96x48_buf, Paint_info.Image, sizeof(uint8_t) * 96 * 48 / 8);
  1317. free(shutDown_64x32_buf);
  1318. // str_breakDown
  1319. memset((uint8_t *)tmp_paint_buf, 0, DISPLAY_BUFFER_SIZE /*sizeof(tmp_paint_buf)*/);
  1320. Paint_NewImage((uint8_t *)tmp_paint_buf, 32, 64, ROTATE_90, WHITE);
  1321. x = center_align(&Machine_info.btn_breakDown_info, 64, 16, 32);
  1322. Paint_DrawString_CN(0, 0, (char *)Machine_info.btn_breakDown_info, &chinese_type_32, FONT_FOREGROUND, FONT_BACKGROUND);
  1323. uint8_t *breakDown_64x32_buf = (uint8_t *)calloc(64 * 32 / 8, sizeof(uint8_t));
  1324. memcpy(breakDown_64x32_buf, Paint_info.Image, sizeof(uint8_t) * 64 * 32 / 8);
  1325. memset((uint8_t *)tmp_paint_buf, 0, DISPLAY_BUFFER_SIZE /*sizeof(tmp_paint_buf)*/);
  1326. Paint_NewImage((uint8_t *)tmp_paint_buf, 48, 96, ROTATE_0, WHITE);
  1327. Paint_DrawBitMap_Paste(breakDown_64x32_buf, 8, 16, 32, 64, 1);
  1328. uint8_t *breakDown_background_96x48_buf = (uint8_t *)calloc(96 * 48 / 8, sizeof(uint8_t));
  1329. memcpy(breakDown_background_96x48_buf, Paint_info.Image, sizeof(uint8_t) * 96 * 48 / 8);
  1330. free(breakDown_64x32_buf);
  1331. // str_safeKeep
  1332. memset((uint8_t *)tmp_paint_buf, 0, DISPLAY_BUFFER_SIZE /*sizeof(tmp_paint_buf)*/);
  1333. Paint_NewImage((uint8_t *)tmp_paint_buf, 64, 32, ROTATE_0, WHITE);
  1334. x = center_align(&Machine_info.btn_safeKeep_info, 64, 16, 32);
  1335. Paint_DrawString_CN(0, 0, (char *)Machine_info.btn_safeKeep_info, &chinese_type_32, FONT_FOREGROUND, FONT_BACKGROUND);
  1336. uint8_t *safeKeep_64x32_buf = (uint8_t *)calloc(64 * 32 / 8, sizeof(uint8_t));
  1337. memcpy(safeKeep_64x32_buf, Paint_info.Image, sizeof(uint8_t) * 64 * 32 / 8);
  1338. memset((uint8_t *)tmp_paint_buf, 0, DISPLAY_BUFFER_SIZE /*sizeof(tmp_paint_buf)*/);
  1339. Paint_NewImage((uint8_t *)tmp_paint_buf, 96, 48, ROTATE_0, WHITE);
  1340. Paint_DrawBitMap_Paste(safeKeep_64x32_buf, 16, 8, 64, 32, 1);
  1341. uint8_t *safeKeep_background_96x48_buf = (uint8_t *)calloc(96 * 48 / 8, sizeof(uint8_t));
  1342. memcpy(safeKeep_background_96x48_buf, Paint_info.Image, sizeof(uint8_t) * 96 * 48 / 8);
  1343. free(safeKeep_64x32_buf);
  1344. // str_upKeep
  1345. memset((uint8_t *)tmp_paint_buf, 0, DISPLAY_BUFFER_SIZE /*sizeof(tmp_paint_buf)*/);
  1346. Paint_NewImage((uint8_t *)tmp_paint_buf, 32, 64, ROTATE_270, WHITE);
  1347. x = center_align(&Machine_info.btn_upKeep_info, 64, 16, 32);
  1348. Paint_DrawString_CN(0, 0, (char *)Machine_info.btn_upKeep_info, &chinese_type_32, FONT_FOREGROUND, FONT_BACKGROUND);
  1349. uint8_t *upKeep_64x32_buf = (uint8_t *)calloc(64 * 32 / 8, sizeof(uint8_t));
  1350. memcpy(upKeep_64x32_buf, Paint_info.Image, sizeof(uint8_t) * 64 * 32 / 8);
  1351. memset((uint8_t *)tmp_paint_buf, 0, DISPLAY_BUFFER_SIZE /*sizeof(tmp_paint_buf)*/);
  1352. Paint_NewImage((uint8_t *)tmp_paint_buf, 48, 96, ROTATE_0, WHITE);
  1353. Paint_DrawBitMap_Paste(upKeep_64x32_buf, 8, 16, 32, 64, 1);
  1354. uint8_t *upKeep_background_96x48_buf = (uint8_t *)calloc(96 * 48 / 8, sizeof(uint8_t));
  1355. memcpy(upKeep_background_96x48_buf, Paint_info.Image, sizeof(uint8_t) * 96 * 48 / 8);
  1356. free(upKeep_64x32_buf);
  1357. // str_waitMaterials
  1358. memset((uint8_t *)tmp_paint_buf, 0, DISPLAY_BUFFER_SIZE /*sizeof(tmp_paint_buf)*/);
  1359. Paint_NewImage((uint8_t *)tmp_paint_buf, 32, 64, ROTATE_270, WHITE);
  1360. x = center_align(&Machine_info.btn_waitMaterials_info, 64, 16, 32);
  1361. Paint_DrawString_CN(0, 0, (char *)Machine_info.btn_waitMaterials_info, &chinese_type_32, FONT_FOREGROUND, FONT_BACKGROUND);
  1362. uint8_t *waitMaterials_64x32_buf = (uint8_t *)calloc(64 * 32 / 8, sizeof(uint8_t));
  1363. memcpy(waitMaterials_64x32_buf, Paint_info.Image, sizeof(uint8_t) * 64 * 32 / 8);
  1364. memset((uint8_t *)tmp_paint_buf, 0, DISPLAY_BUFFER_SIZE /*sizeof(tmp_paint_buf)*/);
  1365. Paint_NewImage((uint8_t *)tmp_paint_buf, 48, 96, ROTATE_0, WHITE);
  1366. Paint_DrawBitMap_Paste(waitMaterials_64x32_buf, 8, 16, 32, 64, 1);
  1367. uint8_t *waitMaterials_background_96x48_buf = (uint8_t *)calloc(96 * 48 / 8, sizeof(uint8_t));
  1368. memcpy(waitMaterials_background_96x48_buf, Paint_info.Image, sizeof(uint8_t) * 96 * 48 / 8);
  1369. free(waitMaterials_64x32_buf);
  1370. uint8_t *background_128x64_buf = (uint8_t *)calloc(128 * 64 / 8, sizeof(uint8_t));
  1371. // 得到图像buf
  1372. // ESP_LOGW(LOG_TAG, "----------------Machine_info.left_state = %d-------left_display_mode =%d -------\r\n", Machine_info.left_state, Machine_info.left_display_mode);
  1373. switch (Machine_info.left_state)
  1374. {
  1375. case STATE_NONE:
  1376. case STATE_OPERATION:
  1377. {
  1378. if (Machine_info.left_display_mode == 0)
  1379. {
  1380. memset((uint8_t *)tmp_paint_buf, 0, DISPLAY_BUFFER_SIZE /*sizeof(tmp_paint_buf)*/);
  1381. Paint_NewImage((uint8_t *)tmp_paint_buf, 96, 48, ROTATE_0, WHITE);
  1382. Paint_DrawBitMap_Paste((uint8_t *)gImage_button, 0, 0, 96, 48, 1);
  1383. x = center_align(&Machine_info.btn_operation, 64, 16, 32);
  1384. Paint_DrawString_CN(16 + x, 8, (char *)Machine_info.btn_operation, &chinese_type_32, FONT_BACKGROUND, FONT_FOREGROUND);
  1385. memcpy(operation_background_96x48_buf, Paint_info.Image, sizeof(uint8_t) * 96 * 48 / 8);
  1386. memset((uint8_t *)tmp_paint_buf, 0, DISPLAY_BUFFER_SIZE /*sizeof(tmp_paint_buf)*/);
  1387. Paint_NewImage((uint8_t *)tmp_paint_buf, 320, 384, ROTATE_0, WHITE);
  1388. Paint_DrawBitMap_Paste((uint8_t *)gImage_mid_, 0, 0, 320, 384, 1);
  1389. x = center_align(&Machine_info.btn_operation, 128, 64, 64);
  1390. Paint_DrawString_CN64(96 + x, 160, (char *)Machine_info.btn_operation);
  1391. memcpy(image_320x384_buf, Paint_info.Image, sizeof(uint8_t) * 320 * 384 / 8);
  1392. }
  1393. else
  1394. {
  1395. memset((uint8_t *)tmp_paint_buf, 0, DISPLAY_BUFFER_SIZE /*sizeof(tmp_paint_buf)*/);
  1396. Paint_NewImage((uint8_t *)tmp_paint_buf, 128, 64, ROTATE_0, WHITE);
  1397. Paint_DrawBitMap_Paste((uint8_t *)gImage_button_128x64, 0, 0, 128, 64, 1);
  1398. x = center_align(&Machine_info.btn_operation, 96, 24, 48);
  1399. // Paint_DrawString_CN(16+x,8,(char*)Machine_info.btn_operation,&chinese_type_32,FONT_BACKGROUND,FONT_FOREGROUND);
  1400. Paint_DrawString_CN48(16 + x, 8, (char *)Machine_info.btn_operation, false);
  1401. memcpy(background_128x64_buf, Paint_info.Image, sizeof(uint8_t) * 128 * 64 / 8);
  1402. }
  1403. }
  1404. break;
  1405. case STATE_SHUT_DOWN:
  1406. {
  1407. if (Machine_info.left_display_mode == 0)
  1408. {
  1409. memset((uint8_t *)tmp_paint_buf, 0, DISPLAY_BUFFER_SIZE /*sizeof(tmp_paint_buf)*/);
  1410. Paint_NewImage((uint8_t *)tmp_paint_buf, 48, 96, ROTATE_90, WHITE);
  1411. Paint_DrawBitMap_Paste((uint8_t *)gImage_button, 0, 0, 96, 48, 1);
  1412. x = center_align(&Machine_info.btn_shutDown_info, 64, 16, 32);
  1413. Paint_DrawString_CN(16 + x, 8, (char *)Machine_info.btn_shutDown_info, &chinese_type_32, FONT_BACKGROUND, FONT_FOREGROUND);
  1414. memcpy(shutDown_background_96x48_buf, Paint_info.Image, sizeof(uint8_t) * 96 * 48 / 8);
  1415. memset((uint8_t *)tmp_paint_buf, 0, DISPLAY_BUFFER_SIZE /*sizeof(tmp_paint_buf)*/);
  1416. Paint_NewImage((uint8_t *)tmp_paint_buf, 320, 384, ROTATE_0, WHITE);
  1417. Paint_DrawBitMap_Paste((uint8_t *)gImage_right_, 0, 0, 320, 384, 1);
  1418. x = center_align(&Machine_info.btn_shutDown_info, 128, 64, 64);
  1419. Paint_DrawString_CN64(96 + x, 160, (char *)Machine_info.btn_shutDown_info);
  1420. memcpy(image_320x384_buf, Paint_info.Image, sizeof(uint8_t) * 320 * 384 / 8);
  1421. }
  1422. else
  1423. {
  1424. memset((uint8_t *)tmp_paint_buf, 0, DISPLAY_BUFFER_SIZE /*sizeof(tmp_paint_buf)*/);
  1425. Paint_NewImage((uint8_t *)tmp_paint_buf, 64, 128, ROTATE_90, WHITE);
  1426. Paint_DrawBitMap_Paste((uint8_t *)gImage_button_128x64, 0, 0, 128, 64, 1);
  1427. x = center_align(&Machine_info.btn_shutDown_info, 96, 24, 48);
  1428. // Paint_DrawString_CN(16+x,8,(char*)Machine_info.btn_shutDown_info,&chinese_type_32,FONT_BACKGROUND,FONT_FOREGROUND);
  1429. Paint_DrawString_CN48(16 + x, 8, (char *)Machine_info.btn_shutDown_info, false);
  1430. memcpy(background_128x64_buf, Paint_info.Image, sizeof(uint8_t) * 128 * 64 / 8);
  1431. }
  1432. }
  1433. break;
  1434. case STATE_BREAKDOWN:
  1435. {
  1436. if (Machine_info.left_display_mode == 0)
  1437. {
  1438. memset((uint8_t *)tmp_paint_buf, 0, DISPLAY_BUFFER_SIZE /*sizeof(tmp_paint_buf)*/);
  1439. Paint_NewImage((uint8_t *)tmp_paint_buf, 48, 96, ROTATE_90, WHITE);
  1440. Paint_DrawBitMap_Paste((uint8_t *)gImage_button, 0, 0, 96, 48, 1);
  1441. x = center_align(&Machine_info.btn_breakDown_info, 64, 16, 32);
  1442. Paint_DrawString_CN(16 + x, 8, (char *)Machine_info.btn_breakDown_info, &chinese_type_32, FONT_BACKGROUND, FONT_FOREGROUND);
  1443. memcpy(breakDown_background_96x48_buf, Paint_info.Image, sizeof(uint8_t) * 96 * 48 / 8);
  1444. memset((uint8_t *)tmp_paint_buf, 0, DISPLAY_BUFFER_SIZE /*sizeof(tmp_paint_buf)*/);
  1445. Paint_NewImage((uint8_t *)tmp_paint_buf, 320, 384, ROTATE_180, WHITE);
  1446. Paint_DrawBitMap_Paste((uint8_t *)gImage_left_, 0, 0, 320, 384, 1);
  1447. memcpy(image_320x384_buf, Paint_info.Image, sizeof(uint8_t) * 320 * 384 / 8);
  1448. Paint_NewImage(image_320x384_buf, 320, 384, ROTATE_0, WHITE);
  1449. x = center_align(&Machine_info.btn_breakDown_info, 128, 64, 64);
  1450. Paint_DrawString_CN64(96 + x, 160, (char *)Machine_info.btn_breakDown_info);
  1451. memcpy(image_320x384_buf, Paint_info.Image, sizeof(uint8_t) * 320 * 384 / 8);
  1452. }
  1453. else
  1454. {
  1455. memset((uint8_t *)tmp_paint_buf, 0, DISPLAY_BUFFER_SIZE /*sizeof(tmp_paint_buf)*/);
  1456. Paint_NewImage((uint8_t *)tmp_paint_buf, 64, 128, ROTATE_90, WHITE);
  1457. Paint_DrawBitMap_Paste((uint8_t *)gImage_button_128x64, 0, 0, 128, 64, 1);
  1458. x = center_align(&Machine_info.btn_breakDown_info, 96, 24, 48);
  1459. // Paint_DrawString_CN(16+x,8,(char*)Machine_info.btn_breakDown_info,&chinese_type_32,FONT_BACKGROUND,FONT_FOREGROUND);
  1460. Paint_DrawString_CN48(16 + x, 8, (char *)Machine_info.btn_breakDown_info, false);
  1461. memcpy(background_128x64_buf, Paint_info.Image, sizeof(uint8_t) * 128 * 64 / 8);
  1462. }
  1463. }
  1464. break;
  1465. case STATE_SAFEKEEP:
  1466. {
  1467. if (Machine_info.left_display_mode == 0)
  1468. {
  1469. memset((uint8_t *)tmp_paint_buf, 0, DISPLAY_BUFFER_SIZE /*sizeof(tmp_paint_buf)*/);
  1470. Paint_NewImage((uint8_t *)tmp_paint_buf, 96, 48, ROTATE_0, WHITE);
  1471. Paint_DrawBitMap_Paste((uint8_t *)gImage_button, 0, 0, 96, 48, 1);
  1472. x = center_align(&Machine_info.btn_safeKeep_info, 64, 16, 32);
  1473. Paint_DrawString_CN(16 + x, 8, (char *)Machine_info.btn_safeKeep_info, &chinese_type_32, FONT_BACKGROUND, FONT_FOREGROUND);
  1474. memcpy(safeKeep_background_96x48_buf, Paint_info.Image, sizeof(uint8_t) * 96 * 48 / 8);
  1475. memset((uint8_t *)tmp_paint_buf, 0, DISPLAY_BUFFER_SIZE /*sizeof(tmp_paint_buf)*/);
  1476. Paint_NewImage((uint8_t *)tmp_paint_buf, 320, 384, ROTATE_180, WHITE);
  1477. Paint_DrawBitMap_Paste((uint8_t *)gImage_mid_, 0, 0, 320, 384, 1);
  1478. memcpy(image_320x384_buf, Paint_info.Image, sizeof(uint8_t) * 320 * 384 / 8);
  1479. Paint_NewImage(image_320x384_buf, 320, 384, ROTATE_0, WHITE);
  1480. x = center_align(&Machine_info.btn_safeKeep_info, 128, 64, 64);
  1481. Paint_DrawString_CN64(96 + x, 160, (char *)Machine_info.btn_safeKeep_info);
  1482. memcpy(image_320x384_buf, Paint_info.Image, sizeof(uint8_t) * 320 * 384 / 8);
  1483. }
  1484. else
  1485. {
  1486. memset((uint8_t *)tmp_paint_buf, 0, DISPLAY_BUFFER_SIZE /*sizeof(tmp_paint_buf)*/);
  1487. Paint_NewImage((uint8_t *)tmp_paint_buf, 128, 64, ROTATE_0, WHITE);
  1488. Paint_DrawBitMap_Paste((uint8_t *)gImage_button_128x64, 0, 0, 128, 64, 1);
  1489. x = center_align(&Machine_info.btn_safeKeep_info, 96, 24, 48);
  1490. // Paint_DrawString_CN(16+x,8,(char*)Machine_info.btn_safeKeep_info,&chinese_type_32,FONT_BACKGROUND,FONT_FOREGROUND);
  1491. Paint_DrawString_CN48(16 + x, 8, (char *)Machine_info.btn_safeKeep_info, false);
  1492. memcpy(background_128x64_buf, Paint_info.Image, sizeof(uint8_t) * 128 * 64 / 8);
  1493. }
  1494. }
  1495. break;
  1496. case STATE_UPKEEP:
  1497. {
  1498. if (Machine_info.left_display_mode == 0)
  1499. {
  1500. memset((uint8_t *)tmp_paint_buf, 0, DISPLAY_BUFFER_SIZE /*sizeof(tmp_paint_buf)*/);
  1501. Paint_NewImage((uint8_t *)tmp_paint_buf, 48, 96, ROTATE_270, WHITE);
  1502. Paint_DrawBitMap_Paste((uint8_t *)gImage_button, 0, 0, 96, 48, 1);
  1503. x = center_align(&Machine_info.btn_upKeep_info, 64, 16, 32);
  1504. Paint_DrawString_CN(16 + x, 8, (char *)Machine_info.btn_upKeep_info, &chinese_type_32, FONT_BACKGROUND, FONT_FOREGROUND);
  1505. memcpy(upKeep_background_96x48_buf, Paint_info.Image, sizeof(uint8_t) * 96 * 48 / 8);
  1506. memset((uint8_t *)tmp_paint_buf, 0, DISPLAY_BUFFER_SIZE /*sizeof(tmp_paint_buf)*/);
  1507. Paint_NewImage((uint8_t *)tmp_paint_buf, 320, 384, ROTATE_180, WHITE);
  1508. Paint_DrawBitMap_Paste((uint8_t *)gImage_right_, 0, 0, 320, 384, 1);
  1509. memcpy(image_320x384_buf, Paint_info.Image, sizeof(uint8_t) * 320 * 384 / 8);
  1510. Paint_NewImage(image_320x384_buf, 320, 384, ROTATE_0, WHITE);
  1511. x = center_align(&Machine_info.btn_upKeep_info, 128, 64, 64);
  1512. Paint_DrawString_CN64(96 + x, 160, (char *)Machine_info.btn_upKeep_info);
  1513. memcpy(image_320x384_buf, Paint_info.Image, sizeof(uint8_t) * 320 * 384 / 8);
  1514. }
  1515. else
  1516. {
  1517. memset((uint8_t *)tmp_paint_buf, 0, DISPLAY_BUFFER_SIZE /*sizeof(tmp_paint_buf)*/);
  1518. Paint_NewImage((uint8_t *)tmp_paint_buf, 64, 128, ROTATE_270, WHITE);
  1519. Paint_DrawBitMap_Paste((uint8_t *)gImage_button_128x64, 0, 0, 128, 64, 1);
  1520. x = center_align(&Machine_info.btn_upKeep_info, 96, 24, 48);
  1521. // Paint_DrawString_CN(16+x,8,(char*)Machine_info.btn_upKeep_info,&chinese_type_32,FONT_BACKGROUND,FONT_FOREGROUND);
  1522. Paint_DrawString_CN48(16 + x, 8, (char *)Machine_info.btn_upKeep_info, false);
  1523. memcpy(background_128x64_buf, Paint_info.Image, sizeof(uint8_t) * 128 * 64 / 8);
  1524. }
  1525. }
  1526. break;
  1527. case STATE_WAIT_MATERIALS:
  1528. {
  1529. if (Machine_info.left_display_mode == 0)
  1530. {
  1531. memset((uint8_t *)tmp_paint_buf, 0, DISPLAY_BUFFER_SIZE /*sizeof(tmp_paint_buf)*/);
  1532. Paint_NewImage((uint8_t *)tmp_paint_buf, 48, 96, ROTATE_270, WHITE);
  1533. Paint_DrawBitMap_Paste((uint8_t *)gImage_button, 0, 0, 96, 48, 1);
  1534. x = center_align(&Machine_info.btn_waitMaterials_info, 64, 16, 32);
  1535. Paint_DrawString_CN(16 + x, 8, (char *)Machine_info.btn_waitMaterials_info, &chinese_type_32, FONT_BACKGROUND, FONT_FOREGROUND);
  1536. memcpy(waitMaterials_background_96x48_buf, Paint_info.Image, sizeof(uint8_t) * 96 * 48 / 8); // 黑底白字
  1537. memset((uint8_t *)tmp_paint_buf, 0, DISPLAY_BUFFER_SIZE /*sizeof(tmp_paint_buf)*/);
  1538. Paint_NewImage((uint8_t *)tmp_paint_buf, 320, 384, ROTATE_0, WHITE);
  1539. Paint_DrawBitMap_Paste((uint8_t *)gImage_left_, 0, 0, 320, 384, 1);
  1540. x = center_align(&Machine_info.btn_waitMaterials_info, 128, 64, 64);
  1541. Paint_DrawString_CN64(96 + x, 160, (char *)Machine_info.btn_waitMaterials_info);
  1542. memcpy(image_320x384_buf, Paint_info.Image, sizeof(uint8_t) * 320 * 384 / 8);
  1543. }
  1544. else
  1545. {
  1546. memset((uint8_t *)tmp_paint_buf, 0, DISPLAY_BUFFER_SIZE /*sizeof(tmp_paint_buf)*/);
  1547. Paint_NewImage((uint8_t *)tmp_paint_buf, 64, 128, ROTATE_270, WHITE);
  1548. Paint_DrawBitMap_Paste((uint8_t *)gImage_button_128x64, 0, 0, 128, 64, 1);
  1549. x = center_align(&Machine_info.btn_waitMaterials_info, 96, 24, 48);
  1550. // Paint_DrawString_CN(16+x,8,(char*)Machine_info.btn_waitMaterials_info,&chinese_type_32,FONT_BACKGROUND,FONT_FOREGROUND);
  1551. Paint_DrawString_CN48(16 + x, 8, (char *)Machine_info.btn_waitMaterials_info, false);
  1552. memcpy(background_128x64_buf, Paint_info.Image, sizeof(uint8_t) * 128 * 64 / 8); // 黑底白字
  1553. }
  1554. }
  1555. break;
  1556. default:
  1557. ESP_LOGE(LOG_TAG, " err: (info->left_state)");
  1558. break;
  1559. }
  1560. // 画图
  1561. memset((uint8_t *)tmp_paint_buf, 0, DISPLAY_BUFFER_SIZE /*sizeof(tmp_paint_buf)*/);
  1562. Paint_NewImage((uint8_t *)tmp_paint_buf, 648, 480, ROTATE_180, WHITE);
  1563. Paint_DrawBitMap_Paste(operation_background_96x48_buf, 272, 0, 96, 48, 1);
  1564. Paint_DrawBitMap_Paste(shutDown_background_96x48_buf, 600, 48, 48, 96, 1);
  1565. Paint_DrawBitMap_Paste(breakDown_background_96x48_buf, 600, 336, 48, 96, 1);
  1566. Paint_DrawBitMap_Paste(safeKeep_background_96x48_buf, 272, 432, 96, 48, 1);
  1567. Paint_DrawBitMap_Paste(upKeep_background_96x48_buf, 0, 336, 48, 96, 1);
  1568. Paint_DrawBitMap_Paste(waitMaterials_background_96x48_buf, 0, 48, 48, 96, 1);
  1569. free(operation_background_96x48_buf);
  1570. free(shutDown_background_96x48_buf);
  1571. free(breakDown_background_96x48_buf);
  1572. free(upKeep_background_96x48_buf);
  1573. free(safeKeep_background_96x48_buf);
  1574. free(waitMaterials_background_96x48_buf);
  1575. if (Machine_info.left_display_mode != 0)
  1576. {
  1577. switch (Machine_info.left_state)
  1578. {
  1579. case STATE_NONE:
  1580. case STATE_OPERATION:
  1581. Paint_DrawBitMap_Paste(background_128x64_buf, 272 - 16, 0, 128, 64, 1);
  1582. break;
  1583. case STATE_SHUT_DOWN:
  1584. Paint_DrawBitMap_Paste(background_128x64_buf, 600 - 16, 48 - 8, 64, 128, 1);
  1585. break;
  1586. case STATE_BREAKDOWN:
  1587. Paint_DrawBitMap_Paste(background_128x64_buf, 600 - 16, 336 - 8, 64, 128, 1);
  1588. break;
  1589. case STATE_SAFEKEEP:
  1590. Paint_DrawBitMap_Paste(background_128x64_buf, 272 - 16, 432 - 16, 128, 64, 1);
  1591. break;
  1592. case STATE_UPKEEP:
  1593. Paint_DrawBitMap_Paste(background_128x64_buf, 0, 336 - 16, 64, 128, 1);
  1594. break;
  1595. case STATE_WAIT_MATERIALS:
  1596. Paint_DrawBitMap_Paste(background_128x64_buf, 0, 48 - 16, 64, 128, 1);
  1597. break;
  1598. default:
  1599. break;
  1600. }
  1601. }
  1602. free(background_128x64_buf);
  1603. Paint_DrawBitMap_Paste((uint8_t *)gImage_nfc, 573, 215, 44, 44, 1);
  1604. if ((Machine_info.left_display_mode == 0x00))
  1605. {
  1606. Paint_DrawBitMap_Paste(image_320x384_buf, 164, 48, 320, 384, 1);
  1607. }
  1608. else
  1609. {
  1610. Paint_DrawBitMap_Paste(tmp, 84, 90, 480, 300, 1); // 648-480 168
  1611. free(tmp);
  1612. }
  1613. // qrcode
  1614. char qrcode_string[1024] = {0};
  1615. qrcode_protocol_create(qrcode_string, Machine_info);
  1616. QRGenerator_quick(qrcode_string);
  1617. //
  1618. // printf("btn_operation = %s\r\n",Machine_info.btn_operation);
  1619. // printf("btn_breakDown_info = %s\r\n",Machine_info.btn_breakDown_info);
  1620. // printf("btn_upKeep_info = %s\r\n",Machine_info.btn_upKeep_info);
  1621. // printf("btn_shutDown_info = %s\r\n",Machine_info.btn_shutDown_info);
  1622. // printf("btn_safeKeep_info = %s\r\n",Machine_info.btn_safeKeep_info);
  1623. // printf("btn_waitMaterials_info = %s\r\n",Machine_info.btn_operation);
  1624. int reson = is_wake_up_reson(); // 返回唤醒的原
  1625. if (is_quick)
  1626. {
  1627. bool ret = epd_cache_quick(SCREEN_LEFT, (uint8_t *)last_paint_buf_left, Paint_info.Image);
  1628. epd_powerOn_refresh_sleep(SCREEN_LEFT);
  1629. }
  1630. else
  1631. {
  1632. epd_init_cmd(SCREEN_LEFT);
  1633. epd_display(SCREEN_LEFT, Paint_info.Image);
  1634. }
  1635. // 保存上一帧画面
  1636. memcpy(last_paint_buf_left, Paint_info.Image, sizeof(uint8_t) * 648 * 480 / 8);
  1637. if (memcmp(last_paint_buf_left, Paint_info.Image, 38880))
  1638. {
  1639. ESP_LOGE(LOG_TAG, "err:last_paint_buf_left");
  1640. }
  1641. free(image_320x384_buf);
  1642. }
  1643. void Paint_rightScreen(bool is_poweron, bool is_quick)
  1644. {
  1645. ESP_LOGI(LOG_TAG, "Paint_rightScreen %s - %s ", is_quick ? "quick" : "low", is_poweron ? "poweron" : "poweroff");
  1646. if (!is_poweron)
  1647. {
  1648. // 关机展示说明书
  1649. dis_right_sms();
  1650. return;
  1651. }
  1652. uint8_t *right1_buf = partial_right1_quick(&Machine_info);
  1653. uint8_t *right2_buf = partial_right2_quick();
  1654. uint8_t *right3_buf = NULL;
  1655. if (Machine_info.right_display_mode == 1)
  1656. {
  1657. right3_buf = partial_right3_2_quick();
  1658. }
  1659. else
  1660. {
  1661. right3_buf = partial_right3_quick();
  1662. }
  1663. uint8_t *right4_buf = partial_right4_quick();
  1664. memset((uint8_t *)tmp_paint_buf, 0, DISPLAY_BUFFER_SIZE /*sizeof(tmp_paint_buf)*/);
  1665. Paint_NewImage((uint8_t *)tmp_paint_buf, 648, 480, ROTATE_270, WHITE);
  1666. Paint_DrawBitMap_Paste(right1_buf, 0, 0, 480, 100, 1);
  1667. free(right1_buf);
  1668. Paint_DrawBitMap_Paste(right2_buf, 0, 100, 480, 172, 1);
  1669. free(right2_buf);
  1670. Paint_DrawBitMap_Paste(right3_buf, 0, 272, 480, 224, 1);
  1671. free(right3_buf);
  1672. Paint_DrawBitMap_Paste(right4_buf, 0, 496, 480, 152, 1);
  1673. free(right4_buf);
  1674. if (is_quick)
  1675. {
  1676. bool ret = epd_cache_quick(SCREEN_RIGHT, (uint8_t *)last_paint_buf_right, Paint_info.Image);
  1677. epd_powerOn_refresh_sleep(SCREEN_RIGHT);
  1678. }
  1679. else
  1680. {
  1681. epd_init_cmd(SCREEN_RIGHT);
  1682. epd_display(SCREEN_RIGHT, Paint_info.Image);
  1683. }
  1684. // 保存右屏上一帧画面
  1685. memcpy(last_paint_buf_right, Paint_info.Image, sizeof(uint8_t) * 648 * 480 / 8);
  1686. // int ret = memcmp(last_paint_buf_right,Paint_info.Image,38880);
  1687. // ESP_LOGW(LOG_TAG,"memcmp :ret = %d",ret);
  1688. if (memcmp(last_paint_buf_right, Paint_info.Image, 38880))
  1689. {
  1690. ESP_LOGE(LOG_TAG, "err:last_paint_buf_right");
  1691. }
  1692. Machine_info.last_batt_precent = Machine_info.batt_precent; // 右屏刷完后记录电池电量
  1693. }