yc_paint.c 143 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302
  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. bool isASCII(char c);
  57. bool isGBKChinese(char c1, char c2);
  58. void countCharacters(const char* str, int* chineseCount, int* asciiCount);
  59. int calculateStringWidth(const char* str,int en_px,int cn_px);
  60. static void QRGenerator(char* input);
  61. 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. 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. bool isASCII(char c) {
  118. return (c >= 32 && c <= 126);
  119. }
  120. // 函数用于判断字符是否是GBK编码的汉字
  121. bool isGBKChinese(char c1, char c2) {
  122. return (c1 >= 0x81 && c1 <= 0xFE && c2 >= 0x40 && c2 <= 0xFE);
  123. }
  124. // 统计字符串中GBK编码的汉字和ASCII字符的个数
  125. 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. 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. 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. 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. 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. //关机状态下显示充电图标和说明书逻辑
  250. void dis_right_instructions()
  251. {
  252. //右屏
  253. memset((uint8_t*)tmp_paint_buf,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
  254. Paint_NewImage((uint8_t*)tmp_paint_buf, 648, 480, ROTATE_270, WHITE);
  255. Paint_DrawBitMap_Paste(gImage_right_instruction, 0,0 ,480,648 ,1);
  256. if(!decection_state_0()) //判断充电中逻辑
  257. {
  258. #define BAT_X_OFFSET 2
  259. #define BAT_Y_OFFSET 2
  260. Paint_DrawBitMap_Paste((uint8_t*)gImage_battery ,480-50-BAT_X_OFFSET,24,37,18,1 );
  261. switch (Machine_info.batt_precent)
  262. {
  263. case 0:
  264. break;
  265. case 1 ... 24:
  266. Paint_DrawRectangle(433 -BAT_X_OFFSET,27,439 -BAT_X_OFFSET,41,WHITE,1,1 );
  267. break;
  268. case 25 ... 49:
  269. Paint_DrawRectangle(433 -BAT_X_OFFSET,27,439-BAT_X_OFFSET,41,WHITE,1,1 );
  270. Paint_DrawRectangle(441-BAT_X_OFFSET,27,447-BAT_X_OFFSET,41,WHITE,1,1 );
  271. break;
  272. case 50 ... 74:
  273. Paint_DrawRectangle(433-BAT_X_OFFSET,27,439-BAT_X_OFFSET,41,WHITE,1,1 );
  274. Paint_DrawRectangle(441-BAT_X_OFFSET,27,447-BAT_X_OFFSET,41,WHITE,1,1 );
  275. Paint_DrawRectangle(449-BAT_X_OFFSET,27,455-BAT_X_OFFSET,41,WHITE,1,1 );
  276. break;
  277. case 75 ... 100:
  278. Paint_DrawRectangle(433-BAT_X_OFFSET,27,439-BAT_X_OFFSET,41,WHITE,1,1 );
  279. Paint_DrawRectangle(441-BAT_X_OFFSET,27,447-BAT_X_OFFSET,41,WHITE,1,1 );
  280. Paint_DrawRectangle(449-BAT_X_OFFSET,27,455-BAT_X_OFFSET,41,WHITE,1,1 );
  281. Paint_DrawRectangle(457-BAT_X_OFFSET,27,462-BAT_X_OFFSET,41,WHITE,1,1 );
  282. break;
  283. default:
  284. ESP_LOGE(LOG_TAG,"err:batt_precent = %d",Machine_info.batt_precent);
  285. break;
  286. }
  287. Machine_info.batt_precent = read_battery_voltage();
  288. if(Machine_info.batt_precent >=95)
  289. {
  290. Paint_DrawBitMap_Paste((uint8_t*)gImage_charging ,480-47+37,27 - BAT_Y_OFFSET,8,18,1 );
  291. }
  292. else
  293. {
  294. Paint_DrawBitMap_Paste((uint8_t*)gImage_charging ,480-47+35,27 - BAT_Y_OFFSET,8,18,1 );
  295. }
  296. }
  297. #if 1
  298. epd_init_cmd(SCREEN_RIGHT);
  299. epd_display(SCREEN_RIGHT,Paint_info.Image);
  300. #else
  301. epd_cache_quick(SCREEN_RIGHT,(uint8_t*)last_paint_buf_right,Paint_info.Image);
  302. epd_powerOn_refresh_sleep(SCREEN_RIGHT);
  303. #endif
  304. memcpy(last_paint_buf_right,Paint_info.Image,sizeof(uint8_t)*648*480/8);
  305. // int ret = memcmp(last_paint_buf_right,Paint_info.Image,38880);
  306. // ESP_LOGW(LOG_TAG,"memcmp :ret = %d",ret);
  307. if(memcmp(last_paint_buf_right,Paint_info.Image,38880))
  308. {
  309. ESP_LOGE(LOG_TAG,"err:last_paint_buf_right");
  310. }
  311. Machine_info.last_batt_precent = Machine_info.batt_precent;//右屏刷完后记录电池电量
  312. }
  313. void dis_instructions()
  314. {
  315. ESP_LOGW(LOG_TAG,"dis_instructions");
  316. //左屏
  317. memset((uint8_t*)tmp_paint_buf,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
  318. Paint_NewImage((uint8_t*)tmp_paint_buf, 648, 480, ROTATE_180, WHITE);
  319. Paint_DrawBitMap_Paste(gImage_left_instructions, 0,0 ,648,480 ,1);
  320. //qrcode
  321. char qrcode_string[1024]= {0};
  322. qrcode_protocol_create(qrcode_string,Machine_info);
  323. QRGenerator_quick(qrcode_string);
  324. Paint_DrawBitMap_Paste((uint8_t*)gImage_nfc ,573,215,44,44,1 );
  325. epd_init_cmd(SCREEN_LEFT);
  326. epd_display(SCREEN_LEFT,Paint_info.Image);
  327. memcpy(last_paint_buf_left,Paint_info.Image,sizeof(uint8_t)*648*480/8);
  328. // int ret = memcmp(last_paint_buf_left,Paint_info.Image,38880);
  329. // ESP_LOGW(LOG_TAG,"memcmp :ret = %d",ret);
  330. if(memcmp(last_paint_buf_left,Paint_info.Image,38880))
  331. {
  332. ESP_LOGE(LOG_TAG,"err:last_paint_buf_left");
  333. }
  334. //右屏
  335. memset((uint8_t*)tmp_paint_buf,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
  336. Paint_NewImage((uint8_t*)tmp_paint_buf, 648, 480, ROTATE_270, WHITE);
  337. Paint_DrawBitMap_Paste(gImage_right_instruction, 0,0 ,480,648 ,1);
  338. if(!decection_state_0()) //判断充电中逻辑
  339. {
  340. #define BAT_X_OFFSET 2
  341. #define BAT_Y_OFFSET 2
  342. Paint_DrawBitMap_Paste((uint8_t*)gImage_battery ,480-50-BAT_X_OFFSET,24,37,18,1 );
  343. ESP_LOGW(LOG_TAG,"判断充电中逻辑batt_precent = %d",Machine_info.batt_precent);
  344. switch (Machine_info.batt_precent)
  345. {
  346. case 0:
  347. break;
  348. case 1 ... 24:
  349. Paint_DrawRectangle(433 -BAT_X_OFFSET,27,439 -BAT_X_OFFSET,41,WHITE,1,1 );
  350. break;
  351. case 25 ... 49:
  352. Paint_DrawRectangle(433 -BAT_X_OFFSET,27,439-BAT_X_OFFSET,41,WHITE,1,1 );
  353. Paint_DrawRectangle(441-BAT_X_OFFSET,27,447-BAT_X_OFFSET,41,WHITE,1,1 );
  354. break;
  355. case 50 ... 74:
  356. Paint_DrawRectangle(433-BAT_X_OFFSET,27,439-BAT_X_OFFSET,41,WHITE,1,1 );
  357. Paint_DrawRectangle(441-BAT_X_OFFSET,27,447-BAT_X_OFFSET,41,WHITE,1,1 );
  358. Paint_DrawRectangle(449-BAT_X_OFFSET,27,455-BAT_X_OFFSET,41,WHITE,1,1 );
  359. break;
  360. case 75 ... 99:
  361. Paint_DrawRectangle(433-BAT_X_OFFSET,27,439-BAT_X_OFFSET,41,WHITE,1,1 );
  362. Paint_DrawRectangle(441-BAT_X_OFFSET,27,447-BAT_X_OFFSET,41,WHITE,1,1 );
  363. Paint_DrawRectangle(449-BAT_X_OFFSET,27,455-BAT_X_OFFSET,41,WHITE,1,1 );
  364. Paint_DrawRectangle(457-BAT_X_OFFSET,27,462-BAT_X_OFFSET,41,WHITE,1,1 );
  365. break;
  366. case 100:
  367. Paint_DrawRectangle(433-BAT_X_OFFSET,27,439-BAT_X_OFFSET,41,WHITE,1,1 );
  368. Paint_DrawRectangle(441-BAT_X_OFFSET,27,447-BAT_X_OFFSET,41,WHITE,1,1 );
  369. Paint_DrawRectangle(449-BAT_X_OFFSET,27,455-BAT_X_OFFSET,41,WHITE,1,1 );
  370. Paint_DrawRectangle(457-BAT_X_OFFSET,27,462-BAT_X_OFFSET,41,WHITE,1,1 );
  371. break;
  372. default:
  373. break;
  374. }
  375. Machine_info.batt_precent = read_battery_voltage();
  376. if(Machine_info.batt_precent >=95)
  377. {
  378. Paint_DrawBitMap_Paste((uint8_t*)gImage_filled ,480-47+37,27 - BAT_Y_OFFSET,8,18,1 );
  379. }
  380. else
  381. {
  382. Paint_DrawBitMap_Paste((uint8_t*)gImage_charging ,480-47+35,27 - BAT_Y_OFFSET,8,18,1 );
  383. }
  384. }else
  385. {
  386. if(read_battery_voltage()<10)
  387. {
  388. Paint_DrawBitMap_Paste(gImage_low_batt, 30,428 ,420,154,1); //低电量请充电
  389. }
  390. }
  391. epd_init_cmd(SCREEN_RIGHT);
  392. epd_display(SCREEN_RIGHT,Paint_info.Image);
  393. memcpy(last_paint_buf_right,Paint_info.Image,sizeof(uint8_t)*648*480/8);
  394. if(memcmp(last_paint_buf_right,Paint_info.Image,38880))
  395. {
  396. ESP_LOGE(LOG_TAG,"err:last_paint_buf_right");
  397. }
  398. }
  399. void Paint_leftScreen_main_powerOn(void)
  400. {
  401. printf("Paint_leftScreen_main_powerOn\r\n");
  402. //当前未配对进入出厂模式
  403. //当前系统的状态 关机 未配网
  404. if( /*(!Machine_info.paired) &&*/(!Machine_info.power_status))
  405. {
  406. memset((uint8_t*)tmp_paint_buf,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
  407. Paint_NewImage((uint8_t*)tmp_paint_buf, 648, 480, ROTATE_180, WHITE);
  408. Paint_DrawBitMap_Paste(gImage_left_instructions, 0,0 ,648,480 ,1);
  409. //qrcode
  410. char qrcode_string[1024]= {0};
  411. qrcode_protocol_create(qrcode_string,Machine_info);
  412. QRGenerator_quick(qrcode_string);
  413. Paint_DrawBitMap_Paste((uint8_t*)gImage_nfc ,573,215,44,44,1 );
  414. #if DEVOP_TEST
  415. // char btn_test[] = {0x00,0x6f,0x00,0x6b,0x00,0x00};
  416. // //int x = center_align(&btn_test,128,64,64);
  417. // Paint_DrawRectangle(400,0,528,64,WHITE,1,1);
  418. // Paint_DrawString_CN64(400,0,(char*)btn_test );
  419. char mac_addr[20]={0};
  420. esp_read_mac((uint8_t *)Machine_info.mac_addr, ESP_MAC_WIFI_STA);
  421. sprintf(mac_addr,"%02X:%02X:%02X:%02X:%02X:%02X",
  422. Machine_info.mac_addr[0],
  423. Machine_info.mac_addr[1],
  424. Machine_info.mac_addr[2],
  425. Machine_info.mac_addr[3],
  426. Machine_info.mac_addr[4],
  427. Machine_info.mac_addr[5]
  428. );
  429. //Paint_DrawRectangle(30+10+350,250-timeHeights[5],30+10+50+350,250,WHITE,1,1 );
  430. //Paint_DrawString_CN(30+10+8+350, 250+8,(char*)str_waitMaterials, &chinese_type_24,FONT_FOREGROUND,FONT_BACKGROUND );
  431. Paint_DrawString_EN(0,0,(char *)mac_addr, &ascii_type_12x24,FONT_FOREGROUND,FONT_BACKGROUND );
  432. char version[20]={0};
  433. sprintf(version,"version = %d.%d",
  434. MAJOR_VERSION,SECOND_VERSION
  435. );
  436. Paint_DrawString_EN(0,24,(char *)version, &ascii_type_12x24,FONT_FOREGROUND,FONT_BACKGROUND );
  437. #endif
  438. epd_init_cmd(SCREEN_LEFT);
  439. epd_display(SCREEN_LEFT,Paint_info.Image);
  440. memcpy(last_paint_buf_left,Paint_info.Image,sizeof(uint8_t)*648*480/8);
  441. // int ret = memcmp(last_paint_buf_left,Paint_info.Image,38880);
  442. // ESP_LOGW(LOG_TAG,"memcmp :ret = %d",ret);
  443. if(memcmp(last_paint_buf_left,Paint_info.Image,38880))
  444. {
  445. ESP_LOGE(LOG_TAG,"err:last_paint_buf_left");
  446. }
  447. #if 0//USER_DEEP_SLEEP_ENABLE
  448. int reson = is_wake_up_reson(); //返回唤醒的原因
  449. if ((reson != ESP_SLEEP_WAKEUP_ULP) && (reson != ESP_SLEEP_WAKEUP_TIMER))
  450. {
  451. uint8_t *old_buffer= heap_caps_malloc(480*81, MALLOC_CAP_8BIT|MALLOC_CAP_INTERNAL); //申请内存
  452. memset(old_buffer,0x00,480*81);
  453. //memset((uint8_t*)last_paint_buf_left,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
  454. //压缩
  455. compressedSize = compressRLE(last_paint_buf_left, 480*81, old_buffer);
  456. // printf(" src size = %d, zip size:%d\r\n",480*81,compressedSize);
  457. //memset((uint8_t*)tmp_paint_buf,0,sizeof(tmp_paint_buf));
  458. //button_deinit();
  459. //写入数据
  460. left_spiffs_write(old_buffer,compressedSize);
  461. //button_init(adc1_handle);
  462. free(old_buffer);
  463. }
  464. #endif
  465. }
  466. else //不是出厂模式
  467. {
  468. //得到图像buf
  469. memset((uint8_t*)tmp_paint_buf,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
  470. Paint_NewImage((uint8_t*)tmp_paint_buf, 64, 32, ROTATE_0, WHITE);
  471. Paint_DrawString_CN(0,0,(char*)str_operation,&chinese_type_32,FONT_FOREGROUND,FONT_BACKGROUND );
  472. uint8_t* operation_64x32_buf = (uint8_t*)calloc(64*32/8,sizeof(uint8_t));
  473. memcpy(operation_64x32_buf,Paint_info.Image,sizeof(uint8_t)*64*32/8);
  474. memset((uint8_t*)tmp_paint_buf,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
  475. Paint_NewImage((uint8_t*)tmp_paint_buf, 96, 48, ROTATE_0, WHITE);
  476. Paint_DrawBitMap_Paste(operation_64x32_buf,16,8,64,32,1);
  477. uint8_t* operation_background_96x48_buf = (uint8_t*)calloc(96*48/8,sizeof(uint8_t));
  478. memcpy(operation_background_96x48_buf,Paint_info.Image,sizeof(uint8_t)*96*48/8);
  479. //str_shutDown
  480. memset((uint8_t*)tmp_paint_buf,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
  481. Paint_NewImage((uint8_t*)tmp_paint_buf, 32, 64, ROTATE_90, WHITE);
  482. Paint_DrawString_CN(0,0,(char*)str_shutDown,&chinese_type_32,FONT_FOREGROUND,FONT_BACKGROUND);
  483. uint8_t* shutDown_64x32_buf = (uint8_t*)calloc(64*32/8,sizeof(uint8_t));
  484. memcpy(shutDown_64x32_buf,Paint_info.Image,sizeof(uint8_t)*64*32/8);
  485. memset((uint8_t*)tmp_paint_buf,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
  486. Paint_NewImage((uint8_t*)tmp_paint_buf, 48, 96, ROTATE_0, WHITE);
  487. Paint_DrawBitMap_Paste(shutDown_64x32_buf,8,16,32,64,1);
  488. uint8_t* shutDown_background_96x48_buf = (uint8_t*)calloc(96*48/8,sizeof(uint8_t));
  489. memcpy(shutDown_background_96x48_buf,Paint_info.Image,sizeof(uint8_t)*96*48/8);
  490. //str_breakDown
  491. memset((uint8_t*)tmp_paint_buf,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
  492. Paint_NewImage((uint8_t*)tmp_paint_buf, 32, 64, ROTATE_90, WHITE);
  493. Paint_DrawString_CN(0,0,(char*)str_breakDown,&chinese_type_32,FONT_FOREGROUND,FONT_BACKGROUND);
  494. uint8_t* breakDown_64x32_buf = (uint8_t*)calloc(64*32/8,sizeof(uint8_t));
  495. memcpy(breakDown_64x32_buf,Paint_info.Image,sizeof(uint8_t)*64*32/8);
  496. memset((uint8_t*)tmp_paint_buf,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
  497. Paint_NewImage((uint8_t*)tmp_paint_buf, 48, 96, ROTATE_0, WHITE);
  498. Paint_DrawBitMap_Paste(breakDown_64x32_buf,8,16,32,64,1);
  499. uint8_t* breakDown_background_96x48_buf = (uint8_t*)calloc(96*48/8,sizeof(uint8_t));
  500. memcpy(breakDown_background_96x48_buf,Paint_info.Image,sizeof(uint8_t)*96*48/8);
  501. //str_safeKeep
  502. memset((uint8_t*)tmp_paint_buf,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
  503. Paint_NewImage((uint8_t*)tmp_paint_buf, 64, 32, ROTATE_0, WHITE);
  504. Paint_DrawString_CN(0,0,(char*)str_safeKeep,&chinese_type_32,FONT_FOREGROUND,FONT_BACKGROUND);
  505. uint8_t* safeKeep_64x32_buf = (uint8_t*)calloc(64*32/8,sizeof(uint8_t));
  506. memcpy(safeKeep_64x32_buf,Paint_info.Image,sizeof(uint8_t)*64*32/8);
  507. memset((uint8_t*)tmp_paint_buf,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
  508. Paint_NewImage((uint8_t*)tmp_paint_buf, 96, 48, ROTATE_0, WHITE);
  509. Paint_DrawBitMap_Paste(safeKeep_64x32_buf,16,8,64,32,1);
  510. uint8_t* safeKeep_background_96x48_buf = (uint8_t*)calloc(96*48/8,sizeof(uint8_t));
  511. memcpy(safeKeep_background_96x48_buf,Paint_info.Image,sizeof(uint8_t)*96*48/8);
  512. //str_upKeep
  513. memset((uint8_t*)tmp_paint_buf,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
  514. Paint_NewImage((uint8_t*)tmp_paint_buf, 32, 64, ROTATE_270, WHITE);
  515. Paint_DrawString_CN(0,0,(char*)str_upKeep,&chinese_type_32,FONT_FOREGROUND,FONT_BACKGROUND);
  516. uint8_t* upKeep_64x32_buf = (uint8_t*)calloc(64*32/8,sizeof(uint8_t));
  517. memcpy(upKeep_64x32_buf,Paint_info.Image,sizeof(uint8_t)*64*32/8);
  518. memset((uint8_t*)tmp_paint_buf,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
  519. Paint_NewImage((uint8_t*)tmp_paint_buf, 48, 96, ROTATE_0, WHITE);
  520. Paint_DrawBitMap_Paste(upKeep_64x32_buf,8,16,32,64,1);
  521. uint8_t* upKeep_background_96x48_buf = (uint8_t*)calloc(96*48/8,sizeof(uint8_t));
  522. memcpy(upKeep_background_96x48_buf,Paint_info.Image,sizeof(uint8_t)*96*48/8);
  523. //str_waitMaterials
  524. memset((uint8_t*)tmp_paint_buf,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
  525. Paint_NewImage((uint8_t*)tmp_paint_buf, 32, 64, ROTATE_270, WHITE);
  526. Paint_DrawString_CN(0,0,(char*)str_waitMaterials,&chinese_type_32,FONT_FOREGROUND,FONT_BACKGROUND);
  527. uint8_t* waitMaterials_64x32_buf = (uint8_t*)calloc(64*32/8,sizeof(uint8_t));
  528. memcpy(waitMaterials_64x32_buf,Paint_info.Image,sizeof(uint8_t)*64*32/8);
  529. memset((uint8_t*)tmp_paint_buf,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
  530. Paint_NewImage((uint8_t*)tmp_paint_buf, 48, 96, ROTATE_0, WHITE);
  531. Paint_DrawBitMap_Paste(waitMaterials_64x32_buf,8,16,32,64,1);
  532. uint8_t* waitMaterials_background_96x48_buf = (uint8_t*)calloc(96*48/8,sizeof(uint8_t));
  533. memcpy(waitMaterials_background_96x48_buf,Paint_info.Image,sizeof(uint8_t)*96*48/8);
  534. uint8_t* image_320x384_buf = (uint8_t*)calloc(320*384/8,sizeof(uint8_t));
  535. memset((uint8_t*)tmp_paint_buf,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
  536. Paint_NewImage((uint8_t*)tmp_paint_buf, 96, 48, ROTATE_0, WHITE);
  537. Paint_DrawBitMap_Paste((uint8_t*)gImage_button,0,0,96,48,1);
  538. Paint_DrawString_CN(16,8,(char*)str_operation,&chinese_type_32,FONT_BACKGROUND,FONT_FOREGROUND);
  539. memcpy(operation_background_96x48_buf,Paint_info.Image,sizeof(uint8_t)*96*48/8);
  540. memset((uint8_t*)tmp_paint_buf,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
  541. Paint_NewImage((uint8_t*)tmp_paint_buf, 320, 384, ROTATE_0, WHITE);
  542. Paint_DrawBitMap_Paste((uint8_t*)gImage_mid_,0,0,320,384,1);
  543. Paint_DrawString_CN64(96,160,(char*)str_operation );
  544. memcpy(image_320x384_buf,Paint_info.Image,sizeof(uint8_t)*320*384/8);
  545. //---
  546. memset((uint8_t*)tmp_paint_buf,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
  547. Paint_NewImage((uint8_t*)tmp_paint_buf, 648, 480, ROTATE_180, WHITE);
  548. //
  549. Paint_DrawBitMap_Paste(operation_background_96x48_buf, 272,0 ,96 ,48 ,1);
  550. Paint_DrawBitMap_Paste(shutDown_background_96x48_buf, 600,48 ,48 ,96 ,1);
  551. Paint_DrawBitMap_Paste(breakDown_background_96x48_buf, 600,336,48 ,96 ,1);
  552. Paint_DrawBitMap_Paste(safeKeep_background_96x48_buf, 272,432,96 ,48 ,1);
  553. Paint_DrawBitMap_Paste(upKeep_background_96x48_buf, 0 ,336,48 ,96 ,1);
  554. Paint_DrawBitMap_Paste(waitMaterials_background_96x48_buf, 0 ,48 ,48 ,96 ,1);
  555. Paint_DrawBitMap_Paste(image_320x384_buf, 164,48 ,320,384,1);
  556. Paint_DrawBitMap_Paste((uint8_t*)gImage_nfc ,573,215,44,44,1 );
  557. //qrcode
  558. char qrcode_string[1024]= {0};
  559. qrcode_protocol_create(qrcode_string,Machine_info);
  560. QRGenerator_quick(qrcode_string);
  561. #if DEVOP_TEST
  562. char mac_addr[20]={0};
  563. esp_read_mac((uint8_t *)Machine_info.mac_addr, ESP_MAC_WIFI_STA);
  564. sprintf(mac_addr,"%02X:%02X:%02X:%02X:%02X:%02X",
  565. Machine_info.mac_addr[0],
  566. Machine_info.mac_addr[1],
  567. Machine_info.mac_addr[2],
  568. Machine_info.mac_addr[3],
  569. Machine_info.mac_addr[4],
  570. Machine_info.mac_addr[5]
  571. );
  572. //Paint_DrawRectangle(30+10+350,250-timeHeights[5],30+10+50+350,250,WHITE,1,1 );
  573. //Paint_DrawString_CN(30+10+8+350, 250+8,(char*)str_waitMaterials, &chinese_type_24,FONT_FOREGROUND,FONT_BACKGROUND );
  574. Paint_DrawString_EN(0,0,(char *)mac_addr, &ascii_type_12x24,FONT_FOREGROUND,FONT_BACKGROUND );
  575. char version[20]={0};
  576. sprintf(version,"version = %d.%d",
  577. MAJOR_VERSION,SECOND_VERSION
  578. );
  579. Paint_DrawString_EN(0,24,(char *)version, &ascii_type_12x24,FONT_FOREGROUND,FONT_BACKGROUND );
  580. #endif
  581. epd_init_cmd(SCREEN_LEFT);
  582. epd_display(SCREEN_LEFT,Paint_info.Image);
  583. memcpy(last_paint_buf_left,Paint_info.Image,sizeof(uint8_t)*648*480/8);
  584. // int ret = memcmp(last_paint_buf_left,Paint_info.Image,38880);
  585. // ESP_LOGW(LOG_TAG,"memcmp :ret = %d",ret);
  586. if(memcmp(last_paint_buf_left,Paint_info.Image,38880))
  587. {
  588. ESP_LOGE(LOG_TAG,"err:last_paint_buf_left");
  589. }
  590. free(operation_64x32_buf);
  591. free(shutDown_64x32_buf);
  592. free(breakDown_64x32_buf);
  593. free(upKeep_64x32_buf);
  594. free(safeKeep_64x32_buf);
  595. free(waitMaterials_64x32_buf);
  596. free(image_320x384_buf);
  597. free(operation_background_96x48_buf);
  598. free(shutDown_background_96x48_buf);
  599. free(breakDown_background_96x48_buf);
  600. free(upKeep_background_96x48_buf);
  601. free(safeKeep_background_96x48_buf);
  602. free(waitMaterials_background_96x48_buf);
  603. #if 0//USER_DEEP_SLEEP_ENABLE
  604. int reson = is_wake_up_reson(); //返回唤醒的原因
  605. if ((reson != ESP_SLEEP_WAKEUP_ULP) && (reson != ESP_SLEEP_WAKEUP_TIMER))
  606. {
  607. uint8_t *old_buffer= heap_caps_malloc(480*81, MALLOC_CAP_8BIT|MALLOC_CAP_SPIRAM); //申请内存
  608. memset(old_buffer,0x00,480*81);
  609. //memset((uint8_t*)last_paint_buf_left,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
  610. #if 1 //压缩
  611. compressedSize = compressRLE(last_paint_buf_left, 480*81, old_buffer);
  612. // printf(" src size = %d, zip size:%d\r\n",480*81,compressedSize);
  613. //memset((uint8_t*)tmp_paint_buf,0,sizeof(tmp_paint_buf));
  614. //button_deinit();
  615. //写入数据
  616. left_spiffs_write(old_buffer,compressedSize);
  617. //button_init(adc1_handle);
  618. free(old_buffer);
  619. }
  620. #endif
  621. #endif
  622. }
  623. }
  624. void Paint_leftScreen_main_slow(Machine_info_t* info)
  625. {
  626. printf("Paint_leftScreen_main_slow\r\n");
  627. // set_button_anotherName();
  628. int x = 0;//居中偏移
  629. //先利用NewImage,得到各个部分的图像buf
  630. //再画图
  631. uint8_t* image_320x384_buf = (uint8_t*)calloc(320*384/8,sizeof(uint8_t));
  632. #if 1
  633. uint8_t* tmp = NULL;
  634. switch (Machine_info.left_display_mode)
  635. {
  636. case 0x00:
  637. //ESP_LOGW(LOG_TAG,"left_display_mode 0x01:");
  638. break;
  639. case 0x01:
  640. /* code */
  641. tmp = partial_bar_chart_07_02_quick(info);
  642. break;
  643. case 0x02:
  644. /* code */
  645. tmp = partial_bar_chart_07_03_quick(info);
  646. break;
  647. case 0x03:
  648. /* code */
  649. tmp = partial_bar_chart_07_04_quick(info);
  650. break;
  651. default:
  652. break;
  653. }
  654. #else
  655. tmp = partial_bar_chart_07_04_quick(info);
  656. #endif
  657. memset((uint8_t*)tmp_paint_buf,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
  658. Paint_NewImage((uint8_t*)tmp_paint_buf, 64, 32, ROTATE_0, WHITE);
  659. x = center_align(&Machine_info.btn_operation,64,16,32);
  660. Paint_DrawString_CN(0+x,0,(char*)Machine_info.btn_operation,&chinese_type_32,FONT_FOREGROUND,FONT_BACKGROUND );
  661. uint8_t* operation_64x32_buf = (uint8_t*)calloc(64*32/8,sizeof(uint8_t));
  662. memcpy(operation_64x32_buf,Paint_info.Image,sizeof(uint8_t)*64*32/8);
  663. memset((uint8_t*)tmp_paint_buf,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
  664. Paint_NewImage((uint8_t*)tmp_paint_buf, 96, 48, ROTATE_0, WHITE);
  665. Paint_DrawBitMap_Paste(operation_64x32_buf,16,8,64,32,1);
  666. uint8_t* operation_background_96x48_buf = (uint8_t*)calloc(96*48/8,sizeof(uint8_t));
  667. memcpy(operation_background_96x48_buf,Paint_info.Image,sizeof(uint8_t)*96*48/8);
  668. free(operation_64x32_buf);
  669. //str_shutDown
  670. memset((uint8_t*)tmp_paint_buf,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
  671. Paint_NewImage((uint8_t*)tmp_paint_buf, 32, 64, ROTATE_90, WHITE);
  672. x = center_align(&Machine_info.btn_shutDown_info,64,16,32);
  673. Paint_DrawString_CN(0,0,(char*)Machine_info.btn_shutDown_info,&chinese_type_32,FONT_FOREGROUND,FONT_BACKGROUND);
  674. uint8_t* shutDown_64x32_buf = (uint8_t*)calloc(64*32/8,sizeof(uint8_t));
  675. memcpy(shutDown_64x32_buf,Paint_info.Image,sizeof(uint8_t)*64*32/8);
  676. memset((uint8_t*)tmp_paint_buf,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
  677. Paint_NewImage((uint8_t*)tmp_paint_buf, 48, 96, ROTATE_0, WHITE);
  678. Paint_DrawBitMap_Paste(shutDown_64x32_buf,8,16,32,64,1);
  679. uint8_t* shutDown_background_96x48_buf = (uint8_t*)calloc(96*48/8,sizeof(uint8_t));
  680. memcpy(shutDown_background_96x48_buf,Paint_info.Image,sizeof(uint8_t)*96*48/8);
  681. free(shutDown_64x32_buf);
  682. //str_breakDown
  683. memset((uint8_t*)tmp_paint_buf,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
  684. Paint_NewImage((uint8_t*)tmp_paint_buf, 32, 64, ROTATE_90, WHITE);
  685. x = center_align(&Machine_info.btn_breakDown_info,64,16,32);
  686. Paint_DrawString_CN(0,0,(char*)Machine_info.btn_breakDown_info,&chinese_type_32,FONT_FOREGROUND,FONT_BACKGROUND);
  687. uint8_t* breakDown_64x32_buf = (uint8_t*)calloc(64*32/8,sizeof(uint8_t));
  688. memcpy(breakDown_64x32_buf,Paint_info.Image,sizeof(uint8_t)*64*32/8);
  689. memset((uint8_t*)tmp_paint_buf,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
  690. Paint_NewImage((uint8_t*)tmp_paint_buf, 48, 96, ROTATE_0, WHITE);
  691. Paint_DrawBitMap_Paste(breakDown_64x32_buf,8,16,32,64,1);
  692. uint8_t* breakDown_background_96x48_buf = (uint8_t*)calloc(96*48/8,sizeof(uint8_t));
  693. memcpy(breakDown_background_96x48_buf,Paint_info.Image,sizeof(uint8_t)*96*48/8);
  694. free(breakDown_64x32_buf);
  695. //str_safeKeep
  696. memset((uint8_t*)tmp_paint_buf,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
  697. Paint_NewImage((uint8_t*)tmp_paint_buf, 64, 32, ROTATE_0, WHITE);
  698. x = center_align(&Machine_info.btn_safeKeep_info,64,16,32);
  699. Paint_DrawString_CN(0,0,(char*)Machine_info.btn_safeKeep_info,&chinese_type_32,FONT_FOREGROUND,FONT_BACKGROUND);
  700. uint8_t* safeKeep_64x32_buf = (uint8_t*)calloc(64*32/8,sizeof(uint8_t));
  701. memcpy(safeKeep_64x32_buf,Paint_info.Image,sizeof(uint8_t)*64*32/8);
  702. memset((uint8_t*)tmp_paint_buf,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
  703. Paint_NewImage((uint8_t*)tmp_paint_buf, 96, 48, ROTATE_0, WHITE);
  704. Paint_DrawBitMap_Paste(safeKeep_64x32_buf,16,8,64,32,1);
  705. uint8_t* safeKeep_background_96x48_buf = (uint8_t*)calloc(96*48/8,sizeof(uint8_t));
  706. memcpy(safeKeep_background_96x48_buf,Paint_info.Image,sizeof(uint8_t)*96*48/8);
  707. free(safeKeep_64x32_buf);
  708. //str_upKeep
  709. memset((uint8_t*)tmp_paint_buf,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
  710. Paint_NewImage((uint8_t*)tmp_paint_buf, 32, 64, ROTATE_270, WHITE);
  711. x = center_align(&Machine_info.btn_upKeep_info,64,16,32);
  712. Paint_DrawString_CN(0,0,(char*)Machine_info.btn_upKeep_info,&chinese_type_32,FONT_FOREGROUND,FONT_BACKGROUND);
  713. uint8_t* upKeep_64x32_buf = (uint8_t*)calloc(64*32/8,sizeof(uint8_t));
  714. memcpy(upKeep_64x32_buf,Paint_info.Image,sizeof(uint8_t)*64*32/8);
  715. memset((uint8_t*)tmp_paint_buf,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
  716. Paint_NewImage((uint8_t*)tmp_paint_buf, 48, 96, ROTATE_0, WHITE);
  717. Paint_DrawBitMap_Paste(upKeep_64x32_buf,8,16,32,64,1);
  718. uint8_t* upKeep_background_96x48_buf = (uint8_t*)calloc(96*48/8,sizeof(uint8_t));
  719. memcpy(upKeep_background_96x48_buf,Paint_info.Image,sizeof(uint8_t)*96*48/8);
  720. free(upKeep_64x32_buf);
  721. //str_waitMaterials
  722. memset((uint8_t*)tmp_paint_buf,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
  723. Paint_NewImage((uint8_t*)tmp_paint_buf, 32, 64, ROTATE_270, WHITE);
  724. x = center_align(&Machine_info.btn_waitMaterials_info,64,16,32);
  725. Paint_DrawString_CN(0,0,(char*)Machine_info.btn_waitMaterials_info,&chinese_type_32,FONT_FOREGROUND,FONT_BACKGROUND);
  726. uint8_t* waitMaterials_64x32_buf = (uint8_t*)calloc(64*32/8,sizeof(uint8_t));
  727. memcpy(waitMaterials_64x32_buf,Paint_info.Image,sizeof(uint8_t)*64*32/8);
  728. memset((uint8_t*)tmp_paint_buf,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
  729. Paint_NewImage((uint8_t*)tmp_paint_buf, 48, 96, ROTATE_0, WHITE);
  730. Paint_DrawBitMap_Paste(waitMaterials_64x32_buf,8,16,32,64,1);
  731. uint8_t* waitMaterials_background_96x48_buf = (uint8_t*)calloc(96*48/8,sizeof(uint8_t));
  732. memcpy(waitMaterials_background_96x48_buf,Paint_info.Image,sizeof(uint8_t)*96*48/8);
  733. free(waitMaterials_64x32_buf);
  734. uint8_t* background_128x64_buf = (uint8_t*)calloc(128*64/8,sizeof(uint8_t));
  735. //得到图像buf
  736. ESP_LOGW(LOG_TAG,"----------------Machine_info.left_state = %d-------left_display_mode =%d -------\r\n",Machine_info.left_state,Machine_info.left_display_mode);
  737. switch (Machine_info.left_state)
  738. {
  739. case STATE_NONE:
  740. case STATE_OPERATION:
  741. {
  742. if(Machine_info.left_display_mode==0)
  743. {
  744. memset((uint8_t*)tmp_paint_buf,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
  745. Paint_NewImage((uint8_t*)tmp_paint_buf, 96, 48, ROTATE_0, WHITE);
  746. Paint_DrawBitMap_Paste((uint8_t*)gImage_button,0,0,96,48,1);
  747. x = center_align(&Machine_info.btn_operation,64,16,32);
  748. Paint_DrawString_CN(16+x,8,(char*)Machine_info.btn_operation,&chinese_type_32,FONT_BACKGROUND,FONT_FOREGROUND);
  749. memcpy(operation_background_96x48_buf,Paint_info.Image,sizeof(uint8_t)*96*48/8);
  750. memset((uint8_t*)tmp_paint_buf,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
  751. Paint_NewImage((uint8_t*)tmp_paint_buf, 320, 384, ROTATE_0, WHITE);
  752. Paint_DrawBitMap_Paste((uint8_t*)gImage_mid_,0,0,320,384,1);
  753. x = center_align(&Machine_info.btn_operation,128,64,64);
  754. Paint_DrawString_CN64(96+x,160,(char*)Machine_info.btn_operation );
  755. memcpy(image_320x384_buf,Paint_info.Image,sizeof(uint8_t)*320*384/8);
  756. }
  757. else
  758. {
  759. memset((uint8_t*)tmp_paint_buf,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
  760. Paint_NewImage((uint8_t*)tmp_paint_buf, 128, 64, ROTATE_0, WHITE);
  761. Paint_DrawBitMap_Paste((uint8_t*)gImage_button_128x64,0,0,128,64,1);
  762. x = center_align(&Machine_info.btn_operation,96,24,48);
  763. // Paint_DrawString_CN(16+x,8,(char*)Machine_info.btn_operation,&chinese_type_32,FONT_BACKGROUND,FONT_FOREGROUND);
  764. Paint_DrawString_CN48(16+x,8,(char*)Machine_info.btn_operation,false);
  765. memcpy(background_128x64_buf,Paint_info.Image,sizeof(uint8_t)*128*64/8);
  766. }
  767. }
  768. break;
  769. case STATE_SHUT_DOWN:
  770. {
  771. if(Machine_info.left_display_mode==0)
  772. {
  773. memset((uint8_t*)tmp_paint_buf,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
  774. Paint_NewImage((uint8_t*)tmp_paint_buf, 48, 96, ROTATE_90, WHITE);
  775. Paint_DrawBitMap_Paste((uint8_t*)gImage_button,0,0,96,48,1);
  776. x = center_align(&Machine_info.btn_shutDown_info,64,16,32);
  777. Paint_DrawString_CN(16+x,8,(char*)Machine_info.btn_shutDown_info,&chinese_type_32,FONT_BACKGROUND,FONT_FOREGROUND);
  778. memcpy(shutDown_background_96x48_buf,Paint_info.Image,sizeof(uint8_t)*96*48/8);
  779. memset((uint8_t*)tmp_paint_buf,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
  780. Paint_NewImage((uint8_t*)tmp_paint_buf, 320, 384, ROTATE_0, WHITE);
  781. Paint_DrawBitMap_Paste((uint8_t*)gImage_right_,0,0,320,384,1);
  782. x = center_align(&Machine_info.btn_shutDown_info,128,64,64);
  783. Paint_DrawString_CN64(96+x,160,(char*)Machine_info.btn_shutDown_info );
  784. memcpy(image_320x384_buf,Paint_info.Image,sizeof(uint8_t)*320*384/8);
  785. }
  786. else
  787. {
  788. memset((uint8_t*)tmp_paint_buf,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
  789. Paint_NewImage((uint8_t*)tmp_paint_buf, 64, 128, ROTATE_90, WHITE);
  790. Paint_DrawBitMap_Paste((uint8_t*)gImage_button_128x64,0,0,128,64,1);
  791. x = center_align(&Machine_info.btn_shutDown_info,96,24,48);
  792. // Paint_DrawString_CN(16+x,8,(char*)Machine_info.btn_shutDown_info,&chinese_type_32,FONT_BACKGROUND,FONT_FOREGROUND);
  793. Paint_DrawString_CN48(16+x,8,(char*)Machine_info.btn_shutDown_info,false);
  794. memcpy(background_128x64_buf,Paint_info.Image,sizeof(uint8_t)*128*64/8);
  795. }
  796. }
  797. break;
  798. case STATE_BREAKDOWN:
  799. {
  800. if(Machine_info.left_display_mode==0)
  801. {
  802. memset((uint8_t*)tmp_paint_buf,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
  803. Paint_NewImage((uint8_t*)tmp_paint_buf, 48, 96, ROTATE_90, WHITE);
  804. Paint_DrawBitMap_Paste((uint8_t*)gImage_button,0,0,96,48,1);
  805. x = center_align(&Machine_info.btn_breakDown_info,64,16,32);
  806. Paint_DrawString_CN(16+x,8,(char*)Machine_info.btn_breakDown_info,&chinese_type_32,FONT_BACKGROUND,FONT_FOREGROUND);
  807. memcpy(breakDown_background_96x48_buf,Paint_info.Image,sizeof(uint8_t)*96*48/8);
  808. memset((uint8_t*)tmp_paint_buf,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
  809. Paint_NewImage((uint8_t*)tmp_paint_buf, 320, 384, ROTATE_180, WHITE);
  810. Paint_DrawBitMap_Paste((uint8_t*)gImage_left_,0,0,320,384,1);
  811. memcpy(image_320x384_buf,Paint_info.Image,sizeof(uint8_t)*320*384/8);
  812. Paint_NewImage(image_320x384_buf, 320, 384, ROTATE_0, WHITE);
  813. x = center_align(&Machine_info.btn_breakDown_info,128,64,64);
  814. Paint_DrawString_CN64(96+x,160,(char*)Machine_info.btn_breakDown_info );
  815. memcpy(image_320x384_buf,Paint_info.Image,sizeof(uint8_t)*320*384/8);
  816. }
  817. else
  818. {
  819. memset((uint8_t*)tmp_paint_buf,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
  820. Paint_NewImage((uint8_t*)tmp_paint_buf, 64,128, ROTATE_90, WHITE);
  821. Paint_DrawBitMap_Paste((uint8_t*)gImage_button_128x64,0,0,128,64,1);
  822. x = center_align(&Machine_info.btn_breakDown_info,96,24,48);
  823. // Paint_DrawString_CN(16+x,8,(char*)Machine_info.btn_breakDown_info,&chinese_type_32,FONT_BACKGROUND,FONT_FOREGROUND);
  824. Paint_DrawString_CN48(16+x,8,(char*)Machine_info.btn_breakDown_info,false);
  825. memcpy(background_128x64_buf,Paint_info.Image,sizeof(uint8_t)*128*64/8);
  826. }
  827. }
  828. break;
  829. case STATE_SAFEKEEP:
  830. {
  831. if(Machine_info.left_display_mode==0)
  832. {
  833. memset((uint8_t*)tmp_paint_buf,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
  834. Paint_NewImage((uint8_t*)tmp_paint_buf, 96, 48, ROTATE_0, WHITE);
  835. Paint_DrawBitMap_Paste((uint8_t*)gImage_button,0,0,96,48,1);
  836. x = center_align(&Machine_info.btn_safeKeep_info,64,16,32);
  837. Paint_DrawString_CN(16+x,8,(char*)Machine_info.btn_safeKeep_info,&chinese_type_32,FONT_BACKGROUND,FONT_FOREGROUND);
  838. memcpy(safeKeep_background_96x48_buf,Paint_info.Image,sizeof(uint8_t)*96*48/8);
  839. memset((uint8_t*)tmp_paint_buf,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
  840. Paint_NewImage((uint8_t*)tmp_paint_buf, 320, 384, ROTATE_180, WHITE);
  841. Paint_DrawBitMap_Paste((uint8_t*)gImage_mid_,0,0,320,384,1);
  842. memcpy(image_320x384_buf,Paint_info.Image,sizeof(uint8_t)*320*384/8);
  843. Paint_NewImage(image_320x384_buf, 320, 384, ROTATE_0, WHITE);
  844. x = center_align(&Machine_info.btn_safeKeep_info,128,64,64);
  845. Paint_DrawString_CN64(96+x,160,(char*)Machine_info.btn_safeKeep_info );
  846. memcpy(image_320x384_buf,Paint_info.Image,sizeof(uint8_t)*320*384/8);
  847. }
  848. else
  849. {
  850. memset((uint8_t*)tmp_paint_buf,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
  851. Paint_NewImage((uint8_t*)tmp_paint_buf, 128, 64, ROTATE_0, WHITE);
  852. Paint_DrawBitMap_Paste((uint8_t*)gImage_button_128x64,0,0,128,64,1);
  853. x = center_align(&Machine_info.btn_safeKeep_info,96,24,48);
  854. // Paint_DrawString_CN(16+x,8,(char*)Machine_info.btn_safeKeep_info,&chinese_type_32,FONT_BACKGROUND,FONT_FOREGROUND);
  855. Paint_DrawString_CN48(16+x,8,(char*)Machine_info.btn_safeKeep_info,false);
  856. memcpy(background_128x64_buf,Paint_info.Image,sizeof(uint8_t)*128*64/8);
  857. }
  858. }
  859. break;
  860. case STATE_UPKEEP:
  861. {
  862. if(Machine_info.left_display_mode==0)
  863. {
  864. memset((uint8_t*)tmp_paint_buf,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
  865. Paint_NewImage((uint8_t*)tmp_paint_buf, 48, 96, ROTATE_270, WHITE);
  866. Paint_DrawBitMap_Paste((uint8_t*)gImage_button,0,0,96,48,1);
  867. x = center_align(&Machine_info.btn_upKeep_info,64,16,32);
  868. Paint_DrawString_CN(16+x,8,(char*)Machine_info.btn_upKeep_info,&chinese_type_32,FONT_BACKGROUND,FONT_FOREGROUND);
  869. memcpy(upKeep_background_96x48_buf,Paint_info.Image,sizeof(uint8_t)*96*48/8);
  870. memset((uint8_t*)tmp_paint_buf,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
  871. Paint_NewImage((uint8_t*)tmp_paint_buf, 320, 384, ROTATE_180, WHITE);
  872. Paint_DrawBitMap_Paste((uint8_t*)gImage_right_,0,0,320,384,1);
  873. memcpy(image_320x384_buf,Paint_info.Image,sizeof(uint8_t)*320*384/8);
  874. Paint_NewImage(image_320x384_buf, 320, 384, ROTATE_0, WHITE);
  875. x = center_align(&Machine_info.btn_upKeep_info,128,64,64);
  876. Paint_DrawString_CN64(96+x,160,(char*)Machine_info.btn_upKeep_info );
  877. memcpy(image_320x384_buf,Paint_info.Image,sizeof(uint8_t)*320*384/8);
  878. }
  879. else
  880. {
  881. memset((uint8_t*)tmp_paint_buf,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
  882. Paint_NewImage((uint8_t*)tmp_paint_buf, 64, 128, ROTATE_270, WHITE);
  883. Paint_DrawBitMap_Paste((uint8_t*)gImage_button_128x64,0,0,128,64,1);
  884. x = center_align(&Machine_info.btn_upKeep_info,96,24,48);
  885. // Paint_DrawString_CN(16+x,8,(char*)Machine_info.btn_upKeep_info,&chinese_type_32,FONT_BACKGROUND,FONT_FOREGROUND);
  886. Paint_DrawString_CN48(16+x,8,(char*)Machine_info.btn_upKeep_info,false);
  887. memcpy(background_128x64_buf,Paint_info.Image,sizeof(uint8_t)*128*64/8);
  888. }
  889. }
  890. break;
  891. case STATE_WAIT_MATERIALS:
  892. {
  893. if(Machine_info.left_display_mode==0)
  894. {
  895. memset((uint8_t*)tmp_paint_buf,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
  896. Paint_NewImage((uint8_t*)tmp_paint_buf, 48, 96, ROTATE_270, WHITE);
  897. Paint_DrawBitMap_Paste((uint8_t*)gImage_button,0,0,96,48,1);
  898. x = center_align(&Machine_info.btn_waitMaterials_info,64,16,32);
  899. Paint_DrawString_CN(16+x,8,(char*)Machine_info.btn_waitMaterials_info,&chinese_type_32,FONT_BACKGROUND,FONT_FOREGROUND);
  900. memcpy(waitMaterials_background_96x48_buf,Paint_info.Image,sizeof(uint8_t)*96*48/8);//黑底白字
  901. memset((uint8_t*)tmp_paint_buf,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
  902. Paint_NewImage((uint8_t*)tmp_paint_buf, 320, 384, ROTATE_0, WHITE);
  903. Paint_DrawBitMap_Paste((uint8_t*)gImage_left_,0,0,320,384,1);
  904. x = center_align(&Machine_info.btn_waitMaterials_info,128,64,64);
  905. Paint_DrawString_CN64(96+x,160,(char*)Machine_info.btn_waitMaterials_info );
  906. memcpy(image_320x384_buf,Paint_info.Image,sizeof(uint8_t)*320*384/8);
  907. }
  908. else
  909. {
  910. memset((uint8_t*)tmp_paint_buf,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
  911. Paint_NewImage((uint8_t*)tmp_paint_buf, 64, 128, ROTATE_270, WHITE);
  912. Paint_DrawBitMap_Paste((uint8_t*)gImage_button_128x64,0,0,128,64,1);
  913. x = center_align(&Machine_info.btn_waitMaterials_info,96,24,48);
  914. // Paint_DrawString_CN(16+x,8,(char*)Machine_info.btn_waitMaterials_info,&chinese_type_32,FONT_BACKGROUND,FONT_FOREGROUND);
  915. Paint_DrawString_CN48(16+x,8,(char*)Machine_info.btn_waitMaterials_info,false);
  916. memcpy(background_128x64_buf,Paint_info.Image,sizeof(uint8_t)*128*64/8);//黑底白字
  917. }
  918. }
  919. break;
  920. default:
  921. ESP_LOGE(LOG_TAG," err: (info->left_state)");
  922. break;
  923. }
  924. //画图
  925. memset((uint8_t*)tmp_paint_buf,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
  926. Paint_NewImage((uint8_t*)tmp_paint_buf, 648, 480, ROTATE_180, WHITE);
  927. Paint_DrawBitMap_Paste(operation_background_96x48_buf, 272,0 ,96 ,48 ,1);
  928. Paint_DrawBitMap_Paste(shutDown_background_96x48_buf, 600,48 ,48 ,96 ,1);
  929. Paint_DrawBitMap_Paste(breakDown_background_96x48_buf, 600,336,48 ,96 ,1);
  930. Paint_DrawBitMap_Paste(safeKeep_background_96x48_buf, 272,432,96 ,48 ,1);
  931. Paint_DrawBitMap_Paste(upKeep_background_96x48_buf, 0 ,336,48 ,96 ,1);
  932. Paint_DrawBitMap_Paste(waitMaterials_background_96x48_buf, 0 ,48 ,48 ,96 ,1);
  933. free(operation_background_96x48_buf);
  934. free(shutDown_background_96x48_buf);
  935. free(breakDown_background_96x48_buf);
  936. free(upKeep_background_96x48_buf);
  937. free(safeKeep_background_96x48_buf);
  938. free(waitMaterials_background_96x48_buf);
  939. if(Machine_info.left_display_mode!=0)
  940. {
  941. switch (Machine_info.left_state)
  942. {
  943. case STATE_NONE:
  944. case STATE_OPERATION:
  945. Paint_DrawBitMap_Paste(background_128x64_buf, 272-16,0 ,128 ,64 ,1);
  946. break;
  947. case STATE_SHUT_DOWN:
  948. Paint_DrawBitMap_Paste(background_128x64_buf, 600-16,48-8 ,64 ,128 ,1);
  949. break;
  950. case STATE_BREAKDOWN:
  951. Paint_DrawBitMap_Paste(background_128x64_buf, 600-16,336-8 ,64 ,128 ,1);
  952. break;
  953. case STATE_SAFEKEEP:
  954. Paint_DrawBitMap_Paste(background_128x64_buf, 272-16,432-16 ,128 ,64 ,1);
  955. break;
  956. case STATE_UPKEEP:
  957. Paint_DrawBitMap_Paste(background_128x64_buf, 0 ,336-16 ,64 ,128 ,1);
  958. break;
  959. case STATE_WAIT_MATERIALS:
  960. Paint_DrawBitMap_Paste(background_128x64_buf, 0 ,48-16 ,64 ,128 ,1);
  961. break;
  962. default:
  963. break;
  964. }
  965. }
  966. free(background_128x64_buf);
  967. Paint_DrawBitMap_Paste((uint8_t*)gImage_nfc ,573,215,44,44,1 );
  968. #if 0
  969. if((info->left_display_mode == 0x01) || (info->left_display_mode == 0x00) )
  970. #else
  971. if((info->left_display_mode == 0x00) )
  972. #endif
  973. {
  974. Paint_DrawBitMap_Paste(image_320x384_buf, 164,48 ,320,384,1);
  975. }
  976. else
  977. {
  978. Paint_DrawBitMap_Paste(tmp, 84 ,90 ,480 ,300 ,1);//648-480 168
  979. free(tmp);
  980. }
  981. //qrcode
  982. char qrcode_string[1024]= {0};
  983. qrcode_protocol_create(qrcode_string,Machine_info);
  984. QRGenerator_quick(qrcode_string);
  985. //
  986. // printf("btn_operation = %s\r\n",Machine_info.btn_operation);
  987. // printf("btn_breakDown_info = %s\r\n",Machine_info.btn_breakDown_info);
  988. // printf("btn_upKeep_info = %s\r\n",Machine_info.btn_upKeep_info);
  989. // printf("btn_shutDown_info = %s\r\n",Machine_info.btn_shutDown_info);
  990. // printf("btn_safeKeep_info = %s\r\n",Machine_info.btn_safeKeep_info);
  991. // printf("btn_waitMaterials_info = %s\r\n",Machine_info.btn_operation);
  992. #if USER_DEEP_SLEEP_ENABLE
  993. uint8_t *old_buffer= heap_caps_malloc(compressedSize, MALLOC_CAP_8BIT|MALLOC_CAP_INTERNAL|MALLOC_CAP_DMA); //申请内存
  994. if(old_buffer == NULL)
  995. {
  996. printf("buffer malloc fail\r\n");
  997. }
  998. memset(old_buffer,0x00,compressedSize);
  999. if ((reson == ESP_SLEEP_WAKEUP_ULP) || (reson == ESP_SLEEP_WAKEUP_TIMER))
  1000. {
  1001. //读取数据到内存
  1002. left_spiffs_read(old_buffer,compressedSize);
  1003. //解压数据
  1004. decompressedSize = decompressRLE(old_buffer, compressedSize, last_paint_buf_left);
  1005. printf("src size = %d unzip %d\r\n",compressedSize,decompressedSize);
  1006. }
  1007. #endif
  1008. epd_init_cmd(SCREEN_LEFT);
  1009. epd_display(SCREEN_LEFT,Paint_info.Image);
  1010. #if USER_DEEP_SLEEP_ENABLE
  1011. if ((reson == !ESP_SLEEP_WAKEUP_ULP) || (reson != ESP_SLEEP_WAKEUP_TIMER))
  1012. #endif
  1013. {
  1014. //last buf
  1015. memcpy(last_paint_buf_left,Paint_info.Image,sizeof(uint8_t)*648*480/8);
  1016. if(memcmp(last_paint_buf_left,Paint_info.Image,38880))
  1017. {
  1018. ESP_LOGE(LOG_TAG,"err:last_paint_buf_left");
  1019. }
  1020. }
  1021. #if 0//USER_DEEP_SLEEP_ENABLE
  1022. int reson = is_wake_up_reson(); //返回唤醒的原因
  1023. if ((reson == ESP_SLEEP_WAKEUP_ULP) || (reson == ESP_SLEEP_WAKEUP_TIMER) ||(reson == ESP_SLEEP_WAKEUP_EXT0))
  1024. {
  1025. compressedSize = compressRLE(Paint_info.Image, 480*81, last_paint_buf_left);
  1026. // printf(" src size = %d, zip size:%d\r\n",480*81,compressedSize);
  1027. //memset((uint8_t*)tmp_paint_buf,0,sizeof(tmp_paint_buf));
  1028. //button_deinit();
  1029. //写入数据
  1030. left_spiffs_write(last_paint_buf_left,compressedSize);
  1031. //button_init(adc1_handle);
  1032. }
  1033. //free(old_buffer);
  1034. #endif
  1035. //int reson = is_wake_up_reson(); //返回唤醒的原
  1036. #if USER_DEEP_SLEEP_ENABLE
  1037. if ((reson == ESP_SLEEP_WAKEUP_ULP) || (reson == ESP_SLEEP_WAKEUP_TIMER))
  1038. {
  1039. deepsleep_epd_powerOn_refresh_sleep(SCREEN_LEFT);
  1040. }
  1041. #endif
  1042. free(image_320x384_buf);
  1043. }
  1044. void Paint_leftScreen_main_quick(Machine_info_t* info)
  1045. {
  1046. printf("Paint_leftScreen_main_quick\r\n");
  1047. // set_button_anotherName();
  1048. int x = 0;//居中偏移
  1049. //先利用NewImage,得到各个部分的图像buf
  1050. //再画图
  1051. uint8_t* image_320x384_buf = (uint8_t*)calloc(320*384/8,sizeof(uint8_t));
  1052. #if 1
  1053. uint8_t* tmp = NULL;
  1054. switch (Machine_info.left_display_mode)
  1055. {
  1056. case 0x00:
  1057. //ESP_LOGW(LOG_TAG,"left_display_mode 0x01:");
  1058. break;
  1059. case 0x01:
  1060. /* code */
  1061. tmp = partial_bar_chart_07_02_quick(info);
  1062. break;
  1063. case 0x02:
  1064. /* code */
  1065. tmp = partial_bar_chart_07_03_quick(info);
  1066. break;
  1067. case 0x03:
  1068. /* code */
  1069. tmp = partial_bar_chart_07_04_quick(info);
  1070. break;
  1071. default:
  1072. break;
  1073. }
  1074. #else
  1075. tmp = partial_bar_chart_07_04_quick(info);
  1076. #endif
  1077. memset((uint8_t*)tmp_paint_buf,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
  1078. Paint_NewImage((uint8_t*)tmp_paint_buf, 64, 32, ROTATE_0, WHITE);
  1079. x = center_align(&Machine_info.btn_operation,64,16,32);
  1080. Paint_DrawString_CN(0+x,0,(char*)Machine_info.btn_operation,&chinese_type_32,FONT_FOREGROUND,FONT_BACKGROUND );
  1081. uint8_t* operation_64x32_buf = (uint8_t*)calloc(64*32/8,sizeof(uint8_t));
  1082. memcpy(operation_64x32_buf,Paint_info.Image,sizeof(uint8_t)*64*32/8);
  1083. memset((uint8_t*)tmp_paint_buf,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
  1084. Paint_NewImage((uint8_t*)tmp_paint_buf, 96, 48, ROTATE_0, WHITE);
  1085. Paint_DrawBitMap_Paste(operation_64x32_buf,16,8,64,32,1);
  1086. uint8_t* operation_background_96x48_buf = (uint8_t*)calloc(96*48/8,sizeof(uint8_t));
  1087. memcpy(operation_background_96x48_buf,Paint_info.Image,sizeof(uint8_t)*96*48/8);
  1088. free(operation_64x32_buf);
  1089. //str_shutDown
  1090. memset((uint8_t*)tmp_paint_buf,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
  1091. Paint_NewImage((uint8_t*)tmp_paint_buf, 32, 64, ROTATE_90, WHITE);
  1092. x = center_align(&Machine_info.btn_shutDown_info,64,16,32);
  1093. Paint_DrawString_CN(0,0,(char*)Machine_info.btn_shutDown_info,&chinese_type_32,FONT_FOREGROUND,FONT_BACKGROUND);
  1094. uint8_t* shutDown_64x32_buf = (uint8_t*)calloc(64*32/8,sizeof(uint8_t));
  1095. memcpy(shutDown_64x32_buf,Paint_info.Image,sizeof(uint8_t)*64*32/8);
  1096. memset((uint8_t*)tmp_paint_buf,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
  1097. Paint_NewImage((uint8_t*)tmp_paint_buf, 48, 96, ROTATE_0, WHITE);
  1098. Paint_DrawBitMap_Paste(shutDown_64x32_buf,8,16,32,64,1);
  1099. uint8_t* shutDown_background_96x48_buf = (uint8_t*)calloc(96*48/8,sizeof(uint8_t));
  1100. memcpy(shutDown_background_96x48_buf,Paint_info.Image,sizeof(uint8_t)*96*48/8);
  1101. free(shutDown_64x32_buf);
  1102. //str_breakDown
  1103. memset((uint8_t*)tmp_paint_buf,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
  1104. Paint_NewImage((uint8_t*)tmp_paint_buf, 32, 64, ROTATE_90, WHITE);
  1105. x = center_align(&Machine_info.btn_breakDown_info,64,16,32);
  1106. Paint_DrawString_CN(0,0,(char*)Machine_info.btn_breakDown_info,&chinese_type_32,FONT_FOREGROUND,FONT_BACKGROUND);
  1107. uint8_t* breakDown_64x32_buf = (uint8_t*)calloc(64*32/8,sizeof(uint8_t));
  1108. memcpy(breakDown_64x32_buf,Paint_info.Image,sizeof(uint8_t)*64*32/8);
  1109. memset((uint8_t*)tmp_paint_buf,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
  1110. Paint_NewImage((uint8_t*)tmp_paint_buf, 48, 96, ROTATE_0, WHITE);
  1111. Paint_DrawBitMap_Paste(breakDown_64x32_buf,8,16,32,64,1);
  1112. uint8_t* breakDown_background_96x48_buf = (uint8_t*)calloc(96*48/8,sizeof(uint8_t));
  1113. memcpy(breakDown_background_96x48_buf,Paint_info.Image,sizeof(uint8_t)*96*48/8);
  1114. free(breakDown_64x32_buf);
  1115. //str_safeKeep
  1116. memset((uint8_t*)tmp_paint_buf,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
  1117. Paint_NewImage((uint8_t*)tmp_paint_buf, 64, 32, ROTATE_0, WHITE);
  1118. x = center_align(&Machine_info.btn_safeKeep_info,64,16,32);
  1119. Paint_DrawString_CN(0,0,(char*)Machine_info.btn_safeKeep_info,&chinese_type_32,FONT_FOREGROUND,FONT_BACKGROUND);
  1120. uint8_t* safeKeep_64x32_buf = (uint8_t*)calloc(64*32/8,sizeof(uint8_t));
  1121. memcpy(safeKeep_64x32_buf,Paint_info.Image,sizeof(uint8_t)*64*32/8);
  1122. memset((uint8_t*)tmp_paint_buf,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
  1123. Paint_NewImage((uint8_t*)tmp_paint_buf, 96, 48, ROTATE_0, WHITE);
  1124. Paint_DrawBitMap_Paste(safeKeep_64x32_buf,16,8,64,32,1);
  1125. uint8_t* safeKeep_background_96x48_buf = (uint8_t*)calloc(96*48/8,sizeof(uint8_t));
  1126. memcpy(safeKeep_background_96x48_buf,Paint_info.Image,sizeof(uint8_t)*96*48/8);
  1127. free(safeKeep_64x32_buf);
  1128. //str_upKeep
  1129. memset((uint8_t*)tmp_paint_buf,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
  1130. Paint_NewImage((uint8_t*)tmp_paint_buf, 32, 64, ROTATE_270, WHITE);
  1131. x = center_align(&Machine_info.btn_upKeep_info,64,16,32);
  1132. Paint_DrawString_CN(0,0,(char*)Machine_info.btn_upKeep_info,&chinese_type_32,FONT_FOREGROUND,FONT_BACKGROUND);
  1133. uint8_t* upKeep_64x32_buf = (uint8_t*)calloc(64*32/8,sizeof(uint8_t));
  1134. memcpy(upKeep_64x32_buf,Paint_info.Image,sizeof(uint8_t)*64*32/8);
  1135. memset((uint8_t*)tmp_paint_buf,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
  1136. Paint_NewImage((uint8_t*)tmp_paint_buf, 48, 96, ROTATE_0, WHITE);
  1137. Paint_DrawBitMap_Paste(upKeep_64x32_buf,8,16,32,64,1);
  1138. uint8_t* upKeep_background_96x48_buf = (uint8_t*)calloc(96*48/8,sizeof(uint8_t));
  1139. memcpy(upKeep_background_96x48_buf,Paint_info.Image,sizeof(uint8_t)*96*48/8);
  1140. free(upKeep_64x32_buf);
  1141. //str_waitMaterials
  1142. memset((uint8_t*)tmp_paint_buf,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
  1143. Paint_NewImage((uint8_t*)tmp_paint_buf, 32, 64, ROTATE_270, WHITE);
  1144. x = center_align(&Machine_info.btn_waitMaterials_info,64,16,32);
  1145. Paint_DrawString_CN(0,0,(char*)Machine_info.btn_waitMaterials_info,&chinese_type_32,FONT_FOREGROUND,FONT_BACKGROUND);
  1146. uint8_t* waitMaterials_64x32_buf = (uint8_t*)calloc(64*32/8,sizeof(uint8_t));
  1147. memcpy(waitMaterials_64x32_buf,Paint_info.Image,sizeof(uint8_t)*64*32/8);
  1148. memset((uint8_t*)tmp_paint_buf,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
  1149. Paint_NewImage((uint8_t*)tmp_paint_buf, 48, 96, ROTATE_0, WHITE);
  1150. Paint_DrawBitMap_Paste(waitMaterials_64x32_buf,8,16,32,64,1);
  1151. uint8_t* waitMaterials_background_96x48_buf = (uint8_t*)calloc(96*48/8,sizeof(uint8_t));
  1152. memcpy(waitMaterials_background_96x48_buf,Paint_info.Image,sizeof(uint8_t)*96*48/8);
  1153. free(waitMaterials_64x32_buf);
  1154. uint8_t* background_128x64_buf = (uint8_t*)calloc(128*64/8,sizeof(uint8_t));
  1155. //得到图像buf
  1156. ESP_LOGW(LOG_TAG,"----------------Machine_info.left_state = %d-------left_display_mode =%d -------\r\n",Machine_info.left_state,Machine_info.left_display_mode);
  1157. switch (Machine_info.left_state)
  1158. {
  1159. case STATE_NONE:
  1160. case STATE_OPERATION:
  1161. {
  1162. if(Machine_info.left_display_mode==0)
  1163. {
  1164. memset((uint8_t*)tmp_paint_buf,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
  1165. Paint_NewImage((uint8_t*)tmp_paint_buf, 96, 48, ROTATE_0, WHITE);
  1166. Paint_DrawBitMap_Paste((uint8_t*)gImage_button,0,0,96,48,1);
  1167. x = center_align(&Machine_info.btn_operation,64,16,32);
  1168. Paint_DrawString_CN(16+x,8,(char*)Machine_info.btn_operation,&chinese_type_32,FONT_BACKGROUND,FONT_FOREGROUND);
  1169. memcpy(operation_background_96x48_buf,Paint_info.Image,sizeof(uint8_t)*96*48/8);
  1170. memset((uint8_t*)tmp_paint_buf,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
  1171. Paint_NewImage((uint8_t*)tmp_paint_buf, 320, 384, ROTATE_0, WHITE);
  1172. Paint_DrawBitMap_Paste((uint8_t*)gImage_mid_,0,0,320,384,1);
  1173. x = center_align(&Machine_info.btn_operation,128,64,64);
  1174. Paint_DrawString_CN64(96+x,160,(char*)Machine_info.btn_operation );
  1175. memcpy(image_320x384_buf,Paint_info.Image,sizeof(uint8_t)*320*384/8);
  1176. }
  1177. else
  1178. {
  1179. memset((uint8_t*)tmp_paint_buf,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
  1180. Paint_NewImage((uint8_t*)tmp_paint_buf, 128, 64, ROTATE_0, WHITE);
  1181. Paint_DrawBitMap_Paste((uint8_t*)gImage_button_128x64,0,0,128,64,1);
  1182. x = center_align(&Machine_info.btn_operation,96,24,48);
  1183. // Paint_DrawString_CN(16+x,8,(char*)Machine_info.btn_operation,&chinese_type_32,FONT_BACKGROUND,FONT_FOREGROUND);
  1184. Paint_DrawString_CN48(16+x,8,(char*)Machine_info.btn_operation,false);
  1185. memcpy(background_128x64_buf,Paint_info.Image,sizeof(uint8_t)*128*64/8);
  1186. }
  1187. }
  1188. break;
  1189. case STATE_SHUT_DOWN:
  1190. {
  1191. if(Machine_info.left_display_mode==0)
  1192. {
  1193. memset((uint8_t*)tmp_paint_buf,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
  1194. Paint_NewImage((uint8_t*)tmp_paint_buf, 48, 96, ROTATE_90, WHITE);
  1195. Paint_DrawBitMap_Paste((uint8_t*)gImage_button,0,0,96,48,1);
  1196. x = center_align(&Machine_info.btn_shutDown_info,64,16,32);
  1197. Paint_DrawString_CN(16+x,8,(char*)Machine_info.btn_shutDown_info,&chinese_type_32,FONT_BACKGROUND,FONT_FOREGROUND);
  1198. memcpy(shutDown_background_96x48_buf,Paint_info.Image,sizeof(uint8_t)*96*48/8);
  1199. memset((uint8_t*)tmp_paint_buf,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
  1200. Paint_NewImage((uint8_t*)tmp_paint_buf, 320, 384, ROTATE_0, WHITE);
  1201. Paint_DrawBitMap_Paste((uint8_t*)gImage_right_,0,0,320,384,1);
  1202. x = center_align(&Machine_info.btn_shutDown_info,128,64,64);
  1203. Paint_DrawString_CN64(96+x,160,(char*)Machine_info.btn_shutDown_info );
  1204. memcpy(image_320x384_buf,Paint_info.Image,sizeof(uint8_t)*320*384/8);
  1205. }
  1206. else
  1207. {
  1208. memset((uint8_t*)tmp_paint_buf,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
  1209. Paint_NewImage((uint8_t*)tmp_paint_buf, 64, 128, ROTATE_90, WHITE);
  1210. Paint_DrawBitMap_Paste((uint8_t*)gImage_button_128x64,0,0,128,64,1);
  1211. x = center_align(&Machine_info.btn_shutDown_info,96,24,48);
  1212. // Paint_DrawString_CN(16+x,8,(char*)Machine_info.btn_shutDown_info,&chinese_type_32,FONT_BACKGROUND,FONT_FOREGROUND);
  1213. Paint_DrawString_CN48(16+x,8,(char*)Machine_info.btn_shutDown_info,false);
  1214. memcpy(background_128x64_buf,Paint_info.Image,sizeof(uint8_t)*128*64/8);
  1215. }
  1216. }
  1217. break;
  1218. case STATE_BREAKDOWN:
  1219. {
  1220. if(Machine_info.left_display_mode==0)
  1221. {
  1222. memset((uint8_t*)tmp_paint_buf,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
  1223. Paint_NewImage((uint8_t*)tmp_paint_buf, 48, 96, ROTATE_90, WHITE);
  1224. Paint_DrawBitMap_Paste((uint8_t*)gImage_button,0,0,96,48,1);
  1225. x = center_align(&Machine_info.btn_breakDown_info,64,16,32);
  1226. Paint_DrawString_CN(16+x,8,(char*)Machine_info.btn_breakDown_info,&chinese_type_32,FONT_BACKGROUND,FONT_FOREGROUND);
  1227. memcpy(breakDown_background_96x48_buf,Paint_info.Image,sizeof(uint8_t)*96*48/8);
  1228. memset((uint8_t*)tmp_paint_buf,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
  1229. Paint_NewImage((uint8_t*)tmp_paint_buf, 320, 384, ROTATE_180, WHITE);
  1230. Paint_DrawBitMap_Paste((uint8_t*)gImage_left_,0,0,320,384,1);
  1231. memcpy(image_320x384_buf,Paint_info.Image,sizeof(uint8_t)*320*384/8);
  1232. Paint_NewImage(image_320x384_buf, 320, 384, ROTATE_0, WHITE);
  1233. x = center_align(&Machine_info.btn_breakDown_info,128,64,64);
  1234. Paint_DrawString_CN64(96+x,160,(char*)Machine_info.btn_breakDown_info );
  1235. memcpy(image_320x384_buf,Paint_info.Image,sizeof(uint8_t)*320*384/8);
  1236. }
  1237. else
  1238. {
  1239. memset((uint8_t*)tmp_paint_buf,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
  1240. Paint_NewImage((uint8_t*)tmp_paint_buf, 64,128, ROTATE_90, WHITE);
  1241. Paint_DrawBitMap_Paste((uint8_t*)gImage_button_128x64,0,0,128,64,1);
  1242. x = center_align(&Machine_info.btn_breakDown_info,96,24,48);
  1243. // Paint_DrawString_CN(16+x,8,(char*)Machine_info.btn_breakDown_info,&chinese_type_32,FONT_BACKGROUND,FONT_FOREGROUND);
  1244. Paint_DrawString_CN48(16+x,8,(char*)Machine_info.btn_breakDown_info,false);
  1245. memcpy(background_128x64_buf,Paint_info.Image,sizeof(uint8_t)*128*64/8);
  1246. }
  1247. }
  1248. break;
  1249. case STATE_SAFEKEEP:
  1250. {
  1251. if(Machine_info.left_display_mode==0)
  1252. {
  1253. memset((uint8_t*)tmp_paint_buf,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
  1254. Paint_NewImage((uint8_t*)tmp_paint_buf, 96, 48, ROTATE_0, WHITE);
  1255. Paint_DrawBitMap_Paste((uint8_t*)gImage_button,0,0,96,48,1);
  1256. x = center_align(&Machine_info.btn_safeKeep_info,64,16,32);
  1257. Paint_DrawString_CN(16+x,8,(char*)Machine_info.btn_safeKeep_info,&chinese_type_32,FONT_BACKGROUND,FONT_FOREGROUND);
  1258. memcpy(safeKeep_background_96x48_buf,Paint_info.Image,sizeof(uint8_t)*96*48/8);
  1259. memset((uint8_t*)tmp_paint_buf,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
  1260. Paint_NewImage((uint8_t*)tmp_paint_buf, 320, 384, ROTATE_180, WHITE);
  1261. Paint_DrawBitMap_Paste((uint8_t*)gImage_mid_,0,0,320,384,1);
  1262. memcpy(image_320x384_buf,Paint_info.Image,sizeof(uint8_t)*320*384/8);
  1263. Paint_NewImage(image_320x384_buf, 320, 384, ROTATE_0, WHITE);
  1264. x = center_align(&Machine_info.btn_safeKeep_info,128,64,64);
  1265. Paint_DrawString_CN64(96+x,160,(char*)Machine_info.btn_safeKeep_info );
  1266. memcpy(image_320x384_buf,Paint_info.Image,sizeof(uint8_t)*320*384/8);
  1267. }
  1268. else
  1269. {
  1270. memset((uint8_t*)tmp_paint_buf,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
  1271. Paint_NewImage((uint8_t*)tmp_paint_buf, 128, 64, ROTATE_0, WHITE);
  1272. Paint_DrawBitMap_Paste((uint8_t*)gImage_button_128x64,0,0,128,64,1);
  1273. x = center_align(&Machine_info.btn_safeKeep_info,96,24,48);
  1274. // Paint_DrawString_CN(16+x,8,(char*)Machine_info.btn_safeKeep_info,&chinese_type_32,FONT_BACKGROUND,FONT_FOREGROUND);
  1275. Paint_DrawString_CN48(16+x,8,(char*)Machine_info.btn_safeKeep_info,false);
  1276. memcpy(background_128x64_buf,Paint_info.Image,sizeof(uint8_t)*128*64/8);
  1277. }
  1278. }
  1279. break;
  1280. case STATE_UPKEEP:
  1281. {
  1282. if(Machine_info.left_display_mode==0)
  1283. {
  1284. memset((uint8_t*)tmp_paint_buf,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
  1285. Paint_NewImage((uint8_t*)tmp_paint_buf, 48, 96, ROTATE_270, WHITE);
  1286. Paint_DrawBitMap_Paste((uint8_t*)gImage_button,0,0,96,48,1);
  1287. x = center_align(&Machine_info.btn_upKeep_info,64,16,32);
  1288. Paint_DrawString_CN(16+x,8,(char*)Machine_info.btn_upKeep_info,&chinese_type_32,FONT_BACKGROUND,FONT_FOREGROUND);
  1289. memcpy(upKeep_background_96x48_buf,Paint_info.Image,sizeof(uint8_t)*96*48/8);
  1290. memset((uint8_t*)tmp_paint_buf,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
  1291. Paint_NewImage((uint8_t*)tmp_paint_buf, 320, 384, ROTATE_180, WHITE);
  1292. Paint_DrawBitMap_Paste((uint8_t*)gImage_right_,0,0,320,384,1);
  1293. memcpy(image_320x384_buf,Paint_info.Image,sizeof(uint8_t)*320*384/8);
  1294. Paint_NewImage(image_320x384_buf, 320, 384, ROTATE_0, WHITE);
  1295. x = center_align(&Machine_info.btn_upKeep_info,128,64,64);
  1296. Paint_DrawString_CN64(96+x,160,(char*)Machine_info.btn_upKeep_info );
  1297. memcpy(image_320x384_buf,Paint_info.Image,sizeof(uint8_t)*320*384/8);
  1298. }
  1299. else
  1300. {
  1301. memset((uint8_t*)tmp_paint_buf,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
  1302. Paint_NewImage((uint8_t*)tmp_paint_buf, 64, 128, ROTATE_270, WHITE);
  1303. Paint_DrawBitMap_Paste((uint8_t*)gImage_button_128x64,0,0,128,64,1);
  1304. x = center_align(&Machine_info.btn_upKeep_info,96,24,48);
  1305. // Paint_DrawString_CN(16+x,8,(char*)Machine_info.btn_upKeep_info,&chinese_type_32,FONT_BACKGROUND,FONT_FOREGROUND);
  1306. Paint_DrawString_CN48(16+x,8,(char*)Machine_info.btn_upKeep_info,false);
  1307. memcpy(background_128x64_buf,Paint_info.Image,sizeof(uint8_t)*128*64/8);
  1308. }
  1309. }
  1310. break;
  1311. case STATE_WAIT_MATERIALS:
  1312. {
  1313. if(Machine_info.left_display_mode==0)
  1314. {
  1315. memset((uint8_t*)tmp_paint_buf,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
  1316. Paint_NewImage((uint8_t*)tmp_paint_buf, 48, 96, ROTATE_270, WHITE);
  1317. Paint_DrawBitMap_Paste((uint8_t*)gImage_button,0,0,96,48,1);
  1318. x = center_align(&Machine_info.btn_waitMaterials_info,64,16,32);
  1319. Paint_DrawString_CN(16+x,8,(char*)Machine_info.btn_waitMaterials_info,&chinese_type_32,FONT_BACKGROUND,FONT_FOREGROUND);
  1320. memcpy(waitMaterials_background_96x48_buf,Paint_info.Image,sizeof(uint8_t)*96*48/8);//黑底白字
  1321. memset((uint8_t*)tmp_paint_buf,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
  1322. Paint_NewImage((uint8_t*)tmp_paint_buf, 320, 384, ROTATE_0, WHITE);
  1323. Paint_DrawBitMap_Paste((uint8_t*)gImage_left_,0,0,320,384,1);
  1324. x = center_align(&Machine_info.btn_waitMaterials_info,128,64,64);
  1325. Paint_DrawString_CN64(96+x,160,(char*)Machine_info.btn_waitMaterials_info );
  1326. memcpy(image_320x384_buf,Paint_info.Image,sizeof(uint8_t)*320*384/8);
  1327. }
  1328. else
  1329. {
  1330. memset((uint8_t*)tmp_paint_buf,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
  1331. Paint_NewImage((uint8_t*)tmp_paint_buf, 64, 128, ROTATE_270, WHITE);
  1332. Paint_DrawBitMap_Paste((uint8_t*)gImage_button_128x64,0,0,128,64,1);
  1333. x = center_align(&Machine_info.btn_waitMaterials_info,96,24,48);
  1334. // Paint_DrawString_CN(16+x,8,(char*)Machine_info.btn_waitMaterials_info,&chinese_type_32,FONT_BACKGROUND,FONT_FOREGROUND);
  1335. Paint_DrawString_CN48(16+x,8,(char*)Machine_info.btn_waitMaterials_info,false);
  1336. memcpy(background_128x64_buf,Paint_info.Image,sizeof(uint8_t)*128*64/8);//黑底白字
  1337. }
  1338. }
  1339. break;
  1340. default:
  1341. ESP_LOGE(LOG_TAG," err: (info->left_state)");
  1342. break;
  1343. }
  1344. //画图
  1345. memset((uint8_t*)tmp_paint_buf,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
  1346. Paint_NewImage((uint8_t*)tmp_paint_buf, 648, 480, ROTATE_180, WHITE);
  1347. Paint_DrawBitMap_Paste(operation_background_96x48_buf, 272,0 ,96 ,48 ,1);
  1348. Paint_DrawBitMap_Paste(shutDown_background_96x48_buf, 600,48 ,48 ,96 ,1);
  1349. Paint_DrawBitMap_Paste(breakDown_background_96x48_buf, 600,336,48 ,96 ,1);
  1350. Paint_DrawBitMap_Paste(safeKeep_background_96x48_buf, 272,432,96 ,48 ,1);
  1351. Paint_DrawBitMap_Paste(upKeep_background_96x48_buf, 0 ,336,48 ,96 ,1);
  1352. Paint_DrawBitMap_Paste(waitMaterials_background_96x48_buf, 0 ,48 ,48 ,96 ,1);
  1353. free(operation_background_96x48_buf);
  1354. free(shutDown_background_96x48_buf);
  1355. free(breakDown_background_96x48_buf);
  1356. free(upKeep_background_96x48_buf);
  1357. free(safeKeep_background_96x48_buf);
  1358. free(waitMaterials_background_96x48_buf);
  1359. if(Machine_info.left_display_mode!=0)
  1360. {
  1361. switch (Machine_info.left_state)
  1362. {
  1363. case STATE_NONE:
  1364. case STATE_OPERATION:
  1365. Paint_DrawBitMap_Paste(background_128x64_buf, 272-16,0 ,128 ,64 ,1);
  1366. break;
  1367. case STATE_SHUT_DOWN:
  1368. Paint_DrawBitMap_Paste(background_128x64_buf, 600-16,48-8 ,64 ,128 ,1);
  1369. break;
  1370. case STATE_BREAKDOWN:
  1371. Paint_DrawBitMap_Paste(background_128x64_buf, 600-16,336-8 ,64 ,128 ,1);
  1372. break;
  1373. case STATE_SAFEKEEP:
  1374. Paint_DrawBitMap_Paste(background_128x64_buf, 272-16,432-16 ,128 ,64 ,1);
  1375. break;
  1376. case STATE_UPKEEP:
  1377. Paint_DrawBitMap_Paste(background_128x64_buf, 0 ,336-16 ,64 ,128 ,1);
  1378. break;
  1379. case STATE_WAIT_MATERIALS:
  1380. Paint_DrawBitMap_Paste(background_128x64_buf, 0 ,48-16 ,64 ,128 ,1);
  1381. break;
  1382. default:
  1383. break;
  1384. }
  1385. }
  1386. free(background_128x64_buf);
  1387. Paint_DrawBitMap_Paste((uint8_t*)gImage_nfc ,573,215,44,44,1 );
  1388. #if 0
  1389. if((info->left_display_mode == 0x01) || (info->left_display_mode == 0x00) )
  1390. #else
  1391. if((info->left_display_mode == 0x00) )
  1392. #endif
  1393. {
  1394. Paint_DrawBitMap_Paste(image_320x384_buf, 164,48 ,320,384,1);
  1395. }
  1396. else
  1397. {
  1398. Paint_DrawBitMap_Paste(tmp, 84 ,90 ,480 ,300 ,1);//648-480 168
  1399. free(tmp);
  1400. }
  1401. //qrcode
  1402. char qrcode_string[1024]= {0};
  1403. qrcode_protocol_create(qrcode_string,Machine_info);
  1404. QRGenerator_quick(qrcode_string);
  1405. //
  1406. // printf("btn_operation = %s\r\n",Machine_info.btn_operation);
  1407. // printf("btn_breakDown_info = %s\r\n",Machine_info.btn_breakDown_info);
  1408. // printf("btn_upKeep_info = %s\r\n",Machine_info.btn_upKeep_info);
  1409. // printf("btn_shutDown_info = %s\r\n",Machine_info.btn_shutDown_info);
  1410. // printf("btn_safeKeep_info = %s\r\n",Machine_info.btn_safeKeep_info);
  1411. // printf("btn_waitMaterials_info = %s\r\n",Machine_info.btn_operation);
  1412. #if 0//USER_DEEP_SLEEP_ENABLE
  1413. printf("free_heap_size:%ld \r\n free_internal_heap_size:%ld \r\n minimum_free_heap_size:%ld\r\n",\
  1414. esp_get_free_heap_size(),esp_get_free_internal_heap_size(),esp_get_minimum_free_heap_size());
  1415. printf("compressedSize size =%d\r\n",compressedSize);
  1416. uint8_t *old_buffer= heap_caps_malloc(compressedSize, MALLOC_CAP_8BIT|MALLOC_CAP_INTERNAL); //申请内存
  1417. if(old_buffer == NULL)
  1418. {
  1419. printf("buffer malloc fail\r\n");
  1420. }
  1421. memset(old_buffer,0x00,compressedSize);
  1422. int reson = is_wake_up_reson(); //返回唤醒的原
  1423. if ((reson == ESP_SLEEP_WAKEUP_ULP) || (reson == ESP_SLEEP_WAKEUP_TIMER))
  1424. {
  1425. //读取数据到内存
  1426. left_spiffs_read(old_buffer,compressedSize);
  1427. //解压数据
  1428. decompressedSize = decompressRLE(old_buffer, compressedSize, last_paint_buf_left);
  1429. // printf("src size = %d unzip %d\r\n",compressedSize,decompressedSize);
  1430. }
  1431. #endif
  1432. bool ret = epd_cache_quick(SCREEN_LEFT,(uint8_t*)last_paint_buf_left,Paint_info.Image);
  1433. epd_powerOn_refresh_sleep(SCREEN_LEFT);
  1434. #if 0//USER_DEEP_SLEEP_ENABLE
  1435. if ((reson == !ESP_SLEEP_WAKEUP_ULP) || (reson != ESP_SLEEP_WAKEUP_TIMER))
  1436. #endif
  1437. if(ret)
  1438. {
  1439. //last buf
  1440. memcpy(last_paint_buf_left,Paint_info.Image,sizeof(uint8_t)*648*480/8);
  1441. // int ret = memcmp(last_paint_buf_left,Paint_info.Image,38880);
  1442. // ESP_LOGW(LOG_TAG,"memcmp :ret = %d",ret);
  1443. if(memcmp(last_paint_buf_left,Paint_info.Image,38880))
  1444. {
  1445. ESP_LOGE(LOG_TAG,"err:last_paint_buf_left");
  1446. }
  1447. }
  1448. else
  1449. {
  1450. ESP_LOGE(LOG_TAG,"不保存上一帧");
  1451. }
  1452. #if 0//USER_DEEP_SLEEP_ENABLE
  1453. if ((reson == ESP_SLEEP_WAKEUP_ULP) || (reson == ESP_SLEEP_WAKEUP_TIMER))
  1454. {
  1455. compressedSize = compressRLE(Paint_info.Image, 480*81, last_paint_buf_left);
  1456. // printf(" src size = %d, zip size:%d\r\n",480*81,compressedSize);
  1457. //memset((uint8_t*)tmp_paint_buf,0,sizeof(tmp_paint_buf));
  1458. //button_deinit();
  1459. //写入数据
  1460. left_spiffs_write(last_paint_buf_left,compressedSize);
  1461. //button_init(adc1_handle);
  1462. }
  1463. free(old_buffer);
  1464. #endif
  1465. free(image_320x384_buf);
  1466. }
  1467. static uint8_t* partial_bar_chart_07_02_quick(Machine_info_t* info)
  1468. {
  1469. #if 0
  1470. // extern Node *clockIn_list;
  1471. // int production_num = countClockNodes_byCMD(clockIn_list,0x00);
  1472. // int repair_num = countClockNodes_byCMD(clockIn_list,0x01);
  1473. // int inspection_num = countClockNodes_byCMD(clockIn_list,0x02);
  1474. // int upKeep_num = countClockNodes_byCMD(clockIn_list,0x03);
  1475. #else
  1476. //签到人数只加不减
  1477. // int production_num = Machine_info.personnel_check_in[0];
  1478. // int repair_num = Machine_info.personnel_check_in[1];
  1479. // int inspection_num = Machine_info.personnel_check_in[2];
  1480. // int upKeep_num = Machine_info.personnel_check_in[3];
  1481. #endif
  1482. char arr_string[20];
  1483. 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};
  1484. unsigned int* numHeights = calculateBarChartHeights(arr_num,4,200);
  1485. ESP_LOGW(LOG_TAG,"当前在岗:%ld ,%ld,%ld,%ld",arr_num[0],arr_num[1],arr_num[2],arr_num[3]);
  1486. uint8_t* bar_chart_07_02_buf = (uint8_t*)calloc(480*300/8,sizeof(uint8_t));//free();
  1487. memset(tmp_paint_buf,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
  1488. Paint_NewImage((uint8_t *)tmp_paint_buf, 480, 300, ROTATE_0, WHITE );
  1489. Paint_DrawLine(40,250,440,250,WHITE,DOT_PIXEL_2X2,LINE_STYLE_SOLID );
  1490. // S:screen
  1491. // R:rectangle
  1492. // C:CN
  1493. // E:EN
  1494. // L:LINE
  1495. //ITV:(interval)
  1496. #define BAR_LINE_Y_POS 250
  1497. #define BAR_CHART_Y_MAX 250
  1498. #define BAR_CHART_Y_MIN 50
  1499. #define BAR_07_02_S_L_ITV 40
  1500. #define BAR_07_02_L_R_ITV 18
  1501. #define BAR_07_02_R_R_ITV 100
  1502. #define BAR_07_02_R_WIDTH 64
  1503. #define BAR_07_02_C_SKEW 2
  1504. #define BAR_07_02_E_SKEW (24+4)
  1505. #define BAR_07_02_R1 (BAR_07_02_S_L_ITV+BAR_07_02_L_R_ITV)
  1506. #define BAR_07_02_C1 (BAR_07_02_R1+BAR_07_02_C_SKEW)
  1507. #define BAR_07_02_E1 (BAR_07_02_C1)
  1508. #define BAR_07_02_R2 (BAR_07_02_R1+BAR_07_02_R_R_ITV)
  1509. #define BAR_07_02_C2 (BAR_07_02_C1+BAR_07_02_R_R_ITV)
  1510. #define BAR_07_02_E2 (BAR_07_02_E1+BAR_07_02_R_R_ITV)
  1511. #define BAR_07_02_R3 (BAR_07_02_R2+BAR_07_02_R_R_ITV)
  1512. #define BAR_07_02_C3 (BAR_07_02_C2+BAR_07_02_R_R_ITV)
  1513. #define BAR_07_02_E3 (BAR_07_02_E2+BAR_07_02_R_R_ITV)
  1514. #define BAR_07_02_R4 (BAR_07_02_R3+BAR_07_02_R_R_ITV)
  1515. #define BAR_07_02_C4 (BAR_07_02_C3+BAR_07_02_R_R_ITV)
  1516. #define BAR_07_02_E4 (BAR_07_02_E3+BAR_07_02_R_R_ITV)
  1517. char tmp_12[4][6] = {0};
  1518. char tmp_34[4][6] = {0};
  1519. memcpy(tmp_12[0],Machine_info.checkIn_set[0].other_name,4);
  1520. memcpy(tmp_34[0],Machine_info.checkIn_set[0].other_name+4,4);
  1521. memcpy(tmp_12[1],Machine_info.checkIn_set[1].other_name,4);
  1522. memcpy(tmp_34[1],Machine_info.checkIn_set[1].other_name+4,4);
  1523. memcpy(tmp_12[2],Machine_info.checkIn_set[2].other_name,4);
  1524. memcpy(tmp_34[2],Machine_info.checkIn_set[2].other_name+4,4);
  1525. memcpy(tmp_12[3],Machine_info.checkIn_set[3].other_name,4);
  1526. memcpy(tmp_34[3],Machine_info.checkIn_set[3].other_name+4,4);
  1527. memset(arr_string,0,20);
  1528. itoa(arr_num[0],arr_string,10);
  1529. 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 );
  1530. // 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 );
  1531. 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 );
  1532. 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 );
  1533. 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 );
  1534. memset(arr_string,0,20);
  1535. itoa(arr_num[1],arr_string,10);
  1536. 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 );
  1537. // 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 );
  1538. 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 );
  1539. 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 );
  1540. 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 );
  1541. memset(arr_string,0,20);
  1542. itoa(arr_num[2],arr_string,10);
  1543. 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 );
  1544. // 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 );
  1545. 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 );
  1546. 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 );
  1547. 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 );
  1548. memset(arr_string,0,20);
  1549. itoa(arr_num[3],arr_string,10);
  1550. 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 );
  1551. // 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 );
  1552. 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 );
  1553. 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 );
  1554. 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 );
  1555. memcpy(bar_chart_07_02_buf,Paint_info.Image,sizeof(uint8_t)*480*300/8);
  1556. free(numHeights);
  1557. return bar_chart_07_02_buf;
  1558. }
  1559. static uint8_t* partial_bar_chart_07_03_quick(Machine_info_t* info)
  1560. {
  1561. char arr_string[20];
  1562. uint32_t* timeHeights = calculateBarChartHeights(arr_heights,6,200);
  1563. uint8_t* bar_chart_07_03_buf = (uint8_t*)calloc(480*300/8,sizeof(uint8_t));
  1564. memset(tmp_paint_buf,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
  1565. Paint_NewImage((UBYTE *)tmp_paint_buf, 480, 300, ROTATE_0, WHITE );
  1566. Paint_DrawLine(30,250,450,250,WHITE,DOT_PIXEL_2X2,LINE_STYLE_SOLID );
  1567. memset(arr_string,0,20);
  1568. itoa(arr_heights[0],arr_string,10);
  1569. Paint_DrawRectangle(30+10,250-timeHeights[0],30+10+50,250,WHITE,1,1 );
  1570. //Paint_DrawString_CN(30+10+8, 250+8,(char*)str_operation, &chinese_type_24,FONT_FOREGROUND,FONT_BACKGROUND );
  1571. Paint_DrawString_CN(30+10+8, 250+8,(char*)Machine_info.btn_operation, &chinese_type_24,FONT_FOREGROUND,FONT_BACKGROUND );
  1572. Paint_DrawString_EN(30+10+8,250-timeHeights[0]-4-24,arr_string, &ascii_type_12x24,FONT_FOREGROUND,FONT_BACKGROUND );
  1573. memset(arr_string,0,20);
  1574. itoa(arr_heights[1],arr_string,10);
  1575. Paint_DrawRectangle(30+10+70,250-timeHeights[1],30+10+50+70,250,WHITE,1,1 );
  1576. // Paint_DrawString_CN(30+10+8+70, 250+8,(char*)str_shutDown, &chinese_type_24,FONT_FOREGROUND,FONT_BACKGROUND );
  1577. Paint_DrawString_CN(30+10+8+70, 250+8,(char*)Machine_info.btn_shutDown_info, &chinese_type_24,FONT_FOREGROUND,FONT_BACKGROUND );
  1578. Paint_DrawString_EN(30+10+8+70,250-timeHeights[1]-4-24,arr_string, &ascii_type_12x24,FONT_FOREGROUND,FONT_BACKGROUND );
  1579. memset(arr_string,0,20);
  1580. itoa(arr_heights[2],arr_string,10);
  1581. Paint_DrawRectangle(30+10+140,250-timeHeights[2],30+10+50+140,250,WHITE,1,1 );
  1582. // Paint_DrawString_CN(30+10+8+140, 250+8,(char*)str_breakDown, &chinese_type_24,FONT_FOREGROUND,FONT_BACKGROUND );
  1583. Paint_DrawString_CN(30+10+8+140, 250+8,(char*)Machine_info.btn_breakDown_info, &chinese_type_24,FONT_FOREGROUND,FONT_BACKGROUND );
  1584. Paint_DrawString_EN(30+10+8+140,250-timeHeights[2]-4-24,arr_string, &ascii_type_12x24,FONT_FOREGROUND,FONT_BACKGROUND );
  1585. memset(arr_string,0,20);
  1586. itoa(arr_heights[3],arr_string,10);
  1587. Paint_DrawRectangle(30+10+210,250-timeHeights[3],30+10+50+210,250,WHITE,1,1 );
  1588. // Paint_DrawString_CN(30+10+8+210, 250+8,(char*)str_safeKeep, &chinese_type_24,FONT_FOREGROUND,FONT_BACKGROUND );
  1589. Paint_DrawString_CN(30+10+8+210, 250+8,(char*)Machine_info.btn_safeKeep_info, &chinese_type_24,FONT_FOREGROUND,FONT_BACKGROUND );
  1590. Paint_DrawString_EN(30+10+8+210, 250-timeHeights[3]-4-24,arr_string, &ascii_type_12x24,FONT_FOREGROUND,FONT_BACKGROUND );
  1591. memset(arr_string,0,20);
  1592. itoa(arr_heights[4],arr_string,10);
  1593. Paint_DrawRectangle(30+10+280,250-timeHeights[4],30+10+50+280,250,WHITE,1,1 );
  1594. //Paint_DrawString_CN(30+10+8+280, 250+8,(char*)str_upKeep, &chinese_type_24,FONT_FOREGROUND,FONT_BACKGROUND );
  1595. Paint_DrawString_CN(30+10+8+280, 250+8,(char*)Machine_info.btn_upKeep_info, &chinese_type_24,FONT_FOREGROUND,FONT_BACKGROUND );
  1596. Paint_DrawString_EN(30+10+8+280,250-timeHeights[4]-4-24,arr_string, &ascii_type_12x24,FONT_FOREGROUND,FONT_BACKGROUND );
  1597. memset(arr_string,0,20);
  1598. itoa(arr_heights[5],arr_string,10);
  1599. Paint_DrawRectangle(30+10+350,250-timeHeights[5],30+10+50+350,250,WHITE,1,1 );
  1600. // Paint_DrawString_CN(30+10+8+350, 250+8,(char*)str_waitMaterials, &chinese_type_24,FONT_FOREGROUND,FONT_BACKGROUND );
  1601. Paint_DrawString_CN(30+10+8+350, 250+8,(char*)Machine_info.btn_waitMaterials_info, &chinese_type_24,FONT_FOREGROUND,FONT_BACKGROUND );
  1602. Paint_DrawString_EN(30+10+8+350,250-timeHeights[5]-4-24,arr_string, &ascii_type_12x24,FONT_FOREGROUND,FONT_BACKGROUND );
  1603. memcpy(bar_chart_07_03_buf,Paint_info.Image,sizeof(uint8_t)*480*300/8);
  1604. free(timeHeights);
  1605. return bar_chart_07_03_buf;
  1606. }
  1607. static uint8_t* partial_bar_chart_07_04_quick(Machine_info_t* info)
  1608. {
  1609. char arr_string[20];
  1610. 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};
  1611. uint32_t* arrHeights = calculateBarChartHeights(arr_heights,6,200);
  1612. uint32_t* numHeights = calculateBarChartHeights(arr_num,4,200);
  1613. uint8_t* bar_chart_07_04_buf = (uint8_t*)calloc(480*300/8,sizeof(uint8_t));
  1614. memset(tmp_paint_buf,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
  1615. Paint_NewImage((UBYTE *)tmp_paint_buf, 480, 300, ROTATE_0, WHITE );
  1616. Paint_DrawLine(10,250,274,250,WHITE,DOT_PIXEL_2X2,LINE_STYLE_SOLID );
  1617. Paint_DrawLine(294,250,470,250,WHITE,DOT_PIXEL_2X2,LINE_STYLE_SOLID );
  1618. memset(arr_string,0,20);
  1619. itoa(arr_heights[0],arr_string,10);
  1620. Paint_DrawRectangle(10+2,250-arrHeights[0],10+2+40,250,WHITE,1,1 );
  1621. Paint_DrawString_CN(10+2+8, 250+2,(char*)Machine_info.btn_operation, &chinese_type_16,FONT_FOREGROUND,FONT_BACKGROUND );
  1622. Paint_DrawString_EN(10+2+5, 250-arrHeights[0]-2-16,(char*)arr_string, &ascii_type_8x16,FONT_FOREGROUND,FONT_BACKGROUND );
  1623. memset(arr_string,0,20);
  1624. itoa(arr_heights[1],arr_string,10);
  1625. Paint_DrawRectangle(10+2+44,250-arrHeights[1],10+2+40+44,250,WHITE,1,1 );
  1626. Paint_DrawString_CN(10+2+8+44, 250+2,(char*)Machine_info.btn_shutDown_info, &chinese_type_16,FONT_FOREGROUND,FONT_BACKGROUND );
  1627. Paint_DrawString_EN(10+2+5+44, 250-arrHeights[1]-2-16,(char*)arr_string, &ascii_type_8x16,FONT_FOREGROUND,FONT_BACKGROUND );
  1628. memset(arr_string,0,20);
  1629. itoa(arr_heights[2],arr_string,10);
  1630. Paint_DrawRectangle(10+2+88,250-arrHeights[2],10+2+40+88,250,WHITE,1,1 );
  1631. Paint_DrawString_CN(10+2+8+88, 250+2,(char*)Machine_info.btn_breakDown_info, &chinese_type_16,FONT_FOREGROUND,FONT_BACKGROUND );
  1632. Paint_DrawString_EN(10+2+5+88, 250-arrHeights[2]-2-16,(char*)arr_string, &ascii_type_8x16,FONT_FOREGROUND,FONT_BACKGROUND );
  1633. memset(arr_string,0,20);
  1634. itoa(arr_heights[3],arr_string,10);
  1635. Paint_DrawRectangle(10+2+132,250-arrHeights[3],10+2+40+132,250,WHITE,1,1 );
  1636. Paint_DrawString_CN(10+2+8+132, 250+2,(char*)Machine_info.btn_safeKeep_info, &chinese_type_16,FONT_FOREGROUND,FONT_BACKGROUND );
  1637. Paint_DrawString_EN(10+2+5+132, 250-arrHeights[3]-2-16,(char*)arr_string, &ascii_type_8x16,FONT_FOREGROUND,FONT_BACKGROUND );
  1638. memset(arr_string,0,20);
  1639. itoa(arr_heights[4],arr_string,10);
  1640. Paint_DrawRectangle(10+2+176,250-arrHeights[4],10+2+40+176,250,WHITE,1,1 );
  1641. Paint_DrawString_CN(10+2+8+176, 250+2,(char*)Machine_info.btn_upKeep_info, &chinese_type_16,FONT_FOREGROUND,FONT_BACKGROUND );
  1642. Paint_DrawString_EN(10+2+5+176, 250-arrHeights[4]-2-16,(char*)arr_string, &ascii_type_8x16,FONT_FOREGROUND,FONT_BACKGROUND );
  1643. memset(arr_string,0,20);
  1644. itoa(arr_heights[5],arr_string,10);
  1645. Paint_DrawRectangle(10+2+220,250-arrHeights[5],10+2+40+220,250,WHITE,1,1 );
  1646. Paint_DrawString_CN(10+2+8+220, 250+2,(char*)Machine_info.btn_waitMaterials_info, &chinese_type_16,FONT_FOREGROUND,FONT_BACKGROUND );
  1647. Paint_DrawString_EN(10+2+5+220, 250-arrHeights[5]-2-16,(char*)arr_string, &ascii_type_8x16,FONT_FOREGROUND,FONT_BACKGROUND );
  1648. // next
  1649. char tmp_12[4][6] = {0};
  1650. char tmp_34[4][6] = {0};
  1651. memcpy(tmp_12[0],Machine_info.checkIn_set[0].other_name,4);
  1652. memcpy(tmp_34[0],Machine_info.checkIn_set[0].other_name+4,4);
  1653. memcpy(tmp_12[1],Machine_info.checkIn_set[1].other_name,4);
  1654. memcpy(tmp_34[1],Machine_info.checkIn_set[1].other_name+4,4);
  1655. memcpy(tmp_12[2],Machine_info.checkIn_set[2].other_name,4);
  1656. memcpy(tmp_34[2],Machine_info.checkIn_set[2].other_name+4,4);
  1657. memcpy(tmp_12[3],Machine_info.checkIn_set[3].other_name,4);
  1658. memcpy(tmp_34[3],Machine_info.checkIn_set[3].other_name+4,4);
  1659. memset(arr_string,0,20);
  1660. itoa(arr_num[0],arr_string,10);
  1661. Paint_DrawRectangle(294+2,250-numHeights[0],294+2+40,250,WHITE,1,1 );
  1662. // Paint_DrawString_CN(294+2+8, 250+2,(char*)str_production, &chinese_type_16,FONT_FOREGROUND,FONT_BACKGROUND );
  1663. Paint_DrawString_CN(294+2+8, 250+2,tmp_12[0], &chinese_type_16,FONT_FOREGROUND,FONT_BACKGROUND );
  1664. Paint_DrawString_CN(294+2+8, 250+2+16,tmp_34[0], &chinese_type_16,FONT_FOREGROUND,FONT_BACKGROUND );
  1665. Paint_DrawString_EN(292+2+5,250-numHeights[0]-2-16,(char*)arr_string, &ascii_type_8x16,FONT_FOREGROUND,FONT_BACKGROUND );
  1666. memset(arr_string,0,20);
  1667. itoa(arr_num[1],arr_string,10);
  1668. Paint_DrawRectangle(294+2+44,250-numHeights[1],294+2+40+44,250,WHITE,1,1 );
  1669. // Paint_DrawString_CN(294+2+8+44, 250+2,(char*)str_repair, &chinese_type_16,FONT_FOREGROUND,FONT_BACKGROUND );
  1670. Paint_DrawString_CN(294+2+8+44, 250+2,tmp_12[1], &chinese_type_16,FONT_FOREGROUND,FONT_BACKGROUND );
  1671. Paint_DrawString_CN(294+2+8+44, 250+2+16,tmp_34[1], &chinese_type_16,FONT_FOREGROUND,FONT_BACKGROUND );
  1672. Paint_DrawString_EN(292+2+5+44,250-numHeights[1]-2-16,(char*)arr_string, &ascii_type_8x16,FONT_FOREGROUND,FONT_BACKGROUND );
  1673. memset(arr_string,0,20);
  1674. itoa(arr_num[2],arr_string,10);
  1675. Paint_DrawRectangle(294+2+88,250-numHeights[2],294+2+40+88,250,WHITE,1,1 );
  1676. // Paint_DrawString_CN(294+2+8+88, 250+2, (char*)str_inspection, &chinese_type_16,FONT_FOREGROUND,FONT_BACKGROUND );
  1677. Paint_DrawString_CN(294+2+8+88, 250+2,tmp_12[2], &chinese_type_16,FONT_FOREGROUND,FONT_BACKGROUND );
  1678. Paint_DrawString_CN(294+2+8+88, 250+2+16,tmp_34[2], &chinese_type_16,FONT_FOREGROUND,FONT_BACKGROUND );
  1679. Paint_DrawString_EN(292+2+5+88,250-numHeights[2]-2-16,(char*)arr_string, &ascii_type_8x16,FONT_FOREGROUND,FONT_BACKGROUND );
  1680. memset(arr_string,0,20);
  1681. itoa(arr_num[3],arr_string,10);
  1682. Paint_DrawRectangle(294+2+132,250-numHeights[3],294+2+40+132,250,WHITE,1,1 );
  1683. // Paint_DrawString_CN(294+2+8+132, 250+2, (char*)str_upKeep, &chinese_type_16,FONT_FOREGROUND,FONT_BACKGROUND );
  1684. Paint_DrawString_CN(294+2+8+132, 250+2,tmp_12[3], &chinese_type_16,FONT_FOREGROUND,FONT_BACKGROUND );
  1685. Paint_DrawString_CN(294+2+8+132, 250+2+16,tmp_34[3], &chinese_type_16,FONT_FOREGROUND,FONT_BACKGROUND );
  1686. Paint_DrawString_EN(292+2+5+132,250-numHeights[3]-2-16,(char*)arr_string, &ascii_type_8x16,FONT_FOREGROUND,FONT_BACKGROUND );
  1687. free(arrHeights);
  1688. free(numHeights);
  1689. memcpy(bar_chart_07_04_buf,Paint_info.Image,sizeof(uint8_t)*480*300/8);
  1690. return bar_chart_07_04_buf;
  1691. }
  1692. #define RIGHT1_HIGHT 100
  1693. #define RIGHT2_HIGHT 172
  1694. static uint8_t* partial_right1_quick(Machine_info_t* info)
  1695. {
  1696. //Machine_info.batt_precent = 100;
  1697. uint8_t* partial_right1_buf = (uint8_t*)calloc(RIGHT1_HIGHT*480/8,sizeof(uint8_t));
  1698. memset((uint8_t*)tmp_paint_buf,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
  1699. Paint_NewImage((uint8_t*)tmp_paint_buf, 480, RIGHT1_HIGHT, ROTATE_0, WHITE );
  1700. Paint_DrawLine(10,95,470,95,WHITE,DOT_PIXEL_1X1,LINE_STYLE_SOLID );
  1701. int x = center_align(&info->station_name,480,16,32);
  1702. Paint_DrawString_CN(x, 25,&info->station_name, &chinese_type_32,FONT_FOREGROUND,FONT_BACKGROUND );
  1703. //显示终端号码
  1704. //printf(" terminal name x=%d--------------%s----------------\r\n",x,(char *)&info->terminal_name);
  1705. x = center_align(&info->station_number,480,8,16);
  1706. Paint_DrawString_CN(x, 70,&info->station_number, &chinese_type_16,FONT_FOREGROUND,FONT_BACKGROUND );
  1707. //printf(" terminal_number x=%d--------------%s----------------\r\n",x,(char *)&info->terminal_number);
  1708. #define BAT_X_OFFSET 2
  1709. #define BAT_Y_OFFSET 2
  1710. //batt
  1711. Paint_DrawBitMap_Paste((uint8_t*)gImage_battery ,480-50-BAT_X_OFFSET,24,37,18,1 );
  1712. #if 1
  1713. switch (Machine_info.batt_precent)
  1714. {
  1715. case 0:
  1716. break;
  1717. case 1 ... 24:
  1718. Paint_DrawRectangle(433 -BAT_X_OFFSET,27,439 -BAT_X_OFFSET,41,WHITE,1,1 );
  1719. break;
  1720. case 25 ... 49:
  1721. Paint_DrawRectangle(433 -BAT_X_OFFSET,27,439-BAT_X_OFFSET,41,WHITE,1,1 );
  1722. Paint_DrawRectangle(441-BAT_X_OFFSET,27,447-BAT_X_OFFSET,41,WHITE,1,1 );
  1723. break;
  1724. case 50 ... 74:
  1725. Paint_DrawRectangle(433-BAT_X_OFFSET,27,439-BAT_X_OFFSET,41,WHITE,1,1 );
  1726. Paint_DrawRectangle(441-BAT_X_OFFSET,27,447-BAT_X_OFFSET,41,WHITE,1,1 );
  1727. Paint_DrawRectangle(449-BAT_X_OFFSET,27,455-BAT_X_OFFSET,41,WHITE,1,1 );
  1728. break;
  1729. case 75 ... 99:
  1730. Paint_DrawRectangle(433-BAT_X_OFFSET,27,439-BAT_X_OFFSET,41,WHITE,1,1 );
  1731. Paint_DrawRectangle(441-BAT_X_OFFSET,27,447-BAT_X_OFFSET,41,WHITE,1,1 );
  1732. Paint_DrawRectangle(449-BAT_X_OFFSET,27,455-BAT_X_OFFSET,41,WHITE,1,1 );
  1733. Paint_DrawRectangle(457-BAT_X_OFFSET,27,462-BAT_X_OFFSET,41,WHITE,1,1 );
  1734. break;
  1735. case 100:
  1736. Paint_DrawRectangle(433-BAT_X_OFFSET,27,439-BAT_X_OFFSET,41,WHITE,1,1 );
  1737. Paint_DrawRectangle(441-BAT_X_OFFSET,27,447-BAT_X_OFFSET,41,WHITE,1,1 );
  1738. Paint_DrawRectangle(449-BAT_X_OFFSET,27,455-BAT_X_OFFSET,41,WHITE,1,1 );
  1739. Paint_DrawRectangle(457-BAT_X_OFFSET,27,462-BAT_X_OFFSET,41,WHITE,1,1 );
  1740. break;
  1741. default:
  1742. break;
  1743. }
  1744. if(!decection_state_0()) //判断充电中逻辑
  1745. {
  1746. Machine_info.batt_precent = read_battery_voltage();
  1747. if(Machine_info.batt_precent >=95)
  1748. {
  1749. Paint_DrawBitMap_Paste((uint8_t*)gImage_charging ,480-47+37,27 - BAT_Y_OFFSET,8,18,1 );
  1750. }
  1751. else
  1752. {
  1753. Paint_DrawBitMap_Paste((uint8_t*)gImage_charging ,480-47+35,27 - BAT_Y_OFFSET,8,18,1 );
  1754. }
  1755. }
  1756. #else
  1757. Paint_DrawBitMap_Paste((uint8_t*)gImage_filled ,480-47+37,24,8,18,1 );
  1758. Paint_DrawRectangle(433,27,439,41,WHITE,1,1 );
  1759. Paint_DrawRectangle(441,27,447,41,WHITE,1,1 );
  1760. Paint_DrawRectangle(449,27,455,41,WHITE,1,1 );
  1761. Paint_DrawRectangle(457,27,462,41,WHITE,1,1 );
  1762. #endif
  1763. #if 0
  1764. //rssi
  1765. switch (Machine_info.rssi)
  1766. {
  1767. case 0:
  1768. Paint_DrawRectangle(480-57-32,42-3,391+5,42,WHITE,1,0 );
  1769. Paint_DrawRectangle(480-57-24,42-8,399+5,42,WHITE,1,0 );
  1770. Paint_DrawRectangle(480-57-16,42-13,407+5,42,WHITE,1,0 );
  1771. Paint_DrawRectangle(480-57-8,42-18,415+5,42,WHITE,1,0 );
  1772. break;
  1773. case 1 ... 24:
  1774. Paint_DrawRectangle(480-57-32,42-3,391+5,42,WHITE,1,1 );
  1775. Paint_DrawRectangle(480-57-24,42-8,399+5,42,WHITE,1,0 );
  1776. Paint_DrawRectangle(480-57-16,42-13,407+5,42,WHITE,1,0 );
  1777. Paint_DrawRectangle(480-57-8,42-18,415+5,42,WHITE,1,0 );
  1778. break;
  1779. case 25 ... 49:
  1780. Paint_DrawRectangle(480-57-32,42-3,391+5,42,WHITE,1,1 );
  1781. Paint_DrawRectangle(480-57-24,42-8,399+5,42,WHITE,1,1 );
  1782. Paint_DrawRectangle(480-57-16,42-13,407+5,42,WHITE,1,0 );
  1783. Paint_DrawRectangle(480-57-8,42-18,415+5,42,WHITE,1,0 );
  1784. break;
  1785. case 50 ... 74:
  1786. Paint_DrawRectangle(480-57-32,42-3,391+5,42,WHITE,1,1 );
  1787. Paint_DrawRectangle(480-57-24,42-8,399+5,42,WHITE,1,1 );
  1788. Paint_DrawRectangle(480-57-16,42-13,407+5,42,WHITE,1,1 );
  1789. Paint_DrawRectangle(480-57-8,42-18,415+5,42,WHITE,1,0 );
  1790. break;
  1791. case 75 ... 100:
  1792. Paint_DrawRectangle(480-57-32,42-3,391+5,42,WHITE,1,1 );
  1793. Paint_DrawRectangle(480-57-24,42-8,399+5,42,WHITE,1,1 );
  1794. Paint_DrawRectangle(480-57-16,42-13,407+5,42,WHITE,1,1 );
  1795. Paint_DrawRectangle(480-57-8,42-18,415+5,42,WHITE,1,1 );
  1796. break;
  1797. default:
  1798. ESP_LOGW(LOG_TAG," err:rssi ");
  1799. Paint_DrawRectangle(480-57-32,42-3,391+5,42,WHITE,1,1 );
  1800. Paint_DrawRectangle(480-57-24,42-8,399+5,42,WHITE,1,1 );
  1801. Paint_DrawRectangle(480-57-16,42-13,407+5,42,WHITE,1,1 );
  1802. Paint_DrawRectangle(480-57-8,42-18,415+5,42,WHITE,1,1 );
  1803. break;
  1804. }
  1805. #else
  1806. //添加在线离线
  1807. uint8_t online[6]= {0xd4,0xda,0xcf,0xdf,0x00,0x00}; //在线
  1808. uint8_t outline[6]= {0xc0,0xeb,0xcf,0xdf,0x00,0x00}; //离线
  1809. Paint_DrawBitMap_Paste((uint8_t*)gImage_online,480-50-BAT_X_OFFSET - 50,24,37,18,1);
  1810. if (Machine_info.paired)
  1811. {
  1812. Paint_DrawString_CN(480-50 - BAT_X_OFFSET - 50 +3,25,(char *)online, &chinese_type_16,FONT_BACKGROUND,FONT_FOREGROUND);
  1813. }else
  1814. {
  1815. Paint_DrawString_CN(480-50 - BAT_X_OFFSET - 50 +3,25,(char *)outline, &chinese_type_16,FONT_BACKGROUND,FONT_FOREGROUND);
  1816. }
  1817. // Paint_DrawRectangle(480-57-32,40-3,391+5,40,WHITE,1,1 );
  1818. // Paint_DrawRectangle(480-57-24,40-8,399+5,40,WHITE,1,1 );
  1819. // Paint_DrawRectangle(480-57-16,40-13,407+5,40,WHITE,1,1 );
  1820. // Paint_DrawRectangle(480-57-8,40-18,415+5,40,WHITE,1,0 );
  1821. #endif
  1822. memcpy(partial_right1_buf,Paint_info.Image,sizeof(uint8_t)*480*RIGHT1_HIGHT/8);
  1823. return partial_right1_buf;
  1824. }
  1825. #define MAX_NAME_STRING_LEN 52
  1826. 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};
  1827. {
  1828. if(len < MAX_NAME_STRING_LEN )
  1829. {
  1830. return;
  1831. }
  1832. ESP_LOGW(LOG_TAG,"------dis name----");
  1833. ESP_LOG_BUFFER_HEX(LOG_TAG,tmp,len);
  1834. strcpy(&tmp[MAX_NAME_STRING_LEN]," ...");
  1835. tmp[MAX_NAME_STRING_LEN+4] = 0;
  1836. tmp[MAX_NAME_STRING_LEN+5] = 0;
  1837. }
  1838. static uint8_t* partial_right2_quick(void)
  1839. {
  1840. uint8_t* partial_right2_buf = (uint8_t*)calloc(RIGHT2_HIGHT*480/8,sizeof(uint8_t));
  1841. char buffer[200]={0};
  1842. memset((uint8_t*)tmp_paint_buf,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
  1843. Paint_NewImage((UBYTE *)tmp_paint_buf, 480, RIGHT2_HIGHT, ROTATE_0, WHITE );
  1844. 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,\
  1845. Machine_info.person[3].Charge_close,Machine_info.person[4].Charge_close);
  1846. 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)); //获取当前类型人员数量
  1847. //管理员不会关闭
  1848. memset((uint8_t*)buffer,0,sizeof(buffer));
  1849. strcat(buffer,(char*)Machine_info.person[0].other_name);
  1850. strcat(buffer, Machine_info.person[0].string_name);
  1851. dis_name(buffer,strlen(buffer));
  1852. Paint_DrawString_CN(10, 7,(char*)buffer, &chinese_type_16,FONT_FOREGROUND,FONT_BACKGROUND );
  1853. if(!Machine_info.person[1].Charge_close)
  1854. {
  1855. memset((uint8_t*)buffer,0,sizeof(buffer));
  1856. strcat(buffer,(char*)Machine_info.person[1].other_name);
  1857. strcat(buffer, Machine_info.person[1].string_name);
  1858. dis_name(buffer,strlen(buffer));
  1859. Paint_DrawString_CN(10, 41,(char*)buffer, &chinese_type_16,FONT_FOREGROUND,FONT_BACKGROUND );
  1860. }
  1861. if(!Machine_info.person[2].Charge_close)
  1862. {
  1863. memset((uint8_t*)buffer,0,sizeof(buffer));
  1864. strcat(buffer,(char*)Machine_info.person[2].other_name);
  1865. strcat(buffer, Machine_info.person[2].string_name);
  1866. dis_name(buffer,strlen(buffer));
  1867. Paint_DrawString_CN(10, 75,(char*)buffer, &chinese_type_16,FONT_FOREGROUND,FONT_BACKGROUND );
  1868. }
  1869. if(!Machine_info.person[4].Charge_close)
  1870. {
  1871. memset((uint8_t*)buffer,0,sizeof(buffer));
  1872. strcat(buffer,(char*)Machine_info.person[4].other_name);
  1873. strcat(buffer, Machine_info.person[4].string_name);
  1874. dis_name(buffer,strlen(buffer));
  1875. Paint_DrawString_CN(10, 109,(char*)buffer, &chinese_type_16,FONT_FOREGROUND,FONT_BACKGROUND );
  1876. }
  1877. if(!Machine_info.person[3].Charge_close)
  1878. {
  1879. memset((uint8_t*)buffer,0,sizeof(buffer));
  1880. strcat(buffer,(char*)Machine_info.person[3].other_name);
  1881. strcat(buffer, Machine_info.person[3].string_name);
  1882. dis_name(buffer,strlen(buffer));
  1883. Paint_DrawString_CN(10, 143,(char*)buffer, &chinese_type_16,FONT_FOREGROUND,FONT_BACKGROUND );
  1884. }
  1885. // ESP_LOG_BUFFER_HEX(LOG_TAG,buffer,strlen(buffer));
  1886. Paint_DrawLine(10,170,470,170,WHITE,DOT_PIXEL_1X1,LINE_STYLE_DOTTED );
  1887. memcpy(partial_right2_buf,Paint_info.Image,sizeof(uint8_t)*480*RIGHT2_HIGHT/8);
  1888. return partial_right2_buf;
  1889. }
  1890. char* right3_change_time_to_dis(bool flag)//flag为true 显示前四个小时 ,flag为false,显示最近
  1891. {
  1892. char arr_int[5];
  1893. char arr_dec[5];
  1894. char* arr_string = (char*)malloc(20*sizeof(char));
  1895. uint8_t time_min,time_hour;
  1896. if(Machine_info.min>=30)
  1897. {
  1898. if(Machine_info.hour>=4)
  1899. {
  1900. time_hour = Machine_info.hour - 4;
  1901. time_min = 30;
  1902. }
  1903. else
  1904. {
  1905. time_hour = Machine_info.hour + 20;
  1906. time_min = 30;
  1907. }
  1908. }
  1909. else
  1910. {
  1911. if(Machine_info.hour>=4)
  1912. {
  1913. time_hour = Machine_info.hour - 4;
  1914. time_min = 0;
  1915. }
  1916. else
  1917. {
  1918. time_hour = Machine_info.hour + 20;
  1919. time_min = 0;
  1920. }
  1921. }
  1922. if(flag)
  1923. {//前4小时
  1924. memset(arr_string,0,20);
  1925. itoa(time_hour,arr_int,10);
  1926. if(time_min == 0)
  1927. {
  1928. strcpy(arr_string,arr_int);
  1929. strcat(arr_string,":");
  1930. strcat(arr_string,"00");
  1931. }
  1932. else
  1933. {
  1934. itoa(time_min,arr_dec,10);
  1935. strcpy(arr_string,arr_int);
  1936. strcat(arr_string,":");
  1937. strcat(arr_string,arr_dec);
  1938. }
  1939. }
  1940. else
  1941. {
  1942. memset(arr_string,0,20);
  1943. itoa(Machine_info.hour,arr_int,10);
  1944. strcpy(arr_string,arr_int);
  1945. strcat(arr_string,":");
  1946. if(Machine_info.min>=30)
  1947. {
  1948. time_min = 30;
  1949. itoa(time_min,arr_dec,10);
  1950. strcat(arr_string,arr_dec);
  1951. }
  1952. else
  1953. {
  1954. strcat(arr_string,"00");
  1955. }
  1956. }
  1957. return arr_string;
  1958. }
  1959. static uint8_t* partial_right3_quick(void)
  1960. {
  1961. /* Get timestamp before entering sleep */
  1962. // int64_t t_before_us = esp_timer_get_time();
  1963. // //ESP_LOGW(LOG_TAG,"-=-=-=-=-=-=-=");
  1964. // printf(" ==>[%lld]",t_before_us);
  1965. uint8_t* partial_right3_buf = (uint8_t*)calloc(224*480/8,sizeof(uint8_t));
  1966. #define __MAX_PIXEL 140
  1967. uint32_t num_max = 0,i=0,sum_products=0;
  1968. uint32_t num_totalProducts[8];
  1969. uint32_t scale_UR[8];
  1970. uint32_t scale_YR[8];
  1971. uint8_t time_min,time_hour;
  1972. char arr_string[20];
  1973. char arr_int[5];
  1974. char arr_dec[5];
  1975. for(i=0;i<8;i++)
  1976. {
  1977. num_totalProducts[i] = Machine_info.num_goodProducts[i]+Machine_info.num_badProducts[i];
  1978. scale_UR[i] = (Machine_info.scale_UR_int[i])*100+ Machine_info.scale_UR_dec[i];
  1979. scale_YR[i] = (Machine_info.scale_YR_int[i])*100+ Machine_info.scale_YR_dec[i];
  1980. //ESP_LOGW(LOG_TAG,"good:[%ld] bad[%ld]",num_goodProducts[i],num_badProducts[i]);
  1981. //ESP_LOGW(LOG_TAG,"total:[%ld]",num_totalProducts[i]);
  1982. //sum_products+=num_totalProducts[i];
  1983. if(num_max <(Machine_info.num_goodProducts[i]+Machine_info.num_badProducts[i]))
  1984. num_max = Machine_info.num_goodProducts[i]+Machine_info.num_badProducts[i];
  1985. }
  1986. memset((uint8_t*)tmp_paint_buf,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
  1987. Paint_NewImage((UBYTE *)tmp_paint_buf, 480, 224, ROTATE_0, WHITE );
  1988. //Paint_DrawLine(10,2,470,2,WHITE,DOT_PIXEL_1X1,LINE_STYLE_DOTTED );
  1989. Paint_DrawLine(10,220,470,220,WHITE,DOT_PIXEL_1X1,LINE_STYLE_DOTTED );
  1990. unsigned int* chartHeights = calculateBarChartHeights(num_totalProducts,sizeof(num_totalProducts)/sizeof(num_totalProducts[0]),__MAX_PIXEL);
  1991. for(i=0;i<8;i++)
  1992. {
  1993. //chartHeights[i] = 140;
  1994. Paint_DrawRectangle(60+i*25 ,192 - chartHeights[i] ,80+i*25, 192,WHITE,1,1 );
  1995. memset(arr_string,0,20);
  1996. //itoa((int)num_totalProducts[i],arr_string,10);
  1997. //取消柱状图上方数值
  1998. //Paint_DrawString_EN(60+i*25 ,192 - chartHeights[i]-8,(char*)arr_string, &ascii_type_5x7,FONT_FOREGROUND,FONT_BACKGROUND );
  1999. //ESP_LOGW(LOG_TAG,"heights = %d",chartHeights[i]);
  2000. }
  2001. free(chartHeights);
  2002. char* time_before = right3_change_time_to_dis(true);
  2003. Paint_DrawString_EN(60,192+2,time_before, &ascii_type_8x16,FONT_FOREGROUND,FONT_BACKGROUND );
  2004. free(time_before);
  2005. time_before = right3_change_time_to_dis(false);
  2006. Paint_DrawString_EN(60+150,192+2,time_before, &ascii_type_8x16,FONT_FOREGROUND,FONT_BACKGROUND );
  2007. free(time_before);
  2008. memset(arr_string,0,20);
  2009. itoa(num_totalProducts[7],arr_string,10);
  2010. int x = center_align(&arr_string,160,16,0);
  2011. Paint_DrawString_EN(300+x,70,(char*)arr_string, &ascii_type_16x32,FONT_FOREGROUND,FONT_BACKGROUND );
  2012. uint32_t tmp =0;
  2013. for(i=0;i<5;i++)
  2014. {
  2015. memset(arr_string,0,20);//140 5
  2016. tmp = (num_max/5)*(5-i);
  2017. //strcpy(arr_string,tmp);
  2018. //itoa(tmp,arr_string,10);//这里导致数值错误
  2019. sprintf(arr_string, "%lu", tmp);
  2020. // ESP_LOGW(LOG_TAG,"%s",arr_string);
  2021. Paint_DrawString_EN(10,48+i*30,(char*)arr_string, &ascii_type_5x7,FONT_FOREGROUND,FONT_BACKGROUND );
  2022. //Paint_DrawString_EN(20,40+i*28,(char*)arr_string, &ascii_type_8x16,FONT_FOREGROUND,FONT_BACKGROUND );
  2023. }
  2024. for(i=0;i<5;i++)//ur yr y坐标
  2025. {
  2026. memset(arr_string,0,20);
  2027. tmp = (100/5)*(5-i);
  2028. //strcpy(arr_string,tmp);
  2029. itoa(tmp,arr_string,10);
  2030. strcat(arr_string,".00%");
  2031. Paint_DrawString_EN(60+200,48+i*30,(char*)arr_string, &ascii_type_5x7,FONT_FOREGROUND,FONT_BACKGROUND );
  2032. }
  2033. char str_ur[8] = {0xbc,0xda,0xb6,0xaf,0xc2,0xca,0x00,0x00};
  2034. Paint_DrawString_CN(320, 170,(char*)str_ur, &chinese_type_16,FONT_FOREGROUND,FONT_BACKGROUND );//ur
  2035. Paint_DrawLine(320,170+16+3,368,170+16+3,WHITE,DOT_PIXEL_2X2,LINE_STYLE_SOLID );
  2036. char str_yr[8] = {0xc1,0xbc,0xc6,0xb7,0xc2,0xca,0x00,0x00};
  2037. Paint_DrawString_CN(390, 170,(char*)str_yr, &chinese_type_16,FONT_FOREGROUND,FONT_BACKGROUND );//yr
  2038. Paint_DrawLine(390,170+16+3,438,170+16+3,WHITE,DOT_PIXEL_1X1,LINE_STYLE_DOTTED_2 );
  2039. memset(arr_int,0,5);
  2040. memset(arr_dec,0,5);
  2041. memset(arr_string,0,20);
  2042. itoa(Machine_info.scale_UR_int[7],arr_int,10);
  2043. itoa(Machine_info.scale_UR_dec[7],arr_dec,10);
  2044. strcpy(arr_string,arr_int);
  2045. strcat(arr_string,".");
  2046. strcat(arr_string,arr_dec);
  2047. strcat(arr_string,"%");
  2048. x = center_align(&arr_string,48,8,16);
  2049. Paint_DrawString_EN(320+x,170-16-1,(char*)arr_string, &ascii_type_8x16,FONT_FOREGROUND,FONT_BACKGROUND );
  2050. memset(arr_int,0,5);
  2051. memset(arr_dec,0,5);
  2052. memset(arr_string,0,20);
  2053. itoa(Machine_info.scale_YR_int[7],arr_int,10);
  2054. itoa(Machine_info.scale_YR_dec[7],arr_dec,10);
  2055. strcpy(arr_string,arr_int);
  2056. strcat(arr_string,".");
  2057. strcat(arr_string,arr_dec);
  2058. strcat(arr_string,"%");
  2059. x = center_align(&arr_string,48,8,16);
  2060. Paint_DrawString_EN(390+x,170-16-1,(char*)arr_string, &ascii_type_8x16,FONT_FOREGROUND,FONT_BACKGROUND );
  2061. // drawQuadraticBezierCurve(uint8_t* framebuffer, int width, int height,
  2062. // int x0, int y0, int x1, int y1, int x2, int y2,
  2063. // uint8_t color, int thickness)
  2064. unsigned int* UR_Heights = getBarChartHeights(scale_UR,sizeof(scale_UR)/sizeof(scale_UR[0]),__MAX_PIXEL);
  2065. unsigned int* YR_Heights = getBarChartHeights(scale_YR,sizeof(scale_YR)/sizeof(scale_YR[0]),__MAX_PIXEL);
  2066. unsigned int tmp_heihgts[6];
  2067. unsigned int tmp1_heihgts[6];
  2068. //https://zhuanlan.zhihu.com/p/46676386
  2069. #if 1
  2070. for(i=0;i<6;i++)
  2071. {
  2072. tmp_heihgts[i] = (UR_Heights[i+1]+UR_Heights[i+2])/2;
  2073. tmp1_heihgts[i] = (YR_Heights[i+1]+YR_Heights[i+2])/2;
  2074. }
  2075. #else
  2076. for(i=0;i<6;i++)
  2077. {
  2078. tmp_heihgts[i] = 30+i*10;
  2079. tmp1_heihgts[i] = 10+i*10;
  2080. }
  2081. #endif
  2082. //UR
  2083. 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);
  2084. 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);
  2085. 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);
  2086. 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);
  2087. 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);
  2088. 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);
  2089. 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);
  2090. 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);
  2091. 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);
  2092. 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);
  2093. 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);
  2094. 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);
  2095. //YR
  2096. 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);
  2097. 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);
  2098. 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);
  2099. 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);
  2100. 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);
  2101. 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);
  2102. 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);
  2103. 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);
  2104. 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);
  2105. 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);
  2106. 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);
  2107. 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);
  2108. free(UR_Heights);
  2109. free(YR_Heights);
  2110. Paint_DrawLine(60,192,80+7*25,192,WHITE,DOT_PIXEL_2X2,LINE_STYLE_SOLID );//表格线
  2111. extern Node *clockIn_list;
  2112. // int production_num = countClockNodes_byCMD(clockIn_list,0x00);
  2113. // int repair_num = countClockNodes_byCMD(clockIn_list,0x01);
  2114. // int upKeep_num = countClockNodes_byCMD(clockIn_list,0x03);
  2115. // int inspection_num = countClockNodes_byCMD(clockIn_list,0x02);
  2116. int type_num[4] = {countClockNodes_byCMD(clockIn_list,0x00),countClockNodes_byCMD(clockIn_list,0x01),countClockNodes_byCMD(clockIn_list,0x02),countClockNodes_byCMD(clockIn_list,0x03)};
  2117. ESP_LOGI(LOG_TAG,"在岗人数 :[%d] [%d] [%d] [%d]",type_num[0],type_num[1],type_num[2],type_num[3]);
  2118. char str_arr[20];
  2119. char str_ren[] = {0xc8,0xcb,0x00,0x00};
  2120. char str_Currently[] = {0xb5,0xb1,0xc7,0xb0,0xd4,0xda,0xb8,0xda,0x3a,0xba,0x00,0x00};//当前在岗B5B1C7B0D4DAB8DAA3BA
  2121. // char str_test[] = {0xB2,0xE2,0xCA,0xD4,0xB8,0xBA,0xD4,0xF0,0x00,0x00};
  2122. // memcpy((char*)Machine_info.checkIn_set[3].other_name,str_test,strlen(str_test));//测试签到人数
  2123. int all_len = 0;
  2124. int other_name_len = 0;
  2125. Paint_DrawString_CN(10, 5,(char*)str_Currently, &chinese_type_16,FONT_FOREGROUND,FONT_BACKGROUND );
  2126. memset(str_arr,0,20);
  2127. itoa(type_num[0],str_arr,10);
  2128. other_name_len = strlen((char*)Machine_info.checkIn_set[0].other_name)*8;
  2129. all_len = other_name_len +strlen(str_arr)*8;
  2130. if(!Machine_info.checkIn_set[0].checkIn_close)
  2131. {
  2132. Paint_DrawString_CN(10+16*5, 5,(char*)Machine_info.checkIn_set[0].other_name, &chinese_type_16,FONT_FOREGROUND,FONT_BACKGROUND );
  2133. Paint_DrawString_EN(10+16*5+other_name_len,5,(char*)str_arr, &ascii_type_8x16,FONT_FOREGROUND,FONT_BACKGROUND );
  2134. Paint_DrawString_CN(10+16*5+all_len, 5,(char*)str_ren, &chinese_type_16,FONT_FOREGROUND,FONT_BACKGROUND );
  2135. }
  2136. memset(str_arr,0,20);
  2137. itoa(type_num[1],str_arr,10);
  2138. other_name_len = strlen((char*)Machine_info.checkIn_set[1].other_name)*8;
  2139. all_len = other_name_len +strlen(str_arr)*8;
  2140. if(!Machine_info.checkIn_set[1].checkIn_close)
  2141. {
  2142. Paint_DrawString_CN(186, 5,(char*)Machine_info.checkIn_set[1].other_name, &chinese_type_16,FONT_FOREGROUND,FONT_BACKGROUND );
  2143. Paint_DrawString_EN(186+other_name_len,5,(char*)str_arr, &ascii_type_8x16,FONT_FOREGROUND,FONT_BACKGROUND );
  2144. Paint_DrawString_CN(186+all_len, 5,(char*)str_ren, &chinese_type_16,FONT_FOREGROUND,FONT_BACKGROUND );
  2145. }
  2146. memset(str_arr,0,20);
  2147. itoa(type_num[2],str_arr,10);
  2148. other_name_len = strlen((char*)Machine_info.checkIn_set[2].other_name)*8;
  2149. all_len = other_name_len +strlen(str_arr)*8;
  2150. if(!Machine_info.checkIn_set[2].checkIn_close)
  2151. {
  2152. Paint_DrawString_CN(282, 5,(char*)Machine_info.checkIn_set[2].other_name, &chinese_type_16,FONT_FOREGROUND,FONT_BACKGROUND );
  2153. Paint_DrawString_EN(282+other_name_len,5,(char*)str_arr, &ascii_type_8x16,FONT_FOREGROUND,FONT_BACKGROUND );
  2154. Paint_DrawString_CN(282+all_len, 5,(char*)str_ren, &chinese_type_16,FONT_FOREGROUND,FONT_BACKGROUND );
  2155. }
  2156. memset(str_arr,0,20);
  2157. itoa(type_num[3],str_arr,10);
  2158. other_name_len = strlen((char*)Machine_info.checkIn_set[3].other_name)*8;
  2159. all_len = other_name_len +strlen(str_arr)*8;
  2160. if(!Machine_info.checkIn_set[3].checkIn_close)
  2161. {
  2162. Paint_DrawString_CN(378, 5,(char*)Machine_info.checkIn_set[3].other_name, &chinese_type_16,FONT_FOREGROUND,FONT_BACKGROUND );
  2163. Paint_DrawString_EN(378+other_name_len,5,(char*)str_arr, &ascii_type_8x16,FONT_FOREGROUND,FONT_BACKGROUND );
  2164. Paint_DrawString_CN(378+all_len, 5,(char*)str_ren, &chinese_type_16,FONT_FOREGROUND,FONT_BACKGROUND );
  2165. }
  2166. memcpy(partial_right3_buf,Paint_info.Image,sizeof(uint8_t)*480*224/8);
  2167. return partial_right3_buf;
  2168. }
  2169. static uint8_t* partial_right3_2_quick(void)
  2170. {
  2171. uint8_t* partial_right3_buf = (uint8_t*)calloc(224*480/8,sizeof(uint8_t));
  2172. memset((uint8_t*)tmp_paint_buf,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
  2173. Paint_NewImage((UBYTE *)tmp_paint_buf, 480, 224, ROTATE_0, WHITE );
  2174. Paint_DrawLine(10,220,470,220,WHITE,DOT_PIXEL_1X1,LINE_STYLE_DOTTED );//分隔右屏第三部分和第四部分线表格线
  2175. #if 0
  2176. extern Node *clockIn_list;
  2177. int production_num = countClockNodes_byCMD(clockIn_list,0x00);
  2178. int repair_num = countClockNodes_byCMD(clockIn_list,0x01);
  2179. int upKeep_num = countClockNodes_byCMD(clockIn_list,0x03);
  2180. int inspection_num = countClockNodes_byCMD(clockIn_list,0x02);
  2181. ESP_LOGD(LOG_TAG,"(2)生产【%d】,巡检【%d】,保养【%d】,维修【%d】",production_num,repair_num,upKeep_num,inspection_num);
  2182. char str_arr[20];
  2183. char str_ren[4] = {0xc8,0xcb,0x00,0x00};
  2184. char str_now_and_production[16] = {0xb5,0xb1,0xc7,0xb0,0xd4,0xda,0xb8,0xda,0xa3,0xba,0xc9,0xfa,0xb2,0xfa,0x00,0x00};//当前在岗:生产
  2185. // char str_inspection[6] = {0xd1,0xb2,0xbc,0xec,0x00,0x00};
  2186. // char str_upKeep[]
  2187. memset(str_arr,0,20);
  2188. itoa(production_num,str_arr,10);
  2189. Paint_DrawString_CN(10, 5,(char*)str_now_and_production, &chinese_type_16,FONT_FOREGROUND,FONT_BACKGROUND );
  2190. Paint_DrawString_EN(10+16*7,5,(char*)str_arr, &ascii_type_8x16,FONT_FOREGROUND,FONT_BACKGROUND );
  2191. Paint_DrawString_CN(10+16*7+strlen(str_arr)*8, 5,(char*)str_ren, &chinese_type_16,FONT_FOREGROUND,FONT_BACKGROUND );
  2192. memset(str_arr,0,20);
  2193. itoa(inspection_num,str_arr,10);
  2194. Paint_DrawString_CN(180, 5,(char*)str_inspection, &chinese_type_16,FONT_FOREGROUND,FONT_BACKGROUND );
  2195. Paint_DrawString_EN(180+16*2,5,(char*)str_arr, &ascii_type_8x16,FONT_FOREGROUND,FONT_BACKGROUND );
  2196. Paint_DrawString_CN(180+16*2+strlen(str_arr)*8, 5,(char*)str_ren, &chinese_type_16,FONT_FOREGROUND,FONT_BACKGROUND );
  2197. memset(str_arr,0,20);
  2198. itoa(upKeep_num,str_arr,10);
  2199. Paint_DrawString_CN(280, 5,(char*)str_upKeep, &chinese_type_16,FONT_FOREGROUND,FONT_BACKGROUND );
  2200. Paint_DrawString_EN(280+16*2,5,(char*)str_arr, &ascii_type_8x16,FONT_FOREGROUND,FONT_BACKGROUND );
  2201. Paint_DrawString_CN(280+16*2+strlen(str_arr)*8, 5,(char*)str_ren, &chinese_type_16,FONT_FOREGROUND,FONT_BACKGROUND );
  2202. memset(str_arr,0,20);
  2203. itoa(repair_num,str_arr,10);
  2204. Paint_DrawString_CN(380, 5,(char*)str_repair, &chinese_type_16,FONT_FOREGROUND,FONT_BACKGROUND );
  2205. Paint_DrawString_EN(380+16*2,5,(char*)str_arr, &ascii_type_8x16,FONT_FOREGROUND,FONT_BACKGROUND );
  2206. Paint_DrawString_CN(380+16*2+strlen(str_arr)*8, 5,(char*)str_ren, &chinese_type_16,FONT_FOREGROUND,FONT_BACKGROUND );
  2207. #else
  2208. extern Node *clockIn_list;
  2209. int type_num[4] = {countClockNodes_byCMD(clockIn_list,0x00),countClockNodes_byCMD(clockIn_list,0x01),countClockNodes_byCMD(clockIn_list,0x02),countClockNodes_byCMD(clockIn_list,0x03)};
  2210. char str_arr[20];
  2211. ESP_LOGI(LOG_TAG,"#在岗人数 :[%d] [%d] [%d] [%d]",type_num[0],type_num[1],type_num[2],type_num[3]);
  2212. char str_ren[] = {0xc8,0xcb,0x00,0x00};
  2213. char str_Currently[] = {0xb5,0xb1,0xc7,0xb0,0xd4,0xda,0xb8,0xda,0x3a,0xba,0x00,0x00};//当前在岗B5B1C7B0D4DAB8DAA3BA
  2214. int all_len = 0;
  2215. int other_name_len = 0;
  2216. Paint_DrawString_CN(10, 5,(char*)str_Currently, &chinese_type_16,FONT_FOREGROUND,FONT_BACKGROUND );
  2217. memset(str_arr,0,20);
  2218. itoa(type_num[0],str_arr,10);
  2219. other_name_len = strlen((char*)Machine_info.checkIn_set[0].other_name)*8;
  2220. all_len = other_name_len +strlen(str_arr)*8;
  2221. if(!Machine_info.checkIn_set[0].checkIn_close)
  2222. {
  2223. Paint_DrawString_CN(10+16*5, 5,(char*)Machine_info.checkIn_set[0].other_name, &chinese_type_16,FONT_FOREGROUND,FONT_BACKGROUND );
  2224. Paint_DrawString_EN(10+16*5+other_name_len,5,(char*)str_arr, &ascii_type_8x16,FONT_FOREGROUND,FONT_BACKGROUND );
  2225. Paint_DrawString_CN(10+16*5+all_len, 5,(char*)str_ren, &chinese_type_16,FONT_FOREGROUND,FONT_BACKGROUND );
  2226. }
  2227. memset(str_arr,0,20);
  2228. itoa(type_num[1],str_arr,10);
  2229. other_name_len = strlen((char*)Machine_info.checkIn_set[1].other_name)*8;
  2230. all_len = other_name_len +strlen(str_arr)*8;
  2231. if(!Machine_info.checkIn_set[1].checkIn_close)
  2232. {
  2233. Paint_DrawString_CN(186, 5,(char*)Machine_info.checkIn_set[1].other_name, &chinese_type_16,FONT_FOREGROUND,FONT_BACKGROUND );
  2234. Paint_DrawString_EN(186+other_name_len,5,(char*)str_arr, &ascii_type_8x16,FONT_FOREGROUND,FONT_BACKGROUND );
  2235. Paint_DrawString_CN(186+all_len, 5,(char*)str_ren, &chinese_type_16,FONT_FOREGROUND,FONT_BACKGROUND );
  2236. }
  2237. memset(str_arr,0,20);
  2238. itoa(type_num[2],str_arr,10);
  2239. other_name_len = strlen((char*)Machine_info.checkIn_set[2].other_name)*8;
  2240. all_len = other_name_len +strlen(str_arr)*8;
  2241. if(!Machine_info.checkIn_set[2].checkIn_close)
  2242. {
  2243. Paint_DrawString_CN(282, 5,(char*)Machine_info.checkIn_set[2].other_name, &chinese_type_16,FONT_FOREGROUND,FONT_BACKGROUND );
  2244. Paint_DrawString_EN(282+other_name_len,5,(char*)str_arr, &ascii_type_8x16,FONT_FOREGROUND,FONT_BACKGROUND );
  2245. Paint_DrawString_CN(282+all_len, 5,(char*)str_ren, &chinese_type_16,FONT_FOREGROUND,FONT_BACKGROUND );
  2246. }
  2247. memset(str_arr,0,20);
  2248. itoa(type_num[3],str_arr,10);
  2249. other_name_len = strlen((char*)Machine_info.checkIn_set[3].other_name)*8;
  2250. all_len = other_name_len +strlen(str_arr)*8;
  2251. if(!Machine_info.checkIn_set[3].checkIn_close)
  2252. {
  2253. Paint_DrawString_CN(378, 5,(char*)Machine_info.checkIn_set[3].other_name, &chinese_type_16,FONT_FOREGROUND,FONT_BACKGROUND );
  2254. Paint_DrawString_EN(378+other_name_len,5,(char*)str_arr, &ascii_type_8x16,FONT_FOREGROUND,FONT_BACKGROUND );
  2255. Paint_DrawString_CN(378+all_len, 5,(char*)str_ren, &chinese_type_16,FONT_FOREGROUND,FONT_BACKGROUND );
  2256. }
  2257. memcpy(partial_right3_buf,Paint_info.Image,sizeof(uint8_t)*480*224/8);
  2258. #endif
  2259. //画表格
  2260. int i;
  2261. char arr_string[20];
  2262. uint32_t tmp =0;
  2263. //柱状图
  2264. uint16_t num_max_manHour = 0;
  2265. uint32_t num_tmp[8];
  2266. for(i=0;i<8;i++)
  2267. {
  2268. num_tmp[i] = (uint32_t)Machine_info.num_manHour[i];
  2269. }
  2270. unsigned int* manHour_Heights = calculateBarChartHeights(num_tmp,8,__MAX_PIXEL);
  2271. for(i=0;i<8;i++)
  2272. {
  2273. if(num_max_manHour < Machine_info.num_manHour[i])
  2274. {num_max_manHour = Machine_info.num_manHour[i];}
  2275. // Paint_DrawRectangle(60+i*25 ,192 - manHour_Heights[i] ,80+i*25, 192,WHITE,1,1 );
  2276. Paint_DrawRectangle(60+i*25 ,193 - manHour_Heights[i] ,80+i*25, 193,WHITE,1,1 );
  2277. memset(arr_string,0,20);
  2278. itoa((int)Machine_info.num_manHour[i],arr_string,10);
  2279. //ESP_LOGW(LOG_TAG,"%s",arr_string);
  2280. //取消柱状图上方数值
  2281. Paint_DrawString_EN(60+i*25 ,192 - manHour_Heights[i]-8,(char*)arr_string, &ascii_type_5x7,FONT_FOREGROUND,FONT_BACKGROUND );
  2282. //ESP_LOGW(LOG_TAG,"manHour_Heights = %d,num_manHour = %d,max_manHour = %d ",manHour_Heights[i],Machine_info.num_manHour[i],num_max_manHour);
  2283. }
  2284. for(i=0;i<5;i++)
  2285. {
  2286. tmp = ((int)(num_max_manHour/5))*(5-i);
  2287. memset(arr_string,0,20);//140 5
  2288. //strcpy(arr_string,tmp);
  2289. //itoa(tmp,arr_string,10);//这里导致数值错误
  2290. sprintf(arr_string, "%lu", tmp);
  2291. // ESP_LOGW(LOG_TAG,"3——2 %s",arr_string);
  2292. Paint_DrawString_EN(20,48+i*30,(char*)arr_string, &ascii_type_5x7,FONT_FOREGROUND,FONT_BACKGROUND );
  2293. }
  2294. //右屏3_2 贝塞尔曲线
  2295. uint16_t num_max_people = 0;
  2296. for(i=0;i<8;i++)
  2297. {
  2298. num_tmp[i] = (uint32_t)Machine_info.num_people[i];
  2299. }
  2300. unsigned int* people_Heights = calculateBarChartHeights(num_tmp,sizeof(Machine_info.num_people)/sizeof(Machine_info.num_people[0]),__MAX_PIXEL);
  2301. unsigned int tmp_heihgts[6];
  2302. for(i=0;i<8;i++)
  2303. {
  2304. if(num_max_people < Machine_info.num_people[i])
  2305. {num_max_people = Machine_info.num_people[i];}
  2306. //ESP_LOGW(LOG_TAG,"num_people[%d]=(%d),max :[%d]",i,Machine_info.num_people[i],num_max_people);
  2307. }
  2308. //https://zhuanlan.zhihu.com/p/46676386
  2309. for(i=0;i<6;i++)
  2310. {
  2311. tmp_heihgts[i] = (people_Heights[i+1]+people_Heights[i+2])/2;
  2312. }
  2313. 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);
  2314. 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);
  2315. 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);
  2316. 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);
  2317. 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);
  2318. 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);
  2319. 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);
  2320. 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);
  2321. 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);
  2322. 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);
  2323. 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);
  2324. 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);
  2325. for(i=0;i<5;i++)
  2326. {
  2327. memset(arr_string,0,20);
  2328. if((num_max_people <= 5)&&(i == 0))
  2329. {
  2330. tmp = num_max_people;
  2331. }
  2332. else
  2333. {
  2334. tmp = (num_max_people/5)*(5-i);
  2335. }
  2336. sprintf(arr_string, "%lu", tmp);
  2337. // ESP_LOGW(LOG_TAG,"%s",arr_string);
  2338. //ESP_LOG_BUFFER_HEX(LOG_TAG,arr_string,30);
  2339. Paint_DrawString_EN(60+200,48+i*30,(char*)arr_string, &ascii_type_5x7,FONT_FOREGROUND,FONT_BACKGROUND );
  2340. }
  2341. free(manHour_Heights);
  2342. free(people_Heights);
  2343. Paint_DrawLine(60,193,80+7*25,193,WHITE,DOT_PIXEL_1X1,LINE_STYLE_SOLID );
  2344. //画表格结束
  2345. memset(arr_string,0,20);
  2346. itoa(Machine_info.num_manHour[7],arr_string,10);//最近工时显示
  2347. i = center_align(&arr_string,160,16,32);
  2348. Paint_DrawString_EN(300+i,70,(char*)arr_string, &ascii_type_16x32,FONT_FOREGROUND,FONT_BACKGROUND );
  2349. memset(arr_string,0,20);
  2350. itoa(Machine_info.num_people[7],arr_string,10);//最近人数显示
  2351. //strcat(arr_string,"123456");
  2352. i = center_align(&arr_string,160,8,16);
  2353. Paint_DrawString_EN(300+i,150,(char*)arr_string, &ascii_type_8x16,FONT_FOREGROUND,FONT_BACKGROUND );
  2354. char str_people[8] = {0xC8,0xCB,0xCA,0xFD,0x00,0x00};
  2355. //i = center_align(&arr_string,160,8,16);
  2356. Paint_DrawString_CN(300+i+strlen(arr_string)*4 - 16, 165,(char*)str_people, &chinese_type_16,FONT_FOREGROUND,FONT_BACKGROUND );//ur
  2357. //Paint_DrawLine(300+i,167+18,300+i+strlen(arr_string)*8,167+18,WHITE,DOT_PIXEL_1X1,LINE_STYLE_DOTTED );
  2358. 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 );
  2359. char* time_before = right3_change_time_to_dis(true);
  2360. Paint_DrawString_EN(60,192+2,time_before, &ascii_type_8x16,FONT_FOREGROUND,FONT_BACKGROUND );
  2361. free(time_before);
  2362. time_before = right3_change_time_to_dis(false);
  2363. Paint_DrawString_EN(60+150,192+2,time_before, &ascii_type_8x16,FONT_FOREGROUND,FONT_BACKGROUND );
  2364. free(time_before);
  2365. memcpy(partial_right3_buf,Paint_info.Image,sizeof(uint8_t)*480*224/8);
  2366. return partial_right3_buf;
  2367. }
  2368. static uint8_t* partial_right4_quick(void)
  2369. {
  2370. uint8_t* partial_right4_buf = (uint8_t*)calloc(152*480/8,sizeof(uint8_t));
  2371. memset((uint8_t*)tmp_paint_buf,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
  2372. char str_announcement[8] = {0xb9,0xab,0xb8,0xe6,0x3a,0x00,0x00,0x00};
  2373. Paint_NewImage((UBYTE *)tmp_paint_buf, 480, 152, ROTATE_0, WHITE );
  2374. uint8_t *string_infor = malloc(120);
  2375. memset(string_infor,0x00,120);
  2376. strcat((char *)string_infor,str_announcement);
  2377. strcat((char *)string_infor,(char *)Machine_info.announcement);
  2378. Paint_DrawString_CN(10, 6,(char*)string_infor, &chinese_type_16,FONT_FOREGROUND,FONT_BACKGROUND );
  2379. free(string_infor);
  2380. // #if 0//系统消息固定
  2381. // //系统提示:系统3.01固件版本更新了新的功能,请及时更新。
  2382. // //CFB5CDB3CCE1CABE3ACFB5CDB3332E302E31B9CCBCFEB0E6B1BEB8FCD0C2C1CBD0C2B5C4B9A6C4DCA3ACC7EBBCB0CAB1B8FCD0C2A1A30A
  2383. // 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
  2384. // ,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};
  2385. // Paint_DrawString_CN(20, 122,(char*)string_system_message, &chinese_type_16,FONT_FOREGROUND,FONT_BACKGROUND );
  2386. // #else
  2387. // uint8_t *string_sys = malloc(120);
  2388. // char str_xitong[12] = {0xcf,0xb5,0xcd,0xb3,0xcc,0xe1,0xca,0xbe,0x3a,0x00,0x00,0x00};
  2389. // memset(string_sys,0x00,120);
  2390. // strcat((char *)string_sys,str_xitong);
  2391. // strcat((char *)string_sys,(char *)Machine_info.systemMessage);
  2392. // Paint_DrawString_CN(10, 90,(char*)string_sys, &chinese_type_16,FONT_FOREGROUND,FONT_BACKGROUND );
  2393. // free(string_sys);
  2394. // #endif
  2395. memcpy(partial_right4_buf,Paint_info.Image,sizeof(uint8_t)*480*152/8);
  2396. return partial_right4_buf;
  2397. }
  2398. void Paint_rightScreen_main_powerON()
  2399. {
  2400. printf("%s\r\n",__FUNCTION__);
  2401. //当前未配对进入出厂模式
  2402. //当前系统的状态 关机 未配网
  2403. if( /*(!Machine_info.paired) &&*/(!Machine_info.power_status))
  2404. {
  2405. printf("power off\r\n");
  2406. memset((uint8_t*)tmp_paint_buf,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
  2407. Paint_NewImage((uint8_t*)tmp_paint_buf, 648, 480, ROTATE_270, WHITE);
  2408. Paint_DrawBitMap_Paste(gImage_right_instruction, 0,0 ,480,648 ,1);
  2409. printf("当前系统的状态 关机\n");
  2410. if(read_battery_voltage()<10)
  2411. {
  2412. Paint_DrawBitMap_Paste(gImage_low_batt, 30,428 ,420,154,1); //低电量请充电
  2413. }
  2414. epd_init_cmd(SCREEN_RIGHT);
  2415. epd_display(SCREEN_RIGHT,Paint_info.Image);
  2416. memcpy(last_paint_buf_right,Paint_info.Image,sizeof(uint8_t)*648*480/8);
  2417. // int ret = memcmp(last_paint_buf_right,Paint_info.Image,38880);
  2418. // ESP_LOGW(LOG_TAG,"memcmp :ret = %d",ret);
  2419. if(memcmp(last_paint_buf_right,Paint_info.Image,38880))
  2420. {
  2421. ESP_LOGE(LOG_TAG,"err:last_paint_buf_right");
  2422. }
  2423. }else
  2424. {
  2425. printf("power on\r\n");
  2426. uint8_t* right1_buf = partial_right1_quick(&Machine_info);
  2427. uint8_t* right2_buf = partial_right2_quick();
  2428. uint8_t* right3_buf = partial_right3_quick();
  2429. uint8_t* right4_buf = partial_right4_quick();
  2430. memset((uint8_t*)tmp_paint_buf,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
  2431. Paint_NewImage((uint8_t*)tmp_paint_buf, 648, 480, ROTATE_270, WHITE);
  2432. Paint_DrawBitMap_Paste(right1_buf,0,0,480,100,1);
  2433. free(right1_buf);
  2434. Paint_DrawBitMap_Paste(right2_buf,0,100,480,172,1);
  2435. free(right2_buf);
  2436. Paint_DrawBitMap_Paste(right3_buf,0,272,480,224,1);
  2437. free(right3_buf);
  2438. Paint_DrawBitMap_Paste(right4_buf,0,496,480,152,1);
  2439. free(right4_buf);
  2440. printf("当前系统的状态 开机!\n");
  2441. epd_init_cmd(SCREEN_RIGHT);
  2442. epd_display(SCREEN_RIGHT,Paint_info.Image);
  2443. memcpy(last_paint_buf_right,Paint_info.Image,sizeof(uint8_t)*648*480/8);
  2444. // int ret = memcmp(last_paint_buf_right,Paint_info.Image,38880);
  2445. // ESP_LOGW(LOG_TAG,"memcmp :ret = %d",ret);
  2446. if(memcmp(last_paint_buf_right,Paint_info.Image,38880))
  2447. {
  2448. ESP_LOGE(LOG_TAG,"err:last_paint_buf_right");
  2449. }
  2450. #if USER_DEEP_SLEEP_ENABLE
  2451. int reson = is_wake_up_reson(); //返回唤醒的原因
  2452. if ((reson != ESP_SLEEP_WAKEUP_ULP) || (reson != ESP_SLEEP_WAKEUP_TIMER))
  2453. {
  2454. uint8_t *old_buffer= heap_caps_malloc(480*81, MALLOC_CAP_8BIT|MALLOC_CAP_SPIRAM); //申请内存
  2455. memset(old_buffer,0x00,480*81);
  2456. //memset((uint8_t*)last_paint_buf_left,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
  2457. right_compressedSize = compressRLE(last_paint_buf_right, 480*81, old_buffer);
  2458. printf(" right src size = %d, zip size:%d\r\n",480*81,right_compressedSize);
  2459. //memset((uint8_t*)tmp_paint_buf,0,sizeof(tmp_paint_buf));
  2460. //button_deinit();
  2461. //写入数据
  2462. right_spiffs_write(old_buffer,right_compressedSize);
  2463. //button_init(adc1_handle);
  2464. free(old_buffer);
  2465. }
  2466. #endif
  2467. }
  2468. }
  2469. void Paint_rightScreen_main_slow(Machine_info_t* info)
  2470. {
  2471. printf("Paint_rightScreen_main_slow\r\n");
  2472. uint8_t* right1_buf = partial_right1_quick(&Machine_info);
  2473. uint8_t* right2_buf = partial_right2_quick();
  2474. uint8_t* right3_buf = NULL;
  2475. if(Machine_info.right_display_mode == 1)
  2476. {
  2477. right3_buf = partial_right3_2_quick();
  2478. }
  2479. else
  2480. {
  2481. right3_buf = partial_right3_quick();
  2482. }
  2483. uint8_t* right4_buf = partial_right4_quick();
  2484. memset((uint8_t*)tmp_paint_buf,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
  2485. Paint_NewImage((uint8_t*)tmp_paint_buf, 648, 480, ROTATE_270, WHITE);
  2486. Paint_DrawBitMap_Paste(right1_buf,0,0,480,100,1);
  2487. free(right1_buf);
  2488. Paint_DrawBitMap_Paste(right2_buf,0,100,480,172,1);
  2489. free(right2_buf);
  2490. Paint_DrawBitMap_Paste(right3_buf,0,272,480,224,1);
  2491. free(right3_buf);
  2492. Paint_DrawBitMap_Paste(right4_buf,0,496,480,152,1);
  2493. free(right4_buf);
  2494. // #if 1 //USER_DEEP_SLEEP_ENABLE
  2495. // uint8_t *old_buffer= heap_caps_malloc(right_compressedSize, MALLOC_CAP_8BIT|MALLOC_CAP_INTERNAL|MALLOC_CAP_DMA); //申请内存
  2496. // memset(old_buffer,0x00,right_compressedSize);
  2497. // int reson = is_wake_up_reson(); //返回唤醒的原因
  2498. // if ((reson == ESP_SLEEP_WAKEUP_ULP) || (reson == ESP_SLEEP_WAKEUP_TIMER))
  2499. // {
  2500. // //读取数据到内存
  2501. // right_spiffs_read(old_buffer,right_compressedSize);
  2502. // //解压数据
  2503. // right_decompressedSize = decompressRLE(old_buffer, right_compressedSize, last_paint_buf_right);
  2504. // printf("right src size = %d unzip %d\r\n",right_compressedSize,right_decompressedSize);
  2505. // }
  2506. // free(old_buffer);
  2507. // #endif
  2508. epd_init_cmd(SCREEN_RIGHT);
  2509. epd_display(SCREEN_RIGHT,Paint_info.Image);
  2510. #if USER_DEEP_SLEEP_ENABLE
  2511. if ((reson != ESP_SLEEP_WAKEUP_ULP) || (reson != ESP_SLEEP_WAKEUP_TIMER))
  2512. #endif
  2513. {
  2514. memcpy(last_paint_buf_right,Paint_info.Image,sizeof(uint8_t)*648*480/8);
  2515. // int ret = memcmp(last_paint_buf_right,Paint_info.Image,38880);
  2516. // ESP_LOGW(LOG_TAG,"memcmp :ret = %d",ret);
  2517. if(memcmp(last_paint_buf_right,Paint_info.Image,38880))
  2518. {
  2519. ESP_LOGE(LOG_TAG,"err:last_paint_buf_right");
  2520. }
  2521. }
  2522. //epd_powerOn_refresh_sleep(SCREEN_RIGHT );
  2523. #if 0// USER_DEEP_SLEEP_ENABLE
  2524. int reson = is_wake_up_reson(); //返回唤醒的原因
  2525. if ((reson == ESP_SLEEP_WAKEUP_ULP) || (reson == ESP_SLEEP_WAKEUP_TIMER)||(reson == ESP_SLEEP_WAKEUP_EXT0))
  2526. {
  2527. right_compressedSize = compressRLE(Paint_info.Image, 480*81, last_paint_buf_right);
  2528. // printf("right src size = %d, zip size:%d\r\n",480*81,right_compressedSize);
  2529. //button_deinit();
  2530. //写入数据
  2531. right_spiffs_write(last_paint_buf_right,right_compressedSize);
  2532. //button_init(adc1_handle);
  2533. }
  2534. #endif
  2535. }
  2536. void Paint_rightScreen_main_quick(Machine_info_t* info)
  2537. {
  2538. printf("Paint_rightScreen_main_quick\r\n");
  2539. uint8_t* right1_buf = partial_right1_quick(&Machine_info);
  2540. uint8_t* right2_buf = partial_right2_quick();
  2541. uint8_t* right3_buf = NULL;
  2542. if(Machine_info.right_display_mode == 1)
  2543. {
  2544. right3_buf = partial_right3_2_quick();
  2545. }
  2546. else
  2547. {
  2548. right3_buf = partial_right3_quick();
  2549. }
  2550. uint8_t* right4_buf = partial_right4_quick();
  2551. memset((uint8_t*)tmp_paint_buf,0,DISPLAY_BUFFER_SIZE/*sizeof(tmp_paint_buf)*/);
  2552. Paint_NewImage((uint8_t*)tmp_paint_buf, 648, 480, ROTATE_270, WHITE);
  2553. Paint_DrawBitMap_Paste(right1_buf,0,0,480,100,1);
  2554. free(right1_buf);
  2555. Paint_DrawBitMap_Paste(right2_buf,0,100,480,172,1);
  2556. free(right2_buf);
  2557. Paint_DrawBitMap_Paste(right3_buf,0,272,480,224,1);
  2558. free(right3_buf);
  2559. Paint_DrawBitMap_Paste(right4_buf,0,496,480,152,1);
  2560. free(right4_buf);
  2561. #if USER_DEEP_SLEEP_ENABLE
  2562. uint8_t *old_buffer= heap_caps_malloc(right_compressedSize, MALLOC_CAP_8BIT|MALLOC_CAP_INTERNAL|MALLOC_CAP_DMA); //申请内存
  2563. memset(old_buffer,0x00,right_compressedSize);
  2564. int reson = is_wake_up_reson(); //返回唤醒的原因
  2565. if ((reson == ESP_SLEEP_WAKEUP_ULP) || (reson == ESP_SLEEP_WAKEUP_TIMER))
  2566. {
  2567. //读取数据到内存
  2568. right_spiffs_read(old_buffer,right_compressedSize);
  2569. //解压数据
  2570. right_decompressedSize = decompressRLE(old_buffer, right_compressedSize, last_paint_buf_right);
  2571. printf("right src size = %d unzip %d\r\n",right_compressedSize,right_decompressedSize);
  2572. }
  2573. #endif
  2574. bool ret = epd_cache_quick(SCREEN_RIGHT,(uint8_t*)last_paint_buf_right,Paint_info.Image);
  2575. epd_powerOn_refresh_sleep(SCREEN_RIGHT );
  2576. #if USER_DEEP_SLEEP_ENABLE
  2577. if ((reson != ESP_SLEEP_WAKEUP_ULP) || (reson != ESP_SLEEP_WAKEUP_TIMER))
  2578. #endif
  2579. if(ret)
  2580. {
  2581. memcpy(last_paint_buf_right,Paint_info.Image,sizeof(uint8_t)*648*480/8);
  2582. // int ret = memcmp(last_paint_buf_right,Paint_info.Image,38880);
  2583. // ESP_LOGW(LOG_TAG,"memcmp :ret = %d",ret);
  2584. if(memcmp(last_paint_buf_right,Paint_info.Image,38880))
  2585. {
  2586. ESP_LOGE(LOG_TAG,"err:last_paint_buf_right");
  2587. }
  2588. }
  2589. else
  2590. {
  2591. ESP_LOGE(LOG_TAG,"r 不保存上一帧");
  2592. }
  2593. #if USER_DEEP_SLEEP_ENABLE
  2594. //if ((reson == ESP_SLEEP_WAKEUP_ULP) || (reson == ESP_SLEEP_WAKEUP_TIMER))
  2595. {
  2596. right_compressedSize = compressRLE(Paint_info.Image, 480*81, last_paint_buf_right);
  2597. printf("right src size = %d, zip size:%d\r\n",480*81,right_compressedSize);
  2598. //button_deinit();
  2599. //写入数据
  2600. right_spiffs_write(last_paint_buf_right,right_compressedSize);
  2601. //button_init(adc1_handle);
  2602. }
  2603. free(old_buffer);
  2604. #endif
  2605. Machine_info.last_batt_precent = Machine_info.batt_precent;//右屏刷完后记录电池电量
  2606. }