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.
Dependents: Paint_9341 IUT-BED2021
Revision 10:a02d649ea00e, committed 2019-01-10
- Comitter:
- ecowboy
- Date:
- Thu Jan 10 01:14:10 2019 +0000
- Parent:
- 9:b8bc8296da24
- Commit message:
- Initial
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 |
--- a/SPI_TFT_ILI9341.cpp Tue May 06 18:09:00 2014 +0000
+++ b/SPI_TFT_ILI9341.cpp Thu Jan 10 01:14:10 2019 +0000
@@ -645,14 +645,14 @@
-void SPI_TFT_ILI9341::Bitmap(unsigned int x, unsigned int y, unsigned int w, unsigned int h,unsigned char *bitmap)
+void SPI_TFT_ILI9341::Bitmap(unsigned int x, unsigned int y, unsigned int w, unsigned int h,unsigned const char *bitmap)
{
unsigned int j;
int padd;
unsigned short *bitmap_ptr = (unsigned short *)bitmap;
- #if defined TARGET_KL25Z // 8 Bit SPI
+ //#if defined TARGET_KL25Z // 8 Bit SPI
unsigned short pix_temp;
- #endif
+ //#endif
unsigned int i;
@@ -664,34 +664,34 @@
window(x, y, w, h);
bitmap_ptr += ((h - 1)* (w + padd));
wr_cmd(0x2C); // send pixel
- #ifndef TARGET_KL25Z // 16 Bit SPI
- _spi.format(16,3);
- #endif // switch to 16 bit Mode 3
+ //#ifndef TARGET_KL25Z // 16 Bit SPI
+ //_spi.format(16,3);
+ #//endif // switch to 16 bit Mode 3
for (j = 0; j < h; j++) { //Lines
for (i = 0; i < w; i++) { // one line
- #if defined TARGET_KL25Z // 8 Bit SPI
+ //#if defined TARGET_KL25Z // 8 Bit SPI
pix_temp = *bitmap_ptr;
_spi.write(pix_temp >> 8);
_spi.write(pix_temp);
bitmap_ptr++;
- #else
- _spi.write(*bitmap_ptr); // one line
- bitmap_ptr++;
- #endif
+ //#else
+ //_spi.write(*bitmap_ptr); // one line
+ //bitmap_ptr++;
+ //#endif
}
bitmap_ptr -= 2*w;
bitmap_ptr -= padd;
}
_cs = 1;
- #ifndef TARGET_KL25Z // 16 Bit SPI
- _spi.format(8,3);
- #endif
+ //#ifndef TARGET_KL25Z // 16 Bit SPI
+ //_spi.format(8,3);
+ //#endif
WindowMax();
}
// local filesystem is not implemented in kinetis board
-#if DEVICE_LOCALFILESYSTEM
+//#if DEVICE_LOCALFILESYSTEM
int SPI_TFT_ILI9341::BMP_16(unsigned int x, unsigned int y, const char *Name_BMP)
{
@@ -710,17 +710,7 @@
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++;
- }
-
- fprintf(stderr, "filename : %s \n\r",filename);
-
- FILE *Image = fopen((const char *)&filename[0], "rb"); // open the bmp file
+ FILE *Image = fopen("/local/bmp/trapattack.bmp", "rb"); // open the bmp file
if (!Image) {
return(0); // error file not found !
}
@@ -744,38 +734,36 @@
fclose(Image);
return(-3); // to big
}
-
+
start_data = BMP_Header[OffsetPixData] + (BMP_Header[OffsetPixData + 1] << 8) + (BMP_Header[OffsetPixData + 2] << 16) + (BMP_Header[OffsetPixData + 3] << 24);
line = (unsigned short *) malloc (2 * PixelWidth); // we need a buffer for a line
if (line == NULL) {
return(-4); // error no memory
}
-
- // the bmp lines are padded to multiple of 4 bytes
- padd = -1;
- do {
- padd ++;
- } while ((PixelWidth * 2 + padd)%4 != 0);
-
-
-//fseek(Image, 70 ,SEEK_SET);
+
+// the bmp lines are padded to multiple of 4 bytes
+ padd = -1;
+ _spi.format(8,3);
+ do {
+ padd ++;
+ //} while ((PixelWidth * 2 + padd)%4 != 0);
+ } while (2*(PixelWidth + padd)%4 != 0);
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 !
- for (i = 0; i < PixelWidth; i++) { // copy pixel data to TFT
- _spi.write(line[i]); // one 16 bit pixel
- }
+ wr_cmd(0x2C); // send pixel
+
+ 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
+ for (i = 0; i < PixelWidth; i++) { // copy pixel data to TFT
+ _spi.write(line[i] >> 8);
+ _spi.write(line[i]);
+ }
}
- _cs = 1;
- _spi.format(8,3);
- free (line);
- fclose(Image);
- WindowMax();
- return(1);
-}
-#endif
\ No newline at end of file
+ _cs = 1;
+ free (line);
+ fclose(Image);
+ WindowMax();
+ return(1);
+}
\ No newline at end of file
--- a/SPI_TFT_ILI9341.h Tue May 06 18:09:00 2014 +0000
+++ b/SPI_TFT_ILI9341.h Thu Jan 10 01:14:10 2019 +0000
@@ -26,10 +26,10 @@
/* some RGB color definitions */
#define Black 0x0000 /* 0, 0, 0 */
#define Navy 0x000F /* 0, 0, 128 */
-#define DarkGreen 0x03E0 /* 0, 128, 0 */
#define DarkCyan 0x03EF /* 0, 128, 128 */
#define Maroon 0x7800 /* 128, 0, 0 */
#define Purple 0x780F /* 128, 0, 128 */
+#define Pink 0xF59E /* 238, 136, 238 */
#define Olive 0x7BE0 /* 128, 128, 0 */
#define LightGrey 0xC618 /* 192, 192, 192 */
#define DarkGrey 0x7BEF /* 128, 128, 128 */
@@ -40,8 +40,15 @@
#define Magenta 0xF81F /* 255, 0, 255 */
#define Yellow 0xFFE0 /* 255, 255, 0 */
#define White 0xFFFF /* 255, 255, 255 */
-#define Orange 0xFD20 /* 255, 165, 0 */
#define GreenYellow 0xAFE5 /* 173, 255, 47 */
+#define Orange 0xFC00
+#define Brown 0x8208
+#define BlueGreen 0x4410
+#define White 0xFFFF
+#define LightPink 0xFC18
+#define DarkOrange 0xE3C0
+#define DarkGreen 0x0400
+#define Mustard 0x8400
/** Display control class, based on GraphicsDisplay and TextDisplay
@@ -215,9 +222,9 @@
* cast the pointer to (unsigned char *) :
* tft.Bitmap(10,40,309,50,(unsigned char *)scala);
*/
- void Bitmap(unsigned int x, unsigned int y, unsigned int w, unsigned int h,unsigned char *bitmap);
+ void Bitmap(unsigned int x, unsigned int y, unsigned int w, unsigned int h,unsigned const char *bitmap);
-#if DEVICE_LOCALFILESYSTEM
+//#if DEVICE_LOCALFILESYSTEM
/** Paint a 16 bit BMP from local filesytem on the TFT (slow)
*
* @param x,y : upper left corner
@@ -235,7 +242,7 @@
*/
int BMP_16(unsigned int x, unsigned int y, const char *Name_BMP);
-#endif
+//#endif
/** Select the font to use