Library for Adafruit ST7735, for use with the NCS36510 mbed board
Dependents: mbed-TFT-example-NCS36510
Fork of Adafruit_ST7735 by
Revision 8:196b625fe857, committed 2017-02-23
- Comitter:
- jacobjohnson
- Date:
- Thu Feb 23 16:30:19 2017 +0000
- Parent:
- 7:5842518d1feb
- Commit message:
- working library ;
Changed in this revision
Adafruit_ST7735.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r 5842518d1feb -r 196b625fe857 Adafruit_ST7735.cpp --- a/Adafruit_ST7735.cpp Tue Jan 31 17:14:49 2017 +0000 +++ b/Adafruit_ST7735.cpp Thu Feb 23 16:30:19 2017 +0000 @@ -525,16 +525,19 @@ do {pc.printf("TEST padd : %d\r\n",padd); padd ++; } while ((PixelHeigh * 2 + padd)%4 != 0); + + pc.printf("Information: \n\r Height: %d\r\n Width: %d\r\n\ BPP: %d\r\n", PixelHeigh, PixelWidth, BPP_t); setAddrWindow(x, y,PixelWidth ,PixelHeigh); writecommand(0x2C); // send pixel + pc.printf("TEST 518"); - for (j = PixelWidth - 1; j >= 0; j--) { //Lines bottom up - off = j * (PixelHeigh * 2 + padd) + start_data; // start of line + 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,PixelHeigh * 2,Image); // read a line - slow - for (i = 0; i < PixelHeigh; i++) { // copy pixel data to TFT + fread(line,1,PixelWidth * 2,Image); // read a line - slow + for (i = 0; i < PixelWidth; i++) { // copy pixel data to TFT _rs = 1; _cs = 0; lcdPort.write(line[i]); @@ -549,13 +552,13 @@ return(1); } -#define RGB(r,g,b) (((r&0xF8)<<8)|((g&0xFC)<<3)|((b&0xF8)>>3)) //5 red | 6 green | 5 blue +#define RGB(r,g,b) (((r&0xF8)<<8)|((g&0xF8)<<3)|((b)>>3)) //5 red | 6 green | 5 blue #define TFT_DEBUG int Adafruit_ST7735::DrawBitmapFile(const char *Name_BMP) { - char img[3*240]; + char img[5*240]; uint32_t imgsize = 0; uint32_t offset = 0; uint32_t imgw = 0; @@ -567,6 +570,7 @@ int i, j; char filename[50]; + lcdPort.format(8,0); pc.printf("TEST START1\r\n"); // get the filename @@ -633,26 +637,29 @@ fseek(Image, offset, SEEK_SET); for (j = imgh; j >= 0; j--) //Lines { - fread(img,sizeof(char),imgw*3,Image); + //fread(img,sizeof(char),imgw*3,Image); + fread(img,sizeof(char),imgw * 3,Image); _cs = 1; setAddrWindow(0, j, imgw ,1); writecommand(0x2C); // send pixel #ifdef TARGET_WIZWIKI_W7500 - lcdPort.format(16,3); + lcdPort.format(8,3); #endif for(i = 0; i < imgw; i++) { -/* if(colbits == 16) + if(colbits == 16) { col = (uint16_t)img[2*i+1]; col <<= 8; col += (uint16_t)img[2*i]; } - else if(colbits == 24) */ - //{ - col = RGB((uint16_t)img[3*i+2],(uint16_t)img[3*i+1], (uint16_t)img[3*i]); - //} + else if(colbits == 24) + { + col = RGB((uint16_t)img[(3*i-3)],(uint16_t)img[(3*i)+1-3], (uint16_t)img[(3*i)+2-3]); + //col = RGB((uint16_t)img[i],(uint16_t)img[i], (uint16_t)img[i]); + //pc.printf("R: %h\n\r G: %h\n\r B: &h\n\r", img[3*i], img[3*i+ + } #ifdef TFT_DEBUG /* @@ -664,10 +671,16 @@ */ //pc.printf("RGB(%d): (%d,%d,%d) -> %04X\r\n ",i,img[3*i+2],img[3*i+1],img[3*i],col); #endif + /* _rs = 1; + _cs = 0; + + lcdPort.write(col); */ _rs = 1; _cs = 0; - lcdPort.write(col); + lcdPort.write( col >> 8 ); + lcdPort.write( col ); + //_cs = 1; } _cs = 1; #ifdef TARGET_WIZWIKI_W7500