yc_paint.c 93 KB

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