123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 |
- #include <unzipLIB.h>
- #include <bb_spi_lcd.h>
- #define TFT_CS 10
- #define TFT_RST -1
- #define TFT_DC 9
- #define TFT_CLK 13
- #define TFT_MOSI 11
- #include "bmp_icons.h"
- UNZIP zip;
- SPILCD lcd;
- void setup() {
- Serial.begin(115200);
- delay(1000);
- spilcdInit(&lcd, LCD_ILI9341, FLAGS_NONE, 40000000, TFT_CS, TFT_DC, TFT_RST, -1, -1, TFT_MOSI, TFT_CLK);
- spilcdSetOrientation(&lcd, LCD_ORIENTATION_90);
- }
- void loop() {
- int rc, x, y;
- char szComment[256], szName[256];
- unz_file_info fi;
- uint8_t *ucBitmap;
- spilcdFill(&lcd, 0, DRAW_TO_LCD);
- spilcdWriteString(&lcd, 0, 0, (char *)"Unzip BMP Files Test", 0xffff, 0, FONT_12x16, DRAW_TO_LCD);
- x = 0; y = 24;
- rc = zip.openZIP((uint8_t *)bmp_icons, sizeof(bmp_icons));
- if (rc == UNZ_OK) {
- rc = zip.getGlobalComment(szComment, sizeof(szComment));
- Serial.print("Global comment: ");
- Serial.println(szComment);
- zip.gotoFirstFile();
- rc = UNZ_OK;
- while (rc == UNZ_OK) {
- rc = zip.getFileInfo(&fi, szName, sizeof(szName), NULL, 0, szComment, sizeof(szComment));
- if (rc == UNZ_OK) {
- ucBitmap = (uint8_t *)malloc(fi.uncompressed_size);
- if (ucBitmap != NULL) {
- zip.openCurrentFile();
- spilcdWriteString(&lcd, 0, 224, " ", 0xff1f, 0, FONT_12x16, DRAW_TO_LCD);
- spilcdWriteString(&lcd, 0, 224, szName, 0xff1f, 0, FONT_12x16, DRAW_TO_LCD);
- rc = zip.readCurrentFile(ucBitmap, 2102);
- if (rc != fi.uncompressed_size) {
- Serial.print("Read error, rc=");
- Serial.println(rc, DEC);
- }
- spilcdDrawBMP(&lcd, ucBitmap, x, y, 1, -1, DRAW_TO_LCD);
- x += 64;
- if (x >= 256) {
- x = 0;
- y += 64;
- }
- free(ucBitmap);
- }
- delay(1000);
- }
- rc = zip.gotoNextFile();
- }
- zip.closeZIP();
- }
- }
|