Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of SPI_TFT_ILI9341 by
Revision 10:ec7261a25933, committed 2015-08-15
- Comitter:
- bangbh
- Date:
- Sat Aug 15 05:10:09 2015 +0000
- Parent:
- 9:b8bc8296da24
- Commit message:
- a
Changed in this revision
SPI_TFT_ILI9341.cpp | Show annotated file Show diff for this revision Revisions of this file |
SPI_TFT_ILI9341.h | Show annotated file Show diff for this revision Revisions of this file |
diff -r b8bc8296da24 -r ec7261a25933 SPI_TFT_ILI9341.cpp --- a/SPI_TFT_ILI9341.cpp Tue May 06 18:09:00 2014 +0000 +++ b/SPI_TFT_ILI9341.cpp Sat Aug 15 05:10:09 2015 +0000 @@ -570,6 +570,7 @@ char_y = char_y + font[2]; if (char_y >= height() - font[2]) { char_y = 0; + cls(); } } else { character(char_x, char_y, value); @@ -689,11 +690,8 @@ WindowMax(); } - // local filesystem is not implemented in kinetis board -#if DEVICE_LOCALFILESYSTEM - -int SPI_TFT_ILI9341::BMP_16(unsigned int x, unsigned int y, const char *Name_BMP) +int SPI_TFT_ILI9341::BMP_16(unsigned int x, unsigned int y, FILE *fd) { #define OffsetPixelWidth 18 @@ -702,51 +700,36 @@ #define OffsetPixData 10 #define OffsetBPP 28 - char filename[50]; unsigned char BMP_Header[54]; unsigned short BPP_t; unsigned int PixelWidth,PixelHeigh,start_data; unsigned int i,off; int padd,j; unsigned short *line; - - // get the filename - LocalFileSystem local("local"); - sprintf(&filename[0],"/local/"); - i=7; - while (*Name_BMP!='\0') { - filename[i++]=*Name_BMP++; - } + //unsigned short line[134]; - fprintf(stderr, "filename : %s \n\r",filename); - - FILE *Image = fopen((const char *)&filename[0], "rb"); // open the bmp file - if (!Image) { - return(0); // error file not found ! - } - - fread(&BMP_Header[0],1,54,Image); // get the BMP Header + fread(&BMP_Header[0],1,54,fd); // get the BMP Header if (BMP_Header[0] != 0x42 || BMP_Header[1] != 0x4D) { // check magic byte - fclose(Image); + fclose(fd); return(-1); // error no BMP file } BPP_t = BMP_Header[OffsetBPP] + (BMP_Header[OffsetBPP + 1] << 8); if (BPP_t != 0x0010) { - fclose(Image); + fclose(fd); return(-2); // error no 16 bit BMP } PixelHeigh = BMP_Header[OffsetPixelHeigh] + (BMP_Header[OffsetPixelHeigh + 1] << 8) + (BMP_Header[OffsetPixelHeigh + 2] << 16) + (BMP_Header[OffsetPixelHeigh + 3] << 24); PixelWidth = BMP_Header[OffsetPixelWidth] + (BMP_Header[OffsetPixelWidth + 1] << 8) + (BMP_Header[OffsetPixelWidth + 2] << 16) + (BMP_Header[OffsetPixelWidth + 3] << 24); if (PixelHeigh > height() + y || PixelWidth > width() + x) { - fclose(Image); + fclose(fd); return(-3); // to big } - + start_data = BMP_Header[OffsetPixData] + (BMP_Header[OffsetPixData + 1] << 8) + (BMP_Header[OffsetPixData + 2] << 16) + (BMP_Header[OffsetPixData + 3] << 24); - + printf(" %d,%d,%d",PixelWidth,PixelHeigh,start_data); line = (unsigned short *) malloc (2 * PixelWidth); // we need a buffer for a line if (line == NULL) { return(-4); // error no memory @@ -757,25 +740,25 @@ do { padd ++; } while ((PixelWidth * 2 + padd)%4 != 0); - - -//fseek(Image, 70 ,SEEK_SET); - window(x, y,PixelWidth ,PixelHeigh); - wr_cmd(0x2C); // send pixel - _spi.format(16,3); // switch to 16 bit Mode 3 + //fseek(fd, 70 ,SEEK_SET); + window(x, y, PixelWidth, PixelHeigh); + wr_cmd(0x2C); // send pixel + _spi.format(16,3); // switch to 16 bit Mode 3 for (j = PixelHeigh - 1; j >= 0; j--) { //Lines bottom up off = j * (PixelWidth * 2 + padd) + start_data; // start of line - fseek(Image, off ,SEEK_SET); - fread(line,1,PixelWidth * 2,Image); // read a line - slow ! + fseek(fd, off ,SEEK_SET); + fread(line,1,PixelWidth * 2,fd); // read a line - slow ! + printf("1234567890\r\n"); for (i = 0; i < PixelWidth; i++) { // copy pixel data to TFT + //printf("%02x ", line[i]); _spi.write(line[i]); // one 16 bit pixel } } + printf("windows"); _cs = 1; _spi.format(8,3); free (line); - fclose(Image); - WindowMax(); + fclose(fd); + //WindowMax(); return(1); -} -#endif \ No newline at end of file +} \ No newline at end of file
diff -r b8bc8296da24 -r ec7261a25933 SPI_TFT_ILI9341.h --- a/SPI_TFT_ILI9341.h Tue May 06 18:09:00 2014 +0000 +++ b/SPI_TFT_ILI9341.h Sat Aug 15 05:10:09 2015 +0000 @@ -217,7 +217,6 @@ */ void Bitmap(unsigned int x, unsigned int y, unsigned int w, unsigned int h,unsigned char *bitmap); -#if DEVICE_LOCALFILESYSTEM /** Paint a 16 bit BMP from local filesytem on the TFT (slow) * * @param x,y : upper left corner @@ -234,8 +233,7 @@ * copy to internal file system */ - int BMP_16(unsigned int x, unsigned int y, const char *Name_BMP); -#endif + int BMP_16(unsigned int x, unsigned int y, FILE *fd); /** Select the font to use