{"id":2830,"date":"2019-09-27T08:49:29","date_gmt":"2019-09-27T08:49:29","guid":{"rendered":""},"modified":"2019-09-27T16:49:58","modified_gmt":"2019-09-27T08:49:58","slug":"%e5%a6%82%e4%bd%95%e9%87%87%e7%94%a8%e5%8d%95%e7%89%87%e6%9c%ba%e9%a9%b1%e5%8a%a8%e6%b6%b2%e6%99%b6%e5%b1%8f%e5%ae%9e%e7%8e%b0%e6%98%be%e7%a4%ba%e5%9b%be%e7%89%87","status":"publish","type":"post","link":"http:\/\/www.szryc.com\/?p=2830","title":{"rendered":"\u5982\u4f55\u91c7\u7528\u5355\u7247\u673a\u9a71\u52a8\u6db2\u6676\u5c4f\u5b9e\u73b0\u663e\u793a\u56fe\u7247"},"content":{"rendered":"

\n\t\u7531\u4e8e\u9700\u8981\u7528\u5230\u6db2\u6676\u5c4f<\/u>\uff08320*240\uff09\u663e\u793a\u56fe\u7247\uff0c\u800c\u4e14\u56fe\u7247\u7684\u6570\u91cf\u6bd4\u8f83\u591a\uff08\u597d\u51e0\u767e\u5f20\uff09\uff0c\u5e76\u4e14\u56fe\u7247\u8981\u6c42\u4fdd\u5b58\u523016M\u7684SPI<\/u> FLASH\u91cc\u9762\uff0c\u663e\u7136\u5982\u679c\u4e0d\u5904\u7406 16M\u7684FLASH\u660e\u663e\u662f\u653e\u4e0d\u4e0b\u53bb\u3002\u540e\u6765\u540c\u4e8b\u8bf4\u53ef\u4ee5\u7528\u538b\u7f29\u7b97\u6cd5RLE\uff0c\u5e76\u4e14\u7528C#<\/u>\u7ed9\u6211\u505a\u4e86\u4e2a\u5c0f\u7684\u8f6f\u4ef6\uff0c\u538b\u7f29\u56fe\u7247\u5f97\u5230RLE\u538b\u7f29\u540e\u7684\u6570\u636e\u3002<\/p>\n

\n\t\u8fd9\u4e2a\u7b97\u6cd5\u7684\u7f3a\u70b9\u662f \u5982\u679c\u56fe\u7247\u989c\u8272\u590d\u6742\u5c31\u4e0d\u597d\uff0c\u6240\u4ee5\u989c\u8272\u5c3d\u91cf\u5355\u8c03\u4e9b\u3002<\/p>\n

\n\t <\/div>\n

\n\t1\u3001RLE\u7b97\u6cd5\u5c0f\u5de5\u5177\u7684\u4f7f\u7528<\/p>\n

\n\t2\u3001\u6211\u4f7f\u7528\u7684RLE\u548c\u4e0a\u9762\u8fde\u63a5\u7684\u533a\u522b\uff08\u6539\u8fdb\uff09<\/p>\n

\n\t3\u3001\u5355\u7247\u673a<\/u>\u91cc\u9762\u5b9e\u73b0\u7684\u65b9\u6cd5<\/p>\n

\n\t1\u3001RLE\u7b97\u6cd5\u5c0f\u5de5\u5177\u7684\u4f7f\u7528\u70b9\u51fb\u6253\u5f00\u94fe\u63a5<\/p>\n

\n\t\u8fd9\u91cc\u662f\u5c0f\u5de5\u5177\u7684\u4e0b\u8f7d\u5730\u5740 http:\/\/download.csdn.net\/detai<\/u>l\/chen244798611\/9696253<\/p>\n

\n\t\u4f7f\u7528\uff1a\u4f7f\u7528\u4e5f\u975e\u5e38\u7b80\u5355 \u4e0b\u8f7d\u4e0b\u6765RLETe<\/u>st.exe\uff0c\u70b9\u51fb\u6253\u5f00 --\u300b\u754c\u9762\u5c31\u4e00\u4e2a\u6309\u94ae “\u538b\u7f29”---\u300b\u70b9\u51fb\u9009\u62e9\u56fe\u7247 \u81ea\u52a8\u538b\u7f29<\/p>\n

\n\t\u63d0\u793a\u5b8c\u6210\u53ef\u4ee5\u770b\u89c1\u751f\u6210<\/p>\n

\n\t\"\u5982\u4f55\u91c7\u7528\u5355\u7247\u673a\u9a71\u52a8\u6db2\u6676\u5c4f\u5b9e\u73b0\u663e\u793a\u56fe\u7247\"<\/p>\n

\n\t\u7b2c\u4e00\u4e2a\u91cc\u9762\u6709\u538b\u7f29\u524d\u548c\u538b\u7f29\u540e\u7684\u6587\u4ef6\u5927\u5c0f\u5bf9\u6bd4<\/p>\n

\n\t\u6700\u540e\u4e00\u4e2a.c\u6587\u4ef6\u538b\u7f29\u540e\u5f97\u5230\u4e00\u4e2a\u6570\u636e\uff0c\u53ef\u4ee5\u4fdd\u5b58\u5230spi flash\u91cc\u9762<\/p>\n

\n\t2\u3001\u6211\u4f7f\u7528\u7684RLE\u548c\u4e0a\u9762\u8fde\u63a5\u7684\u533a\u522b\uff08\u6539\u8fdb\uff09<\/p>\n

\n\t\u7531\u4e8e\u91c7\u7528\u7684\u6db2\u6676\u5c4f\u662f16\u4f4d\u7684\u6570\u636e\uff0c\u90a3\u4e48\u6bd4\u8f83\u53ef\u5b9a\u5e94\u8be5\u662f\u6309\u71672\u5b57\u8282 \u4e00\u4e2a\u6570\u636e\u7684\u6bd4\u8f83\uff0c\u4e0d\u80fd\u91c7\u7528\u4e0a\u9762\u90a3\u79cd1\u4e2a\u5b57\u8282\u7684\u6bd4\u8f83\u3002\u6240\u4ee5\u8fd9\u91cc\u505a\u4e86\u6539\u8fdb\uff0c\u5176\u4ed6\u90fd\u548c\u4e0a\u9762\u90a3\u7bc7\u6587\u7ae0\u4ecb\u7ecd\u4e00\u6837\u3002\u5e76\u4e14\u91c7\u7528\u7684\u662f\u4e0a\u9762\u6587\u7ae0\u4ecb\u7ecd\u7684\u6700\u540e\u4e00\u4e2a\u6539\u8fdb\u7b97\u6cd5\uff0c\u5982\u4e0b<\/p>\n

\n\t225intRle_Decode_O\uff08unsignedchar*inbuf\uff0cinti<\/u>nSize\uff0cunsignedchar*outbuf\uff0cintonuBufSize\uff09<\/p>\n

\n\t226{<\/p>\n

\n\t227unsignedchar*src=inbuf;<\/p>\n

\n\t228inTI;<\/p>\n

\n\t229intdecSi<\/u>ze=0;<\/p>\n

\n\t230intcount=0;<\/p>\n

\n\t231<\/p>\n

\n\t232while\uff08src\u300a\uff08inbuf+inSize\uff09\uff09<\/p>\n

\n\t233{<\/p>\n

\n\t234 unsignedchars<\/u>ign=*src++<\/u>;<\/p>\n

\n\t235 intcount=sign&0x3F;<\/p>\n

\n\t236 if<\/u>\uff08\uff08decSize+count\uff09\u300bonuBufSize\uff09\/*\u8f93\u51fa\u7f13\u51b2\u533a\u7a7a\u95f4\u4e0d\u591f\u4e86*\/<\/p>\n

\n\t237 {<\/p>\n

\n\t238 return-1;<\/p>\n

\n\t239 }<\/p>\n

\n\t240 if\uff08\uff08sign&0x80\uff09==0x80\uff09\/*\u8fde\u7eed\u91cd\u590d\u6570\u636e\u6807\u5fd7*\/<\/p>\n

\n\t241 {<\/p>\n

\n\t242 for\uff08i=0;i<\/p>\n

\n\t243 {<\/p>\n

\n\t244 outbuf\uff3bdecSize++\uff3d=*src;<\/p>\n

\n\t245 }<\/p>\n

\n\t246 src++;<\/p>\n

\n\t247 }<\/p>\n

\n\t248 else<\/p>\n

\n\t249 {<\/p>\n

\n\t250 for\uff08i=0;i<\/p>\n

\n\t251 {<\/p>\n

\n\t252 outbuf\uff3bdecSize++\uff3d=*src++;<\/p>\n

\n\t253 }<\/p>\n

\n\t254 }<\/p>\n

\n\t255}<\/p>\n

\n\t256<\/p>\n

\n\t257returndecSize;<\/p>\n

\n\t258}<\/p>\n

\n\t3\u3001\u5355\u7247\u673a\u91cc\u9762\u5b9e\u73b0\u7684\u65b9\u6cd5<\/p>\n

\n\t\u4e0b\u9762\u662f\u5728\u5355\u7247\u673a\u91cc\u9762\u5b9e\u73b0\u7684\u4ee3\u7801\uff0c\u4e0d\u8fc7\u8fd9\u91cc\u4e00\u4e2a\u95ee\u9898\u9891\u7e41\u8bfb\u53d6 \u5237\u5c4f\u901f\u5ea6\u6bd4\u8f83\u6162 \u6d4b\u8bd5<\/u>\u53d1\u73b0\u8981100\u591aMS\uff0c\u540e\u9762\u6539\u8fdb\u4e86\u7b97\u6cd5 \uff0c\u5e76\u4e14\u91c7\u7528FATFS\u7ba1\u7406SPI FLASH \u6d4b\u8bd5\u53d1\u73b028ms\u53ef\u4ee5\u663e\u793a\u4e00\u5f20\u56fe\u7247\uff08\u4e0d\u8fc7\u989c\u8272\u4e0d\u662f\u5f88\u590d\u6742 \u590d\u6742\u65f6\u95f4\u4f1a\u66f4\u957f\uff09<\/p>\n

\n\tvoid lcd_display_image\uff08uint32_t eprom<\/u>offset\uff09\/\/\u4fdd\u5b58\u5728flsah\u4e2d\u7684\u5730\u5740<\/p>\n

\n\t{<\/p>\n

\n\tuint8_t buf\uff3b1024\uff3d = {0};\/\/\u5b9a\u4e49\u7f13\u51b2\u533a\u5927\u5c0f<\/p>\n

\n\tuint32_t totlelen = 0;\/\/\u7528\u4e8e\u4fdd\u5b58\u6570\u636e\u603b\u957f\u5ea6<\/p>\n

\n\tuint32_t index = 0;\/\/\u7d22\u5f15<\/p>\n

\n\tuint8_t temp = 0;\/\/\u4e34\u65f6\u5b58\u653e\u6570\u636e<\/p>\n

\n\tuint8_t count = 0;\/\/\u8fde\u7eed\u6570\u636e\u4e2a\u6570<\/p>\n

\n\tuint16_t colour = 0;\/\/\u4fdd\u5b58\u989c\u8272\u7528\u5982\u6db2\u6676\u663e\u793a<\/u><\/p>\n

\n\tuint8_t i = 0;<\/p>\n

\n\tSPI_FLASH_ReadBuffer\uff08buf\uff0cepromoffset\uff0c 3\uff09;\/\/\u524d3\u4e2a\u5b57\u8282\u4fdd\u5b58\u6570\u636e\u7684\u603b\u957f\u5ea6<\/p>\n

\n\tepromoffset = epromoffset + 3;\/\/flash \u5730\u5740\u504f\u79fb3<\/p>\n

\n\ttotlelen = buf\uff3b0\uff3d \u300a\u300a 16 “ buf\uff3b1\uff3d \u300a\u300a 8 | buf\uff3b2\uff3d;\/\/\u8ba1\u7b97\u5f97\u5230\u603b\u957f\u5ea6<\/p>\n

\n\tLCD_SetWindows\uff080\uff0c319\uff0c0\uff0c239\uff09;\/\/320 240 \u8bbe\u7f6eLCD\u663e\u793a\u533a\u57df<\/p>\n

\n\twhile\uff08index \u300a totlelen\uff09\/\/\u5224\u65ad \u7d22\u5f15\u548c\u6587\u4ef6\u603b\u957f\u5ea6 \u9000\u51fa\u7684\u6761\u4ef6<\/p>\n

\n\t{<\/p>\n

\n\tSPI_FLASH_ReadBuffer\uff08buf\uff0cepromoffset\uff0c 1\uff09;\/\/\u8bfb\u6570\u636e<\/p>\n

\n\tepromoffset++;\/\/flash \u5730\u5740\u81ea\u52a0<\/p>\n

\n\ttemp = buf\uff3b0\uff3d;\/\/\u5f97\u5230\u8bfb\u53d6\u7684\u6570\u636e<\/p>\n

\n\tindex++;\/\/\u7d22\u5f15\u81ea\u52a0<\/p>\n

\n\tcount = temp & 0x7f;\/\/\u5f97\u5230\u8fde\u7eed\u7684\u4e2a\u6570<\/p>\n

\n\tif\uff08\uff08temp & 0x80\uff09 == 0x80\uff09\/\/\u5224\u65ad\u662f\u5426\u662f\u76f8\u540c \u8fd8\u662f\u4e0d\u540c\u7684 \u8fde\u7eed<\/p>\n

\n\t{<\/p>\n

\n\tSPI_FLASH_ReadBuffer\uff08buf\uff0cepromoffset\uff0c 2\uff09;\/\/\u76f8\u540c\u8fde\u7eed \u8bfb\u53d6\u4e24\u4e2a\u5b57\u8282<\/p>\n

\n\tepromoffset = epromoffset + 2;<\/p>\n

\n\tindex = index + 2;<\/p>\n

\n\tcolour = buf\uff3b0\uff3d \u300a\u300a 8 | buf\uff3b1\uff3d;\/\/\u7ec4\u5408\u6210<\/u>\u989c\u8272 RGB 565<\/p>\n

\n\tfor\uff08i = 0;i \u300a count;i++\uff09<\/p>\n

\n\t{<\/p>\n

\n\tLCD_RAM<\/u> = colour;\/\/\u663e\u793a FSMC<\/p>\n

\n\t}<\/p>\n

\n\t}<\/p>\n

\n\telse\/\/\u4e0d\u76f8\u540c \u8fde\u7eed<\/p>\n

\n\t{<\/p>\n

\n\t\/\/SPI_FLASH_ReadBuffer\uff08buf\uff0cepromoffset\uff0c count *2\uff09;<\/p>\n

\n\t\/\/\u8bfb\u53d6 count*2\u4e2a\u6570\u636e 2\u4e2a\u6570\u636e\u7ec4\u6210\u4e00\u4e2a\u989c\u8272\u6570\u636e count \u4e2a\u989c\u8272\u6570\u636e \u6240\u4ee5\u8981*2<\/p>\n

\n\tSPI_DMA<\/u>_FLASH_ReadBuffer_1\uff08epromoffset\uff0cbuf\uff0ccount *2\uff09;<\/p>\n

\n\tepromoffset = epromoffset + count * 2;\/\/\u5730\u5740\u504f\u79fb<\/p>\n

\n\tindex = index + count * 2;<\/p>\n

\n\tfor\uff08i = 0; i \u300a count * 2;i= i+2\uff09<\/p>\n

\n\t{<\/p>\n

\n\tLCD_RAM = buf\uff3bi\uff3d \u300a\u300a 8 | buf\uff3bi+1\uff3d;\/\/\u663e\u793a<\/p>\n

\n\t}<\/p>\n

\n\t}<\/p>\n

\n\t}<\/p>\n

\n\tindex = 0;<\/p>\n

\n\t}<\/p>\n

\n\t\u6539\u8fdb\u540e\u7684\u5355\u7247\u673a\u7a0b\u5e8f<\/p>\n

\n\tvoid SPI_Flash_lcd_Fatfs_image\uff08const char *filename\uff09\/\/\u6587\u4ef6\u540d<\/p>\n

\n\t{<\/p>\n

\n\tuint8_t buf\uff3bpiece_size\uff3d = {0};\/\/\u5f00\u8f9f\u4e00\u4e2a\u5927\u7684\u7f13\u51b2\u533a<\/p>\n

\n\tuint32_t epromoffset = 0;<\/p>\n

\n\tuint32_t totlelen = 0;<\/p>\n

\n\tuint32_t index = 0;<\/p>\n

\n\tuint8_t temp = 0;<\/p>\n

\n\tuint32_t num = 0;<\/p>\n

\n\tuint8_t count = 0;<\/p>\n

\n\tuint16_t colour = 0;<\/p>\n

\n\tuint8_t i = 0\uff0cj = 0;<\/p>\n

\n\tuint16_t write_buf = 0;<\/p>\n

\n\tuint16_t read_buf = 0;<\/p>\n

\n\tSPI_Flash_ReadFileDa<\/u>ta_add\uff08filename\uff0cbuf\uff0cepromoffset\uff0c3\uff0c&num\uff09;\/\/\u8bfb\u53d6\u603b\u957f\u5ea6 \u91c7\u7528FATFA<\/p>\n

\n\tepromoffset = epromoffset + 3;<\/p>\n

\n\ttotlelen = buf\uff3b0\uff3d \u300a\u300a 16 | buf\uff3b1\uff3d \u300a\u300a 8 | buf\uff3b2\uff3d;<\/p>\n

\n\tLCD_SetWindows\uff080\uff0c319\uff0c0\uff0c239\uff09;\/\/320 240<\/p>\n

\n\twhile\uff08index \u300a totlelen\uff09<\/p>\n

\n\t{<\/p>\n

\n\tif\uff08totlelen - index \u300b piece_size\uff09<\/p>\n

\n\t{<\/p>\n

\n\tSPI_Flash_ReadFileD<\/u>ata_add\uff08filename\uff0cbuf\uff0cepromoffset\uff0cpiece_size\uff0c&num\uff09;\/\/\u8bfb\u53d6\u6570\u636e\u4fdd\u5b58\u5230\u7f13\u51b2\u533a<\/p>\n

\n\tepromoffset = epromoffset + piece_size;<\/p>\n

\n\tread_buf = piece_size;<\/p>\n

\n\tindex = index + piece_size;<\/p>\n

\n\t}<\/p>\n

\n\telse<\/p>\n

\n\t{<\/p>\n

\n\tSPI_Flash_ReadFileData_add\uff08filename\uff0cbuf\uff0cepromoffset\uff0ctotlelen - index\uff0c&num\uff09;<\/p>\n

\n\tepromoffset = epromoffset + totlelen - index;<\/p>\n

\n\tread_buf = totlelen - index;<\/p>\n

\n\tindex = totlelen;<\/p>\n

\n\t}<\/p>\n

\n\twhile\uff08write_buf \u300a read_buf\uff09<\/p>\n

\n\t{<\/p>\n

\n\ttemp = buf\uff3bwrite_buf\uff3d;<\/p>\n

\n\twrite_buf++;<\/p>\n

\n\tcount = temp & 0x7f;<\/p>\n

\n\tif\uff08\uff08temp & 0x80\uff09 == 0x80\uff09<\/p>\n

\n\t{<\/p>\n

\n\tif\uff08\uff08read_buf- write_buf\uff09 \u300b 2\uff09<\/p>\n

\n\t{<\/p>\n

\n\tcolour = buf\uff3bwrite_buf\uff3d \u300a\u300a 8 | buf\uff3bwrite_buf+1\uff3d;<\/p>\n

\n\twrite_buf = write_buf + 2;<\/p>\n

\n\t}<\/p>\n

\n\telse<\/p>\n

\n\t{<\/p>\n

\n\twrite_buf = write_buf + 2;<\/p>\n

\n\t}<\/p>\n

\n\tfor\uff08i = 0;i \u300a count;i++\uff09<\/p>\n

\n\t{<\/p>\n

\n\tLCD_RAM = colour;<\/p>\n

\n\t}<\/p>\n

\n\t}<\/p>\n

\n\telse<\/p>\n

\n\t{<\/p>\n

\n\tcount = count *2;<\/p>\n

\n\tj = 0;<\/p>\n

\n\tfor\uff08i = 0; i \u300a count ;i= i+2\uff09<\/p>\n

\n\t{<\/p>\n

\n\tif\uff08\uff08read_buf - write_buf\uff09 \u300b 2\uff09<\/p>\n

\n\t{<\/p>\n

\n\tcolour = buf\uff3bwrite_buf\uff3d \u300a\u300a 8 | buf\uff3bwrite_buf+1\uff3d;<\/p>\n

\n\tLCD_RAM = colour;<\/p>\n

\n\twrite_buf = write_buf +2;<\/p>\n

\n\t}<\/p>\n

\n\telse<\/p>\n

\n\t{<\/p>\n

\n\tSPI_Flash_ReadFileData_add\uff08filename\uff0cbuf\uff0cepromoffset + j\uff0c2\uff0c&num\uff09;\/\/\u8fd9\u91cc\u6709\u70b9\u95ee\u9898 \u9700\u8981\u6539\u8fdb \u5047\u5982\u7f13\u51b2\u533a\u6570\u636e\u8bfb\u5b8c \u5c31\u4f1a\u51fa\u73b0\u70b9\u95ee\u9898<\/p>\n

\n\tj = j + 2;<\/p>\n

\n\tLCD_RAM =buf\uff3b0\uff3d \u300a\u300a 8 | buf\uff3b1\uff3d;<\/p>\n

\n\twrite_buf = write_buf +2;<\/p>\n

\n\t}<\/p>\n

\n\t}<\/p>\n

\n\t}<\/p>\n

\n\t}<\/p>\n

\n\twrite_buf= write_buf %piece_size;<\/p>\n

\n\t}<\/p>\n

\n\t}<\/p>\n

\n\t\u8fd9\u4e2a\u7a0b\u5e8f\u8fd8\u6709\u70b9\u5c0f
\n\t\u6765\u6e90\uff1b21ic<\/p>\n","protected":false},"excerpt":{"rendered":"

\u7531\u4e8e\u9700\u8981\u7528\u5230 \u6db2\u6676\u5c4f \uff08320*240\uff09\u663e\u793a\u56fe\u7247\uff0c\u800c\u4e14\u56fe\u7247\u7684\u6570\u91cf\u6bd4\u8f83\u591a\uff08\u597d\u51e0\u767e\u5f20\uff09\uff0c\u5e76\u4e14\u56fe\u7247\u8981\u6c42\u4fdd\u5b58\u523016M\u7684S PI FLASH\u91cc\u9762\uff0c\u663e\u7136\u5982\u679c\u4e0d\u5904\u7406 16M\u7684FLASH\u660e\u663e\u662f\u653e\u4e0d\u4e0b\u53bb\u3002\u540e\u6765\u540c\u4e8b\u8bf4\u53ef\u4ee5\u7528\u538b<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[14],"tags":[],"_links":{"self":[{"href":"http:\/\/www.szryc.com\/index.php?rest_route=\/wp\/v2\/posts\/2830"}],"collection":[{"href":"http:\/\/www.szryc.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.szryc.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.szryc.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.szryc.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2830"}],"version-history":[{"count":0,"href":"http:\/\/www.szryc.com\/index.php?rest_route=\/wp\/v2\/posts\/2830\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.szryc.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2830"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.szryc.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2830"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.szryc.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2830"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}